Movable Lights

A fully dynamic light capable of changing all of its properties during runtime.

Windows
MacOS
Linux

lighting_overview_banner_001.png

Movable Lights cast completely dynamic light and shadows. They can change position, rotation, color, brightness, falloff, radius, and just about every other property they have. None of the light they cast gets baked into the lightmaps, and do not support indirect lighting without a dynamic global illumination method.

Shadowing

Movable lights are set up to cast shadows use whole scene dynamic shadows, which have a significant performance cost. The performance cost comes primarily from the number of meshes affected by the light, and the triangle count of those meshes. This means that a shadow-casting, movable light with a large radius will cost many times more than a movable light with a small radius.

Usage

On any light under the Transform category, you will find a pull-down property called Mobility; change that to Movable. This property also appears on light components added to a Blueprint.

ML_movableProp.png

Shadow Biasing

Adjusting the Shadow Bias properties of lights reduces shadowing artifacts that can occur due to shadow mapping techniques (such as, faceting across geometry faces) when using dynamic lighting.

Usage

Shadow Bias is adjustable per-light using the Slope Bias (or Constant Bias) and Shadow Slope Bias properties. Adjusting the Shadow Slope Bias is proportional to the Shadow Bias and between these two properties, it's possible to reduce some of shadow mapping artifacts that can occur.

Shadow Bias (Constant and Slope): Default

Shadow Bias (Constant and Slope): Adjusted

Adjusting the Shadow Slope Bias reduces self-shadowing artifacts at the loss of shadow accuracy, which can cause a peter-panning (or floating) effect for grounded objects in the scene. Slope bias adjustments won't solve all your self-shadowing issues with dynamic lighting, but it can solve most of them. It's up to you to decide the right balance for your project.

Directional Lights have an extra depth bias property that enables you to control the bias strength across the Cascaded Shadow Maps (CSM), reducing dicontinuities of shadow artifacts at cascade transition points.

Shadow Bias (Constant and Slope): Default

Shadow Bias (Constant and Slope): Adjusted

In addition to per-light properties, you can control Constant, Slope, and Receiver bias through global console variables per-light type using a value between 0 and 1:

  • Directional: r.Shadow.CSMReceiverBias

  • Spot: r.Shadow.SpotReceiverBias

  • Point: r.Shadow.PointReceiverBias

  • Rect: r.Shadow.RectReceiverBias

Shadow Bias Settings

The following settings enable you to adjust the bias in your scene for lighting and shadowing:

Property

Description

Point, Spot, and Rect Lights

Shadow Bias

Controls how accurate self shadowing of whole scene shadows from this light are. At 0, shadows will start at their caster surface but there will be many self-shadowing artifacts. With larger values, shadows will start further from their caster and there won't be self-shadowing artifacts but the object might appear to fly or float above a surface. At around a value of 0.5, there is a good trade-off balanced between accuracy and reduction in self-shadowing artifacts.

This also affects the soft transition of shadows.

Shadow Slope Bias

This property works in addition to Shadow Bias in controlling how accurate self-shadowing of whole scene shadows from this light are. It works by increasing the amount of bias depending on the slope of a given surface. At 0, shadows will start at thir caster surface but will have many self-shadowing artifacts. With larger values, shadows will start frther from their caster and there won't be self-shadowing artifacts but objects might appear to fly or float above a surface. At around a value of 0.5, there is a good trade-off balanced between accuracy and reduction in self-shadowing artifacts.

This also affects the soft transition of shadows.

Directional Light

Shadow Bias

Controls how accurate self shadowing of whole scene shadows from this light are. At 0, shadows will start at their caster surface but there will be many self-shadowing artifacts. With larger values, shadows will start further from their caster and there won't be self-shadowing artifacts but the object might appear to fly or float above a surface. At around a value of 0.5, there is a good trade-off balanced between accuracy and reduction in self-shadowing artifacts.

This also affects the soft transition of shadows.

Shadow Slope Bias

This property works in addition to Shadow Bias in controlling how accurate self-shadowing of whole scene shadows from this light are. It works by increasing the amount of bias depending on the slope of a given surface. At 0, shadows will start at thir caster surface but will have many self-shadowing artifacts. With larger values, shadows will start frther from their caster and there won't be self-shadowing artifacts but objects might appear to fly or float above a surface. At around a value of 0.5, there is a good trade-off balanced between accuracy and reduction in self-shadowing artifacts.

This also affects the soft transition of shadows.

Shadow Cascade Bias Distribution

Controls the depth bias scaling across a Directional Light's cascades. This allows it to mitigate the difference in shadow artifacts between shadow cascades transition. A value of 1 scales shadow bias based on each cascade size, whereas a value of 0 scales shadow bias uniformly across all cascades.

Shadow Map Caching

When a point or spot light is not moving, we can store off the shadow map for that light and reuse it next frame. This makes shadow casting movable Point and Spot lights much more affordable in games where the environment is often not moving. In this section, we will take a look at how you can use Shadow Map Caching in your own projects.

Shadow Map Caching and Performance

Shadow Map Caching is an automatically-enabled feature in any UE4 project. To check performance, enable and disable Shadow Map Caching by performing the following actions:

For the following demonstration of Shadow Map Caching, the Sun Temple project was used. You can find the Sun Temple map in the Learn tab of the Epic Games Launcher.

  1. Select all of the lights that you want to have cast dynamic shadows in your project's level.

    SMC_Select_All_Lights.png

  2. Set the lights' Mobility to Movable and make sure that Cast Shadows is enabled.

    SMC_Set_Mob_Shadow_Cast.png

  3. Press the Backtick (`) key to open up the Console, and type Stat Shadowrendering to see the current cost of dynamic shadows.

    SMC_Console_ShadowRendering.png

  4. Press the Backtick (`) key again to open the Console, and type r.Shadow.CacheWholeSceneShadows 0 to disable dynamic shadow caching.

    SMC_Disable_Shadow_Cache.png

    Make sure to note the the numbers in the CallCount and InclusiveAug sections.

  5. Now press the Backtick key one more time to open the Console and type r.Shadow.CacheWholeSceneShadows 1 to re-enable shadow caching. If you compare the CallCount and InclusiveAug numbers, you can see the impact this feature has on dynamic shadow performance.

    Shadow Caching On

    Shadow Caching Off

Performance

Shadow Map Caching has a significant impact on performance. Here are the results of testing this optmization out using an NVIDIA 970 GTX GPU at a screen resolution of 1920x1200.

  • Before enabling this feature, three shadow-casting point lights without caching took 14.89ms to render Shadow Depths.

  • When Cached Shadow Maps were enabled, the same three shadow-casting lights took .9ms to render which is about 16 times faster!

    Note that it still costs 2 ms to render the contributions of the 33 point lights, which can be optimized in other ways but are not affected by this change.

  • You can control the maximum of memory used by the Shadow Map Cache using r.Shadow.WholeSceneShadowCacheMb

Limitations

While Shadow Map Caching can decrease the cost of using dynamic shadows in your UE4 projects, there are some limitations that could cause rendering artifacts if used with non-supported features.

  • By default, caching can only happen when an object meets the following requirements:

    • Primitives have their mobility Mobility set to Static or Stationary.

    • Materials used in the level do not use World Position Offset.

    • A light needs to be either a Point or Spot light, have its Mobility set to Movable, and have Shadow Casting enabled.

    • Lights have to remain at one location.

    • Materials that use animated Tessellation or Pixel Depth Offset can cause artifacts as their shadow depths are cached.

Select Skin
Light
Dark

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback