| 1 |
greg |
1.2 |
{ RCSid $Id: diskcoords.cal,v 1.1 2018/11/30 17:49:59 greg Exp $ }
|
| 2 |
greg |
1.1 |
{
|
| 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
|
| 6 |
|
|
}
|
| 7 |
|
|
{ Compute square position from disk coordinates }
|
| 8 |
|
|
norm_radians(p) : if(-p - PI/4, p + 2*PI, p);
|
| 9 |
|
|
idr(idx,idy) = sqrt(idx*idx + idy*idy);
|
| 10 |
|
|
idp(idx,idy) = norm_radians(atan2(idy, idx));
|
| 11 |
|
|
|
| 12 |
|
|
idrgn(idp) = floor((idp + PI/4)/(PI/2)) + 1;
|
| 13 |
|
|
|
| 14 |
|
|
square_a(idr,idp) = select(idrgn(idp),
|
| 15 |
|
|
idr,
|
| 16 |
|
|
(PI/2 - idp)*idr/(PI/4),
|
| 17 |
|
|
-idr,
|
| 18 |
|
|
(idp - 3*PI/2)*idr/(PI/4));
|
| 19 |
|
|
|
| 20 |
|
|
square_b(idr,idp) = select(idrgn(idp),
|
| 21 |
|
|
idp*idr/(PI/4),
|
| 22 |
|
|
idr,
|
| 23 |
|
|
(PI - idp)*idr/(PI/4),
|
| 24 |
|
|
-idr);
|
| 25 |
|
|
|
| 26 |
|
|
square_x(idx,idy) = (square_a(idr(idx,idy),idp(idx,idy)) + 1)/2;
|
| 27 |
|
|
square_y(idx,idy) = (square_b(idr(idx,idy),idp(idx,idy)) + 1)/2;
|
| 28 |
|
|
|
| 29 |
greg |
1.2 |
inc_sqx = square_x(-Idx,-Idy); { Negative because of Klems reversal }
|
| 30 |
|
|
inc_sqy = square_y(-Idx,-Idy);
|
| 31 |
greg |
1.1 |
|
| 32 |
|
|
sqx_in(sx,sy,sz) = inc_sqx; { Only a function of incident ray direction }
|
| 33 |
|
|
sqy_in(sx,sy,sz) = inc_sqy;
|
| 34 |
|
|
|
| 35 |
greg |
1.2 |
sqx_out(sx,sy,sz) = square_x(Ldx(sx,sy,sz),Ldy(sx,sy,sz));
|
| 36 |
|
|
sqy_out(sx,sy,sz) = square_y(Ldx(sx,sy,sz),Ldy(sx,sy,sz));
|