#include "rmannotes.sl" surface jellyfish(float Ka = .5, Kd = .6; float Ks = .6, roughness = .16; color specularcolor = color(1,1,0); color ringcolor = color(2,.2,.8); color bodycolor = color(.4,.8,.3); color stripecolor = color (.1,.2,.75); ) { color surface_color, layer_color; color layer_opac, surface_opac; point PP; point Nf, V; float fuzz = .05; float xx, yy, zz, ss, tt; point center; float radius, width; float d, noi; float freq = 5; float noifreq = 5; float noiscale = 0.4; /* Background layer */ surface_color = bodycolor; surface_opac = .25; /* solid rings */ PP = transform("shader", P); xx = repeat(xcomp(PP),2); layer_color = stripecolor; layer_opac = pulse(.35,.65,fuzz,xx)*.5; surface_color = blend(surface_color, layer_color, layer_opac); surface_opac = union(surface_opac, layer_opac); noi = noise(s * noifreq, t * noifreq); ss = s + snoise(noi + 912) * noiscale; tt = t + snoise(noi + 333) * noiscale; /* wavy rings */ ss = repeat(ss, freq); tt = repeat(tt, freq); center = (0.5, 0.5, 0); radius = 0.35; width = 0.1; d = distance(center, (ss, tt, 0)); layer_color = ringcolor; layer_opac = pulse(radius - width / 2, radius + width / 2, fuzz, d); 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 */ Ci = surface_color * surface_opac; Oi = surface_opac; }