TorqueShaderEngine/LightingSystem/Dynamic Shadows
From TDN
|
[edit] IntroductionThis section explains the Torque Lighting System's implementation of dynamic lighting and shadows in TGEA.
[edit] Dynamic LightingMost dynamic lighting features are shared between all versions of the Torque Lighting System and are covered in the Basic Lighting articles (which also cover static lighting).
There a several features specific to TGEA's implementation:
Lighting Shader Features
The Feature property determines which of the base material features (diffuse, bump, specular, cube mapping, ...) the dynamic light reproduces, which adds control over the light's visual impact and quality. Reducing features also improves rendering performance (see Dynamic Lighting Performance for details).
The lighting features are:
Full - reproduces the entire base material features Lighting Mask
The Mask Cube property allows a dynamic light to be filtered using the specified cube map texture. The mask is applied using modulation, meaning that white areas allow lighting to pass unaffected, while dark areas apply a shadowing effect. The effect also applies the filter's color to the light, so transparency effects like dirty, broken, and stained glass can be created.
[edit] Dynamic ShadowsThe Torque Lighting System's dynamic shadow implementation casts shadows from dynamic DTS objects onto the world and the objects themselves (based on shadow quality and hardware availability). Dynamic shadows like all dynamic real-time effects create rendering overhead and should be used sparingly (see Performance Considerations for more details).
Different types of DTS objects (TSStatic, ShapeBase derived, ...) cast either static or dynamic shadows. To understand the differences and to find out which objects are best for your scene; see DTS Lighting and Shadows
Object shadows are adjusted using the following datablock properties:
shadowEnable - enables shadows on the object. Dynamic shadows automatically perform LOD transitions based on the distance from the viewer to improve performance when quality is not as critical. The LOD affects both shadow size and quality (disabling self-shadowing at a suitable distance).
Dynamic shadows can be reduced from multiple shadows-per-object to a single shadow with the user pref $pref::LightManager::sgMultipleDynamicShadows, or disabled with the user pref Note 1: Unlike shadows cast on interiors, DTS to DTS shadowing cannot use depth partitioning. This means DTS objects can receive shadows through walls and other objects. To minimize this effect, use zoned lighting, reduce the casting object's shadow projection distance, rig lighting to avoid shadow casting lights near thin walls, floors, or ceilings, or design levels with thick walls, floors, and ceilings.
[edit] Dynamic Shadow QualityDynamic shadow quality is adjustable on several levels, including; per-object via datablock, automatically based on hardware support, and through the user quality pref
$pref::LightManager::sgDynamicShadowQuality (0 - high, 1 - medium, 2 - low), which limits the quality of all dynamic shadows, trading quality for performance.
High quality shadows perform self-shadowing and provide a nice soft shadow edge. High quality requires pixel shader 3.0 or higher, the user quality pref set to high (0), and the object set to self-shadow.
Medium quality shadows perform self-shadowing, but have a less smooth edge. Medium quality requires pixel shader 2.0 or higher, the user quality pref set to at least medium (1), and the object set to self-shadow.
Low quality shadows do not self-shadow, but provide a nice soft edge. Low quality is used on hardware with < pixel shader 2.0, when the user quality pref is set to low (2), or on objects that do not self-shadow.
[edit] Dynamic Shadow SizeDynamic shadow size works similar to shadow quality, though it's not limited by hardware. An object's maximum shadow size is set using the datablock property shadowSize. The user shadow size pref $pref::LightManager::sgDynamicShadowDetailSize (0 - highest, 1 - next smaller size, ...) reduces the size of all shadows, trading quality for performance.
[edit] Tweaking Self-shadowingSelf-shadowing can cause some visual artifacts especially when using small shadow sizes, this can be reduced using the datablock property shadowBias. The default value is 0.0005 - increasing the value reduces any visual artifacts, while decreasing the value makes shadows more accurate.
[edit] Performance ConsiderationsSee TGEA Performance Considerations.
|




