Tim Hobson

Lighting: Capsule Shadows

This is a new feature in 4.11.
This example will show you how to enable the new feature for Capsule Shadows to produce soft shadows in statically lit indirectly lit areas. this can provide a grounded effect for your Skeletal Meshes!

For additional adjustments and comparisons of Console Variables scroll to the bottom of this page.

Setup: Creating Capsule Physical Asset

1. In your Content Browser select any available Skeletal Mesh. For my example, I copied the Skeletal Mesh "TutorialTPP" from the Engine folder.
2. Once selected, right-click on the Skeletal Mesh and select Create > Physical Asset
3. The settings window for the Physical Asset will come up. Adjust the Minimum Bone Size to be a larger value then click OK.
When creating your capsule shadows, it's important to remember that you don't need to have a capsule for each bone. By using a larger Minimum Bone Size you can skip past smaller bones for hands and feet that aren't needed. Keep in mind that the capsule shadows are meant to give your                         character a grounded look and do not have to be 100% accurate.
4. Now the newly created Physical Asset will open and any adjustments that need to be made can be done so here. If you used the settings above you should have something that looks similar to this.
The shadows in the scene are not representative of what the capsule shadows will be!
You'll notice that the hands and feet do not have capsules. This is OK. We don't need accurate capsules for every part of the body. However, since the feet do need to be a little bit lower to give a good grounded effect for our Capsule Shadows. 

Select the two capsules for the lower parts of the legs where the shins are and scale these along the Z-axis to stretch them out more. You should have something similar to this when you are done. Keep in mind that the Feet are an important area to make your character feel grounded so it may be needed to add some small capsules/spheres for the foot as well, but for the purposes of this example this will suffice.

Assigning Physical Asset to Skeletal Mesh

1. Select the Skeletal Mesh and double-click to open it with Persona.
2. Once Persona opens, in the left side panel for Mesh Details type in "Shadows" at the top or scroll to the Light tab and locate the option for Shadow Physics Asset. 
3. Click the drop-down and select the Physics Asset you'd like to use for Capsule Shadows. I had previously named mine PA_CapsuleShadows so that I could easily locate it if I had multiple Physics asset in my project.

Enabling Capsule Shadows for Skeletal Mesh

In the next part I have a scene that has already been created with a couple of walls and ceiling to demonstrate a statically lit environment with some good indirect lighting to demonstrate the effect of Capsule Shadows. 
This scene uses only a Skylight actor with its mobility set to Static for this scene.  There are no other light sources present. This scene has already had the lighting built as well to generate the indirect light samples needed to use Indirect Capsule Shadows.
1. Drag your Skeletal Mesh into the scene. At this point you should notice that it doesn't cast any soft shadows or look grounded in the scene.
2. Select the Skeletal Mesh and in the Details panel, scroll down to the Lighting tab and enable the option for Capsule Indirect Shadows.
3. Once enabled you will now see soft shadows generated from the Physics Asset capsules for the Skeletal Mesh.  
You might not think this is much, but if you move the Skeletal Mesh towards other surfaces like the back wall you can see the difference these Capsule Shadows can make for your statically lit environments. 

Demonstration

Capsule Shadows will interpolate between the indirect lighting cache samples placed throughout your the level when you build with static lighting. In the video demonstrations below you will see that the interpolation as the Skeletal Mesh moves across a directly lit surface adjusts it's direction. 

The scene below is a comparison to show the statically lit scene vs an unlit scene with the indirect lighting cache samples visualization. 

Capsule Shadows in Editor View

In this view as I drag the Skeletal Mesh you can see the capsule shadows interpolate as they pass the indirect lighting cache samples placed along the surface. Since this scene is only being lit by a Static Skylight actor there is no direct shadowing for the skeletal mesh other than the use of the capsule shadows for indirect lighting.

Direct and Indirect Capsule Shadows Comparison

This scene is lit using a Stationary Directional Light.
  • Top Left: No shadow casting
  • Top Right: Dynamic Shadow casting for the Skeletal Mesh 
  • Bottom Left: Capsule Indirect Shadows enabled.
  • Bottom Right: Capsule Direct Shadows enabled.

Limitations

  • Requires DX-11 due to using tiled deferred implementation using compute shaders. 
  • Self shadowing artifacts for arbitrary mesh shapes. 

Console Variable's

Using the following console variables you can adjust how values for how Capsule Shadows look in your game.  
Console Variable Description
r.CapsuleIndirectConeAngle Light source angle used when the indirect shadow direction is derived from precomputed indirect lighting (no stationary skylight present). Default Value: 0.392699
r.CapsuleIndirectShadowMinVisibility Minimum visibility caused by capsule indirect shadows. This is used to keep the indirect shadows from going fully black. Default Value: 0.1
r.CapsuleMaxDirectOcclusionDistance Maximum cast distance for direct shadows from capsules. �This has a big impact on performance. Default Value: 400
r.CapsuleMaxIndirectOcclusionDistance Maximum cast distance for indirect shadows from capsules. This has a big impact on performance. Default Value: 200
r.CapsuleShadowFadeAngleFromVertical Angle from vertical up to start fading out the indirect shadow, to avoid self shadowing artifacts. Default Value: 1.047198
r.CapsuleShadows Whether to allow capsule shadowing on skinned components with bCastCapsuleDirectShadow or bCastCapsuleIndirectShadow enabled.
r.CapsuleShadowsFullResolution Whether to compute capsule shadows at full resolution. Disabled by Default.
r.CapsuleSkyAngleScale Scales the light source angle derived from the precomputed unoccluded sky vector (stationary skylight present) Default Value: 0.6

Capsule Indirect Cone Angle Comparison

Capsule Indirect Shadow Min Visibility Comparison

Capsule Max Direct Occlusion Distance Comparison

Coming Soon!

Capsule Max Indirect Occlusion Distance Comparison

This is a very subtle change in this scene. Look at the top right character on the wall. The shadow occlusion is extended to 500 units instead of 400 in this scene example.

Capsule Shadow Fade Angle From Vertical Comparison 

Coming Soon!!

Capsule Shadow Full Resolution Comparison

Coming Soon!!

Capsule Sky Angle Scale Comparison