/* Displacement shader "hills" * Final Assignment: use of noise * Tom Suchan * This is a simple but verstile displacement shader good for beach parties, * moon walks, or where ever an uneven surface is needed. The shader is * intended to create a hilly surface. The user can control the amount * of displacement with Km and the "hill" (frequancy) parameter. */ #include "rmannotes.sl" displacement hills(float Km = 0.4; float hill = 4) { float magnitude = 0, layer_mag; point PP; PP = transform("shader", P); /*change space */ layer_mag = noise(PP * hill); /* add noise to create bumbs */ magnitude += layer_mag; /* output */ P += -Km * magnitude * normalize(N); N = calculatenormal(P); }