/* fin1.sl, from the pinchers of some bug * * decription: * * param: * * colors "one,two,three" * * complexity and density control the turbulence * * usual parameters for "plastic" * * author: Heath Hanlin */ #include "rmannotes.sl" surface fin1(color one = color(1,0,0), two = color(0,1,0), three = color(0,0,1); float fuzz = 0.01; float density = .5; float complexity = 10; float Ka = 1, Kd = 0.3; float Ks = 0.7, roughness = 0.3; color specularcolor = 1 ) { color surface_color, layer_color; color surface_opac, layer_opac; float ss,tt; point Nf, V, PP; float width, cutoff, fade, f, turb, maxfreq = 16; /* background layer */ surface_color = Cs; surface_opac = Os; /* turbie */ PP = transform("shader", P) * density; width = filterwidth_point(PP); cutoff = clamp(0.1 / width, 1, maxfreq); turb = 0; for (f = 1; f < 0.5 * cutoff; f *= 2) turb += abs(snoise(PP * f)) / f; fade = clamp(10 * (cutoff - f) / cutoff, 6, 10); turb += fade * abs(snoise(PP * f)) / f; turb *= 0.5; /* layer1 */ tt = float noise(t * complexity * turb); layer_color = one; layer_opac = smoothstep(.1,.9,tt) - .3; surface_color = blend(surface_color, layer_color, layer_opac); /* layer 2 */ ss = float noise(s * -complexity * (-turb * .5)); layer_color = two; layer_opac = smoothstep(.1,.9,ss) - .3 ; surface_color = blend(surface_color, layer_color, layer_opac); /* layer 3 */ tt = float noise(PP * complexity * turb); layer_color = three; layer_opac = smoothstep(.1,.9,tt) - .3 ; surface_color = blend(surface_color, layer_color, layer_opac); /* shading */ 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; }