Lumberyard
User Guide (Version 1.16)

Object Shadows

With object shadows, you can assign custom shadow maps to selected objects, resulting in increased shadow quality due to higher world space shadow texel (texture element) density and reduced depth range.

The drawbacks of using object shadows are increased memory consumption of the additional shadow maps and increased shadow filtering cost.

Object shadows only affect sun shadows. For performance reasons they are not sampled on forward geometry such as particles, hair, and eyes.

Using Flow Graph

This topic references tools and features that are legacy. If you want to use legacy tools in Lumberyard Editor, disable the CryEntity Removal gem using the Project Configurator or the command line. To learn more about legacy features, see the Amazon Lumberyard Legacy Reference.

You can use the Environment:PerEntityShadows flow graph node and assign the target entity to the Entity slot. The Trigger input applies the settings to Lumberyard.

Because this node is stateless with respect to the entity, you can add multiple Environment:PerEntityShadows nodes for the same entity. The last one to be triggered will be in effect.

Use the following node inputs to tweak the shadow appearance:

  • ConstBias/SlopeBias – Reduces avoid self-shadowing artifacts.

  • Jittering – Filters kernel size, which directly affects shadow softness.

  • BBoxScale – Scale factor for the bounding box of the selected entity. Can be useful in case the bounding box is too small or too large.

  • ShadowMapSize – Size of the custom shadow map, which is automatically rounded to the next power of two.

Using I3DEngine

The following I3DEngine interface functions can be called from anywhere in game code. The function parameters are equivalent to the parameters for the Environment:PerEntityShadows Flow Graph node.

  • AddPerObjectShadow – Adds an object shadow.

  • RemovePerObjectShadow – Removes an object shadow.

  • GetPerObjectShadow – Retrieves object shadow settings for a given RenderNode. Do not overwrite the RenderNode pointer. Instead use AddPerObjectShadow\RemovePerObjectShadow.

  • ShadowMapSize: Size of the custom shadow map, which is automatically rounded to the next power of two.

Console Variables

You can use the e_ShadowsPerObject console variable with object shadows. With this variable, 0 = 0ff, 1 = on, and -1 = don't draw object shadows.