I’m having a problem that I’ve struggled with for a few times now, and I’ve never found a detailed enough explanation of the “Build Lightning” feature in UE4.
To be honest, I’m not sure what it does, except from baking the lightning (basically so that we won’t have to do this at runtime and eat up memory), but whenever I use this feature, the lightning in my scene changes.
Would someone please explain to me why the shadows change this much after building the lightning? Is there a way to stop this, and keep the “nice” lightning (image 1: Before baking)?
The lighting you see before baking (in the viewport) is dynamic and not static.
The reason why you are seing black faces might be related to the lightmap UV layout of your static meshes and/or its lightmap resolution.
Can you post an image of your lightmap layout?
Also: Do you use a lightmass importance volume?
If you switch your lights to “movable” and thus use dynamic lighting, you will see a result more similar to the viewport look.
Dynamic lighting however has its own caveats, performance being one of them.
First off, I don’t actually have any UV mapping of these meshes, as I’m trying to play around with the idea that “less-is-more”.
Second; How hard is the dynamic lightning on the performance compared to the static lightning?
This foliage is made from a model that I’ve imported into UE4. I changed the trees lightmap resolution to 16 instead of 64. Does that have anything to do with it?
Dynamic lighting is more power hungry and usually look less realistic. But in a scene like yours it could work.
Baked (static) lighting gives the most accurate results because it gives global illumination and realistic shadows. It’s also runs faster than dynamic. This method require all your static meshes to have a lightmap. The lighting information is going to be saved on that map after the build.
Well, lightmap UVS are a absolutely required for static lighting. If you dont have them, the texture UVs will be used istead.
If the mesh faces there are too close together, or even overlapping, you will see these results.
Think of the botton of the tree (which is of course dark as it doesnt get any light) “bleeding” its darkness onto some leaves that are too closely UV-wise…
That depends on how large/complex your world is.
The performance demands are different for different types of resources.
Lightmaps are created at designtime, so during gameplay they do not create a lot of computational overhead at runtime. But they use memory f course.
Bigger lightmaps, more memory needed and more data is streamed.
Dynamic lighting spares you the memory consumption and lighting build process, but the computational overhead is bigger as the lighting has to be constantly calculated at runtime.
Most use cases will be somewhere in between but you could say that static lighting eats on RAM, while dynamic lighting requires a strong CPU…
Good idea to try to adjust the lightmap resolution, but wrong direction
You need to increase the resiolution for a more detailed result… Try 128 or 256 instead.
(But without a proper lightmap you will hardly see any improvement).
UE4’s rendering engine has a few passes that account for the final results:
1 - Shader
2 - Direct Specular lighting
3 - Bounce light
4 - Reflections
5 - Shadow
6 - Post Process
Lightmass handles shadows and bounce light for static objects in the distance. This bathes your scene with light and fills it with shadows to look very nice. When you dynamically light a bunch of trees, unfortunately, all you’re getting is the direct light from the sun and a shadow. Everything in the shadow is pitch black because you’re not telling the engine to put any light there. If you want to fill it, you need a skylight to account for all the lighting happening all around the level, not just the sun. I prefer stationary skylights which are also computer into lightmass for bounce lighting and fill the entire world with a nice sky reflection. Lightmass helps the shadows a lot by precomputing it. However, lightmass also adds that indirect lighting layer to the calculations which previously went unaccounted for, so that’s why it appears to take more instructions to render when you check the stats in the material editor.
For a scene like yours, ditching lightmass and filling it in with a skylight (especially a stationary skylight that adds a sky reflection on everything) can work, but you’d have to force lightmass off and find some way to generate shadows on everything without crashing the computer. Up close, use cascaded shadow maps from the sun, set in the properties of the directional Light Source. This is good for everything 10,000 units and less: going further will be too difficult to render because it basically takes a snapshot of all the pixels in range and sends out a shadow. Yes, this even casts shadows from moving alpha cards for dynamic foliage shadows. But it’s not good for everything! You can use UE4’s more experimental distance fields for shadows in the distance… but even with very large levels and light maps, lightmass does not need more than a few MBs. If you have ten thousand grass meshes everywhere… then that’s another story.
In the end, it all depends on the results you want to achieve. Do you want a cartoonish world of flat colors and simple rendering, or do you want light to flood into your scene, take advantage of UE4’s reflections, and take people’s breath away?