/* surface shader: spinningblade.sl creator: Nick Meshes, DePaul University description: If this baby works, it will produce a look like that of a helicopter blade in motion. Parameters: float Ka, Kd, Ks, roughness: familiar old friends color specularcolor: float hmin, hmax, wmin, wmax: the standard min-max box float slope: slope of the blade float bladelength: length of the blade float orientate: x(0), y(1), or z(2) - sorry, it's orthogonal fer now float bladewidth: width of the blade float bladedepth: how deep do you want to go float clock: (1) clockwise or (0) counter-clockwise float blurmargin: slope of the farthest line of blurring */ surface spinningblade( float Ka = 1, Kd = 0.75, Ks = 0.4, roughness = 0.1; color specularcolor = 1; float slope = 0; float bladelength = 3; float bladedepth = 1; float orientate = 0; float bladewidth = 1; float clock = 1; float blurmargin = 0; ){ normal Nf; vector V; point cent, curr, len; float zcoord; setxcomp(cent, (wmin + wmax)/2); setycomp(cent, (hmin + hmax)/2); setzcomp(cent, 0); if (orientate == 0){ setxcomp(curr, ycomp(P)); setycomp(curr, zcomp(P)); zcoord = xcomp(P); } else if (orientate == 1){ setxcomp(curr, xcomp(P)); setycomp(curr, zcomp(P)); zcoord = ycomp(P); } else{ setxcomp(curr, xcomp(P)); setycomp(curr, ycomp(P)); zcoord = zcomp(P); } setzcomp(curr, 0); len = cent - curr; if (length(len) > bladelength) Oi = 0; else if (abs(zcoord) > bladedepth) Oi = 0; else { float Tslope = -(slope/2); Tslope = slope - Tslope; float A = xcomp(cent) - xcomp(curr); A = A/Tslope; float B = ycomp(cent) - ycomp(curr); B = B/Tslope; point ST; setxcomp(ST, xcomp(cent) + (A * slope)); setycomp(ST, ycomp(cent) + (B * slope)); len = ST - curr; if (length(len) <= bladewidth) Oi = 1; else Oi = .2; } Nf = faceforward(normalize(N),I); V = -normalize(I); Ci = Oi * ( Cs * (Ka*ambient() + Kd*diffuse(Nf)) + specularcolor * Ks*specular(Nf,V,roughness)); }