Short Contents

8.8 The DSM display driver

This display driver produces deep shadow maps. As explained in Shadows, DSMs support opacity, prefiltering and motion blur. It is suggested to use DSMs whenever possible.

"float tolerance" [0.02]
DSMs tend to grow quite large, unfortunately. The display driver tries to compress them using an algorithm that shrinks file size without exceeding some specified error threshold. A value of `0' (that is, no error allowed) produces large DSMs and should never be used and a value of `1' compresses DSMs too much and results are unsatisfactory. If this parameter is not specified or set to -1, the display driver computes a default value (currently always 0.02).
"string compressionlevel" ["2"]
This option turns on additional compression which makes DSMs even smaller without affecting quality. "0" means no additional compression is not recommended. "1" uses compression which has no significant speed impact. "2" is the default and usually creates quite smaller files at the expense of slightly longer generation time.
"string nomipmap" ["off"]
Disables or enables mipmapping for this deep shadow map. Mipmapping is enabled by default but one could save more than 25% of storage space by using raw DSMs. Be careful though, since mipmaped DSMs usually produce nicer results (especially when viewed from far away).
"string volumeinterpretation" ["discrete"]
Specifies whether the deep shadow map is used to compute shadows cast by solid objects or those cast by participating media (fog, clouds, smoke, etc). When rendering participating media shadows, one should specify "continuous" to this parameter. Default is "discrete".
"float fadedistance[2]" [0 0]
If set to values other than zero, shadows will fade between these two distances from the surface generating them. Using the same value twice will cause a sharp cutoff, similar to a maxdist when tracing shadows. To get the smooth fadeout, "continuous" volume interpretation must be used.

EXAMPLE

# Write out a deep shadow map for participating media
Display "shadow.dsm" "dsm" "rgbaz"
    "string volumeinterpretation" ["continuous"]

There is not need to run tdlmake on files produced by this display driver since they are already in the right format. This display is limited to resolutions which are a power of two.

Particle and volume self-shadowing

Particles rendered into a deep shadow map will appear as flat objects. Thus, when viewed from a different location than the light, the half closer to the light will not be shadowed while the other half will have self-shadowing. To work around this problem, 3Delight allows shaders to specify the thickness of a surface by outputting a "float __thickness" variable. This will spread the opacity computed by the shader over the specified depth around the surface. The depth should be specified in "current" space by the shader. For particles, using width as the thickness is usually correct:

surface particle_shader(
    varying float width = 0;
    output varying float __thickness = 0; )
{
    __thickness = width;
    // More shading code...
}

3Delight will also automatically compute a thickness for interior and atmosphere shaders. It is possible to disable that feature by having the shader output a __thickness of 0.

Note that this features requires that the "volumeinterpretation" parameter of the DSM display driver be set to "continuous".

3Delight 10.0. Copyright 2000-2011 The 3Delight Team. All Rights Reserved.