/* * fluffy.sl * * Displacement Shader to create slight fluffiness * for use in modeling duck * especially for pasting on spheres and ellipsoids * because it tapers the flufiness at the ends instead * of bunching them. * * M. Geroch * TV Digital Lighting HW 5 * Spring, 1996 * */ #include "/usr/local/accad/shaders/rmannotes.sl" displacement fluffy( float Km = 0.02; float scrunch = 30; float ramp= 0.17; float Kmtex = 0.05; string texturename=""; ) { float magnitude; float taper; float fuzz=0.14; /* taper the regular displacement at the ends if desired */ taper = pulse(ramp, 1-ramp+fuzz, fuzz, t); /* main layer */ magnitude = taper * noise(s*scrunch, t*scrunch); /* get more displacement from texture map if desired */ /* Km and Kmtex modulate the height of the displacement */ if (texturename != "") { magnitude += 2*(float texture(texturename, s, t)); P += Kmtex * magnitude * normalize(N); } else { P += Km * magnitude * normalize(N); } /* now recalculate the normal at the point */ N = calculatenormal(P); }