/* Marla Mayerson*/ /* This shader is based on a turbulent model and simulates a cloudy planet*/ /*surface like the moon*/ #include "rmannotes.sl" surface cloudy(float turbfreq = 2; color topc = color (1, 0, 0); color bottomc = color (0, 0, 1); float Ka = 0.5, Kd = 0.5; float Ks =0.5, roughness = 0.16; color specularcolor = 1) { color paper, ink; float paper_opac, ink_opac; float ss, tt; point Nf, V; point PP; float pixelsize, twice; float scale, turb; paper = 0; paper_opac =1; Nf = faceforward(normalize(N), I); V = -normalize(I); ss = s; tt = t; ink = mix(topc, bottomc, t) + mix(topc, bottomc, s); ink_opac = 1; paper = mix(paper, ink, ink_opac); paper = paper * Ka * ambient() + paper * Kd * diffuse(Nf) + specularcolor * Ks * specular(Nf, V, roughness); PP = transform("shader", P) * turbfreq; pixelsize = sqrt(area(PP)); twice = pixelsize * 2; turb = 0; for (scale = 1; scale > twice; scale /= 2) turb += abs(noise(PP / scale) - 0.5) * scale; turb = turb * 2; Ci =turb; Oi = paper * paper_opac; }