/* 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
ventdisp( float width=.005, spacing=.005, depth = .005) {

	point sN, Nf, PP;
	//color Pcolor;
	
	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)) {
		/*height unchanged*/
		P = P;
		N = N;
	} else {
		/*place at depth*/
		P = transform("shader", (PP - (sN*depth)));
		N = calculatenormal(P);
	}
}