1 |
greg |
1.1 |
{ |
2 |
|
|
Adobe texture. |
3 |
|
|
|
4 |
|
|
Applies to any large, flat surface. |
5 |
|
|
|
6 |
|
|
A1 - overall magnitude |
7 |
|
|
} |
8 |
|
|
|
9 |
|
|
{ Basic texture is scaled gradient of 3D Perlin noise function. |
10 |
|
|
Additional perturbation is added when in_crack is true. } |
11 |
|
|
dx = A1 * noise3a(Px, Py, Pz) + if(in_crack, cdx, 0); |
12 |
|
|
dy = A1 * noise3b(Px, Py, Pz) + if(in_crack, cdy, 0); |
13 |
|
|
dz = A1 * noise3c(Px, Py, Pz) + if(in_crack, cdz, 0); |
14 |
|
|
|
15 |
|
|
{ First, compute crack coordinate system, which is at 3 times original |
16 |
|
|
bump scale and has additional fractal noise through in for irregularity |
17 |
|
|
over an even larger scale. } |
18 |
|
|
fn3 = fnoise3(Px, Py, Pz); |
19 |
|
|
cu = Px/3 + fn3/30; |
20 |
|
|
cv = Py/3 + fn3/30; |
21 |
|
|
cw = Pz/3 + fn3/30; |
22 |
|
|
|
23 |
|
|
{ Test in_crack returns true (positive) when sum of [-1,1] Perlin noise in |
24 |
|
|
crack coordinate system is about -.4 times the fractal noise function at |
25 |
|
|
the same point. } |
26 |
|
|
in_crack = inside(-.02, noise3(cu, cv, cw) + .4*fnoise3(cu, cv, cw), .02); |
27 |
|
|
|
28 |
|
|
{ Final crack perturbation is 5 times as large as normal gradient at that |
29 |
|
|
point in Perlin function, meaning it will yank the surface normal one way |
30 |
|
|
or the other along that wiggly line where in_crack is true, yielding an |
31 |
|
|
apparent discontinuity in the surface. } |
32 |
|
|
cdx = 5*A1*noise3a(cu, cv, cw); |
33 |
|
|
cdy = 5*A1*noise3b(cu, cv, cw); |
34 |
|
|
cdz = 5*A1*noise3c(cu, cv, cw); |