1 |
|
{ RCSid $Id$ } |
2 |
|
{ |
3 |
|
Shirley-Chiu coordinate calculation for BRDF data types (plasdata, metdata) |
4 |
– |
|
5 |
– |
Assumes material in X-Y plane with Y axis "up" and surface normal is Z-axis |
4 |
|
} |
7 |
– |
Up(i) = arg(AC-3+i); { up vector does not need to be normalized } |
8 |
– |
Vux = cross(1,Up,N); |
9 |
– |
Vuy = cross(2,Up,N); |
10 |
– |
Vuz = cross(3,Up,N); |
11 |
– |
vnorm = 1/sqrt(Vux*Vux + Vuy*Vuy + Vuz*Vuz); |
12 |
– |
Vnx = Vux*vnorm; |
13 |
– |
Vny = Vuy*vnorm; |
14 |
– |
Vnz = Vuz*vnorm; |
15 |
– |
Vn(i) = select(i, Vnx, Vny, Vnz); |
16 |
– |
Unx = cross(1,N,Vn); |
17 |
– |
Uny = cross(2,N,Vn); |
18 |
– |
Unz = cross(3,N,Vn); |
19 |
– |
{ Transform vectors, normalized (dx,dy,dz) away from surf } |
20 |
– |
surf_dx(dx,dy,dz) = dx*Unx + dy*Uny + dz*Unz; |
21 |
– |
surf_dy(dx,dy,dz) = dx*Vnx + dy*Vny + dz*Vnz; |
22 |
– |
surf_dz(dx,dy,dz) = dx*Nx + dy*Ny + dz*Nz; |
23 |
– |
|
24 |
– |
inc_dx = surf_dx(-Dx,-Dy,-Dz); |
25 |
– |
inc_dy = surf_dy(-Dx,-Dy,-Dz); |
26 |
– |
inc_dz = Rdot; |
5 |
|
{ Compute square position from disk coordinates } |
6 |
|
norm_radians(p) : if(-p - PI/4, p + 2*PI, p); |
7 |
|
idr(idx,idy) = sqrt(idx*idx + idy*idy); |
24 |
|
square_x(idx,idy) = (square_a(idr(idx,idy),idp(idx,idy)) + 1)/2; |
25 |
|
square_y(idx,idy) = (square_b(idr(idx,idy),idp(idx,idy)) + 1)/2; |
26 |
|
|
27 |
< |
inc_sqx = square_x(-inc_dx,-inc_dy); { Negative because of Klems reversal } |
28 |
< |
inc_sqy = square_y(-inc_dx,-inc_dy); |
27 |
> |
inc_sqx = square_x(-Idx,-Idy); { Negative because of Klems reversal } |
28 |
> |
inc_sqy = square_y(-Idx,-Idy); |
29 |
|
|
30 |
|
sqx_in(sx,sy,sz) = inc_sqx; { Only a function of incident ray direction } |
31 |
|
sqy_in(sx,sy,sz) = inc_sqy; |
32 |
|
|
33 |
< |
sqx_out(sx,sy,sz) = square_x(surf_dx(sx,sy,sz),surf_dy(sx,sy,sz)); |
34 |
< |
sqy_out(sx,sy,sz) = square_y(surf_dx(sx,sy,sz),surf_dy(sx,sy,sz)); |
33 |
> |
sqx_out(sx,sy,sz) = square_x(Ldx(sx,sy,sz),Ldy(sx,sy,sz)); |
34 |
> |
sqy_out(sx,sy,sz) = square_y(Ldx(sx,sy,sz),Ldy(sx,sy,sz)); |