/* * duck_bill_color(): color surface for duck bill pattern * * M. Geroch * TV Digital Lighting HW 5 * Spring, 1996 */ #include "/usr/local/accad/shaders/rmannotes.sl" surface duck_bill_color(float Ka=0.4, Kd=0.4, Ks = 1.0, roughness=0.1; color specularcolor=1; ) { float D, finder; color layer_color, layer_opac, surface_color, surface_opac; color trim_color = color "rgb" (0.2, 0.2, 0.1); color find_color = color "rgb" (0.0, 0.0, 1.0); float fuzz = 0.005; point Nf, V; Nf = faceforward( normalize(N), I ); V = -normalize(I); surface_color = Cs; surface_opac = Os; /* edge lines around bill */ D = 1 - smoothstep(0.02-fuzz, 0.02, s) + pulse(0.48, 0.52, fuzz, s) + smoothstep(0.98-fuzz, 0.98, s); surface_color = blend(surface_color, trim_color, D); /* center_ridge of top of bill */ D = 0.7 * pulse(0.24, 0.26, fuzz, s); surface_color = blend(surface_color, trim_color, D); /* air holes */ D = 1 - smoothstep(0.02-fuzz, 0.02, sqrt(pow((s-0.17), 2) + pow((t-0.61),2))); surface_color = blend(surface_color, trim_color, D); D = 1 - smoothstep(0.02-fuzz, 0.02, sqrt(pow((s-0.33), 2) + pow((t-0.61),2))); surface_color = blend(surface_color, trim_color, D); Oi = surface_opac; Ci = Oi * ( surface_color * (Ka*ambient() + Kd*diffuse(Nf)) + specularcolor * Ks * specular(Nf,V,roughness) ); }