#include "rmannotes.sl" surface tomshader2(float Ka = 0.4, Kd = 0.4, Ks = 0.6, roughness = 0.2; color specularcolor = 1) { color surface_color, layer_color; color surface_opac, layer_opac; float ss, tt; float row; float fuzz = 0.05; float freq = 6; point Nf, V; /* background layer (layer 0) */ surface_color = color (0.2, 0.6, 0.8); /* grey */ surface_opac = 1; /* layer #1 */ ss = repeat(s, 6); tt = repeat(t, 4); layer_color = color (0,0,1); layer_opac = pulse(0.35, 0.65, 0.02, ss); surface_color = blend(surface_color, layer_color, layer_opac); surface_opac = union(surface_opac, layer_opac); /* layer #2 */ ss = repeat(s, 6); tt = repeat(t, 12); layer_color = color (.8,.9,.1); layer_opac = pulse(0.35, 0.65, 0.1, tt); layer_opac *= 0.5; surface_color = blend(surface_color, layer_color, layer_opac); surface_opac = union(surface_opac, layer_opac); /* layer #3 */ ss = repeat(s, 6); tt = repeat(t, 4); layer_color = color (1,1,0); layer_opac = pulse(0.45, 0.55, 0.02, ss); surface_color = blend(surface_color, layer_color, layer_opac); surface_opac = union(surface_opac, layer_opac); layer_opac *= 1; /* layer #4 */ ss = repeat(s, 12); tt = repeat(t, 8); layer_color = color (.8,.1,.6); layer_opac = pulse(0.48, 0.52, 0.0, ss); surface_color = blend(surface_color, layer_color, layer_opac); surface_opac = union(surface_opac, layer_opac); layer_opac *= 1; /* layer 5 */ ss = repeat(s, freq); tt = repeat(t, freq); row = whichtile(t, freq); if (even(row)) ss = mod(ss + 1, 1); layer_color = color (1,.5,0); layer_opac = intersection(pulse(0.35, 0.65, fuzz, ss), pulse(0.35, 0.65, fuzz, tt)); layer_opac *= .55; surface_color = blend(surface_color, layer_color, layer_opac); /* illum */ Nf = faceforward(normalize(N), I); V = -normalize(I); surface_color = surface_color * (Ka * ambient() + Kd * diffuse(Nf)) + specularcolor * Ks * specular(Nf, V, roughness); /* output */ Oi = surface_opac; Ci = surface_color * surface_opac; }