Slim Appearance Scripts

return to main index


The Cutter text editor is designed to assist artists create, edit and test slim scripts. This tutorial provides a summary of Cutter's features There are two types of slim scripts, those that define the UI for a shader (.slo) imported into HyperShade and those that implement a Slim shading node. The former are called appearance slim scripts; the latter are called template slim scripts - both have the same .slim file extension. How Cutter handles template slim scripts is dealt with in the tutorial Cutter: Slim Template Scripts.

Appearance .slim Scripts

When a shader (.slo) is imported into HyperShade the RfM plugin (RenderMan for Maya) references the shader and searches for an optional slim file with the same name as the shader. If the script is found the information it contains directs RfM to lay out specific widgets in the shaders attribute editor to control the parameters of the shader.

Step 1 - Creating an Appearance

Open a shader source code file in Cutter. For the purposes of illustration the following code, taken from the tutorial RSL: Color By Height, will be used to demonstrate the capabilities of Cutter.

colorByObjOrigin(float  Kfb = 1,
                        minheight = 1.25,
                        maxheight = 2.5;
                color   mincolor = color(1,0,0),
                        maxcolor = color(0,1,0))
point originC = point "object" (0,0,0);
point originW = transform("world", originC);
float height = originW[1];
float blend = smoothstep(minheight, maxheight, height);
color surfcolor = mix(mincolor, maxcolor, blend);
Oi = Os;
Ci = Oi * surfcolor * Kfb;

Compile the RSL source code using the keyboard shortcut alt+e or control+e or apple+e. Cutter will generate and save a slim appearance script in the same directory as the compiled shader. A copy of the slim script can be found here.

The user interface (UI) defined by the appearance slim is shown below. With or without an appearance the RenderManShader is fully functional with the exception of being able to be connected to other HyperShade nodes.

Figure 1

Although each shader parameter has its default value defined in the RSL code, Cutter uses a few rules when it generates the parameter blocks in an appearance slim file. For example, parameters that begin with upper-case 'K' have their min/max range set from 0.0 to 1.0. Other float parameters, for example,

    float  minheight = 1.25

have their ranges set to 0.0 to twice their default value ie. 0.0 to 2.5.

Step 2 - Controlling an Appearance

Cutter never guesses if a float parameter should be presented in HyperShade as a checkbox rather than a slider. For example, if an additional parameter,

    float  swapColors = 0;

was added to, it would appear in the Maya's Attribute Editor as a slider rather than a checkbox.


However, Cutter looks for ui-hints embedded in the comments associated with each parameter. For example, the ui-hint,
      [0 or 1]
embedded within the following comment,

    float  swapColors = 0; /* Swaps min and max colors. [0 or 1] */

"tells" Cutter to specify a checkbox (a switch in Slim-speak).


Notice that the text of the comment becomes the popup description. Although the tutorial Cutter: Slim UI Hints lists the ui-hints that Cutter recognizes another example of "ui-hinting" is given next. The ui-hint,
      [Group some_name]
"collect" widgets into groups. The keyword Group can be all lowercase, or, Collection or collection can also be used. The following declarations and comments,

colorByObjOrigin(float  Kfb = 1,
                        minheight = 1.25,
                        maxheight = 2.5;
                float   swapColors = 0;          /* [group "Colors" 0 or 1] */
                color   mincolor = color(1,0,0), /* [group "Colors"] */
                        maxcolor = color(0,1,0)  /* [group "Colors"] */ )

would cause Cutter to write an appearance slim that defines the following UI.

© 2002- Malcolm Kesson. All rights reserved.