/* 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 vent( float Ka = 1, Kd = 0.5, Ks = 0.5; float roughness = 0.1; color specularcolor = 1, holecolor =(0,0,0); float width=.005, spacing=.005) { point sN, Nf, V; color Pcolor; V = -normalize(I); Nf = faceforward (normalize(N),I); Pcolor = color "rgb" (1,0.1,0.1); /*sN = normalize(transform("shader",N)-transform("shader",(0,0,0))); */ //sN = normalize(transform("shader",N)); //PP = transform("shader",P); if ((mod(t,(width+spacing)) < width) || (mod(s,(width+spacing)) < width)) { /*we're in a stripe*/ Oi = 1; Ci = Os * ( Cs * (Ka*ambient() + Kd*diffuse(Nf)) + specularcolor * Ks * specular(Nf,V,roughness) ); } else { /* we're in a hole */ Oi = 1; Ci = Os * ( holecolor * (Ka*ambient() + Kd*diffuse(Nf)) + specularcolor * Ks * specular(Nf,V,roughness) ); } }