Skip to main content

Unreal Engine - How to Enable Dynamic Shadows & Correct Reflection Maps on Mobile

✍ Last Updated : January 27, 2023

Mega Blast Mobile Optimized Lighting

UploadThere are a lot of questions and not a lot of concrete answers swirling around about dynamic lighting on mobile.

Here’s how we got it to work in Mega Blast:

  1. Anything that receives or casts shadows must use the Default Lit material shading model

  2. In ProgressWorld Settings, under Rendering, make sure that Allow Static Lighting = TRUE.

    This is the key part: To get non-black shadows,

  3. some lighting needs to be baked to generate indirect lighting information

  4. Set up a Lightmass Importance Volume that encompasses your entire visible game scene

  5. You should have two lights in your scene:

    • Skylight set to STATIC
    • Directional Light set to MOVEABLE
  6. The Directional Light should have the following settings:

    • Cast Shadows = TRUE
    • Cast Dynamic Shadows = TRUE
    • Edit the settings in Cascaded Shadow maps to optimize performance (for instance using 1 cascade is more efficient, but mobile supports up to 2 cascades)
  7. The Skylight should have Cast Shadows = FALSE

  8. You can use a cube map for your skylight to light the scene by using SLS Specified Cube Map as the Source Type for the Skylight (we do this because we don’t need a skymap in Mega Blast, since the sky is not directly visible)

  9. Make sure that you have some items in your scene that can cast static shadows and can have lightmaps.

    1. these can be set to non-visible at runtime if you don’t want these items to be visible in game.
    2. We set up a large placeholder ground plane that generates nice bounced lighting from the “floor”.
    3. We then hide this at runtime, since the “real” ground is constructed from dynamically-placed objects with real-time shadows.
  10. Build lighting - this will bake the lighting and generate indirect lighting information that will be used to lighten your shadows

  11. Test on device Shadows should now appear correctly for objects that use the Default Lit shading model.

  12. BONUS: This method will also allow your reflection capture spheres to work correctly -

Console Command

Useful console commands that can also be set in Default Device Profiles for optimization:

  1. r.Shadow.MaxResolution - sets the resolution of shadow maps
  2. r.ShadowQuality - sets the number of cascades used (your Directional Light can be set to use 2 for instance, but each device can be set to use the same or less, or none)
  3. r.Shadow.RadiusThreshold - sets the screen size ratio at which shadows won’t appear. If you see shadows “popping in” at certain distances, you can change this setting to make sure shadows are rendered correctly in the distance (0.02 seems to work well for us)
  • The Default Lit shading model is very expensive on non-metal devices so it should be used sparingly.
    • For non-metal devices we use unlit materials with no cast shadows. See this post on how to display specific assets per device 59.

Please let me know if this works well for you or if there are any gaps in this information that you come across for your project. I’ll update the information if there are any corrections needed.


Lights on Movable Mesh

When using Stationary or Movable Lights on a movable mesh (not static) the shadow visibility of that movable mesh is dependent upon the size of the mesh and its distance from the camera.

Command Line Value to Tweak:

  1. r.Shadow.FadeResolution - controls how big the light has to be on the screen before it starts to fade out.
    • Default Value: 64
    • Can lower this value to keep shadows from fading out at further distances
  2. r.Shadow.MinResolution - controls how big the light has to be on the screen before it finishes fading out, at which point it no longer has cost.
    • Default Value: 32
    • Lower values seem to increase shadow visibility.
  3. r.Shadow.TexelsPerPixel - Causes a higher resolution to be assigned and then it should fade out less aggressively
    • Default Value: 1.27324
    • Can increase this value to improve shadow rendering visibility & quality
  4. r.Shadow.RadiusThreshold
    • Default Value: 0.03
    • A lower value of 0.02 or 0.01 greatly increases shadow visibility at far camera distances
    • seems to have the most impact of all the console commands

Useful Link: