Documentation/User Attributes And Options

From PixieWiki

Jump to: navigation, search


It's often desirable to control the behaviour of a shader - perhaps to turn on or off raytracing. This can be done with a parameter to the shader. However, this can mean that there are lots of places to change if you want to switch the mode. This can be the case even if you're using a modelling package which supports renderman shaders directly.

[edit] User Attributes

"User Attributes" allow you to store user-defined data in the attribute state for Pixie. That means the data gets pushed and popped with AttributeBegin and AttributeEnd. This can be queried from a shader to alter it's behaviour, or via Conditional RIB.

An option can be defined like so:

Attribute "user" "<type> <name>" [data]

eg.

Attribute "user" "string specialShaderMode" ["bake"]

or

Attribute "user" "int shaderSwitch" [1]

[edit] User Options

"User Options" allow you to set modes for a whole scene which can be queried from a shader, or via the new Conditional RIB support:

Option "user" "<type> <name>" [data]

eg.

Option "user" "string passname" ["bake"]

[edit] Querying from SL

The SL shadeops option() and attribute() support user-defined options and attributes. For example, you can use:

//..
string passName;
option("user:passName",passName);
if (passName == "beauty") {
 // do my beauty-pass-only SL here
}

This means you can switch the operation of many shaders and many shader instances simply by including

Option "user" "string passName" "<myRenderPassName>"

At the top of your RIB.

Personal tools