shadow_stencil

Determines the type of dynamic shadows cast by models.

Range:

0 - Z-buffer shadows (default).
1 - Z-pass stencil shadows.
2 - Z-fail stencil shadows  A7 .

Type:

var

Remarks:

Stencil buffer shadows look better than z-buffer shadows: they 'bend' around corners, and objects can cast shadows on themselves. Due to the hard shadow edges, especially with self shadows, they work best with high polygon models and rather dark levels with hard light contrasts. Stencil buffer shadows have the following restrictions:

Z-pass stencil shadows are faster than z-fail shadows, but don't allow to move the camera into a shadow volume. They are the best method for elevated 3rd person cameras, like in an isometric game. In first person mode the player's shadow is automatically switched off when z-pass stencil shadows are activated.

Z-fail stencil shadows are slower than z-pass shadows, but more robust. They are independent of the camera position and allow LOD models to differ greatly from the original model, which would otherwise cause shadow faults with the z-pass algorithm. Z-fail shadow volumes are columns rather than cones, although the difference is only visible with close lights. A script can be used for tracing a ray from a light source to the camera, and automatically switching to z-fail shadows when the ray hits an obstacle.

Z-buffer shadows are projected onto the floor below the model by the sun only. The projection direction is given by the sun azimuth and elevation (sun_angle).

Example:

shadow_stencil = 2; // activate z-fail stencil shadows

See also:

CAST, SHADOW, shadow_threshold

► latest version online