pill_plastic.sl

[index]

22th February 2009   6:12pm 37sec
/stuhome/vsfx419/shaders/pill_plastic.sl


PillmixcolorST_plastic_RSL



/* Shader description goes here */
surface
pill_plastic(float    Ka = 1,            
                    Kd = 0.5,        
                    Ks = 0.7,        
                    opac = 0.2,  
                    roughness = 0.1,
                    blend = 0.5;
            color     hilitecolor = 1,    
                    C1 = (1,0,0),
                    C2 = (0,0,1) )
{
color    ambientcolor, diffusecolor, speccolor,
        surfcolor = 1;
color pillcolor = 1;
/* STEP 1 - make a copy of the surface normal one unit in length */
normal    n = normalize(N);
normal    nf = faceforward(n, I);
  
/* STEP 2 - set the apparent surface opacity */
Oi = Os * opac;
  
/* STEP 3 - calculate the lighting components */
ambientcolor = Ka * ambient();
diffusecolor = Kd * diffuse(nf);
pillcolor = mix (C1,C2,blend*t) ;
    
  
vector    i = normalize(-I);
speccolor = Ks * specular(nf, i, roughness) * hilitecolor;
  
/* STEP 4 - calculate the apparent surface color */
Ci = Oi * Cs * surfcolor * pillcolor * (ambientcolor + diffusecolor + speccolor);
}