26.01.2015 Views

The RenderMan Interface - Paul Bourke

The RenderMan Interface - Paul Bourke

The RenderMan Interface - Paul Bourke

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

color c, d=1, e=color(1,0,0);<br />

<strong>The</strong> initialization value may be any scalar or color expression. If a scalar expression is used,<br />

its value is promoted to a color by duplicating its value into each component.<br />

Colors may be specified in a particular color space by:<br />

color [space] (u,v,w)<br />

<strong>The</strong> optional specifier space, which must be a string literal, indicates the color coordinate<br />

system of the 3-tuple. <strong>The</strong> default color coordinate system is ”rgb”. This construct lets you<br />

specify the color u,v,w in a particular color space, but this statement implicitly converts<br />

the color into its ”rgb” equivalent. Table 11.1, Color Coordinate Systems, lists the color<br />

coordinate systems that are supported in the Shading Language.<br />

Coordinate System<br />

”rgb”<br />

”hsv”<br />

”hsl”<br />

”xyz”, ”XYZ”<br />

”YIQ”<br />

Description<br />

Red, green, and blue.<br />

Hue, saturation, and value.<br />

Hue, saturation, and lightness.<br />

CIE XYZ coordinates.<br />

NTSC coordinates.<br />

Table 11.1: Color Coordinate Systems.<br />

11.3 Points, Vectors, and Normals<br />

Point-like variables are (x,y,z) triples of floats that are used to store locations, direction vectors,<br />

and surface normals.<br />

A point is a position in 3D space. A vector has a length and direction, but does not exist in<br />

a particular location. A normal is a special type of vector that is perpendicular to a surface,<br />

and thus describes the surface’s orientation.<br />

All calculations involving points, vectors, and normals are assumed to take place in an<br />

implementation-dependent coordinate system, usually either the camera or world coordinate<br />

system. Procedures exist to transform points, vectors, and normals from the shading coordinate<br />

system to various named coordinate systems, or to define a point, vector, or normal<br />

in one of several coordinate systems and transform it to the shading coordinate system. It<br />

should be noted that point locations, direction vectors, and normals do not transform in<br />

the same way, and therefore it is important to use the correct transformation routine for<br />

each type.<br />

A number of standard coordinate systems are known to a shader. <strong>The</strong>se include: ”raster”,<br />

”NDC”, ”screen”, ”camera”, ”world”, and ”object”. <strong>The</strong>se are discussed in the section on<br />

Camera in Part I. In addition, a shader knows the coordinate systems shown in Table 11.2,<br />

Point Coordinate Systems.<br />

Point-like variables are declared:<br />

point u, v=1, w=point(1,1,1);<br />

115

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!