/* Assignment 1, part 2 */ /* Digital Lighting/tv */ /* Spring 96 */ /* Mark Fontana */ #include "/usr/local/accad/shaders/rmannotes.sl" /* greenish-yellow sine wave pattern with pink and blue polka dots above and below the wave */ surface ripply(float hfreq = 1, vfreq = 1, angle = 0; float 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 surface_opac, layer_opac; float fuzz = 0.005, cv; float yy, ss, tt; /* background layer */ surface_color = Cs; surface_opac = 1; rotate2d(s, t, radians(angle), 0.5, 0.5, ss, tt); s = mod(ss*hfreq, 1); t = mod(tt*vfreq, 1); /* wave layer */ yy = 0.5+0.2*cos(s*2*PI); cv = smoothstep(yy-0.2, yy+0.2, t); layer_color = color "rgb" (spline(cv, 0, 0.1, 0.1, 0.9, 0.1, 0.1, 0), spline(cv, 0, 0.5, 0.6, 0.9, 0.6, 0.5, 0), spline(cv, 0, 1, 0.1, 0.1, 0.1, 1, 0)); layer_opac = pulse(yy-0.2, yy+0.2, fuzz, t); surface_color = mix(surface_color, layer_color, layer_opac); /* purple circle layer */ layer_color = color "rgb" (0.5, 0.3, 0.5); layer_opac = 1-smoothstep(0.16-fuzz, 0.16, sqrt((s-0.5)*(s-0.5) + (t-0.8)*(t-0.8))); surface_color = mix(surface_color, layer_color, layer_opac); /* blue circle layer, left half */ layer_color = color "rgb" (0, 0.2, 1); layer_opac = 1-smoothstep(0.12-fuzz, 0.12, sqrt(s*s+(t-0.3)*(t-0.3))); surface_color = mix(surface_color, layer_color, layer_opac); /* blue circle layer, right half */ layer_opac = 1-smoothstep(0.12-fuzz, 0.12, sqrt((1.0-s)*(1.0-s)+(t-0.3)*(t-0.3))); surface_color = mix(surface_color, layer_color, layer_opac); /* output color */ Oi = surface_opac; Ci = Oi*(surface_color*(Ka*ambient() + /* plastic illumination */ Kd*diffuse(Nf)) + specularcolor*Ks*specular(Nf, V, roughness)); }