Phenomenon Roots

The above example also illustrates a new option allowed in phenomenon but not shader definitions, the phenomenon root. There are several types of root statements:

    root shader
    root material "material_name"

    geometry shader
    volume shader
    environment shader
    lens shader
    output shader
    output ["type"] "format" [opt] "filename"
    contour store shader
    contour contrast shader

    volume priority priorityint
    lens priority priorityint
    output priority priorityint

All of these except one of the first two are optional. The first root statement specifies the primary root shader of a phenomenon that is called when the phenomenon is called. In the above example, the mtlsh shader, when called, calls the phenomenon phong_phen, which immediately calls its subshader sub because sub is specified in its root statement.

The root material variant creates a material phenomenon. This type of phenomenon must be declared with the return type material. It is instanced normally with a shader statement, which provides the interface parameter values. The resulting shader is different from regular shaders; its name can be used everywhere where a material name is valid. A regular phenomenon that does not have type material and no root material statement, when instanced using a shader statement, becomes a shader, not a material. Material phenomena should be used instead of regular phenomena if the phenomenon depends on not only assigning a single shader, such as a material shader, but other material components such as shadow shader, photon shader, volume shader etc. as well. See page matphen for an example of a material phenomenon.

In addition to the main root statement, other roots may be defined that reference shaders of other types:

geometry

The geometry shader or shader list is evaluated before rendering starts. This allows the phenomenon to introduce procedural geometry into the scene. For example, a light beam phenomenon might install a transparent cone in the scene that bounds the volume effect.

volume

The volume shader or shader list is added to the camera before rendering starts. This allows the phenomenon to specify a global atmosphere that should be installed if the phenomenon is defined.

environment

The environment shader or shader list is added to the camera before rendering starts. This allows the phenomenon to specify a global environment shader that should be installed if the phenomenon is defined. Environment shaders are called when a ray does not intersect any object.

lens

This root is doing the same thing for lens shaders that should be added to the camera before rendering starts.

output

The list of output shaders and file output statement is added to the camera before rendering starts. This allows the phenomenon to specify output shaders that should be installed if the phenomenon is defined. For example, the phenomenon might write a label frame buffer whose values are picked up by the output shader after rendering completes.

contour  store

The contour store shader is used for contour rendering.

contour  contrast

The contour contrast shader is used for contour rendering.

Note that during rendering, only root (or root material in the material phenomenon case) has any significance because the others have been removed and added to the camera or the scene before rendering started. After rendering and output shading completes, all these changes are undone. Note that if the phenomenon is defined several times (using multiple shader statements or anonymous shader definitions that reference it), the roots other than the main root are added to the scene more than once [9]interface or shader parameter assignments.

The shader priority statements provide control over the placing of the specified shaders or shader lists in the corresponding shader list in the camera. Shaders with greater priority numbers are appended to shaders with smaller priority numbers, and hence execute later. Shaders with no priority number have priority 0, so they get executed before shaders with positive priority numbers. The shaders defined in the camera always have priority 0.

[9] Shaders attached directly or indirectly to the output, contour store, and contour contrast roots may not use shader assignmentinterface or shader parameter assignments.

Copyright © 1986-2009 by mental images GmbH