displacement smoothbump2(float Km = 0.1, min = 0.1, max = 0.8, fuzz = 0.1) { float hump = 0; normal n; /* STEP 1 - make a copy of the surface normal one unit in length */ n = normalize(N); /* STEP 2 - calculate an appropriate value for the displacement */ hump = smoothstep(min, min + fuzz, t) * (1 - smoothstep(max, max + fuzz, t)); /* STEP 3 - calculate the new position of the surface point */ /* "P" based on the value of hump */ P = P - n * hump * Km; /* STEP 4 - calculate the new orientation of the surface normal */ N = calculatenormal(P); }