shader: "decal"

"decal"

ShaderReflectance

"decal"( "selector" LtShader NULL
"decal texture space" LtShader NULL
"base displacement" LtShader NULL
"decal displacement LtShader NULL
"base transparency" LtShader NULL
"decal transparency" LtShader NULL
"base colour" LtShader NULL
"decal colour" LtShader NULL
"base reflectance" LtShader NULL
"decal reflectance" LtShader NULL
"keep base texture space" LtBoolean TRUE
"transparency mode" LtEnum LI_DECAL_TRANSPARENCY_MODE_ATTENUATE
)
Synopsis Reflectance shader that provides support for surface property trees.
Locationlishclas
Description A shader which provides the entry point to support surface property trees. This shader switches between two sets of surface properties and illumination models defined by the corresponding sets of shaders:

  • base surface determined by "base displacement", "base transparency", "base colour" and "base reflectance",

  • decal surface determined by "decal displacement", "decal transparency", "decal colour" and "decal reflectance".

Switching between the two sets of properties is accomplished using the alpha shader global. This global is calculated by a transparency shader which is passed to the decal reflectance shader through the "selector" parameter. The calculated value of alpha is used as a switching coefficient (m). It divides the surface into two areas:

  • base area---where m = 0.0,

  • decal area---where m > 0.0.

Placing decals on the base surface corresponds to placing one, possibly semi-transparent, object (the decal) onto another (the base). It has the following implications for the way the surface properties (normal, transparency, colour) are calculated in each area.

In the {\b base area} the shading process simply uses the base shaders.

In the {\b decal area} the results obtained at each stage of the shading pipeline are combinations of the results of applying the appropriate base and decal shaders at that stage of the pipeline. The proportions in which the base and decal shaders influence the surface appearance depend not only on the value provided by the "selector" shader, but also on the value of the "decal transparency" shader passed as an argument to the decal reflectance shader. The blending coefficient cblend used to combine base and decal shaders is therefore calculated as:

cblend = m * a_d,

where a_d is the alpha value calculated by the "decal transparency" shader. If there is no "decal transparency" shader, then the blending coefficient is simply equal to m. A blending coefficient of 0.0 means that only base shaders determine the surface appearance. In other words, where the decal is transparent, only the base surface properties (as determined by the displacement, colour and reflectance shaders) are included in the final result.

The results of the base and decal shaders are combined as follows.

Displacement:

  • in base area---as calculated by the "base displacement" shader;

  • in decal area---the normal deviation resulting from the "base displacement" shader is calculated. This is then added to the deviation resulting from the "decal displacement" shader attenuated by cblend. The "decal displacement" shader is therefore executed after the "base displacement" shader.

Transparency:

  • in base area---as calculated by "base transparency" shader;

  • in decal area---the method of calculating transparency depends on the value of the "transparency_mode" parameter:

    • LI_DECAL_TRANSPARENCY_MODE_ATTENUATE: The resultant transparency is the base transparency attenuated by the decal transparency. To avoid aliasing effects along the borders of the decal area, the final decal transparency is calculated as:

      tr = m * tr(d) + (1.0 - m) * tr(b)

      where tr stands for both alpha and To transparencies; tr(d) is the transparency of the pure decal (the transparency calculated by the "base transparency" shader, attenuated by the transparency calculated by the "decal transparency" shader); and tr(b) is the base area transparency as calculated by the "base transparency" shader.

      In this mode the final transparency cannot be greater than either the base or the decal transparency. This corresponds to the natural effect of placing several, semi-transparent labels over each other. Here the final surface is always less transparent than each individual label.

    • LI_DECAL_TRANSPARENCY_MODE_MIX: In this mode the decal transparency is mixed with the base transparency using the value of m. The formula for the final transparency is the same as for LI_DECAL_TRANSPARENCY_MODE_ATTENUATE, but now tr(d) simply represents the transparency calculated by the "decal transparency" shader. In the area where m=1.0 and the decal shader results in a transparent surface, the final result is also transparent, regardless of the result of the base transparency calculation. In this mode the "decal transparency" shader can therefore be used to make holes in opaque base surfaces.

Colour:

The colours of the base and decal areas are calculated using the corresponding colour and reflectance shaders. In the areas where the blending coefficient is in the range 1.0 > cblend > 0.0 the final colour is calculated as a linear interpolation of the colours calculated by the decal and base reflectance shaders. The blending coefficient is used in the linear interpolation.

The decal reflectance shader takes several other shaders as parameters. The default values for each of these shaders is NULL. If a NULL shader parameter is assigned (or left as default) then the corresponding value (colour, normal, transparency) will remain unchanged. This is equivalent to applying the shader originally assigned to the surface. Having NULL for the base or decal reflectance shaders is equivalent to using dummy "constant" reflectance shaders.

Using the "decal texture space" parameter, it is possible to define a texture space shader for use in the decal area. The "keep base texture space" parameter determines which texture space will be applied to the shaders in the base branch of the decal reflectance shader in the shade tree. If this parameter is set to TRUE, then the original texture space assigned to the primitive will be restored before executing the base shaders of this decal shader.

If set to FALSE then the base shaders will be executed using the texture space co-ordinates calculated by their parent shader in the shader tree. Note that "keep base texture space" only affects shaders assigned directly to the decal shader for which the parameter is set. This property is not inherited by child decal shaders. To use the primary texture space for shaders in the base branches at all levels of the shade tree then it is necessary to set the "keep base texture space" parameter appropriately for each used reflectance decal shader.

Previous page alphabetically (decal)
Next page alphabetically (depthcue)
Index


Copyright © 1990-2004, 2005 LightWork Design Limited. All rights reserved