/* * Displacement Shader "fractal_bumps" -- yields an irregular bumpy surface * whose "graininess" depends on the number of octaves evaluated. * * by Matt Brandt * (off-campus student from NASA Goddard Space Flight Center) * * (This is a variation on the "dented" shader from * _The_RenderMan_Companion_ by Steve Upstill.) */ displacement fractal_bumps(float Km = 1.0, octaves = 5.0) { float size = 1.0, mag = 0.0, i; point P2; P2 = transform("shader", P); for(i = 0; i < octaves; i += 1.0) { /* Do simple fractal noise. */ mag += abs(.5 - noise(P2 * size)) / size; size *= 2.0; } P2 = P + normalize(N) * (mag * mag * mag) * Km; N = calculatenormal(P2); }