/* * Produces slightly raised patterns to match with * patterns in "vase_ptn_surf" * */ #include "rmannotes.sl" displacement vase_ptn_disp(float freq = 12, Km = 0.001) { float surface_mag, layer_mag; float ss, tt; float fuzz = 0.08; float row, col; point Ndiff; float left, right, top, bottom; float stripe_fuzz = 0.2; float rectangle, pattern1, square; float circle, radius, d; point center; point Nf, V; /* background layer */ surface_mag = 0; /* repeat layers */ ss = repeat(s, freq); tt = repeat(t, freq); col = whichtile(s, freq); row = whichtile(t, freq); /* pattern layer */ /* shift even rows 1/2 tile */ ss = repeat(s, freq); tt = repeat(t, freq); row = whichtile(t, freq); if (even(row)) ss = mod(ss + 0.5, 1); /* rectangle */ left = 0.15; right = 0.85; /* rectangle sides */ top = 0.45; bottom = 0.55; rectangle = pulse(left, right, fuzz, ss) * pulse(top, bottom, fuzz, tt); /* circle */ center = (0.5, 0.5, 0); radius = 0.2; d = distance(center, (ss, tt, 0)); circle = 1 - smoothstep(radius - fuzz, radius, d); /* square */ square = intersection(pulse(0.45, 0.55, fuzz, ss), pulse(0.45, 0.55, fuzz, tt)); /* use union and difference to create pattern */ pattern1 = union(rectangle, circle); layer_mag = difference(pattern1, square) * 0.8; surface_mag = max(surface_mag, layer_mag) + layer_mag; /* displace and account for smooth shading */ Ndiff = normalize(N) - normalize(Ng); P += Km * surface_mag * normalize(N); N = normalize(calculatenormal(P)) + Ndiff; }