Introduction to the Shading Language


Remarkably realistic images can be produced with a few fairly simple shapes made from interesting materials and lighted in a natural way. Creating a photorealistic image requires the specification of these material and lighting properties. This part of the document describes the Shading Language, which is used to write custom shading and lighting procedures called shaders. Providing a language allows a user to extend shading models or to create totally new ones. Models of light sources with special lenses, concentrators, flaps or diffusers can be created. The physics of materials can be simulated or special materials can be created. This is done by modeling the interaction of light at the surface and in the interior of a region of space. Material types can also be combined, simulating the many coats of paint or finish applied to a surface. Providing a shading language also allows many of the tricks and shortcuts commonly performed during production rendering to be accommodated without destroying the conceptual integrity of the shading calculations. Visualizing the results of scientific simulations is also easier because shaders can be written that produce a surface color that is based directly on the results of a computation. For example, it is possible to write a shader that sets the surface color based on temperature and surface curvature. Shaders can also be used to specify nonlinear geometric transformations and to modify the final pixel values before they are written to the display.

The Shading Language is a C-like language with extensions for handling color and point data types. A large number of trigonometric and mathematical functions, including interpolation and noise functions, are provided. Color operators are provided that simulate the mixing and filtering of light. Point operators perform common geometric operations such as dot and cross product. A collection of commonly used geometric functions is also provided. These include functions to transform points to specific coordinate systems. Common lighting and shading formulas, such as ambient, diffuse, specular, or phong, are available as built-in functions. Built-in texture access functions return values from images representing texture maps, environment maps, bump maps, and shadow depth maps. The texture coordinates given to these functions can be either the pre-supplied texture coordinates or values computed in the Shading Language. Since texture map values are just like any other value in the language, they can be used to control any aspect of the shading calculation. There is in principle no limit to the number of texture maps per surface.

The Shading Language is also used for specifying surface displacement functions such as ripples or nubs. Shading Language functions are also used for pixel operations. This type of shader is referred to as an imager. Imagers are used to do special effects processing, to compensate for non-linearities in display media, and to convert to device dependent color spaces (such as CMYK or pseudocolor).


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.