Defining a Render Tree

To define a render tree in a MetaShader, you put all render tree Node and Connection definitions in the BeginText...EndText section. For example:

MetaShader "pheno_shader"
{
   Name = "Example Pheno Shader";
   Type = texture;
   Renderer "mental ray"
   {
       Name = "example_pheno_shader";
       Options
       {
          "version" = 1;
       }
       BeginText
       Node "rayswitch" = guid "{8604221E-BCFA-11D1-90E9-0000F804EB21}";
       Node "photon" = guid "{6D228369-EB66-11D1-8054-00A0C906835D}";
       Connection "rayswitch::photon" = "photon";
       Connection root    = "rayswitch";
       EndText
   }
}

The node and connection syntax is the same as it was for phenomena shaders.

Each shader in a render tree is declared by its GUID:

Node "<shader instance name>" = GUID "<shader guid>";

Then you can then use the declared shaders to set up a connection tree. There are three different ways you can do this.

• Set a shader parameter value to a constant value. For example:

# Get the Colour_Share shader and set its input to red.
Node "constant_color" = GUID "{BDE291BB-077A-11D2-8A1A-00A0C9892542}";
Connection "constant_color::input" = Value 1.0 0.0 0.0 1.0;

• Connect to the property set of a shader:

# Get the Colour_Share shader and set its input to whatever
# the value of the "color" parameter. We assume that this
# parameter has been defined above in the "PropertySet" 
# section.
Node "constant_color" = GUID "{BDE291BB-077A-11D2-8A1A-00A0C9892542}";
Connection "constant_color::input" = Interface "color";

• Establish a shader-to-shader connection. If a shader has a single output it is enough to refer to its name. If it has multiple outputs and only one component is desired the syntax "<shader>.<output>" can be used. Example of both:

# Get the color_math shader and connect one of its input
# to the color_share node and the other to the specular
# output of the base phong shader.
Node "constant_color" = GUID "{BDE291BB-077A-11D2-8A1A-00A0C9892542}";
Node "multiply_color" = GUID "{6EE27300-A1E2-11D3-AE51-00A0C96E63E1}";
Node "phong" = GUID "{89C75826-BCFA-11D1-90E9-0000F804EB21}";

Connection "multiply_color::input1" = "constant_color";
Connection "multiply_color::input2" = "phong.specular";
Connection "multiply_color::op" = 2; # Multiply

Finally, a single shader needs to provide the output value of the shader. This can be done by connecting it to the root connector:

Connection root = "multiply_color";

This sets the output of the render tree to whatever result multiply_color gives.

There are other connections available if you want to add some global shaders into the mix for the render tree (such as lens, output, contour store/contrast, and volume).



Autodesk Softimage v7.5