Guide for: Baking and Switching between multiple Volumetric Lightmaps
Why?
Per Sublevel baking is supported - but when you use volumetric lightmaps you have to bake everything at once - on larger worlds this will increase baking time or hit your memory limit.
How?
Unreal doesn’t support multiple VLMs (Volumetric Lightmaps) instead one global volumetric lightmap texture is set on Level load.
But there are two interesting behaviors:
- It will use the VLM from the latest loaded Level when one is available.
- When baking: the lightmaps are stored per sub Level. But only one VLM is baked and stored inside the persistent level. The Sublevels will not have any VLM data.
→ We will have empty “Proxy Levels” which only contain the volumetric lightmaps and are loaded on demand.
Result Preview
Guide
1. Creating the scene
In this example I will use a simple scene with a castle and a forest. And the global lighting on a seperate level so its easier to bake.
Toggling the levels:
2. Baking
Now for everything I want to bake seperatley I will create an empty Level. They will only store the VLM data.
Here inside the baking scene for the Forest. I will add the forest Level and the Lighting Level.
Now I will bake the scene.
Same process for the castle.
3. Switching
Now I will add the baking Levels to the Mainlevel. Note: It will only add the Level not its sublevel - which is nice in this case because it will only load the VLM.
Now I will add some simple logic for loading the different VLMs based on overlap volumes.
Snipped:
4. Result
When I now move the pawn it will switch between different VLM.
Nice thing is you can have a seperate controll over the level loading.
Notes
Sublevel Offset?
Sublevel offset will not change the location of the VLMs. There is a fix but it seems like it will not work in a packaged project. Sad because it was there since 2017… 6 years ago!
https://github.com/EpicGames/UnrealEngine/pull/3627
GetLevel()->PrecomputedLightVolume->ApplyWorldOffset(GetActorLocation());
Loading Problems
I recommend having one VLM to be always loaded - you can unloaded it after the level is loaded. Sometimes if there is no VLM on level start it won’t register new ones.
Faster Development
You can also use this only for faster development and then in the end bake the final level together - no changes needed. Just pressed bake:
Cleaner Transitions
For a cleaner transition between levels and no light popping and less shadow inconsistencies you could have a shared transition level on the border. This would make the volumetric lightmap extend and align. Then you won’t see when they are switched out.
Load other Levels
Keep in mind that any Level which has VLM will apply it on load. If you want to bake some background assets just bake the Levels as Sublevels inside an empty level. So they won’t generate an VLM.
Disclaimer
This was tested on UE 5.1. Tested on packaged project on Windows. Feel free to share your experiences or problems.