shadow_stencil
Determines the type of dynamic shadows cast by models.
Range:
off - Z buffer shadows (default).
on - Stencil buffer shadows.
Type:
var, redefinable.
Remarks:
Stencil buffer shadows look better than z buffer shadows: they 'bend'
around corners, and objects 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:
- Stencil buffer shadows are slower than z buffer shadows, and only run on
3D cards with 8 bit stencil buffer support. Most 3D cards manufactured after
2000 fulfil this requirement.
- Stencil buffer shadows can only be cast by nontransparent models consisting
of closed meshes with no holes or polygons intersecting or touching each
other with their flat side. Otherwise rendering errors (dark lines projecting
from the model to the shadow) can be visible. In a closed mesh, every edge
is shared by exactly two triangles. If the model's mesh is not closed, create
a closed mesh LOD model for shadow casting. The MED meshtester can be used for determining whether a mesh is closed
or not.
- Dynamic shadows are not clipped by walls. A shadow can be cast on a wall,
at the back side of the wall, and on the floor behind the wall at the same
time. Take care that level and models are very dark in unlit parts (or use
the cast flag) to cover or suppress unwanted shadows.
- Stencil shadows are also visible on model polygons that point away from
the light source, which can lead to undesired flickering shadow polygons.
To avoid this, use a material with low ambient and a high diffuse part.
- For speed reasons, a z-pass stencil shadow algorithm is used that
does not allow to move the camera into a shadow volume. Therefore the
player should only cast a stencil shadow when using a 3rd person
camera. In first person mode the player's shadow is automatically
switched off when stencil shadows are activated.
Z buffer shadows behave the following way:
- They are projected onto the floor below the model only.
- The projection direction is given by the sun
azimuth and elevation (sun_angle).
Example:
var shadow_stencil = on;
See also:
cast, shadow, shadow_threshold