Torque/LightingSystem/DTS Lighting and Shadows

From TDN

Introduction

Unlike interiors and the terrain, DTS objects are not light mapped, which makes lighting them tricky. Luckily the Torque Lighting System does an excellent job approximating lighting on movable DTS objects and provides tools to tune lighting on static DTS objects.

Contents


DTS Lighting Sources

DTS objects have three potential light sources; diffuse, ambient, and self-illumination. Diffuse and ambient lighting can come from a combination of light objects and environmental lighting (from the interiors and the terrain beneath the object), while self-illumination is applied during the modeling process.

The advanced DTS lighting options allow different combinations of environmental and custom lighting to be used for the diffuse, ambient, and self-illumination sources. For instance, some of the more common environmental lighting sources are the sun and terrain/interior lighting.

The following is a list of the possible environmental lighting sources and their settings:

Image:TLK-DTS-LightingChart.jpg


TGEA / TGE 1.5 related info:

The Receive LM option can be used to modify Receive Sunlight, changing the diffuse contribution to the color picked up from the interior or terrain beneath the object instead of using the sun's color (while still using the sun's ambient).


TLK related info:

Stronger directional lighting can be achieved from environmental lighting by setting the pref
$pref::OpenGL::sgDynamicDTSVectorLighting to true.

More stylized lighting can be achieved from environmental lighting by adjusting the pref
$pref::OpenGL::sgDynamicDTSShadingDiffuseAmount. This value balances the ratio of diffuse to ambient lighting (this is disabled when using $pref::OpenGL::sgDynamicDTSVectorLighting).

DTS Shadows

The Torque Lighting System allows DTS objects to cast both static and dynamic shadows. Torque has many different types of DTS objects (TSStatic, Player, Items, ...), and each casts different types of shadow. The following shows the shadows cast by the base objects types:

Image:TLK-ShadowChartA.jpg

Each shadow type has pros and cons that should be considered when placing static DTS objects in levels. Deciding on the shadow types to use will dictate the object type.

Image:TLK-ShadowChartB.jpg

DTS objects have the option to disable animation and movement of shadows (optionally the shadow can be completely disabled) to minimize rendering overhead.

Multiple dynamic DTS shadows can be disabled by setting the pref
$pref::LightManager::sgMultipleDynamicShadows (TLK uses $pref::TS::sgMultiDynamicDTSShadows) to false. This reverts the shadows back to the older style single shadow.

The detail of dynamic DTS shadows can be changed by adjusting the prefs
$pref::LightManager::sgDynamicShadowDetailSize and $pref::LightManager::sgDynamicShadowQuality (TLK uses $pref::TS::sgShadowDetailSize). TGE 1.5 and TLK ship with seven shadow detail levels, which are chosen by using the detail index 0 - 6 (the lower the index the higher the detail). TGEA's shadows can be reduced any number of levels.

These options are highly effective in tuning performance.


(static DTS shadows are based on the object's collision mesh - if a proper collision mesh does not exist no shadow is produced)

Direct -vs- Linked Lighting

In addition to environmental lighting, static DTS objects can receive lighting directly from light objects. There are two ways to achieve this: direct and linked lighting.

Direct lighting occurs when a light object's datablock is set to affect DTS objects. The light directly illuminates DTS objects and is blended with any lighting already affecting the object.

Linked lighting occurs when a light is not set to affect DTS objects and it, or its containing group, is added to a static DTS object's lightGroupName property, which links the DTS object to a light or group of lights, causing it to be illuminated by a light that otherwise would not illuminate it.

Light linking is especially helpful in situations where DTS lighting shines through obstructions (DTS lighting doesn't cast shadows) and zone lighting cannot be used. Instead the lights are set to not affect DTS objects and any object that should receive lighting is hand linked to the lights.

Multiple light objects and group names can be linked to a DTS object by separating the names with semicolons (';').

Shadows on DTS Objects

DTS objects do not directly receive shadows, instead these are shaded to simulate being lit or shadowed. Object lighting and shadowing is determined in different ways depending on the type of lighting used.

Static lighting, which is baked into terrain and interior light maps, is transferred to DTS objects by sampling the lighting of the terrain or interior surface directly beneath the object. Samples are taken from the terrain light map or the interior vertex lighting (even when light mapping is used). Because lighting and shadows are baked into the terrain and interiors, the lighting transferred to DTS objects is usually fairly accurate.

Direct lighting from static lights contributes additional lighting directly to DTS objects. In TGE 1.5 and TLK this lighting is not occluded (blocked) in any way, this means direct lighting shines through walls and can only be controlled with zone lighting or by switching to linked lighting.

In TGE 1.5.1 direct lighting from static lights is occluded by all normal shadow casting objects (terrain, interiors, and other DTS objects). This means DTS objects will behave as if they are receiving shadows from other objects. The occlusion check does cause a slight performance hit, which can be reduced by dropping the occlusion quality using the pref $pref::LightManager::sgDynamicLightingOcclusionQuality (0 - high, 1 - medium, 2 - low, 3 - off). The occlusion test can also be toggled per-object using the object property useLightingOcclusion.