Pixar
August, 1990
This is a list of known errors in the first printing of The RenderMan Companion, including syntax errors, typographical mistakes and omissions that make the code listings incorrect as they appear in the book. The second printing corrected some, but not all, of these errors. As a result, this document may include errors that do not appear in your book. Extra code required to make the examples run, such as camera setup for the geometry chapters, is not discussed here.
p. 25 -- Listing 2.3: There are two problems with the initialization of the array Cube[6][4]. First, commas are missing between the second and third points and also between the third and fourth points in the bottom face definition. Second, the polygons' normals all face towards the center of the cube. This is a somewhat subtle error, but an error nonetheless. Note that the second and fourth columns of data are switched. The cube's definition should be as follows:
static RtPoint Cube[6][4] = { { {L,D,F}, {L,D,N}, {R,D,N}, {R,D,F} }, /* Bottom face */ { {L,D,F}, {L,U,F}, {L,U,N}, {L,D,N} }, /* Left face */ { {R,U,N}, {L,U,N}, {L,U,F}, {R,U,F} }, /* Top face */ { {R,U,N}, {R,U,F}, {R,D,F}, {R,D,N} }, /* Right face */ { {R,D,F}, {R,U,F}, {L,U,F}, {L,D,F} }, /* Far face */ { {L,U,N}, {R,U,N}, {R,D,N}, {L,D,N} } /* Near face */ };
p. 34 -- Listing 2.8: The picture files produced by the animation sequence have names which are too long for MS-DOS filenames. These should be changed to anim#.pic where # is a number from 1 to 10. Do this by changing the call to sprintf() to read:
sprintf( filename, "anim%d.pic", frame);
p. 62: parameters to RiSphere() are illustrated at left should read "... illustrated at right".
p. 64: ... points in the x,z plane of three-dimensional gspace, then calls RiHyperboloid() ... should read ... three-dimensional space, ....
p. 67 -- Listing 4.3: The call to RiSphere() in the middle of TorusWave() has an incorrect argument list. As the comment indicates, a downward-opening hemisphere is desired, but downward-opening from the perspective of the viewer, not the object coordinate space. Because of the 90 degree rotation about the X axis, an upward-opening is needed for the hemisphere's creation. The comment and code should read as follows:
/* Create the cap for the center of the wave */ RiSphere( innerrad, -innerrad, 0.0, thetamax, RI_NULL);
p. 76 -- Listing 5.2: The #include reference to surfor.h should not be there. Note that the other #include file pin.hyper.h is not presented.
The comment in PolySurfOR() refers to "the goblet description". This should read "the surface profile".
PolyBoid() is supposed to be provided as a triangular polygon approximation to hyperboloids, with the addition of suitable surface normals. It is meant as an improvement to the PolyBoid() function in Listing 5.1. What is provided instead is a function called PolyBand(), which is semantically identical to the PolyBoid() function presented in Listing 5.3. This function illustrates the RiPointsPolygons() interface call. Replace PolyBand() with the PolyBoid() function shown below:
/* ================================================================ */ #define SWAP(a,b,temp) temp = a; a = b; b = temp; #define COPY_POINT(d, s) {d[0]=s[0]; d[1]=s[1]; d[2]=s[2];} PolyBoid(point0, point1, normal0, normal1, ndivs, parity) RtFloat *point0, *point1, *normal0, *normal1; int ndivs, parity; { RtPoint vertexpair0[2], vertexpair1[2], *ptrnextvertex = vertexpair0, *ptrlastvertex = vertexpair1, *temp, vertextriangle[3]; RtPoint normalpair0[2], normalpair1[2], *ptrnextnormal = normalpair0, *ptrlastnormal = normalpair1, normaltriangle[3]; int i; getnextpair(0+parity/2.0, ptrnextvertex, point0, point1, ndivs); getnextpair(0+parity/2.0, ptrnextnormal, normal0, normal1, ndivs); for (i = 1; i <= ndivs; i++) { SWAP(ptrlastvertex, ptrnextvertex, temp) SWAP(ptrlastnormal, ptrnextnormal, temp) getnextpair(i+parity/2.0, ptrnextvertex, point0, point1, ndivs); getnextpair(i+parity/2.0, ptrnextnormal, normal0, normal1, ndivs); COPY_POINT(vertextriangle[0], ptrlastvertex[0]); COPY_POINT(vertextriangle[1], ptrlastvertex[1]); COPY_POINT(vertextriangle[2], ptrnextvertex[1]); COPY_POINT(normaltriangle[0], ptrlastnormal[0]); COPY_POINT(normaltriangle[1], ptrlastnormal[1]); COPY_POINT(normaltriangle[2], ptrnextnormal[1]); RiPolygon(3, RI_P, (RtPointer) vertextriangle, RI_N, (RtPointer) normaltriangle, RI_NULL); COPY_POINT(vertextriangle[0], ptrnextvertex[0]); COPY_POINT(vertextriangle[1], ptrnextvertex[1]); COPY_POINT(vertextriangle[2], ptrlastvertex[0]); COPY_POINT(normaltriangle[0], ptrnextnormal[0]); COPY_POINT(normaltriangle[1], ptrnextnormal[1]); COPY_POINT(normaltriangle[2], ptrlastnormal[0]); RiPolygon(3, RI_P, (RtPointer) vertextriangle, RI_N, (RtPointer) normaltriangle, RI_NULL); } } /* ================================================================ */
p. 94 -- Listing 6.2: The call to RiBasis() is missing a comma after the first RI_CATMULLROMSTEP argument. It should read:
RiBasis( RiCatmullRomBasis, RI_CATMULLROMSTEP, RiCatmullRomBasis, RI_CATMULLROMSTEP);
p. 101 -- Listing 6.3: There is a problem in consistency between this listing and the other surface of revolution listings; this listing revolves about the y-axis, everything else revolves about the z-axis. To make this example also revolve about the z-axis, change the assignments of the mesh[][][] to read as follows:
mesh[v][u][0] = points[v].x * coeff[u][0]; mesh[v][u][1] = points[v].x * coeff[u][1]; mesh[v][u][2] = points[v].y;
The comments refering to "XY plane" and "Y axis" should also be changed to "XZ plane" and "Z axis", respectively.
All references to wrap and nowrap surfaces should be changed to periodic and nonperiodic. The text in this section of the book should be updated to reflect this fact: the term RI_NOWRAP should be changed to RI_NONPERIODIC, and RI_WRAP should be changed to RI_PERIODIC.
p. 102 -- Listing 6.4: All references to wrap and nowrap surfaces should be changed to periodic and nonperiodic. The text in this section of the book should be updated to reflect this fact: the term RI_NOWRAP should be changed to RI_NONPERIODIC, and RI_WRAP should be changed to RI_PERIODIC.
p. 128 -- Listing 7.2: #include <math.h> should be at the top of this listing to support the calls to sqrt().
p. 135 -- Listing 7.4: The parameter list to PlacePins() should be changed so that the first parameter reads "xseparation", rather than "separation". Of course the following RtFloat declaration should also be updated.
p. 154 -- Listing 8.4: The function min() does not exist in the math library, but can be #defined with:
#define min(a,b) ((a)<(b)?(a):(b))
The fov parameter in RiProjection() should be in degrees, not radians. This can be done with the following change:
fov = 2 * atan((min(framewidth,frameheight)*.5)/focallength);
should read
fov = 2 * atan((min(framewidth,frameheight)*.5)/focallength) *180.0/3.14159;
p. 168 -- Listing 8.5: The call to RiProjection() should not be done; it is being done in the call to FrameCamera().
Casting PICXRES and PICYRES to RtInt in the #define section causes parameter passing problems when calling FrameCamera(). To fix this, change the call to FrameCamera() to read:
FrameCamera((float)PICXRES*CAMZOOM, (float)PICXRES, (float)PICYRES);
p. 205 -- Listing 10.3: In addition to <ri.h>, <math.h> and <stdio.h> should be #included.
There is no presentation of RiProcedural() in this example. The following code should be inserted between the typedef of FractalTriangle() and the #definition of MOVEPT.
/* ================================================================ */ Go() { int childnum; FractalTriangle mytriangle; FractalPoint *pVertex; RtBound bound; pVertex = &(mytriangle.vertices[0]); pVertex->location[0] = -1; pVertex->location[1] = -0.5; pVertex->location[2] = 0; (pVertex++)->seed = random(); pVertex->location[0] = 1; pVertex->location[1] = -0.5; pVertex->location[2] = 0; (pVertex++)->seed = random(); pVertex->location[0] = 0; pVertex->location[1] = 0.5; pVertex->location[2] = 1; (pVertex++)->seed = random(); mytriangle.level = 0; mytriangle.children = (FractalTriangle *) NULL; TriangleBound( &mytriangle, bound ); RiProcedural( &mytriangle, bound, FractalDiv, FractalFree ); } /* ================================================================ */
The call to RiProcedural() in TriangleSplit() is missing a semicolon (;) at the end of the line. Also, "data" should be of type RtPointer, not char *. Actually, this doesn't matter much, because TriangleSplit() needs to be fixed, as noted below.
FractalDiv() does not correctly split a triangle and render its children; FractalDiv() and TriangleSplit() should be modified to read as follows:
/* ================================================================ */ #define MAXLEVELS 5 /* * FractalDiv(): RenderMan refinement procedure for subdividing a fractal * triangle. */ FractalDiv( data, levelofdetail ) RtPointer data; RtFloat levelofdetail; { FractalTriangle *pTriangle = (FractalTriangle *)data, *pChild; RtPoint vertices[3]; RtBound bound; int nchildren; if (levelofdetail<1.0 || pTriangle->level>MAXLEVELS ) { /* Small enough to be rendered */ MOVEPT(pTriangle->vertices[0].location, vertices[0]); MOVEPT(pTriangle->vertices[1].location, vertices[1]); MOVEPT(pTriangle->vertices[2].location, vertices[2]); RiPolygon( 3, RI_P, vertices, RI_NULL ); } else { /* Too large; subdivide */ if(!pTriangle->children) TriangleSplit( pTriangle ); pChild = pTriangle->children; nchildren = 4; while( nchildren-- ) { /* TriangleBound() computes the bounding box for a triangle */ TriangleBound( pChild, bound ); RiProcedural( pChild++, bound, FractalDiv, FractalFree ); } } } TriangleSplit( pFT ) FractalTriangle *pFT; { int childnum; FractalTriangle *pChildren; pFT->children = pChildren = (FractalTriangle *)malloc( 4*sizeof(FractalTriangle) ); for(childnum = 0; childnum < 4; childnum++) { pChildren[childnum].children = NULL; pChildren[childnum].level = pFT->level+1; } for( childnum = 0; childnum < 3; childnum++ ) { pChildren[childnum].vertices[0] = pFT->vertices[childnum]; EdgeSplit( &(pFT->vertices[childnum]), &(pFT->vertices[(childnum+1)%3]), &(pChildren[childnum].vertices[1])); } for( childnum = 0; childnum < 3; childnum++ ) { pChildren[3].vertices[childnum] = pChildren[(childnum+1)%3].vertices[2] = pChildren[childnum].vertices[1]; } } /* ================================================================ */
A FractalFree() function is not provided in . Append the following code to Listing 10.3.
/* ================================================================ */ FractalFree( data ) RtPointer data; { FractalTriangle *pTriangle = (FractalTriangle *)data; if(pTriangle->level == 0) FreeChildren( pTriangle->children ); } FreeChildren( pFTChildren ) FractalTriangle *pFTChildren; { if( pFTChildren ) { FreeChildren( pFTChildren ); free( pFTChildren++ ); FreeChildren( pFTChildren ); free( pFTChildren++ ); FreeChildren( pFTChildren ); free( pFTChildren++ ); FreeChildren( pFTChildren ); free( pFTChildren++ ); } } /* ================================================================ */
p. 216: RiMatte() has a boolean flag which enables/disables (RI_TRUE/RI_FALSE) the matte attribute.
RiMatte(onoff) RtBoolean onoff;
p. 222: It (Fconeangle) decays from 1 in the spotlight direction (to-from) to 0 coneangle radians away, and so is nonzero only inside a cone 2*coneangle degrees wide. According to the RMIS, p. 25, coneangle is in radians, thus this passage should read ... 2*coneangle radians wide.
p. 227 -- Figure 11.6: I+L should be L-I (to reverse the direction of I). The lengths of I and L should also be normalized before averaging to get H and this should be implied in the figure by making the two vectors the same length. In actuality no equation is really needed at all for H, as the fact that angles A and A are equal, and the description of H in the text are sufficient.
p. 228 -- Listing 11.2: The order of the frames goes 3, 1, 2, 4. It seems reasonable to change this to 1, 2, 3, 4.
p. 253 -- Listing 12.1: The order of the points in textcoords[] does not agree with corners[]. The line:
textcoords[] = {{0,0}, {0.5,0}, {0.5,0.5}, {0,0.5}};
should read:
textcoords[] = {{0,0}, {0.5,0}, {0,0.5}, {0.5,0.5}};
p. 254 -- Listing 12.2: In addition to <ri.h>, <math.h> should be #included because of the call to sqrt().
In MapSurfOR(), "npts" is an input parameter, but is later referred to as "npoints"; the same thing happens with "pts" and "points". The declaration should be changed to:
MapSurfOR(points, npoints) Point2D points; int npoints;
Also, MAXNPOINTS is not defined. NPOINTS can be used instead.
In TextSurfOR(), "tmap" is used as an interface variable, but it is not declared. The call to RiSurface() must be prefaced by the RiDeclare() call:
RtToken RI_TMAP; RI_TMAP = RiDeclare("tmap", "uniform string"); RiSurface("mytexture", RT_TMAP, (RtPointer)&tmap, RI_NULL);
p. 266 -- Listing 12.3: At the top of the file, add
#include <stdio.h>
before <ri.h>.
The declaration of "filename" should be done outside of the main() function. Change the line
char filename[BUFSIZE], tfilenames[6][BUFSIZE+4];
to read
char tfilenames[6][BUFSIZE+4];
and put the line
char filename[BUFSIZE];
immediately after the CameraFrom declaration at the top of the file.
In the call to RiDeclare(), change the argument "reflmap" to "mapname". The surface used for the sphere is the "shiny" surface, which has "mapname" as its parameter.
The declaration of parameters in Snap() should be changed. "tfilename" should be recognized as a pointer to char, and "resolution" is really an RtInt.
Snap( direction, tfilename, resolution ) char *direction, tfilename; int resolution;
should read
Snap( direction, tfilename, resolution ) char *direction, *tfilename; RtInt resolution;
In Snap(), CameraTo is treated as if it were a camera direction. Change the following lines:
CameraTo[0] = CameraTo[1] = CameraTo[2] = 0.0; switch(direction[0]) { case 'x': axis = 0; break; case 'y': axis = 1; break; case 'z': axis = 2; break; } CameraTo[axis] = (direction[1] == '-') ? -1 : 1;
to read
CameraTo[0] = CameraFrom[0]; CameraTo[1] = CameraFrom[1]; CameraTo[2] = CameraFrom[2]; switch(direction[0]) { case 'x': axis = 0; break; case 'y': axis = 1; break; case 'z': axis = 2; break; } CameraTo[axis] += (direction[1] == '-') ? -1 : 1;
The coercion of 0.0 to RtFloat in the call to PlaceCamera() is not appropriate. The line should read:
PlaceCamera(CameraFrom, CameraTo, 0.0);
p. 267 -- Listing 12.4: Since chapter 16 presents a reflection map shader ("shiny"), it will be used in this listing. Note that this shader uses "mapname" rather than "reflmap". Change
RiSurface("myreflector", (RtToken)"reflmap", (RtPointer) &mapname, RI_NULL);
to read
RiSurface("shiny", (RtToken)"mapname", (RtPointer) &mapname, RI_NULL);
The second argument of RiTranslate() is wrong. Replace
RiTranslate(CameraFrom[0], CameraFrom[2], CameraFrom[2]);
to read
RiTranslate(CameraFrom[0], CameraFrom[1], CameraFrom[2]);
p. 270 -- Listing 12.5: A new RiDisplay() call must be made inside frame 2, to change to rgba rendering rather than z rendering. The new call to RiDisplay() in frame 2 should be:
RiFrameBegin(2); RiDisplay("ri.pic", RI_FILE, RI_RGBA, RI_NULL);
shadowfile is not declared as an interface variable. The following line should appear next to the char declaration at the top of the listing:
RtToken RI_SHADOWFILE;
and the call to RiLightsource() should have "source" capitalized and be preceded by RiDeclare():
RI_SHADOWFILE = RiDeclare("shadowfile", "uniform string"); RiLightSource("shadowspot", RI_SHADOWSPOT, (RtPointer)&shadowfile, RI_NULL);
p. 279 --The reference to Listing 16.NNN should be Listing 16.24.
p. 282 -- Listing 13.1: An alternate "clouds" shader is presented than that in dark image because the sum of the noise rarely exceeds 0.1. Although lighting can be used here, a more effective looking shader ignores the lights and scales the sum somewhat. The color computation used is:
color white = color(1.0, 1.0, 1.0);
Ci = mix(Cs, white, sum*4.0);
Notice that there is a numbering error in the book; 19 is applied to two lines in the listing.
p. 298 -- Table 14.4: Logical AND is presented as "&". It should be "&&", as presented on RMIS p. 94.
p. 312 -- Table 15.1: The "Returns" columns for step() and smoothstep() is incorrect. They should both say:
0 if val < min; 1 if val => max
p. 335 -- Listing 16.2: The normal, N, must be normalized in its use for light components.
point Nf = faceforward(N, I);
should read
point Nf = faceforward(normalize(N), I);
p. 336 -- Listing 16.3: The normal must be normalized, as in Listing 16.2 above. Also, the vector "-I" in the specular() call should be normalized. This is commonly done by adding the following line just after the declaration of Nf:
point V = normalize(-I);
Then use V in the specular() call instead of -I.
p. 337 -- Listing 16.4: The normal (N) and incident (I) vectors must be normalized, as in Listing 16.3 above.
p. 338 -- Listing 16.6: To mimic the standard shader, the default position should be in camera space. Also, the shader parameter list has a semicolon (;) instead of a comma (,).
point from = point(0,0,0); /* light position */ to = point(0,0,1))
should read
point from = point "camera" (0,0,0), /* light position */ to = point "camera" (0,0,1))
p. 339 -- Listing 16.7: To mimic the standard shader, the default position should be in camera space. Also, the shader parameter list has an extra semicolon (;).
point from = point(0,0,0)); /* light position */
should read
point from = point "camera" (0,0,0)) /* light position */
p. 340 -- Listing 16.8: To mimic the standard shader, the default position should be in camera space.
point from = point(0,0,0), /* light position */ to = point(0,0,1); /* light direction */
should read
point from = point "camera" (0,0,0), /* light position */ to = point "camera" (0,0,1); /* light direction */
The coneangle and conedeltaangle declarations have semicolons where there should be commas.
float coneangle = radians(30); conedeltaangle = radians(5);
should read
float coneangle = radians(30), conedeltaangle = radians(5),
p. 345 -- Listing 16.12: The comment above the code says the shader is checker(), but it is declared as checks(). checker() seems more appropriate. N should be normalized inside the faceforward() call.
Kd*diffuse(faceforward(N,I)));
should read
Kd*diffuse(faceforward(normalize(N),I)));
p. 349 -- Listing 16.14: The normal (N) and incident (I) vectors must be normalized, as in Listing 16.3 above.
p. 351 -- Listing 16.15: This texture tends to alias near the quick jump from darkwood back to lightwood. To fix this, change the 0.86 argument in the smoothstep() function should be changed to 1.0. Also, the "* (1 -" stuff is not necessary.
r = smoothstep(0, 0.8, r) - smoothstep(0.83, 1.0, r);
p. 353 -- Listing 16.17: The normal (N) and incident (I) vectors must be normalized, as in Listing 16.3 above.
p. 354 -- Listing 16.18: The normal (N) and incident (I) vectors must be normalized, as in Listing 16.3 above.
p. 355 -- Listing 16.19: The normal (N) and incident (I) vectors must be normalized, as in Listing 16.3 above.
p. 357 -- Listing 16.20: The normal, N, must be normalized in its use for light components.
point Nf = faceforward(N, I);
should read
point Nf = faceforward(normalize(N), I);
p. 361 -- Listing 16.21: The initialization of Nf should be removed.
Also the line
in2 = faceforward(normalize(in), path);
should be changed to
in2 = normalize(in); in2 *= sign(-path.in2);
p. 363 -- Listing 16.22: The I and N vectors must be normalized, as shown below:
point II = normalize(I); point NN = normalize(N); diffuse = II.NN / (II.II * NN.NN);
p. 365 -- Listing 16.23: The last line in this shader, the assignment of N, should not be in the "if" block.
P = center + radius*normalize(P-center); N = calculatenormal(P); } }
should read
P = center + radius*normalize(P-center); } N = calculatenormal(P); }
p. 373 -- Listing 16.28: "spread" should be a uniform float, not a uniform point.
p. 376 -- Listing 16.31: There are some syntax errors in the parameter list. The semicolons after each of the float values (Ka, Kd, etc.) should be commas, as shown below:
float Ka = .5, Kd = .5, Ks = .8, roughness = .1, spin = 0;
In the assignment of Nf, N must be normalized. It's also helpful to assign V = normalize(-I), for use in the specular() call.
The formulas for the red crown should use "u" instead of "v":
else { /* between ring and top, create red crown */ u = (u+.2)*6; u = u-floor(u); if (u < .5) if (2*u - 0 > (y-10.5)/(12.0-10.5)) cs = REDCOLOR; else cs = NEUTRALCOLOR; else if (2*u - 1 + (y-10.5)/(12.0-10.5) < 1) cs = REDCOLOR; else cs = NEUTRALCOLOR; }
All the texture names should be consistent in using the extension "txt", not "tx". Thus "coated.tx" should be "coated.txt", "circle.tx" should be "circle.txt", and "b.tx" should be "b.txt".
The formulas for the dirt and gouge texture are wrong. Replace
strength = 1 - float texture(texturename, t+spin, y);
with the following:
strength = 1 - float texture(texturename, s+spin, y/15.0);
The specular() call at the end of the shader should use "V" instead of "-I" in its parameter list.
p. 379 -- Listing 16.32: The formulas for accessing the texture are wrong. Replace
P += (-Km * texture(texturename, t+spin, y))*normalize(N);
with the following:
P += (-Km * texture(texturename, s+spin, y/15.0))*normalize(N);
p. 380 -- Listing 16.33: Semicolon (;) should be a comma (,) in the declaration of coneangle, i.e.:
float coneangle = radians(30),
Declaration of string shadowname should be string shadowfile, as should the call inside the shadow() function. Also, shadow() returns 1.0 for 100% shadow, so its inverse is needed. The lines should read:
string shadowfile = "";) attenuation *= (1.0 - shadow( shadowfile, Ps));
p. 383 -- Listing 16.36: There is a syntax error in the declaration of Km at the top of the shader. The comma at the end of the line should be a semicolon.
p. 384 -- Listing 16.37: The normal (N) and incident (I) vectors must be normalized, as in Listing 16.3 above.
p. 384 -- Listing 16.38: The normal must be normalized, as in Listing 16.2 above.
p. 411: RiGeometry() is not listed in the Appendix.
RiGeometry(type) RtToken type;
Nor is it described in the text of the book other than a mention in the table on page 58.
p. 412: RiMatte() has a boolean flag.
RiMatte(onoff) RtBoolean onoff;
pp. 414,415: The following are not listed
RiScale(sx, sy, sz) 113 RtFloat sx, sy, sz;
RiSkew(angle, dx1, dy1, dz1, dx2, dy2, dz2) 113 RtFloat angle, dx1, dy1, dz1, dx2, dy2, dz2;
RiTransformBegin() 111
RiTransformEnd() 111
Pixar Animation Studios
|