Defining the Shader Parameters: MetaShader SPDL
The MetaShader section of the SPDL file identifies each of the renderers capable of using the shader.
Example: Multiple Implementation Shader
MetaShader "water"
{
Type = texture;
Renderer "mental ray"
{
Name = "water_mr";
Options
{
Scanline = off;
}
}
Renderer "renderman"
{
Name = "water_rm";
BeginText
color water_rm( )
{
return( noise( P ) );
}
EndText
}
Renderer "opengl"
{
Name = "water_ogl";
File = "opengl";
}
}
It contains the following parameters:
• Type: Specifies the type of the shader and the context in which it can be used. Softimage uses pre-defined types for mental ray and realtime shaders: lens, light, light photon, material, rtrendercontext, material photon, shadow, volume, volume photon, environment, output, geometry, texture and displace.
• Renderer: Identifies and contains options for each rendering system that is capable of using this metashader. There is one Renderer section per rendering system. The parameter is a text string, representing the name of the rendering engine that can render this shader. There is one Renderer section for each rendering engine.
The Renderer parameter includes the following sub-parameters:
- Name: Indicates the symbol name of the shader code to use. For example with mental ray shaders this would indicate the prefix for the symbol (callback) name in the DLL where the code for the shader is.
- Options: Contains a list of string/value pairs that are passed to the renderer. The option name can be any string. The value can be boolean, integer, float or string.
Depending on the renderer, the Option list is used in different ways:
- mental ray renderer: The Option list stores the rendering options for this particular shader, such as whether shadows are on or off.
- Realtime renderers: Softimage’s metashaders provide many examples of using the Option section to store parameter pairs. This a portion is Softimage’s Phong metashader, which supports both mental ray and Cg. The Cg paramaters are shown below:
Renderer "Cg"
{
Name = "material-phong_cg";
Options
{
"param0" = "ambient";
"param1" = "diffuse";
"param2" = "specular";
"param3" = "ambience";
"param4" = "shiny";
"const0" = "diffuse_inuse";
"const1" = "specular_inuse";
"param7" = "radiance";
}
- Other renderers: The Option section could provide a path for the location of the source code of the shader. For example, this is useful for the RenderMan shader library where the all the code for a large shader library could be provided as one big SL file. It could be used in conjunction with the Name parameter to indicate which of the shaders defined in the file is the one that this SPDL represents. For mental ray, you could also provide a source code which would then be compiled at render time.
• BeginText / EndText: Provides a placeholder for any arbitrary text that can then be interpreted or compiled into a shader by the rendering engine. Anything between these two markers is stored in a text section and is not parsed in any way by the SPDL parser. This is useful for providing quick shaders without having to create multiple files for containment.
For more information about the SPDL files and the MetaShader section, see SPDL Reference.
Autodesk Softimage v7.5