Distance field shadows

This recipe is quite short, but too sweet to be just a quick tip. Besides what was discussed in the previous recipe, there is a further pre-computed shadow type that is off by default. The full name for it is a signed distance field baked shadow. But what does that mean? UDK has this method built into its dominant lights, and once enabled it replaces the native shadows. Besides being distance based, a key difference is in the compactness of the information stored. The technology is derived from Valve's Alpha Tested Magnification and effectively stores the lighting information in the separate RGB channels of a texture. For more information, explore Valve's paper, which discusses limited texture artifacts: http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf.

Getting ready

Open the provided scene Packt_08_LightEnvironment_DEMO.UDK. This is the same scene as was used previously. Roll the camera over some area of the ground where the trees are casting shadows.

How to do it...

  1. There is really only one thing to worry about, the Whole Scene Dynamic Shadow Radius. Remembering this only works with DominantDirectionalLights, go to the Edit | Find Actors then search for Dominant and you should get the actor which is performing as the scene's sun. This also works in the default map templates (post-June 2011), which all have a DominantDirectionalLights already provisioned.
  2. Open the selected light's properties and under Lights | Light Component expand the Cascaded Shadow Maps section, and in the property Whole Scene Dynamic Shadow Radius enter a value of 1024. Build and PIE to try and see any difference in the shadow detail.
    How to do it...
  3. In the left-hand side screenshot, we have Whole Scene Dynamic Radius set to 1024. For that image, in the DominantDirectionalLight properties, the value for CascadedShadowMaps | NumWholeSceneDynamicShadowCascades was 10. A value of 1 would be less detailed, but its softness would be equal all around. In the right-hand side screenshot, it is set to 0, which disables the dynamic shadow.

How it works

The distance field method gives us a cheap shadow type that is good for sharp, detailed shadow situations. The downside is that we don't have a penumbra or Falloff we can access, and the calculation is from the camera, not distance from the base of the object. If you must have shadow penumbras, try using a DirectionalLightToggleable, which can do those, but is more expensive over a whole scene. Penumbras are covered in depth in the next topic.

Overall, we have a few ways to generate shadows in UDK (static shadows, dynamic shadows, composite shadows, and cascaded shadows). Until there's an uber lighting solution, it is enough for most cases.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.114.132