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.

A.4 Volume Shaders<br />

A.4.1<br />

Depth cue shader<br />

volume<br />

depthcue(<br />

float mindistance = 0, maxdistance = 1;<br />

color background = 0;)<br />

{<br />

float d;<br />

d = clamp((depth(P) - mindistance) /<br />

(maxdistance - mindistance), 0.0, 1.0);<br />

Ci = mix(Ci, background, d);<br />

Oi = mix(Oi, color(1, 1, 1), d);<br />

}<br />

A.4.2<br />

Fog shader<br />

volume<br />

fog(float distance = 1; color background = 0;)<br />

{<br />

float d;<br />

d = 1 - exp(-length(I) / distance);<br />

Ci = mix(Ci, background, d);<br />

Oi = mix(Oi, color(1, 1, 1), d);<br />

}<br />

A.5 Displacement Shaders<br />

A.5.1<br />

Bumpy shader<br />

displacement<br />

bumpy(<br />

float Km = 1;<br />

string texturename = ””;)<br />

{<br />

float amp = Km * float texture(texturename, s, t);<br />

P += amp * normalize(N);<br />

N = calculatenormal(P);<br />

}<br />

159

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

Saved successfully!

Ooh no, something went wrong!