Relationship to the RenderMan Interface


The Shading Language is designed to be used with the RenderMan Interface described in Part I of this document. This interface is used by modeling systems to describe scenes to a rendering system. Like most graphics systems, the RenderMan Interface maintains a current graphics state. This state contains all the information needed to render a geometric primitive.

The graphics state contains a set of attributes that are attached to the surface of each geometric primitive. These shading attributes include the current color (set with RiColor and referred to as Cs) and current opacity (set with RiOpacity and referred to as Os). The geometric primitive also contains a current surface shader (RiSurface) and several volume shaders: the current atmosphere shader (RiAtmosphere), current interior shader (RiInterior) and a current exterior shader (RiExterior). All geometric primitives use the current surface shader for computing the surface shading at their surfaces and the current exterior shader for computing the attenuation of light through the volume containing them. Light directed toward the viewer is attenuated with the current atmosphere shader. If the surface shader of a primitive causes rays to be traced (with the trace() function), the ray color will be attenuated with either the current exterior shader or current interior shader, depending on whether the traced ray is in the direction of, or opposite to, the surface normal.

The graphics state also contains a current list of light sources that contains the light sources that illuminate the geometric primitives. Light sources may be added to this list using RiIlluminate. Light sources can be attached to geometric primitives to define area light sources (RiAreaLightSource) or procedurally define their geometric properties (RiLightSource). The current area light source contains a list of geometric primitives that define its geometry. Defining a geometric primitive adds that primitive to this list.

The graphics state also maintains the current transformation that is the transformation corresponding to the modeling hierarchy. The graphics state also contains a current displacement shader (RiDisplacement) and an imager (RiImager).

The RenderMan Interface predefines standard shaders for light sources, surfaces, and volumes. These standard shaders are available in all rendering programs that implement the RenderMan Interface, even if some algorithmic limitation prevents them from supporting programmable shaders. Standard and implementation-dependent shaders should always be specified in the Shading Language, even if they are built in. The predefined shaders provided by the Shading Language are listed in Table 10.1, Standard Shaders. There is also a null shader that is used as a placeholder. Shading Language definitions for these shaders are given in Appendix A.

Table 10.1 Standard Shaders

Type Shader
Light sources ambientlight
distantlight
pointlight
spotlight
Surfaces constant
matte
metal
shinymetal
plastic
paintedplastic
Atmosphere fog
depthcue
Displacement bumpy
Imager background

Shaders contain instance variables that customize a particular shader of that type. For a surface shader these variables may denote material properties; for a light source shader these variables may control its intensity or directional properties. All instance variables have default values that are specified in the definition of the shader. When a shader is added to the graphics state, these default values may be overridden by user-supplied values. This is done by giving a parameter list consisting of name-value pairs. The names in this list are the same as the names of the instance variables in the shader definition. Note that many different versions of the same shader can be instanced by giving different values for its instance variables. The instance variables associated with a shader effectively enlarge the current graphics state to include new appearance attributes. Because the attributes in the graphics state are so easily extended in this way, the number of "built-in" or "predefined" shading-related variables in the graphics state has been kept to a minimum.

There are several steps involved in using a shader defined in the Shading Language. First, a text file containing the source for the shader is created and edited. Second, this file is then compiled using the Shading Language compiler to create an object file. Third, the object file is placed in a standard place to make it available to the renderer. At this point, a shader programmed in the Shading Language is equivalent to any other shader used by the system. When a RenderMan Interface command involving a programmed shader (that is, one that is not built-in) is invoked, the shader is looked up by name in the table of available shaders, read into the rendering program, and initialized. This shader is then instanced using the instance variables supplied in the RenderMan Interface procedure. Finally, when a geometric primitive is being shaded, the shaders associated with it are executed.


No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of Pixar. The information in this publication is furnished for informational use only, is subject to change without notice and should not be construed as a commitment by Pixar. Pixar assumes no responsibility or liability for any errors or inaccuracies that may appear in this publication.

 

Pixar Animation Studios
(510) 752-3000 (voice)   (510) 752-3151 (fax)
Copyright © 1996- Pixar. All rights reserved.
RenderMan® is a registered trademark of Pixar.