#include "rmannotes.sl" surface demo() { float fuz = 0.05; color surface_color = 1; /* tile coords */ float freq = 4; float col = whichtile(s, freq); float row = whichtile(t, freq); float i, j, true_col=col, true_row=row; for (i=-1; i<=1; i+=1) { /* consider three columns */ for(j=-1; j<=1; j+=1) { /* consider three rows */ float ss = repeat(s, freq) - i; float tt = repeat(t, freq) - j; col = mod((true_col + i), freq); row = mod((true_row + j), freq); float bomb = noise(col * 10 + 0.5, row * 10 + 0.5); /* rotate coords */ float tmps = ss, tmpt = tt; float Rot = udn(bomb * 777, -60, 60); rotate2d(tmps, tmpt, radians(Rot), 0.5, 0.5, ss, tt); /* scale each feature randomly */ float sc = udn(bomb * 3824, .33, 2); ss = (ss-0.5)*sc + 0.5; tt = (tt-0.5)*sc + 0.5; /* add noise to feature samples - same for every feature */ ss += .25 * snoise(ss*6 + 437); tt += .25 * snoise(tt*6 + 298); /* add noise to layer color - same for each tile */ color layer_color = udn2(ss*6+312, tt*6+252, 0,1); float d = distance(point(.5,.5,0), point(ss,tt,0)); color layer_opac = 1 - smoothstep(0.3-fuz, 0.3, d); surface_color = blend(surface_color, layer_color, layer_opac); } } Ci = surface_color; }