/* by Craig Brown 6/9/97 */ /* surface shader which gives blue/white marbleized look to object */ #include "rmannotes.sl" surface noise7(float Ka = 0.5, Kd = 0.5, Ks = 0.5, roughness = 0.15; color specularcolor = 1) { /* DECLARATION OF VARIABLES */ color surface_color, layer_color; color surface_opac, layer_opac; float ss, tt, d; point center, Nf, V; float radius, width, noi; float fuzz = 0.025; float freq = 3; float noisefreq = 3; float scale = 20; /* GO */ surface_color = Cs; surface_opac = Os; /* BRING THE NOIZE */ noi = noise(s * noisefreq, t * noisefreq); /* PERTURB */ ss = s + snoise(noi + 123) * scale; tt = t + snoise(noi + 456) * scale; /* WIRED DONUTS */ ss = repeat(ss, freq); tt = repeat(tt, freq); center = (0.5, 0.5, 0); radius = 0.3; width = 0.3; d = distance(center, (ss, tt, 0)); layer_color = color (0,0,.8); layer_opac = smoothstep(radius - width / 2, radius + width / 2 * fuzz, d); surface_color = blend(surface_color, layer_color, layer_opac); /* ILLUMINATA */ 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_opac * surface_color; }