Lighting Cheat Sheet

My previous posts on the topic were very wordy. So here, I want to have a quick summary of the technical aspects of lighting.

Lighting has 4 parts.

  1. Direct lighting and shadows.
  2. Indirect lighting known as global illumination.
  3. Reflections
  4. Ambient Occlusion.

Direct lighting and shadows

Direct lighting is done the same way no matter what pipeline you use. But how you do shadows will greatly affect all the rest of how you do lighting.

  1. Nanite + Virtual Shadow Maps
  2. Traditional Cascade Shadow Maps (directional light)

You must choose which one. Or if you want to use both (just not at the same time), you can set them up in your scalability settings.

Raytraced shadows will override both of these, but you must still choose which pipeline you want.

Virtual Shadow Maps

If you choose Virtual Shadow Maps, you must turn on Nanite even if you don’t use it. VSM is optimized for Nanite, but you can use it with non nanite assets. You’ll just have overhead penalty of both pipelines. If you only use Nanite (and no non-Nanite assets), then the traditional pipeline won’t be used at all and you can get some performance back.

VSM handles all shadows for you. And this is by far the simpler route to take.

Cascade Shadow Maps

If you choose Cascade Shadow Maps, you enter the world of the traditional pipeline and things get VERY complicated. But hopefully, this article will simplify a lot of it.

If you use a directional light, all shadows within the CSM radius will be under the control of the directional light. If you have other lights like spotlights within the radius, those will produce shadows one at at time, but the shadow budget is still under control of the directional light. The directional light is optimized to build all shadows within its radius at once. The number of CSM levels controls the resolution and hence blurriness of each level.

The radius of CSM is set with the property called “Dynamic Shadow Distance”. There are two such settings depending if your light is stationary or movable.

Beyond, this radius, you have three choices. But let’s list them in terms of distance.

  1. Closest: directional light + CSM
  2. Medium distance: far shadows OR distance field shadows w/ static shadows
  3. Nothing or static shadows

Beyond the CSM radius, you can choose either far shadows or DFS or nothing.

  1. Far shadows are like CSM, but further out.
  2. Distance Field Shadows use distance fields and will also use static shadows (static lighting) if you have baked them.

CSM + DFS is a common choice.

The distance is set on the directional light in each section.

Beyond this, only static shadows will display or no shadows at all. It’s usually too far away to see shadows anyways.

Global Illumination

Global illumination is when light bounces off an object and hits another object before hitting the camera. This is what causes shadows to not be completely black. It’s what allows emissives to shine their light onto other objects.

Here, you have 4 choices:

  1. Lumen
  2. Screen Space Global Illumination (deprecated)
  3. Lumen Lite
  4. None

Lumen is quite expensive, but is the best looking solution. In Unreal Engine 5.8, they deprecated Screen Space Global Illumination. There is a new Lumen mode called Lumen Lite which is twice as fast as regular Lumen. Lumen requires Distance Fields to be turned on and all your assets must have proper distance fields generated. You can go into the eye icon dropdown at the top of the viewport, then at the bottom of the list at Vizualize, then select Global Distance Field or Mesh Distance Fields.

Setting any of these up is done in in the PostProcessVolume under the section called Global Illumination.

To use Lumen Lite, you select Lumen and set sg.GlobalIlluminationQuality 1 or set it in your scalability settings ini file.

Screen Space GI is where only assets seen on screen contribute to indirect lighting. It is faster, but less accurate.

Reflections

The types of reflections you have is based on if you have Lumen on or off. This is set in the PostProcessVolume section under Reflections.

  1. Lumen Reflections (only available if Lumen GI is on)
  2. Screen Space Reflections
  3. None

You can only use Lumen reflections if you have Lumen turn on for Global Illumination as well. But you can always choose screen space reflections as well even with Lumen.

If you don’t have Lumen turned on for GI, then your only options are Screen Space Reflections or nothing.

Screen space reflections only use what is on screen, but look absolutely terrible. They cannot handle emissives properly. However, Lumen reflections are in many ways even worse than SSR. Lumen reflections are blurry and won’t do Niagara reflections at all. They just won’t show up. Now, if you use raytracing, you can get nice reflections. But if you intend on having your game look good on older hardware with Lumen Reflections, good luck.

Now, if you don’t use Lumen Reflections, you do have extra tools at your disposal that aren’t available to those who use Lumen Reflections. The first is Planar Reflections. These are by far the best reflections in the engine. And they don’t work with Lumen though it seems they’re trying. Remember to make these invisible if you use Lumen in your scalability settings as it will cause all Lumen GI to flicker like crazy even if you can’t see it, but has it’s Visible property set to true. Planar Reflections can use a specific list of actors to re-render to cut down the cost. It is expensive to use, but looks amazing and can do mirror reflections.

The other tools available or reflection captures with sphere or box reflection captures. These allow reflections to be used even if they are off screen. They should be used as static captures. You can use them as Runtime captures but it’s much more expensive.

Reflections tend to be a host of compromises regardless if you go with Lumen or not.

Ambient Occlusion

Ambient occlusion is when you have lots of nearby geometry that prevents light from going into these areas. This will create softer and darker shadows.

Here, you have several options:

  1. Lumen AO (on by default if you use Lumen GI)
  2. Screen Space AO (many use this instead of Lumen AO)
  3. Distance Field AO
  4. Ray Traced AO
  5. Baked AO

If you use Lumen, it already does indirect lighting so it already computes Ambient Occlusion. However, many people feel it’s not strong enough and manually turn on SSAO with r.Lumen.DiffuseIndirect.SSAO 1.

If you use Screen Space AO, these settings are configured in the PostProcessVolume under Ambient Occlusion. Note that these settings only take effect when SSAO is used. If you don’t use SSAO, they are ignored.

To use DFAO, you need to turn on distance fields and set your SkyLight to movable. If you use Lumen, this may not be available unless you use Lumen Lite.

To use Ray Traced AO, this is only available when not using Lumen. Lumen will use hardware raytracing through other means and use it for AO automatically. To enable this if you don’t use Lumen, you can turn it on in the PostProcessVolume under Ray Tracing Ambient Occlusion section.

Baked AO is used with static lighting and requires baking your lighting. This will be used when static lighting is used. I’ve only ever been able to see this used when all other AO methods are disabled. But maybe it can appear in other cases.

You can also do Ambient Occlusion with materials, but this is deprecated with Lumen and with Substrate. The new workflow is to just multiply your AO map with your diffuse (color) map.

Posted in Uncategorized.