#include "rmannotes.sl" surface n1(float Ka=1, Kd=.6, Ks=.4, roughness=.3) { color surface_color, layer_color, surface_opac, layer_opac; float surface_mag, layer_mag; float fuz = 0.05; float freq = 8; /* num features */ /**************************************************/ /* base layer */ surface_color = color (.8, .7, .2); surface_mag = 0; /**************************************************/ /* cone layer */ float ss = repeat(s, freq*2); /* tile coords */ float tt = repeat(t, freq); float d = distance(point(.5,.5,0), point(ss,tt,0)); /* dist from center */ float R = 0.4; /* feature radius */ layer_color = color(.8, .2, .1); layer_opac = 1 - smoothstep(R-fuz, R, d); surface_color = blend(surface_color, layer_color, layer_opac); float max_height = .2; layer_mag = max_height * (1-clamp(d/R,0,1)) * comp(layer_opac,0); surface_mag += layer_mag; /**************************************************/ /* displacement */ vector Nn = normalize(N); P += Nn * (surface_mag / length(vtransform("shader", Nn))); N = calculatenormal(P); /* lighting */ normal Nf = faceforward (normalize(N),I); surface_color = surface_color * (Ka*ambient() + Kd*diffuse(Nf)) + Ks*specular(Nf, -normalize(I), roughness); Ci = surface_color; }