Using the Mental Ray Shader Wizard

 
 
 

Before you write the code for your shader function, you can build its interface and create the necessary project files so that you can successfully integrate your shader with Softimage. You can use the shader wizard to do this.

The shader wizard steps you through the templates that compose the SPDL file, which contains the information required to display the shader's user interface. It also generates the project files you need to write your shader, ensuring that your implementation structures match the parameter definitions in the SPDL file.

  1. Click File Plug-ins to open the Plug-in Manager.
    Note

    In the Tools Development Environment layout, click the Plug-ins tab to switch to the Plug-in Manager view.

  2. Do one of the following:
    • To create the property in the User location, click File New Shaders Mental Ray Shader.
    • To create the shader in a different location (such as a workgroup or an Add-on directory), expand the location in the Plug-in Tree, right-click the SPDL folder and click New Shaders Mental Ray Shader.

    The mental ray shader wizard appears.

  3. Under Shader Name, type short and long names for the shader.

    The first character in a shader name should be a letter. Subsequent characters can be letters, numbers, or underscore (_) characters.

  4. Add parameters to the shader.
  5. If the shader supports more than one render engine, fill in the metashader information.
  6. Define the layout of the parameters on the property page.
  7. On the Shader Information tab, click Generate Project to generate the SPDL, C++, and .VCPROJ files for the shader.

    All the generated files are put in the specified output folder (by default, in the Application\spdl folder).

  8. If the spdl file is not listed in the Plug-in Tree, click the SPDL tab and then click Update All.
  9. Compile the shader. Put the compiled dll/dso in the Application\bin\{CPU} folder, where {CPU} is nt-x86, linux, or nt-x86-64.
  10. Generate a preset for the shaders. In the Plug-in Tree, right-click the SPDL file and choose Regenerate Preset.

Adding Parameters

The Parameters tab allows you to customize the Parameter section in the generated SPDL file.

  1. In the Shader Wizard, click the Parameters tab.
  2. Under New Parameter, define a parameter:
    • In the Type list, click the type of the parameter.
    • In the Name box, type a name for the parameter.
    • In the Label box, type the text that will appear on the property page.
    • Set the other parameter attributes as required.
  3. Click Add Parameter.
Note
  • To edit a parameter, click the shaded cell at the start of a row (the row should be highlighted a light green), and then click Edit Selected. Edit the parameter definition and then click Update Parameter.
  • To delete a parameter, click the shaded cell at the start of a row (the row should be highlighted a light green), and then click Delete Selected.

MetaShader Information

The Metashader Information tab allows you to customize the MetaShader section in the generated SPDL file. For example, you can set options for mental ray, or specify a custom render engine.

To add a custom render engine

  1. Select the Use a custom section check box.
  2. In the Renderer Name box, type the name of the rendering engine.
  3. In the Entry Point Name, type the name of the shader function.
  4. If the shader is implemented in a file, type the name of the file in the File Name box.
  5. Shader Text is text that is inserted in the BeginText...EndText section of the SPDL file. For example, the implementation of the shader may be included in this section.
  6. Add any options required by the render engine.

To add an option

  1. Under Add Custom Option:
    • In the Name box, type the name of the option.
    • In the Value box, tpye the vale oft he option.
  2. Click Add Option.
    • To edit the name or value of an option after you add it, click a cell and type the new text.
    • To delete an option, click the shaded cell at the start of a row (the row should be highlighted a light green), and then click Delete Selected Options.

Defining the Layout

The Layout tab allows you to define the layout of controls on the shader's property page.

To add controls to the property page

In the Parameters list, click a parameter, and then click Add.

By default, parameters are added to the layout in the order you add them. But if you select a parameter in the Layout list, then the next time you add a parameter it is inserted above the selected parameter.

You can reorder the Layout list using the Up and Down buttons.

To add a row

  1. Click Add Row.

    An empty row is added to the Layout list. If a parameter is selected in the Layout list, the row is added above the selected parameter.

  2. In the Layout list, click one of the parameters you want to put in the row, and then click Up (or Down) until the parameter is in the row.

    Do the same for the other parameters you want to put in the row.

To add a group

  1. Under Groupings, in the Name box, type a name for the group.
  2. Click Add Group.

    An empty group is added to the Layout list. If a parameter is selected in the Layout list, the group is added above the selected parameter.

  3. To move a parameter into the group, click the parameter and then click either Up (if the parameter is below the group in the Layout list) or Down (if the parameter is above the group in the Layout list).

    Similarily, to move a parameter out of a group, click the parameter and then click Up or Down until the parameter moves out of the group.

To add a tab

  1. Under Groupings, in the Name box, type a name for the tab.
  2. Click Add Tab.

    The first time you add a tab, all parameters already in the Layout list are put on that tab.

  3. To add another tab, type a name for the tab in the Name box, and then (before you click Add Tab) do one of the following:
    • Add more parameters to the layout, and then, in the Layout list, click one of the parameters you just added.
    • Use the Up and Down buttons to move some parameters off the tab.
    • Click a tab (the Tab "name" { line)in the Layout list. This will result in an empty tab being added.

Generating a Preset

In the Plug-in Tree, expand the SPDLs folder, right-click the shader SPDL file, and choose Regenerate Preset.

If the Plug-in Tree does not show the shader SPDL file, click Update All on the SPDL tab.

Editing a Shader SPDL File

The Logic section of the SPDL file lets you add behavior to your shader's property page. For example, if no texture is applied to a selected object, you can make the texture parameters inaccessible to users. The shader wizard does not generate this type of behavior. You'll have to add it to the SPDL file yourself.

Examples

You can also see the related example Show Edges and Wireframe located in the examples folder of the Softimage SDK installation directory.

Creative Commons License Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License