3 |
|
{ |
4 |
|
Interpolate triangle-mesh values using barycentric coordinates. |
5 |
|
|
6 |
< |
A1 through A12 = Transformation matrix for barycentric system |
6 |
> |
A1 = Major axis (0==X, 1==Y, 2==Z) |
7 |
> |
A2 through A7 = Transformation for barycentric system |
8 |
|
and: |
9 |
< |
A13 through A21 = Surface normal perturbation matrix |
9 |
> |
A8 through A16 = Surface normal perturbation matrix |
10 |
|
or: |
11 |
< |
A13 through A18 = Lookup in 2-dimensional pattern or texture |
11 |
> |
A8 through A13 = Lookup in 2-dimensional pattern or texture |
12 |
|
} |
13 |
|
{ Compute barycentric coordinates } |
14 |
< |
a = Px*arg( 1) + Py*arg( 2) + Pz*arg( 3) + arg( 4); |
15 |
< |
b = Px*arg( 5) + Py*arg( 6) + Pz*arg( 7) + arg( 8); |
16 |
< |
c = Px*arg( 9) + Py*arg(10) + Pz*arg(11) + arg(12); |
14 |
> |
bu = select(arg(1)+1, Py, Pz, Px); |
15 |
> |
bv = select(arg(1)+1, Pz, Px, Py); |
16 |
> |
a = bu*arg( 2) + bv*arg( 3) + arg( 4); |
17 |
> |
b = bu*arg( 5) + bv*arg( 6) + arg( 7); |
18 |
> |
c = 1 - a - b; |
19 |
|
{ Compute variables } |
20 |
< |
v1 = a*arg(13) + b*arg(14) + c*arg(15); |
21 |
< |
v2 = a*arg(16) + b*arg(17) + c*arg(18); |
22 |
< |
v3 = a*arg(19) + b*arg(20) + c*arg(21); |
20 |
> |
v1 = a*arg( 8) + b*arg( 9) + c*arg(10); |
21 |
> |
v2 = a*arg(11) + b*arg(12) + c*arg(13); |
22 |
> |
v3 = a*arg(14) + b*arg(15) + c*arg(16); |
23 |
|
{ Surface normal perturbation } |
24 |
|
nf = 1/sqrt(v1*v1 + v2*v2 + v3*v3); |
25 |
|
dx = v1*nf - Nx; |