#include "rmannotes.sl" displacement dispnoise7(float freq = 8, Km = .2, flatness = .2;) { /* VARIABLES */ float ss, tt; float fuzz = 0.5; float mag, layer_mag, surface_mag; float noi; float col, row; float width, cutoff, fade, f, turb, maxfreq = 25; point Nf, PP; /* NOISE */ col = whichtile(s, freq); row = whichtile(t, freq); noi = noise(col * row); /* TURBULENCE */ PP = transform("shader", P) * freq; width = filterwidth_point(PP); cutoff = clamp(0.5 / width, 0, maxfreq); turb = 1; for (f = 1.5; f < 0.5 * cutoff; f *= 2.3) turb += abs(snoise(PP * f - noi)) / 3; fade = clamp(2 * (cutoff - f) / cutoff, 0, 1); turb += fade * abs(snoise(PP * f)) / f; /* CREATE FLAT AREAS */ mag = pow(turb * noi, flatness); surface_mag = .5; /* OUTPUT */ P += Km * mag * normalize(N); N = calculatenormal(P); }