View Full Version : RSL book example bad illum loop?

03 March 2012, 01:10 AM
Im on page 240 of Rudy Cortes' book The Renderman Shading Language Guide. The rest of the book has been really informative and every example has worked. However, I've been struggling with this one for the past week. And unfortunately, it doesnt work and the rest of the chapter seems to build on it. Im using 3delight studio pro 10.

I'm using an ambient light with a hdr hooked along with a provided teapot and the surface shader that the books specifies. The book also claims that you can use the parameter __nonspec to control the specularity from the light on the teapot surface shader. If I use another surface shader it works (but the nonspec doesnt work because i've been told that you need to make a custom illum loop)

Unfortunately, I just get a flat shaded image. Just reading the code I dont see any reference to diffuse like in the shaders before. However, they build on this shader a lot and the same exact code is given in the download section for the book.

If I cant get this to work within the next day Im going to probably switch books until I figure out more about illuminance loops and then switch back. I'm concerned with WHY this isnt working at all, if its a renderman versus 3delight thing?, and if it is broken, why does it appear in print and download and why do they build on it?

What I'm getting vs what I should be getting.


Option "searchpath" "shader" "@:E:/Cutter/compiled stuff/shaders"
Option "searchpath" "texture" "@:E:/Cutter/compiled stuff/textures"
Option "searchpath" "archive" "@E:/Cutter/compiled stuff/archives"
Display "../images/chapter8/l_RP_enhambientlight2.tif" "framebuffer" "rgb"
Format 500 500 1
PixelSamples 3 3
Clipping 0.001 1000
Projection "perspective" "fov" 30
Translate -1 0 30
Rotate -22 1 0 0
Rotate 19 0 1 0
Translate 0 -3 0

# Rotate the current space to affect the environment map
Rotate -90 1 0 0
LightSource "l_RP_enhambientlight" 2 "float intensity" [.08] "string ambientMap" ["campus_probe.tdl"]
"float ambientMapBlur" [0.1] "float ambientMapFilterWidth" [1]
LightSource "distantlight" 1 "intensity" [1]

## Begin teapot object
Attribute "displacementbound" "float sphere" [0.15]
Displacement "d_simplenoise" "float noiFreq" [15] "float Km" [0.0075]
#Surface "s_plastic3dl"
Surface "s_RP_ambient"
ReadArchive "teapotArch.rib"

Surface shader

#include "RP_illumloops.h"

surface s_RP_ambient(
float Ka = 1;
color surfaceColor = 0.75;
output varying float Cocc = 1;
/*Variables */

normal NN = normalize(N);

Ci = rpAmbient(NN, P, Cocc) * surfaceColor;


The illumination loop header

color rpAmbient(varying normal NN;
varying point P;
output varying float Cocc;
/* Variables */
color Cout = 0;
Cocc = 1;

illuminance("ambient", P){
Cocc = 1 - Cocc;
Cout += Cl;
return Cout;

Light Shader

light l_enhancedAmbient(
uniform float intensity = 1;
uniform color lightcolor = 1;
string ambientMap = "";
string envSpace = "shader";
uniform float ambientMapBlur = 0.1;
uniform float ambientMapFilterWidth= 1;
string ambientMapFilter = "gaussian";
string __category = "ambient";
float __nonspecular = 1;


normal Ns = normalize(N);
vector Nv;
color ambientMapColor = lightcolor;

illuminate (Ps + Ns) {
Nv = vector (ntransform(envSpace, Ns));

if (ambientMap !="")
ambientMapColor = environment (ambientMap, Nv,
"blur", ambientMapBlur,
"filter", ambientMapFilter,
"width", ambientMapFilterWidth);

Cl = intensity * lightcolor * ambientMapColor;

03 March 2012, 05:59 AM
The problem, basically, is that Pixar ignores their RenderMan spec, while 3Delight follows it. In PRMan, the predefined variable "N" is the same in both surface and light shaders. However, the RenderMan spec states that in a light source shader, "N" should return the shading normal of the emitting object (which is undefined except for area lights). 3Delight adds a predefined variable "Ns" to get the shading normal of the illuminated object.

So to fix your light shader, replace "Ns" with something else, and "N" with "Ns".

03 March 2012, 04:22 PM
Ok thanks a lot.

I've started reading Advanced Renderman in addition to this book and thats filling in the gaps.

CGTalk Moderation
03 March 2012, 04:22 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.