Optimization with Lightmaps, LOD, and Collisions

From PSwiki
Revision as of 09:43, 14 November 2025 by Talad (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Lightmap Density

To check lightmap density, click the Lit menu, then "Optimization Viewmode" then "Lightmap density" , or alt+0.

This view mode uses a color scale and grid texture to simplify balancing lightmap resolutions, and also identify mapping errors. In this layout, blue is too low res, green is optimal, and red is too high res. Occasionally errors will create purple when there is overlap or sever distortion.

In the case of correct mapping but incorrect scale, lightmap resolution should be changed from the default 64 to a size that shifts the color to green, done under "General Settings" -> "Light Map Resolution" in the the mesh details panel.

Please note you can change this setting at runtime and you see the color changing in the viewport, without the need to rebuild lights.

Lightmap generation

If you use "Generate Lightmap UVs" setting, then Unreal will read the "Source Lightmap Index" (usually 0) where your base color UV are stored, and will generate a new lightmap UV to be stored in "Destination Lightmap index" (usually 1).

You still have to be sure that your "Light Map Coordinate Index" is pointing to the proper destination Index (example 1). This is the one used to generate the lightmap texture.

If you want to import custom UV lightmap, then you need to uncheck "Generate Lightmap UVs" setting and add a new UV layer in Blender to represent your lightmap UV. You can generate it in Blender using Data->UV Maps -> Add a new one, then use "Unwrap" -> "Smart UV Project". This will not create any overlapping UVs.


Official documentation is here:

https://dev.epicgames.com/documentation/en-us/unreal-engine/understanding-lightmapping-in-unreal-engine

Others notes

For the purple errors, the mesh needs a lightmap unwrapped in blender, typically because it already has multiple internal UV maps and can't properly autogenerate to a new channel. To fix this, first make sure the correct channel is assigned, by looking at the mesh uv channels and determining if there is a proper lightmap channel already. These typically show every face mapped individually and quite small in a large array.

If there is no proper lightmap, open the mesh in blender and use unwrap lightmap uvs, making sure to unwrap to a new channel and not over the main texture channel. Once done, reimport without autogeneration of lightmaps on, and select the new channel for lightmap baking.

For LOD, or level of detail, unreal engine has a good auto LOD generator that can be used bot for distance meshes and higher quality collision meshes where appropriate. First, set the asset to the correct LOD group, which will auto generate the LODs. Then, check the new LODs and test them at their set distances to make sure the swap is clean between them, and that the generation process didn't distort the profile too much. If it did, play with the reduction settings by changing the percent decrease slider until you have the right balance.

Additionally, these new lower LOD models can be applied as a complex collision mesh, which for certain assets like buildings gives a better performance than using LOD0 as a complex collision mesh, but offers higher fidelity for things like columns that auto convex collision doesn't work well for.