{
        Adobe texture.

        Applies to any large, flat surface.

        A1      - overall magnitude
}

{ Basic texture is scaled gradient of 3D Perlin noise function.
  Additional perturbation is added when in_crack is true. }
dx = A1 * noise3a(Px, Py, Pz) + if(in_crack, cdx, 0);
dy = A1 * noise3b(Px, Py, Pz) + if(in_crack, cdy, 0);
dz = A1 * noise3c(Px, Py, Pz) + if(in_crack, cdz, 0);

{ First, compute crack coordinate system, which is at 3 times original
  bump scale and has additional fractal noise through in for irregularity
  over an even larger scale. }
fn3 = fnoise3(Px, Py, Pz);
cu = Px/3 + fn3/30;
cv = Py/3 + fn3/30;
cw = Pz/3 + fn3/30;

{ Test in_crack returns true (positive) when sum of [-1,1] Perlin noise in
  crack coordinate system is about -.4 times the fractal noise function at
  the same point. }
in_crack = inside(-.02, noise3(cu, cv, cw) + .4*fnoise3(cu, cv, cw), .02);

{ Final crack perturbation is 5 times as large as normal gradient at that
  point in Perlin function, meaning it will yank the surface normal one way
  or the other along that wiggly line where in_crack is true, yielding an
  apparent discontinuity in the surface. }
cdx = 5*A1*noise3a(cu, cv, cw);
cdy = 5*A1*noise3b(cu, cv, cw);
cdz = 5*A1*noise3c(cu, cv, cw);
