When every fraction of a millisecond matters, you will eventually need to optimize this as well. Below is a brief explanation of how Lumen Cards work and how you can optimize them depending on your project’s needs.
You already know what Lumen Cards are and why they exist. But keep the following in mind:
-
Lumen Cards are generated in real time. Why not ahead of time? Because the same Static Mesh in a scene can use different materials.
-
As you move through the scene, the engine updates Lumen Cards for objects that enter the Lumen scene and have a significant contribution to indirect lighting. The faster the movement, the more cards the engine needs to update. Existing cards may also be refreshed while moving.
-
By default, even if the camera is not moving, the engine still refreshes Lumen Cards for objects that already have them. Why? Because a material’s color may change over time.
-
By default, the engine generates separate Lumen Cards even for objects (and instances) that use the same mesh and the same material. Why? Because there is no guarantee that two identical instances will always have the same material color.
-
The generated Lumen Cards are stored in a shared atlas. Atlas management is similar to Virtual Texture management. The atlas size is fixed. New cards are added, old ones are discarded, and cards that are more important at the moment may replace less important ones. Some cards may not fit into the atlas.
-
By default, the engine uses the material shader when generating Lumen Cards. If the shader is complex, card generation takes longer.
-
Different objects use different numbers of Lumen Cards. By default, the maximum number of cards per Static Mesh is 12. The engine tries to choose the number of cards that gives the best coverage of the object.
So, by default, the engine is configured to handle the most general case: any scene, any materials, and any hardware. For many projects, this is more than necessary. The good news is that you can tune all of it.
Below are the most important console commands and settings for debugging and optimization.
Debugging
r.Lumen.Visualize.CardPlacement - Lets you see how your objects are covered by Lumen Cards. Useful for finding unnecessary cards.
View Mode → Lumen → Surface Cache - Shows what Lumen sees. If a part of an object is not covered by a Lumen Card, it becomes bright pink. In reflections, that area will appear black. Yellow objects mean their Lumen Cards did not fit into the atlas. They will also appear black.
r.LumenScene.SurfaceCache.LogUpdates - Prints the list of updated cards every frame. Useful for estimating update counts and finding problematic Static Meshes. Can be used together with Unreal Insights.
r.Lumen.Visualize 22 - Shows groups of objects that share the same Lumen Card. See the material setting below.
Optimization
Compatible with Lumen Card Sharing (Material setting) - Enable this if you know that all objects using this material will have approximately the same color. Then identical meshes with the same material can share Lumen Cards. Use the Card Sharing visualization command above to verify the result.
RayTracingQualitySwitchReplace (Material node) - Lets the engine ignore expensive parts of the material when generating Lumen Cards. Can provide a significant performance boost for complex materials. A must-have.
Max Lumen Mesh Cards - Reduce the number of cards so they only cover the largest, most important, and most visible parts of the mesh. Small errors are usually not noticeable.
r.LumenScene.SurfaceCache.CardCapturesPerFrame - Default: 300. Reduce if needed.
r.LumenScene.SurfaceCache.CardCaptureRefreshFraction - Default: 0.125, meaning 12.5% of existing cards are refreshed. This can be reduced. In some cases, it can even be set to 0 if materials never change over time.
r.LumenScene.SurfaceCache.CardMaxResolution - Higher values increase both quality and cost. Default: 512. Lower it if quality remains acceptable.
r.LumenScene.SurfaceCache.AtlasSize - Default: 4096. This may be unnecessary for lower-end hardware. Reduce it together with the Lumen Card resolution setting.
Additionally
Go through the other settings under r.LumenScene.SurfaceCache. There are many more useful options worth exploring.
Summary
By adjusting these settings, you can significantly reduce the number of Lumen Cards in your scene, decrease the number of required card updates, speed up global illumination, and improve overall performance.
Of course, this post does not cover everything about Lumen Cards. But I hope you found it useful.
I wish you a high frame rate!
Reference screenshots
