BumpMapping

From Odwiki

Jump to: navigation, search


Bump Mapping is the technique of shading a surface in a SurfaceShader so that it looks like it has displaced details. This is usually done by perturbing the SurfaceNormal before a LightingModel is applied. You can perturb the normal in many ways - here are a couple of common methods:

  • virtually offset the shading point (P) and calculate the new normal. This is particularly simple and can be used with procedural displacements most easily. VEX Code Example
  surface bumpy() {
     vector displacedP = P + .1*noise(P);
     vector displacedN = computenormal(P);
     Cf = diffuse(normalize(frontface(displacedN, I)));
 }
  • perturb the normal by shifting it's direction along the surface derivatives using the gradient of a texturemap. This is an older technique but is still effective. VEX Code Example
 surface bumpy() {
     vector preturbedN = normalize(N);
     float mapclr = luminance(texture("Mandril.pic"));
     preturbedN += normalize(dPds)*Du(mapclr);
     preturbedN += normalize(dPdt)*Dv(mapclr);
     Cf = diffuse(normalize(frontface(preturbedN, I)));
 }
© 2009 od[force].net | advertise