Example 1: Render 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;

output varying color Cambient=0;

output varying color Cdiffuse=0;

output varying color Cspecular=0;

)

{

normal Nf;

vector V;

 

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

V=-normalize(I);

 

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

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

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

 

Oi = Os;

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

}