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...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Section 14<br />

SHADERS AND FUNCTIONS<br />

<strong>The</strong> Shading Language distinguishes between shaders and functions. Shaders are procedures<br />

that are referred to by <strong>RenderMan</strong> <strong>Interface</strong> procedures. Functions are procedures<br />

that can be called from within the Shading Language. <strong>The</strong> distinction between shaders and<br />

functions is primarily a consequence of different argument passing conventions.<br />

14.1 Shaders<br />

Shaders are introduced by the keywords light, surface, volume, displacement, or imager<br />

and are followed by the name of the shader and the statements that comprise its definition.<br />

<strong>The</strong>se keywords indicate the type of <strong>RenderMan</strong> <strong>Interface</strong> shader that is being defined.<br />

<strong>The</strong> <strong>RenderMan</strong> <strong>Interface</strong> uses the shader type to enforce a type match in subsequent calls<br />

to <strong>RenderMan</strong> <strong>Interface</strong> procedures. For example, it is illegal to declare a shader to be of<br />

type light and then instance it using RiSurface.<br />

<strong>The</strong> arguments to a shader are referred to as its instance variables. All of these variables are<br />

required have default values, and are assumed to be uniform unless declared otherwise.<br />

Shader instance variable values can be changed when a particular shader is instanced from<br />

the <strong>RenderMan</strong> <strong>Interface</strong>. For example, consider the shader weird:<br />

surface<br />

weird( float a=0.5; varying float b=0.25 )<br />

{<br />

Ci = color (mod(s,a), abs(sin(a+b)), mod(b,t));<br />

}<br />

This surface shader may be referenced through the <strong>RenderMan</strong> <strong>Interface</strong> with the RiSurface<br />

command. For example,<br />

RiSurface ( ”weird”, RI NULL );<br />

instances the above shader with all its defaults.<br />

129

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

Saved successfully!

Ooh no, something went wrong!