Open Shading Language

return to main index


    Sony OSL
    Pixar PxrOSL
    OSL Specification [pdf]
    OSL Overview

Summary of Cutter's Features

    Syntax Coloration
    Popup Menu - Metadata & Functions
    Popup Menu - rib files, ui preview and convert to args script
    Compiling a Shader
    Typing Completion
    Assigning a RfM Nodeid
    Listing Shader Parameters


This tutorials outlines the features of Cutter that support the writing of OSL shaders

Syntax Coloration

Cutter applies a syntax coloration scheme to OSL source code - listing 1.

Listing 1 - OSL Syntax Coloration

    float s = 0 
        int lockgeom = 0
    float t = 0 
        int lockgeom = 0
    output color resultRGB = 0)
resultRGB = color(s, t, 1);

Syntax colors can be set by the "Colors" preferences panel for ".osl" - figure 1.

Figure 1 - Syntax Colors

Osl Compiler

If shaders are to be compiled for use with RenderMan the path to "RPS root" must be set in the Installation Directories panel - figure 2.

Alternatively, if the shaders will be used with another rendering package the explicit location of the "oslc" compiler must be set in the Languages->Osl tab panel - figure 3.

Figure 2 - Path to RenderManProserver

Figure 3 - Path to the compiler bin directory

Paths - User Source Code & Compiled Shaders

The location of the users .osl source code files and the compiled .oso files are set in the Rman->User panel - figure 4.

Figure 4 - Paths to the users .osl and .oso directories

Popup Menu - Metadata & Functions

The popup menu for .osl documents is context sensitive. When activated (right mouse button) in the parameter declarations block the following options are available.

Figure 5

If the cursor is positioned within a metadata block ie. between opening and closing square brackets, [[ ]], metadata hints can be conveniently inserted. For example, in figure 5 if "Label" had been chosen the following metadata would have been inserted.

    float frequency = 5 
        string label = "Your Label",
    float variation = 1,

If the popup is activated within the body of the shader the following options are available.

Figure 6

Popup Menu - Rib files

The Create... menu enables rib files to be generated that can be used to test a shader without the need to load the shader in Maya's HyperShade.

Figure 7

Popup Menu - UI Preview

The Create... menu also enables the UI of the shader to be previewed in a web browser. This is useful when adding metadata to customize the "look" of the shader when loaded into HyperShade.

Popup Menu - Convert to Args Script

Finally, the Create... Args Script menu item offers a convenient way of creating an .args file that defines the UI of a C++ pattern plugin that will be the equivalent to a shader. For example, the osl shown on the left would generate the args on right.

Figure 8

    float s = 0 [[
                string widget = "null",
                int lockgeom = 0
    float t = 0 [[
                string widget = "null",
                int lockgeom = 0
    color patcolor = color(1,1,0)
                string label = "Pattern Color",
    output color resultRGB = 0
<args format="1.0">
        <tag value="pattern"/>
        No Description Available.
        <param name="patcolor"
            label="Pattern Color"
            type="color" default="1 1 0" 
                <tag value="color"/>
        <output name="resultRGB"
                <tag value="color"/>
    <rfmdata nodeid="1" classification="rendernode/RenderMan/pattern"/>

Compiling a Shader

If the prefs (figures 2 and 3) have been set and the "shaders" path is valid (figure 4), compiling an OSL shader is done using the keyboard shortcut alt + e, control + e or apple + e. Confirmation of the compilation will be shown in the Process Monitor - figure 9.

Figure 9

Typing Completion

Cutter also implement simple typing completion. Completion is activated by the tab key.

Assigning a RfM Nodeid

RenderMan for Maya (RfM) version 21 introduced a way of pre-registering compiled shaders for direct use as specific nodes in HyperShade without the need to use the generic PxrOSL node. The registration relies on the presence of metadata of the following form.

int rfm_nodeid = 3,
string rfm_classification = "rendernode/RenderMan/pattern",
string help = "Brief description goes here."

The value of rfm_nodeid must be a unique integer. A range of nodeids can be obtained by studios from AutoDesk so that they do not load shaders and .args files that define nodes that will clash with other nodes. However, individuals who do not intend to distribute shaders (or .args files) are free to use nodeid values in the range 1 to 524288.

The range of nodeids to be used for shaders (and .args files) can be set in Cutter's preferences.

Figure 10

To help automate the chore of assigning a nodeid to a shader the popup menu has an Assign NodeID menu item.

Figure 11

When the item is selected Cutter will examine the nodeids that have been assigned to the users shaders and .args files and will either insert or update the metadata at the head of the shader. A summary of the all the users nodeids can be generated from the Rman Tools->Plugins menu.

Figure 12

This functionality has been provided so that users can check if a nodeid is used by more than one shader or .args file.

Listing Shader Parameters

The "procs" button now provides a way of finding a specific parameter. This is useful when editing a shader with many parameters. The name of each parameter is prefixed with the name of its page.

Figure 13

© 2002- Malcolm Kesson. All rights reserved.