The RenderMan Interface - Paul Bourke
The RenderMan Interface - Paul Bourke
The RenderMan Interface - Paul Bourke
- 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.
Section 12<br />
SHADER EXECUTION ENVIRONMENT<br />
When a shader is attached to a geometric primitive it inherits a set of varying variables<br />
that completely defines the environment in the neighborhood of the surface element being<br />
shaded. <strong>The</strong>se state variables are predefined and should not be declared in a Shading<br />
Language program. It is the responsibility of the rendering program to properly initialize<br />
these variables before a shader is executed.<br />
All the predefined variables which are available to each type of shader are shown in Table<br />
12.1, Predefined Surface Shader Variables, through Table 12.5, Predefined Imager Shader Variables.<br />
In these tables the top section describes state variables that can be read by the shader.<br />
<strong>The</strong> bottom section describes the state variables that are the expected results of the shader.<br />
By convention, capitalized variables refer to points and colors, while lower-case variables<br />
are floats. If the first character of a variable’s name is a C or O, the variable refers to a<br />
color or opacity, respectively. Colors and opacities are normally attached to light rays; this<br />
is indicated by appending a lowercase subscript. A lowercase d prefixing a variable name<br />
indicates a derivative.<br />
All predefined variables are considered to be read-only, with the exception of the result<br />
variables, which are read-write in the appropriate shader type, and Cs, Os, N, s and t,<br />
which are read-write in any shader in which they are readable. Vectors are not normalized<br />
by default.<br />
12.1 Surface Shaders<br />
<strong>The</strong> geometry is characterized by the surface position P which is a function of the surface<br />
parameters (u,v). <strong>The</strong> rate of change of surface parameters are available as (du,dv). <strong>The</strong><br />
parametric derivatives of position are also available as dPdu and dPdv. <strong>The</strong> actual change<br />
in position between points on the surface is given by P(u+du)=P+dPdu*du and P(v+dv)=P+dPdv*dv.<br />
<strong>The</strong> calculated geometric normal perpendicular to the tangent plane at P is Ng. <strong>The</strong> shading<br />
normal N is initially set equal to Ng unless normals are explicitly provided with the<br />
geometric primitive. <strong>The</strong> shading normal can be changed freely; the geometric normal<br />
is automatically recalculated by the renderer when P changes, and cannot be changed by<br />
shaders. <strong>The</strong> texture coordinates are available as (s,t). Figure 12.1 shows a small surface<br />
element and its associated state.<br />
<strong>The</strong> optical environment in the neighborhood of a surface is described by the incident ray<br />
119