displacement waves_water ( float Km = 0.1, /*displace scale*/ freq = 3, /* wave freq */ turb = 4, /* wind freq */ /* wave wind direction for best result move one wind and one wave values at once */ waves = 2, wavet = 1, winds = 1, windt = 2, TrueDisplace = 1, /* displace or bump */ /* wave noise layers */ layers = 3; /* coordinate space */ string space = "object" ) { float humpA = 0, humpB =0 , hump = 0 ; normal n = normalize(N); point p = transform(space, P); float j, h = turb, f = freq, amplitude = 1 , ss = s + waves, tt = t + wavet, sss = s + winds , ttt = t + windt ; for(j = 0; j < layers; j += 1) { humpA += abs(noise(ss * f, tt * f) - 0.5) * amplitude ; /* loop for waves */ humpB += abs(noise(sss * h, ttt * h) - 0.5) * amplitude ; /* loop for wind turb */ hump = humpA + humpB; /* add merge values */ f *= 2; h *=2; amplitude *= 0.5; } if (TrueDisplace < 0 ) { P = P - n * hump * Km; N = calculatenormal(P); } else { N = calculatenormal(P - n * hump * Km); } }