Shadow calculation and lightmaps explained

Talk about the track editor here

Moderator: English Moderator

Post Reply
User avatar
TMarc
Posts: 14391
Joined: 05 Apr 2011, 19:10
Location: Europe
Contact:

Shadow calculation and lightmaps explained

Post by TMarc » 24 Jan 2013, 23:20

Since this might be interesting for everyone, here some information about shadows and lightmaps.
[b][color=#FF8000]Fix[/color][/b] wrote:For what i know (LuckyBoy may correct me if I'm wrong here :) There are 2 lightmaps : the one on your computer (also used on solo tracks), and the one saved in the map.Gbx, shared and downloaded by other users in multiplayer.

-You compute in very high and ultra, you have nice antialisaing, bounces, etc... and your lightmap is stored as .dds and is 4096x4096 or 2048x2048 big.
-When you save your map, it's a 1024x1024 .jpg version that is saved. so, if you map is very big, You'll have artifacts that will show up because of the lower texel ratio.
[b][color=#FF8000]LuckyBoy[/color][/b] wrote:What we call lightmap is the storage of ambient and local lighting.
This information is quite complex to compute (ambient requires many samples from the whole scene, several bounces, each local light requires shadow), and because game content can be very different in maniaplanet (can be quite complex in geometry and local lights number), we made the choice of precomputing this data.
(Some games dynamically compute this data, but quality is reduced, for instance 1 bounce and only for sun, and only few local close shadows)
Then lightmap are stored to disk to be re-used during multiplayer.
Yet they can be stored in 2 ways:

a) a "local" full res. (2k or 4k for ultra), full bump (3 maps), cache stored in "ProgramData\ManiaPlanet\Cache\"
size is around 5.5Mb (20Mb for ultra).
By "local" I mean the cache WILL NEVER be transfered by P2P.

b) a "embedded" small res. (1k), bump intes (1 average map, 1 bump_intens map), cache embedded in the map file
size is around 500Kb.

cache (b) is required to play the map in multiplayer, this is the default behaviour.
cache (a) may be used even in multiplayer, only if this cache has been computed locally before.

About quality difference, obviously due to it's smaller storage (smaller res. and heavier compression), embedded cache quality is lower.
But it's important to note that compute quality and storage quality are two different things, when lightmap are computed in a given quality (say high for instance), both local and embedded cache are updated (embedded is stored when map is saved) from the same compute quality, yet embedded cache looses quality due to its compression.

Again about quality, in the screens you give, one can see horizontal red lines on the dark wall, this is due to block margin in the lightmap space. The cause is the image compression (jpg or webp) which doesn't like sharp color variations, and because beside this block wall side may be allocated the opposite side (facing to more light), the 2 sides blurs on each other.
What does the "light index of lightmaps" setting do? I didn't check it when I did my test.
This compute a lightmap local light list each time a map is loaded (never stored to disk), to render
dynamic local speculars.
[b][color=#FF8000]Fix[/color][/b] wrote:Ultra is really better : more bounces, more sampling.
It's smoother, more accurate and can fix a lot of contrasted noisy effects (especially in tunnels).
Another interesting thing is you can let ManiaPlanet calculate lightmaps in a batch job:
[b][color=#FF0000]jonthekiller[/color][/b] wrote:
slugish wrote: Additionally, I have a request. Since each recent update has required the recomputation of shadows for maps, is there a way to compute shadows on maps in a specified folder via the command line? I realize that I can compute shadows on all user maps, and did it this way for the last update. It is just somewhat confusing to move all of my maps to a backup folder and place only the ones needed in the maps folder to be computed. I have many half-finished and proof of concept maps that I don't need to recompute each time.
It's already possible. It will compute all maps in My Maps folder.

Code: Select all

ManiaPlanet.exe /computeallshadows /useronly /collections=Storm /LmQuality=High
LmQuality (Fast, Default, High, Ultra).

It will launch the game and compute all maps.
[b][color=#FF8000]Alinoa[/color][/b] wrote:About the LP computing, Jon explained it well and you can also specify some options. For example:
/useronly (only lightmaps calculated on players' tracks)
/LmQuality=Fast
/LmQuality=Default
/LmQuality=High
/collections=Storm
/collections=Storm,Canyon
w1lla wrote:How to launch it? Try a .bat file

Code: Select all

SET CurrentDir=%~dp0
cd "C:\Program Files\ManiaPlanet"
"C:\Program Files\ManiaPlanet\ManiaPlanet.exe" /LmQuality=Fast
pause
Note: Please do not forget to update the drive and the folders accordingly to your own system in the batch!
niarfman wrote: There is the possibility to use a batch script to make run the shadows calculation for all the maps which are located in the subfolder GameData\Maps of the location of ManiaPlanet.exe.

It is also possible to create a shortcut to the executable ManiaPlanet.exe and to adapt it like this:

Code: Select all

Target: "C:\Program Files\ManiaPlanet\ManiaPlanet.exe" /LmQuality=Fast
Start in:  "C:\Program Files\ManiaPlanet"
The time necessary for the lightmap (shadows) calculation in Ultra mode is about 15 to 20 minutes for each map.

Using a GeForce will be (edit: somehow) faster than using a Radeon. The script is optimized for nVidia-cuda !

A map where the lightmap already has been calculated with a specific quality will not be updated when you launch the script again. It will be considered as already processed.
A map where the lightmap quality was already calculated with a lower quality will be processed again with the requested quality.
A map which was already calculated with a higher quality will not be taken into account.
jonthekiller wrote:The game is more optimized for Nvidia, the studio works with Nvidia cards essentially.
[b][color=#FF8000]LuckyBoy[/color][/b] wrote:
eyebo wrote:
zarexz wrote:Shadows also seem to get lost after cleaning your cache but I can't put my finger on it yet.
High and Ultra shadows are always saved in your cache. So these will disappear if you clear your cache. Only default quality shadows are saved in map files. This is apparently desired functionality, from what communications I've had with Nadeo about it. The higher quality shadows in the cache still provide more calculations for the default shadows saved in the map file. So quality is still increased by calculating them. But this would explain why the shadows might disappear after cleaning your cache.
To make things a bit clearer, computed shadows with at least "Fast Quality" are saved as separate files in your cache folder (also used by p2p downloads), if the current map is "bound to a file" (this is the case when you just load a map from a file, but not when you've edited a loaded map and not saved it yet).
Fortunately, if you load a map, edit it, compute shadows, and then save, the locals cache will be saved at the map save point (because they're up-to-date).
Indeed if you clean your cache, you'll loose all your local shadow caches, but the embedded caches in the map won't be lost. This mean you'll still be able to play with the maps on multiplayer, but in the map editor, the compute dialog will display that nothing has been computed (this dialog ignores the embedded cache).
Thanks
[b][color=#FF8000]Fix[/color][/b] wrote:The screenshots show no normal map bumpmapping, so it's not the highest.

lightmap bump is automatically ON with the very nice settings (oops my bad, a while while ago it was a separate checkbox), but you can have a temporary lightmap that stores local light specularity.
(not saved on disk because it is heavy, so it's computed everytime you open a map, but it looks sexy).

launcher>advanced>compatibility>lightindex (bellow ultra lightmap)
Current games for the /collections= switch are:
Canyon
Stadium
Storm
HaagseSmurf wrote:We used this code for our Royal Server and computed all maps (thx to W1lla)

Code: Select all

ManiaPlanet.exe /computeallshadows /useronly /fullcheck /LmQuality=High
or

Code: Select all

ManiaPlanet.exe /computeallshadows /useronly /fullcheck /LmQuality=Default
or

Code: Select all

ManiaPlanet.exe /computeallshadows /useronly /fullcheck /LmQuality=Low
Good luck
Last edited by TMarc on 01 May 2014, 10:41, edited 9 times in total.
Reason: Updated with commandline examples from the Smurfs team
maniaplanet forum global moderator

Link list with FAQ, Support, Wiki, Tutorials, Community activities, and much more.

System specs: Intel i7-970 12GB RAM, nVidia GTX 970, Creative SB X-Fi, 2xSSD

User avatar
Fix
Nadeo
Nadeo
Posts: 1247
Joined: 14 Jun 2010, 17:28

Re: Shadow calculation and lightmaps explained

Post by Fix » 25 Jan 2013, 14:09

:thumbsup:

User avatar
niarfman
Posts: 303
Joined: 07 Dec 2012, 10:46

Re: Shadow calculation and lightmaps explained

Post by niarfman » 25 Jan 2013, 14:50

Nice :)

To complete your post, you should add /fullcheck option given by LuckyBoy here :
http://forum.maniaplanet.com/viewtopic. ... ck#p139308
or
http://forum.maniaplanet.com/viewtopic. ... ck#p139342

There were also some ticks about batch file or shortcuts to launch the script :
http://forum.maniaplanet.com/viewtopic. ... ps#p133294
or
http://forum.maniaplanet.com/viewtopic. ... te#p138063
Image
Ľѷҳ Choupa Oups! ツ

User avatar
Demented
Posts: 1953
Joined: 07 Nov 2010, 13:17
Location: United States

Re: Shadow calculation and lightmaps explained

Post by Demented » 25 Jan 2013, 16:30

This is an interesting and helpful topic.
Thanks.
CPU: Intel I7-4770 64Bit @ 3.4Ghz.
Ram: 16GB DDR3
GPU: Geforce GXT 1060 6GB DDR5
Windows: 7 Pro SP1 64bit

User avatar
TMarc
Posts: 14391
Joined: 05 Apr 2011, 19:10
Location: Europe
Contact:

Re: Shadow calculation and lightmaps explained

Post by TMarc » 25 Jan 2013, 23:16

Thanks :thx:
I preferred not to add the /fullcheck option yet since there is still something to clarify about it ;)
maniaplanet forum global moderator

Link list with FAQ, Support, Wiki, Tutorials, Community activities, and much more.

System specs: Intel i7-970 12GB RAM, nVidia GTX 970, Creative SB X-Fi, 2xSSD

User avatar
slugish
Posts: 129
Joined: 10 Jul 2012, 04:30
Location: United States | Kentucky | Somerset
Contact:

Re: Shadow calculation and lightmaps explained

Post by slugish » 30 Jan 2013, 23:02

TMarc wrote:
niarfman wrote: There is the possibility to use a batch script to make run the shadows calculation for all the maps which are located in the subfolder GameData\Maps of the location of ManiaPlanet.exe.

It is also possible to create a shortcut to the executable ManiaPlanet.exe and to adapt it like this:

Code: Select all

Target: "C:\Program Files\ManiaPlanet\ManiaPlanet.exe /LmQuality=Fast"
Start in:  "C:\Program Files\ManiaPlanet"
This will not work.

Code: Select all

Target: "C:\Program Files\ManiaPlanet\ManiaPlanet.exe /LmQuality=Fast"
should be

Code: Select all

Target: "C:\Program Files\ManiaPlanet\ManiaPlanet.exe" /LmQuality=Fast
^^Notice the location of the closing double quote? It is a tiny, but super important difference.

Additionally, here is what I use:

Code: Select all

"C:\Program Files (x86)\ManiaPlanet\ManiaPlanetLauncher.exe" /computeallshadows /useronly /collections=Storm /LmQuality=Ultra
Obviously, I am playing Shootmania... hence the "storm".

User avatar
TMarc
Posts: 14391
Joined: 05 Apr 2011, 19:10
Location: Europe
Contact:

Re: Shadow calculation and lightmaps explained

Post by TMarc » 30 Jan 2013, 23:13

slugish wrote: This will not work.

Code: Select all

Target: "C:\Program Files\ManiaPlanet\ManiaPlanet.exe /LmQuality=Fast"
should be

Code: Select all

Target: "C:\Program Files\ManiaPlanet\ManiaPlanet.exe" /LmQuality=Fast
^^Notice the location of the closing double quote? It is a tiny, but super important difference.

Additionally, here is what I use:

Code: Select all

"C:\Program Files (x86)\ManiaPlanet\ManiaPlanetLauncher.exe" /computeallshadows /useronly /collections=Storm /LmQuality=Ultra
Obviously, I am playing Shootmania... hence the "storm".
Yeah, I also had some doubts about the position of the quotes.
But I also experienced that Windows (XP or Vista) would not let me add any parameters in some case.
Not tried again with Win7 since then honestly.
maniaplanet forum global moderator

Link list with FAQ, Support, Wiki, Tutorials, Community activities, and much more.

System specs: Intel i7-970 12GB RAM, nVidia GTX 970, Creative SB X-Fi, 2xSSD

User avatar
niarfman
Posts: 303
Joined: 07 Dec 2012, 10:46

Re: Shadow calculation and lightmaps explained

Post by niarfman » 31 Jan 2013, 09:55

Indeed, the double-quotes needs to be around the path of the executable, arguments have to be outside of them, as the screenshot I sent initially ;)

Thank you for having corrected this point

Ps : It has been test under Windows 7
Image
Ľѷҳ Choupa Oups! ツ

User avatar
niarfman
Posts: 303
Joined: 07 Dec 2012, 10:46

Re: Shadow calculation and lightmaps explained

Post by niarfman » 31 Jan 2013, 11:26

You can also modify my post about the time for computing.

Using a GeForce will be 3x faster than using a Radeon. The script is optimized for cuda !
Image
Ľѷҳ Choupa Oups! ツ

User avatar
TMarc
Posts: 14391
Joined: 05 Apr 2011, 19:10
Location: Europe
Contact:

Re: Shadow calculation and lightmaps explained

Post by TMarc » 31 Jan 2013, 21:10

Corrections and comments added :thumbsup:
maniaplanet forum global moderator

Link list with FAQ, Support, Wiki, Tutorials, Community activities, and much more.

System specs: Intel i7-970 12GB RAM, nVidia GTX 970, Creative SB X-Fi, 2xSSD

Post Reply

Return to “Track Editor”

Who is online

Users browsing this forum: No registered users and 1 guest