/* Assignment 1, part 2 */ /* Digital Lighting/tv */ /* Spring 96 */ /* Mark Fontana */ #include "/usr/local/accad/shaders/rmannotes.sl" /* procedural texture of a single 50's style "binky" star & plastic shading */ surface binky(float hfreq = 1, vfreq = 1, width = 0.04, Ka = 0.5, Kd = 0.5, Ks = 0.5, roughness = 0.1; color specularcolor = 1) { point Nf = faceforward(normalize(N), I); point V = normalize(-I); color surface_color, layer_color; float layer_opac; float fuzz = 0.005, half_width, d; point p1, p2; /* background layer */ surface_color = Cs; Oi = 1; /* layers for the 5 lines in the binky */ s = mod(s*hfreq, 1); t = mod(t*vfreq, 1); layer_color = color "rgb" (1, 1, .8); half_width = width/2; p1 = (0.5, 0.05, 0); p2 = (0.5, 0.12, 0); d = ptlined(p1, p2, (s, t, 0)); layer_opac = 1 - smoothstep(half_width - fuzz, half_width, d); surface_color = mix(surface_color, layer_color, layer_opac); p1 = (0.60, 0.12, 0); p2 = (0.55, 0.17, 0); d = ptlined(p1, p2, (s, t, 0)); layer_opac = 1 - smoothstep(half_width - fuzz, half_width, d); surface_color = mix(surface_color, layer_color, layer_opac); p1 = (0.40, 0.12, 0); p2 = (0.45, 0.17, 0); d = ptlined(p1, p2, (s, t, 0)); layer_opac = 1 - smoothstep(half_width - fuzz, half_width, d); surface_color = mix(surface_color, layer_color, layer_opac); p1 = (0.55, 0.23, 0); p2 = (0.60, 0.27, 0); d = ptlined(p1, p2, (s, t, 0)); layer_opac = 1 - smoothstep(half_width - fuzz, half_width, d); surface_color = mix(surface_color, layer_color, layer_opac); p1 = (0.45, 0.23, 0); p2 = (0.40, 0.27, 0); d = ptlined(p1, p2, (s, t, 0)); layer_opac = 1 - smoothstep(half_width - fuzz, half_width, d); surface_color = mix(surface_color, layer_color, layer_opac); /* output color */ Ci = surface_color; Ci = Oi*(Ci*(Ka*ambient() + /* plastic illumination */ Kd*diffuse(Nf)) + specularcolor*Ks*specular(Nf, V, roughness)); }