surface
#define udn(x,lo,hi) (smoothstep(.25, .75, noise(x)) * ((hi) - (lo)) + (lo)) #define whichtile(x,freq) (floor((x) * (freq))) #define pulse(a,b,fuzz,x) (smoothstep((a)-(fuzz),(a),(x)) - \ normal Nf; vector V; color Cfg = (1,1,1); color Cbg = (0,0,0); float ss, tt, row, col; float x, y, radius, noiz, z, offset; float value = 0; float matte = 0; point center; /* tile the surface & find row, colum*/ ss = mod(s*Hfreq,1.0); tt = mod(t*Vfreq,1.0); row = whichtile(s,Hfreq); col = whichtile(t,Vfreq); /* move center randomly and adjust radius*/ x = udn((row+col+.46),(-0.1),(0.1)); y = udn((row+col+1.54),(-0.1),(0.1)); center = point ( 0.5 + x, 0.5 + y,0); radius = 0.4 - max (x,y); /* Randomly make a matte of circles or squares & then */ /* Randomly make a smaller circle or square inside */ /* only if figure is drawn */ for (z = 1; z < 3 ;z += 1){
/* define three colors */ color c1 = (0.528,0.387,0.134); color c2 = (0.733,1.0,0.76); color c3 = (0.724,0.178,0.259); /* calculate background line pattern with noise */ noiz = (noise (s*Vfreq,t*Hfreq) * 0.1); offset = (x * pulse (0.5,1.0,0.5,tt)) + (noiz * (1-pulse (0.5,1.0,0.5,tt))); value = pulse (0.5+offset, 0.6+offset, 0.1, ss); offset = (y * pulse (0.5,1.0,0.5,ss)) + (noiz * (1-pulse (0.5,1.0,0.5,ss))); value = clamp ((value + pulse (0.5+offset, 0.6+offset, 0.1, tt)),(0.0),(1.0)); Cbg = spline (value, c1, c1, c2, c3, c3); /* make Foreground color to fill squares & circles */ noiz = udn ((row*col*Hfreq*Vfreq+0.5), 0.1, 0.8); Cfg = spline (noiz, c3, c3, c2, c1, c1); /* if (noiz<0.45) Cfg = c1; else if (noiz<0.55) Cfg = c2; else Cfg = c3;*/ Nf = faceforward( normalize(N), I ); V = -normalize(I); Oi = Os; /* Ci = Os * ( Csnew * (Ka*ambient() + Kd*diffuse(Nf)) + Ci = mix(Cbg, Cfg, matte); } |