/* Dan Schneider * Andrew Sun * * Project 2 * *--------------------------------------------------------------------------- * grille - displacement shader for a perpendicular cross-hatch ventilation * thing. Horizontal cross-hatches are displaced downwards. * * width - width of crosshatches * spacing - space between crosshatches * depth - displacement depth for horizontal crosshatches *-------------------------------------------------------------------------*/ surface button( float Ka = 1, Kd = 0.5, Ks = 0.5; float roughness = 0.1; color specularcolor = 1, buttoncolor =(.8,.8,.8); float hwidth=.01, vwidth = .005, hspacing=.002, vspacing=.005) { point sN, Nf, V; //color Pcolor; V = -normalize(I); Nf = faceforward (normalize(N),I); if ((mod(s,(hwidth+hspacing)) < hspacing) || (mod(t,(vwidth+vspacing)) < vspacing)) { /* between buttons */ Oi = 1; Ci = Os * ( Cs * (Ka*ambient() + Kd*diffuse(Nf)) + specularcolor * Ks * specular(Nf,V,roughness) ); } else { /*in a button*/ Oi = 1; Ci = Os * ( buttoncolor * (Ka*ambient() + Kd*diffuse(Nf)) + specularcolor * Ks * specular(Nf,V,roughness) ); } }