Blue Moon Rendering Tools 2.4

Part 6: Shading Language Compiler, slc


revised 27 August 1998


Larry I. Gritz
gritzl@acm.org



If you are using rendrib, you are probably already used to one aspect of working with the RenderMan Interface: specifying scenes. In other words, using the procedural interface (the C library calls) or using RIB (the ASCII archival format).

There is another aspect to using the RenderMan Interface: writing your own shaders. You've already used some of the "standard" shaders such as "matte", "metal", "plastic", and so on. You may already have used some custom shaders that I wrote (such as "planks"). Part of the real power of the RenderMan interface is the ability to write your own shaders to control the appearance of your objects.

Shaders control the appearance of objects. There are several types of shaders:

surface
Control surface color and reflection characteristics.
displacement
Adds detail to the positions or normals of a surface (like making it look dented).
light
Specify how a light source illuminates its environment.
transformation
Transforms points in space.
imager
Alters pixel colors.
volume
Attenuates light due to volumes or participating media.

The RenderMan interface specifies that there are several standard shaders available. Standard surface shaders include "constant", "matte", "metal", "plastic", "shiny", and "paintedplastic". Standard light source shaders are "ambientlight", "distantlight", "pointlight", and "spotlight". Standard volume shaders are "depthcue" and "fog". The only standard displacement shader is "bumpy", and there are no standard transformation or imager shaders.

6.1 Compiling .sl files

Once you have written a shader, save it in a file whose name ends with the extension ".sl". To compile it, do the following:

	slc myshader.sl

This will result either in a compiled shading language object file called myshader.so, or you will get error messages. Hopefully, the error message will direct you to the line in your file on which the error occurred, and some clue as to the type of error. slc only can compile one .sl file at a time.

IMPORTANT NOTE: slc uses the C preprocessor (cpp). This executable is usually kept in the /lib directory. Therefore, you need to have this directory in your execution PATH or slc will not be able to run properly.

Since .sl files are passed through the C preprocessor, you can use the #include directive, just as you would for C language source code. You can also give an explicit path for include files using the -I command line option to slc (just like you would for the C compiler). You can also use #ifdef and other C preprocessor directives in a shader. A variable named BMRT is defined, so you can do something like #ifdef BMRT.


This document last updated 27 Aug 98 by gritzl@acm.org

All BMRT components are Copyright 1990-1998 by Larry I. Gritz. All rights reserved.

The RenderMan Interface Procedures and RIB Protocol are: Copyright 1988, 1989, Pixar. All rights reserved. RenderMan is a registered trademark of Pixar.