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...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}<br />

Oi = sum;<br />

Ci = Cs * Oi * (Ka + Kd * I.N * I.N / (I.I * N.N) );<br />

16.1.2 Ray tracer<br />

<strong>The</strong> following is a procedure to implement a Turner Whitted-style ray tracer.<br />

surface<br />

whitted(<br />

float eta = 1.5; /* index of refraction */<br />

float Kr =.8; /* reflective coefficient */<br />

float Kt =.2; /* transmissive coefficient */<br />

float Ks =.2; /* specular coefficient */<br />

float Kss = 2; /* specular exponent */<br />

float eta = 1.5; ) /* index of refraction */<br />

{<br />

normal Nn = faceforward(normalize(N), I);<br />

/* ambient term */<br />

Ci = Kd * ambient();<br />

/* diffuse and specular terms */<br />

illuminance( P, Nn, PI/2 ) {<br />

/* diffuse */<br />

Ci += Kd * Cl * (L . Nn);<br />

}<br />

/* specular */<br />

vector H = normalize(normalize(L)+I);<br />

Ci += Ks * Cl * pow(max(0,0, Nn.H), Kss);<br />

/* reflection */<br />

Ci += Ks * trace( reflect( I, Nn ) );<br />

}<br />

/* transmittance */<br />

vector T = refract( I, Nn, (N.I)

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

Saved successfully!

Ooh no, something went wrong!