26.01.2015 Views

The RenderMan Interface - Paul Bourke

The RenderMan Interface - Paul Bourke

The RenderMan Interface - Paul Bourke

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Section 3<br />

RELATIONSHIP TO THE RENDERMAN SHADING<br />

LANGUAGE<br />

<strong>The</strong> capabilities of the <strong>RenderMan</strong> <strong>Interface</strong> can be extended by using the Shading Language.<br />

<strong>The</strong> Shading Language is described in Part II of this document. This section describes<br />

the interaction between the <strong>RenderMan</strong> <strong>Interface</strong> and the Shading Language.<br />

Special procedures, called shaders, are declared in this language. <strong>The</strong> argument list of a<br />

shader declares variables that can be passed through the <strong>RenderMan</strong> <strong>Interface</strong> to a shader.<br />

For example, in the shading language a shader called weird might be declared as follows:<br />

surface<br />

weird ( float f = 1.0; point p = (0,0,0) )<br />

{<br />

Cs = Ci * mod ( length(P-p)*f - s + t, 1.0 );<br />

}<br />

<strong>The</strong> shader weird is referred to by name and so are its variables.<br />

RtFloat foo;<br />

RtPoint bar;<br />

RiSurface (”weird”, ”f”, (RtPointer)&foo, ”p”, (RtPointer)&bar, RI NULL);<br />

passes the value of foo to the Shading Language variable f and the value bar to the variable<br />

p. Note that since all parameters are passed as arrays, the single float must be passed by<br />

reference.<br />

In order to pass shading language variables, the <strong>RenderMan</strong> <strong>Interface</strong> must know the type<br />

of each variable defined in a shader. All predefined shaders predeclare the types of the<br />

variables that they use. Certain other variables, such as position, are also predeclared.<br />

Additional variables are declared with:<br />

RtToken<br />

RiDeclare (char *name, char *declaration)<br />

12

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!