/**************************************************************************** * (Just a piece of) cel.sl * * from: * _Advanced RenderMan: Creating CGI for Motion Picture_, * by Anthony A. Apodaca and Larry Gritz, Morgan Kaufmann, 1999. * ****************************************************************************/ #include "material.h" color LocIllumCelDiffuse ( normal N; ) { color C = 0; extern point P; illuminance (P, N, PI/2) { /* Must declare because extern L & Cl because we're in a function */ extern vector L; extern color Cl; float nondiff = 0; lightsource ("__nondiffuse", nondiff); if (nondiff < 1) { C += Cl * ((1-nondiff) * smoothstep(0,0.1,N.normalize(L))); } } return C; } color MaterialCel (normal Nf; color Cs; float Ka, Kd, Ks, roughness, specsharpness;) { extern vector I; vector IN = normalize(I), V = -IN; return Cs * (Ka*ambient() + Kd*LocIllumCelDiffuse(Nf)) + Ks * LocIllumGlossy (Nf, V, roughness/10, specsharpness); } surface cel ( float Ka = 1, Kd = 1, Ks = .5, roughness = 0.25;) { normal Nf = faceforward(normalize(N),I); Ci = MaterialCel (Nf, Cs, Ka, Kd, Ks, roughness, 0.25); }