RixPattern Plugins
|
Introduction
Version 19 of RMS and RPS introduced an advanced form of raytracing called
RIS. RIS relies on the
use of shading networks built from components written, not in RSL, but in C++.
Pixar's documentation about the RIS API can be found
here,
RixPattern plugins are implemented by two files - a text file and a DSO (dynamic shared object). A ".args" text document describes the inputs and outputs of a plugin. When a plugin is loaded by Maya's HyperShade its corresponding ".args" file is used to define the "look" of user interface. For example, part of the ".args" document for the CutrBBones plugin (figure 1) is shown below. It defines two inputs, "rgb_input" and "s_cutoff", and a single output named "resultC". The interface is shown in figure 2. |
Listing 1 (CutrBBones.args)
|
|
Cutter & Writing Pattern Plugins
Writing a pattern plugin consists of using Cutter to create and add inputs and outputs to an ".args"
file. After which, Cutter can be used to generate a ".cpp" file that will implement most
of the (routine) code required by the RixPatter API. This tutorial demonstrates, step-by-step,
how Cutter can be used to develop
and test a simple RixPattern plugin named "CutrBBones". The plugin applies a color, figure 3,
to an object where its surface exceeds a pre-defined 's' texture value. The full code for the
".args" and ".cpp" files are available here,
maya/projects/ |_ RfM_ris/ | |_Args/ | | |_ [pattern.args files are kept here] | | | |_ [pattern.cpp files are kept here] | |_ RfM_ini/ | |_ RenderMan_for_Maya.ini | |_ RMSWorkspace.ini | |_other RfM_xxx directories Creating a RixPattern PluginStep 1 - Creating a .args fileSelect the Templates->Args->cutrEmptyPattern.args menu item.
A basic .args document will open. Save it as, maya/projects/RfM_ris/Args/CutrBBones.args Step 2 - Adding Inputs
Right-mouse click on the line immediately after the "Inputs begin" comment. From
the popup menu choose,
Each param is identified by two strings, "name" and "label". The "label" string sets the title of the widget in HyperShade. However, the "name" string is more significant than the "label" because it must match an item in the C++ source code file of the plugin. Readers are strongly advised to think carefully about the value of the "name" string because changing it at a later date can be very tedious. Assign the following "name", "label" and "default" values to the inputs. |
<param name="rgb_input" label="Color" type="color" default="1 0 0" input="True" widget="color" tag="color and pattern"/> <param name="s_cutoff" label="S Cutoff" type="float" default="0.5" input="True" widget="default"/> |
Step 3 - Adding an OutputRight-mouse click on the line immediately after the "Outputs begin" comment. From the popup menu choose "Results/Outputs->Color" - figure 7.
The output name |
Step 4 - Previewing the Interface in a Browser
To preview the ".args" interface use the keyboard shortcut alt+e (or control+e or apple+e).
Cutter will write and display a web page that pre-visualizes the appearance of the plugin
in HyperShade - figure 8.
The preferred browser can be set using the Preferences Tool (Edit->Show Preferences) - figure 9.
Step 5 - Generate the C++ Code
Right-mouse click anywhere within the CutrBBones.args document and select,
Cutter will generate a ".cpp" document. For example, from maya/projects/RfM_ris/CutrBBones.cpp Step 6 - Compile/Make the DSO
Before inspecting and editing the cpp code use Cutter to compile and link
a DSO. On linux and MacOSX Cutter will automatically create and execute
a makefile named Makefile.CutrBBones that it will save
in the same directory as the ".cpp" file. On Windows Cutter will create and run
a ".bat" file named "Build_CutrBBones.bat".
Use the alt+e shortcut to generate and run the makefile. On OSX and Linux the process
monitor window will open and report the creation of a DSO named "CutrBBones.so" - figure 11.
Note: WindowsAs of Cutter versions 6.8.5 it is assumed the user has a version of Microsoft Visual Studio (MVS) installed on their Windows computer. Cutter uses a MVS file named "vcvars86_amd64.bat" when it runs it compiles and builds a pattern plugin. The full path to the vcvars86_amd64.bat must be specified in preferences. For example, in figure 12 the path has been specified as follows. |
C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/x86_amd64/vcvarsx86_amd64.bat |
|
|
// A "user" "int" option is read as a RtInt. RtInt iOptValue; err = rstate->GetOption("user:input_color_profile", &iOptValue, sizeof(RtInt), &optType, &optNumValues); if(err == 0 && optType == RixRenderState::k_Integer) { m_msg->Info("user:profile: %d", iOptValue); } else iOptValue = 1.0; // default value ? |
Header File LookupRight mouse clicking on most datatypes and functions will raise a popup menu that will provide convenient access to the appropriate header file.
|
Typing CompletionA popup menu of alternative completions will appear after the first three letters have been typed. Insertion is done by hitting the tab key.
|
Pixar DocsControl + double clicking (OSX - Apple + double clicking) a word in the pattern .cpp document will cause Cutter to open the Pixar doc "Writing Patterns". |
© 2002- Malcolm Kesson. All rights reserved.