The RenderMan Interface - Paul Bourke
The RenderMan Interface - Paul Bourke
The RenderMan Interface - Paul Bourke
- No tags were found...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
diffuse returns the diffuse component of the lighting model. N is a unit-length surface<br />
normal.<br />
color<br />
specular( normal N; vector V; float roughness )<br />
{<br />
color C = 0;<br />
illuminance( P, N, PI/2 )<br />
C += Cl * specularbrdf (normalize(L), N, V, roughness);<br />
return C;<br />
}<br />
specular returns the specular component of the lighting model, using an implementationdependent<br />
specularbrdf. N is the unit-length normal to the surface. V is a unit-length<br />
vector from a point on the surface towards the viewer.<br />
color specularbrdf ( vector L; normal N; vector V; float roughness )<br />
Returns the specular attenuation of light coming from the direction L, reflecting toward<br />
direction V , with surface normal N and roughness rough. All of L, V , and N<br />
are assumed to be of unit length. This is the same reflection model calculation found<br />
inside the illuminance loop of the specular function. This allows users to write an<br />
illuminance loop that reproduces the functionality of the specular() function, even if<br />
the renderer has an implementation-specific formula for built-in specular reflection.<br />
Here is an example implementation of specularbrdf:<br />
color specularbrdf( vector L, N, V; float roughness )<br />
{<br />
vector H = normalize(L+V);<br />
return pow (max (0, N.H), 1/roughness);<br />
}<br />
color<br />
phong( normal N; vector V; float size )<br />
{<br />
color C = 0;<br />
vector R = reflect( -normalize(V), normalize(N) );<br />
illuminance( P, N, PI/2 ) {<br />
vector Ln = normalize(L);<br />
C += Cl * pow(max(0.0,R.Ln), size);<br />
}<br />
return C;<br />
}<br />
phong implements the Phong specular lighting model.<br />
color trace( point P, point R )<br />
trace returns the incident light reaching a point P from a given direction R. If a particular<br />
implementation does not support the Ray Tracing capability, and cannot compute<br />
the incident light arriving from an arbitrary direction, trace will return 0 (black).<br />
142