Shadows make objects feel grounded in the world and give the viewer a sense of depth and space. Static shadows are free as far as rendering goes, but dynamic shadows can be one of the biggest drains on performance. This document covers the basics of the 4 types of shadow casting you can have in Unreal Engine 4.
Static Lights
Static lights cast completely static shadows and light, meaning they will have no direct effect on dynamic objects (static lights are baked into the Indirect Lighting Cache so they have some effect) like on the bronze men below.
The bronze character on the left is standing in the light of a static light, it does not affect him in any way (lighting or shadows) while the one on the right is in the light of a stationary light.
Directional Light Cascading Shadow Maps (Whole Scene Shadows)
Directional Stationary Lights are special because they support whole scene shadows through Cascaded Shadow Maps at the same time as static shadowing. This is very useful in levels with a lot of animating foliage; you want to have moving shadows around the player but do not want to pay the cost of having many cascades to cover a large view range. The dynamic shadows are faded into static shadows over distance, such that the transition is often indistinguishable. To set this up, just change the Dynamic Shadow Distance StationaryLight of aDirectionalLightStationary to be the range at which you want the fade to happen.
Stationary Light Shadows
Dynamic objects (like StaticMeshComponents and SkeletalMeshComponents with Mobility set to Movable) must integrate into the static shadowing of the world from distance field shadowmaps. This is accomplished with Per Object shadows. Each movable object creates two dynamic shadows from a stationary light: a shadow to handle the static world casting onto the object, and a shadow to handle the object casting onto the world. With this setup, the only shadowing cost for stationary lights comes from dynamic objects that it affects. This means the cost can vary from very little to a large amount, depending on how many dynamic objects there are. With enough dynamic objects, it is more efficient to use a Movable light instead.
In the scene below, the spheres are all movable, and they all receive shadows from the static world and cast their own shadows, which merge with the distance field shadows. The Per Object shadow frustums for each Movable component are also shown.
Dynamic Shadows
Movable lights cast completely dynamic shadows (and light) on everything. None of its light data will get baked into the light maps and it will be free to cast dynamic shadows on everything. Static Meshes, Skeletal Meshes, effects, etc... will all cast and receive dynamic shadows from a movable light.
On average, movable dynamic shadow casting lights are the most expensive.
Preview Shadows
When editing a Stationary or Static Light in such a way that the lighting becomes un-built, Preview Shadowing is enabled to give you an idea of what the shadows will look like when lighting is rebuilt.
These shadows are shown in the editor with the text "Preview" to distinguish them from pre-existing shadows as seen below.
If you test your game in the editor prior to rebuilding lighting, the Preview Shadows will disappear as the preview only exists within the editor and not during Play In Editor.
In order to generate shadows from the Preview Shadows, you will need to select Build Lighting from the Build option off the Main Editor Tool Bar.
You can disable Preview Shadows by un-checking the Preview Shadows Indicator option in the Viewport's Show/Visualize menu.
All Together
When all the shadows are brought together, each bringing their strengths to make up for the weakness of the others, impressive and rapidly rendered visuals can be brought to life.
Shadows make objects feel grounded in the world and give the viewer a sense of depth and space. Static shadows are free as far as rendering goes, but dynamic shadows can be one of the biggest drains on performance. This document covers the basics of the 4 types of shadow casting you can have in Unreal Engine 4.
Static Lights
Static lights cast completely static shadows and light, meaning they will have no direct effect on dynamic objects (static lights are baked into the Indirect Lighting Cache so they have some effect) like on the bronze men below.
The bronze character on the left is standing in the light of a static light, it does not affect him in any way (lighting or shadows) while the one on the right is in the light of a stationary light.
Directional Light Cascading Shadow Maps (Whole Scene Shadows)
Directional Stationary Lights are special because they support whole scene shadows through Cascaded Shadow Maps at the same time as static shadowing. This is very useful in levels with a lot of animating foliage; you want to have moving shadows around the player but do not want to pay the cost of having many cascades to cover a large view range. The dynamic shadows are faded into static shadows over distance, such that the transition is often indistinguishable. To set this up, just change the Dynamic Shadow Distance StationaryLight of aDirectionalLightStationary to be the range at which you want the fade to happen.
Stationary Light Shadows
Dynamic objects (like StaticMeshComponents and SkeletalMeshComponents with Mobility set to Movable) must integrate into the static shadowing of the world from distance field shadowmaps. This is accomplished with Per Object shadows. Each movable object creates two dynamic shadows from a stationary light: a shadow to handle the static world casting onto the object, and a shadow to handle the object casting onto the world. With this setup, the only shadowing cost for stationary lights comes from dynamic objects that it affects. This means the cost can vary from very little to a large amount, depending on how many dynamic objects there are. With enough dynamic objects, it is more efficient to use a Movable light instead.
In the scene below, the spheres are all movable, and they all receive shadows from the static world and cast their own shadows, which merge with the distance field shadows. The Per Object shadow frustums for each Movable component are also shown.
Dynamic Shadows
Movable lights cast completely dynamic shadows (and light) on everything. None of its light data will get baked into the light maps and it will be free to cast dynamic shadows on everything. Static Meshes, Skeletal Meshes, effects, etc... will all cast and receive dynamic shadows from a movable light.
On average, movable dynamic shadow casting lights are the most expensive.
Preview Shadows
When editing a Stationary or Static Light in such a way that the lighting becomes un-built, Preview Shadowing is enabled to give you an idea of what the shadows will look like when lighting is rebuilt.
These shadows are shown in the editor with the text "Preview" to distinguish them from pre-existing shadows as seen below.
If you test your game in the editor prior to rebuilding lighting, the Preview Shadows will disappear as the preview only exists within the editor and not during Play In Editor.
In order to generate shadows from the Preview Shadows, you will need to select Build Lighting from the Build option off the Main Editor Tool Bar.
You can disable Preview Shadows by un-checking the Preview Shadows Indicator option in the Viewport's Show/Visualize menu.
All Together
When all the shadows are brought together, each bringing their strengths to make up for the weakness of the others, impressive and rapidly rendered visuals can be brought to life.