|
The information in this document has been taken from the Pixar
RenderMan Pro-Server document "shadingProcessOverview.html". You are strongly advised to
review the information in that document.
Surface Shaders
The geometry is characterized by the surface position P which is a
function of the surface parameters (u,v). The rate of change of
surface parameters are available as (du,dv). The parametric
derivatives of position are also available as dPdu and dPdv. The actual
change in position between points on the surface is given by
P(u+du)=P+dPdu*du and P(v+dv)=P+dPdv*dv. The calculated geometric
normal perpendicular to the tangent plane at P is Ng. The shading normal N is
initially set equal to Ng unless normals are explicitly provided with the
geometric primitive. The shading normal can be changed freely; the geometric
normal is automatically recalculated by the renderer when P changes, and
cannot be changed by shaders. The texture coordinates are available as
(s,t). Figure 3 shows a small surface element and its associated state.
The optical environment in the neighborhood of a surface is described by
the incident ray I and light rays L. The incoming rays come either
directly from light sources or indirectly from other surfaces. The direction
of each of these rays is given by L; this direction points from the
surface towards the source of the light. A surface shader computes the
outgoing light in the direction -I from all the incoming light. The color
and opacity of the outgoing ray is Ci and Oi. (Rays have an opacity so
that compositing can be done after shading. In a ray tracing environment,
opacity is normally not computed.) If either Ci or Oi are not set,
they default to black and opaque, respectively.
Predefined Surface Shader Variables
Name |
Type |
Storage Class |
Description |
Cs |
color |
varying/uniform |
Surface color |
Os |
color |
varying/uniform |
Surface opacity |
P |
point |
varying |
Surface position |
dPdu |
vector |
varying |
Derivative of surface position along u |
dPdv |
vector |
varying |
Derivative of surface position along v |
N |
normal |
varying |
Surface shading normal |
Ng |
normal |
varying/uniform |
Surface geometric normal |
u,v |
float |
varying |
Surface parameters |
du,dv |
float |
varying/uniform |
Change in surface parameters |
s,t |
float |
varying |
Surface texture coordinates |
L |
vector |
varying/uniform |
Incoming light ray direction |
Cl |
color |
varying/uniform |
Incoming light ray color |
Ol |
color |
varying/uniform |
Incoming light ray opacity |
E |
point |
uniform |
Position of the eye |
I |
vector |
varying |
Incident ray direction |
ncomps |
float |
uniform |
Number of color components |
time |
float |
varying |
Current shutter time |
dtime |
float |
varying |
The amount of time covered by this shading sample |
dPdtime |
vector |
varying |
How the surface position P is changing per unit time, as described by
motion blur in the scene. |
Result Variables |
|
|
|
Ci |
color |
varying |
Incident ray color |
Oi |
color |
varying |
Incident ray opacity |
Light Source Shaders
A light source shader is slightly different (see Figure 4:
Light source shader state). It computes the amount of light cast along
the direction L which arrives at some point in space Ps.
The color of the light is Cl while the opacity is Ol.
The geometric parameters described above (P, du, N, etc.) are available
in light source shaders; however, they are the parameters of the light
emitting surface (e.g., the surface of an area light source)--not the
parameters of any primitive being illuminated. If the light source is a point
light, P is the origin of the light source shader space and the
other geometric parameters are zero. If either Cl or Ol
are not set, they default to black and opaque, respectively.
Predefined Light Source Variables
P |
point |
varying |
Surface position |
dPdu |
vector |
varying |
Derivative of surface position along u |
dPdv |
vector |
varying |
Derivative of surface position along v |
N |
normal |
varying |
Surface shading normal |
Ng |
normal |
varying/uniform |
Surface geometric normal |
u,v |
float |
varying |
Surface parameters |
du,dv |
float |
varying/uniform |
Change in surface parameters |
s,t |
float |
varying |
Surface texture coordinates |
L |
vector |
varying/uniform |
Incoming light ray direction |
Ps |
point |
varying |
Position being illuminated |
E |
point |
uniform |
Position of the eye |
ncomps |
float |
uniform |
Number of color components |
time |
float |
uniform |
Current shutter time |
dtime |
float |
uniform |
The amount of time covered by this shading sample. |
Result Variables |
|
|
|
Cl |
color |
varying/uniform |
Outgoing light ray color |
Ol |
color |
varying/uniform |
Outgoing light ray opacity |
Volume Shaders
A volume shader is not associated with a surface, but rather attenuates a
ray color as it travels through space. As such, it does not have access to any
geometric surface parameters, but only to the light ray I and its
associated values. The shader computes the new ray color at the ray origin
P-I. The length of I is the distance traveled
through the volume from the origin of the ray to the point P.
Predefined Volume Shader Variables
Name |
Type |
Storage Class |
Description |
P |
point |
varying |
Light ray origin |
E |
point |
uniform |
Position of the eye |
I |
vector |
varying |
Incident ray direction |
Ci |
color |
varying |
Ray color |
Oi |
color |
varying |
Ray opacity |
ncomps |
float |
uniform |
Number of color components |
time |
float |
uniform |
Current shutter time |
dtime |
float |
uniform |
The amount of time covered by this shading sample. |
Result Variables |
|
|
|
Ci |
color |
varying |
Attenuated ray color at origin |
Oi |
color |
varying |
Attenuated ray opacity at origin |
Displacement Shaders
The displacement shader environment is very similar to a surface
shader, except that it only has access to the geometric surface
parameters. It computes a new P and optionally a new N and
dPdtime. In rendering implementations that do not support the
Displacement capability, modifications to P or dPdtime will
not actually move the surface (change the hidden surface elimination
calculation); however, modifications to N will still occur
correctly.
Predefined Displacement Shader Variables
Name |
Type |
Storage Class |
Description |
P |
point |
varying |
Surface position |
dPdu |
vector |
varying |
Derivative of surface position along u |
dPdv |
vector |
varying |
Derivative of surface position along v |
N |
normal |
varying |
Surface shading normal |
Ng |
normal |
varying/uniform |
Surface geometric normal |
I |
vector |
varying |
Incident ray direction |
E |
point |
uniform |
Position of the eye |
u,v |
float |
varying |
Surface parameters |
du,dv |
float |
varying/uniform |
Change in surface parameters |
s,t |
float |
varying |
Surface texture coordinates |
ncomps |
float |
uniform |
Number of color components |
time |
float |
uniform |
Current shutter time |
dtime |
float |
uniform |
The amount of time covered by this shading sample. |
dPdtime |
vector |
varying |
How the surface position P is changing per unit time, as described by
motion blur in the scene. |
Result Variables |
|
|
|
P |
point |
varying |
Displaced surface position |
N |
point |
varying |
Displaced surface shading normal |
dPdtime |
vector |
varying |
How the displaced surface position P is changing per unit time |
Imager Shaders and PixelSampleImager Shaders
An Imager shader manipulates a final pixel color after all of the
geometric and shading processing has concluded.
In the context of an imager shader, P is the position of the of the pixel
center in current space as it is for all shaders. The other geometric
variables have their usual meanings. The variables u and v
run from 0 to 1 over the entire output image (over the ScreenWindow).
The imager shader environment also provides access to texture mapping
variables s,t, which are the texture mapping coordinates over the
ScreenWindow. These coordinates represent pixel centers, such that calls
to texture() can map an appropriately prepared image over the entire
output resolution. A raster coordinate may be obtained using this formula:
(s*xres-0.5,t*yres-0.5).
A PixelSampleImager manipulates pixel samples, prior to pixel filtering.
Such a shader has access to the exact (possibly jittered) pixel positions of
the samples, as specified by RiPixelSamples. The shader is still applied
after all geometric processing and hidden surface determination is complete.
Both Imager and PixelSampleImager shaders have access to any arbitrary
output variables generated by shading.
Predefined Imager Shader Variables
Name |
Type |
Storage Class |
Description |
P |
point |
varying |
Surface position |
dPdu |
vector |
varying |
Derivative of P along u |
dPdv |
vector |
varying |
Derivative of P along v |
E |
point |
uniform |
Position of the eye |
I |
vector |
varying |
Ray direction from eye to P in current space |
u,v |
float |
varying |
Surface parameters, running 0-1 over the output image resolution |
du,dv |
float |
varying/uniform |
Change in surface parameters |
s,t |
float |
varying |
Texture coordinates |
Ci |
color |
varying |
Pixel color |
Oi |
color |
varying |
Pixel opacity |
alpha |
float |
uniform |
Fractional pixel coverage |
ncomps |
float |
uniform |
Number of color components |
time |
float |
uniform |
Current shutter time |
dtime |
float |
uniform |
The amount of time covered by this shading sample. |
Result Variables
Name |
Type |
Storage Class |
Description |
Ci |
color |
varying |
Output pixel color |
Oi |
color |
varying |
Output pixel opacity |
Special Shader Parameters
Certain shader parameters beginning with __ are interpreted specially by
the renderer and help control the shading pipeline.
Renderer-interpreted Shader Parameters
Name |
Relevant shaders |
Description |
__computesOpacity |
surface shader |
A value of 0 means that the shader does not compute opacity (i.e
Oi == Os). This can be used to override a transmission hit mode of
shader. For such shaders, the opacity() method will be skipped
for transmission rays.
A value of 1 means that the shader does indeed compute opacity.
Such shaders will be run to evaluate their opacity for transmission
rays. That result may be cached by the renderer, and thus must be
view-independent.
A value of 2 means that the shader computes opacity in
view-dependent manner. As such the renderer will avoid caching opacity
for transmission rays. The opacity is still cached for the purpose of
controlling continuations on diffuse and specular rays, but
view-dependent shadows may be generated using areashadow() or
transmission(). For mode 2, the opacity() method must only
depend on view-dependent entities within a check for raytype ==
"transmission".
|
__category |
co-shader or light shader |
The getlights() shading function may be optionally passed a
category, which it matches against the shader parameter __category
when constructing a list of shaders to return. getshaders() may
also use category matching to control which shaders are returned.
The matching syntax is described in the Shader and Message Passing
Functions
documentation.
|
__ignoresShaderSpace |
all shaders |
Shaders can be annotated with a hint to the renderer indicating that
they do not care about shader space. When uniform float
__ignoresShaderSpace = 1 is found on a shader the renderer will force
the shader space to be identity. Gprims that share identical shaders
but have different coordinate systems will be combinable. |
Pixar Animation Studios
Copyright©
Pixar. All rights reserved.
Pixar® and RenderMan® are registered trademarks of Pixar.
All other trademarks are the properties of their respective holders. |
|