Example 2: Light Passes

Text    hb_plastic.sl    prepare.rib    interact.sl    interact.rib    Makefile

hb_plastic.sl

surface hb_plastic(

float Ks=0.5;

float Kd=0.5;

float Ka=1;

float roughness=0.2;

color specular_color=1;

)

{

normal Nf;

vector V;

Nf=faceforward(normalize(N),I);

V=-normalize(I);

 

color Cambient=Cs*(Ka*ambient());

color Cdiffuse=Cs*(Kd*diffuse(Nf));

color Cspecular=specular_color*Ks*specular(Nf,V,roughness);

 

Oi=Os;

Ci=Os*(Cambient+Cdiffuse+Cspecular);

}