Sitemap
Sagar

Sagar

rgbguy

What is Lumen in Unreal Engine 5

5 min readMar 20, 2022

--

Press enter or click to view image in full size
First Scene Demoed on UE5
  • Dynamic lighting in UE4 was done using Direct Lighting (Only light sources affected objects).
  • Indirect illumination in UE4 relied on approximations, faking or pre-rendered global illumination.
  • Global illumination is expensive. BUT, next generation of games will require more advance lighting. And here comes the need for real time global illumination (Let’s call it GI).
  • Processing and computing GI is a lot of work. It’s the holy grail of graphics. UE5 tries to change that. How?

Features of GI in UE5:

  • Color Bleeding: how color of an illuminated object affects the surrounding.
  • Indirect Shadows: Indirect shadows required pre-made occlusion maps, or screen space occlusion algorithms. Lumen completely replaces SSAO removing the need for these.
  • Emissive Surfaces: In UE4, we could make emissive (glowing) surfaces. It didn’t affect the world unless you are using static lighting with light maps. In UE5, we can use emissive surfaces to add indirect lighting to the scene in real time.
  • SkyLights: Sky affects the world. It will appear in the reflections and lighting of your scene. This can also be reproduced in UE4 by using SkyAtmosphere and a skylight that update real time, or by specifying a cubemap.

Get Sagar’s stories in your inbox

Join Medium for free to get updates from this writer.

How does all this work?

  • Most common method of solving realtime GI is ray tracing. (Using bouncing light rays to compute the final color of the image). Lumen makes heavy use of hardware accelerated ray tracing. Along with this, Lumen also has a built-in software ray tracing solution for older hardware.
  • Software ray tracing solution traces to a simplified version of the scene which is generated using signed distance fileds (A volumetric representation of the 3D surface). Unreal Engine generates mesh distance fields for every static mesh while importing it. SDFs are fast to trace.
  • So now we have a solution to calculate the GI. But to bounce light around properly, we need to sample material properties of each hit surface. To sample these from the geometry is expensive. Unreal uses a smarter approach to do this. It creates a parameterisation of nearby surfaces of a mesh. To explain in a simplified way, it is similar to a inverted cubemap built around each object. It is known as the surface cache. Lumen captures the material properties for each mesh from multiple angles. These capture positions (called Cards) are generated offline for each mesh. These can be visualized with r.Lumen.Visualize.CardPlacement 1.
  • After the Surface Cache is populated with material properties, Lumen calculates direct and indirect lighting for these surface positions accumulated over multiple frames. Now lumen has everything. When computed for the whole scene, this is together called as the ‘Lumen Scene’. Enabling the Lumen Scene visualization will be usually the first thing to do when something seems wrong with your lighting or your reflections. Lumen Scene is what the lumen ray tracer sees.
  • For many years in games, lighting and reflections had to be completely separated systems. This always required some effort from artists to make them match. But in real life, these are all a single phenomenon. Lumen GI finally unifies that. GI and reflections in Unreal Engine 5 are calculated together.
  • Enabling Lumen: It comes enabled by default in UE5. For manual activation, head to the Project Settings, and search for dynamic global illumination method. Set it to Lumen. It sets the default reflection method to Lumen. It enables generate mesh distance fields in the project. You must restart the editor to propagate the changes and to generate the mesh distance fields.
  • Creating a simple scene in UE5 to demonstrate Lumen: Add a Directional light, SkyAtmosphere, SkyLight and see the magic. (Don’t keep the scene blank, add some objects. Windows will show you the real effect of lumen). Try rotating the directional light to check the day/night cycles. Everything works out of the box! Looks so good!
Press enter or click to view image in full size
Demo Lumen Scene

Best Practices:

  • Emissive surfaces are not meant to replace light sources. You can use emissive services in Lumen, but make sure that you keep them large and not too bright. Flat screens or large windows are a good use case here. The small and brighter meshes will add lots of noise to the scene.
  • By default, texture and material features may look a little bit blurred if you try to emulate mirror like surfaces. You can alleviate that by enabling harder acceleration in Lumen and increasing the reflection quality. By default, reflection mode is set to 1. So Lumen samples material information and lighting from the surface cache. Your reflections will basically look the same as the Lumen Scene.
  • With reflection mode is set to 2, Lumen samples material information from the hit shader, but it still uses lighting information from the surface cache.
  • Mode 4 has the highest quality. Lumen not only samples material information from the hit shader, but also the direct lighting using only indirect lighting information from the surface cache.
  • The mesh distance field resolution is assigned based on the imported scale of the static mesh. If you use significant scaling up on placed instances, use the distance field resolution scale to compensate.
  • By default, Lumen traces against each mesh distance fields for the first few meters for accuracy, and then traces the merge global distance field for the rest of each ray. We use these for objects farther from the camera, which allows our traces to be really fast.
  • Scenes that require areas with a lot of small objects crammed together should consider baking these to a single mesh or whether setting the software tracing mode to global traces. That may reduce overall quality, but will increase performance.
  • Play around with the Final Gather Quality option under Global Illumination settings inside your post process volume. Higher quality will benefit ultra realistic scenes. Higher quality has higher performance cost.

These were my notes on Lumen UE5. I am trying to explore and learn more about how things work in detail. Do share the article if you found it useful! Thanks. :)

--

--