ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cal/cal/fovsample.cal
(Generate patch)

Comparing ray/src/cal/cal/fovsample.cal (file contents):
Revision 1.3 by greg, Fri Apr 5 23:49:59 2019 UTC vs.
Revision 1.4 by greg, Sun Apr 7 15:38:35 2019 UTC

# Line 11 | Line 11
11                  D :             field of view (full angle in degrees)
12  
13          Inputs:
14 <                iDx, iDy, iDz = uniformly generated sampling vector
14 >                forward =       1 if forward conversion, -1 if reverse
15 >                iDx, iDy, iDz = input sampling vector
16          
17          Outputs:
18 <                oDx, oDy, oDz = foveated sample direction (normalized)
18 >                oDx, oDy, oDz = output sample direction (normalized)
19          
20          Other variables computed:
21 <                iTheta =        original angle to center (radians)
22 <                oTheta =        new angle to center (radians)
21 >                iTheta =        input angle to center (radians)
22 >                oTheta =        output angle to center (radians)
23   }
24  
25   r : PI/360 * D;         { half-angle of foveal region in radians }
# Line 41 | Line 42 | iDot = nCx*niDx + nCy*niDy + nCz*niDz;
42   degen = iDot - cos(.05*PI/180);
43  
44   iTheta = acos(iDot);
45 +                        { quadratic function coefficients mate to linear ramp }
46 + qa : (PI - PI/M)/sq(PI - rp);
47 + qb : 1/M - 2*PI*r*(M - 1)/sq(PI - rp);
48 + qc : (PI - PI/M)/sq(PI/rp - 1);
49  
50 < gamma = 1 + sq((iTheta-rp)/(PI-rp)) * (log(M)/(log(PI/(PI-r)) - log(M)));
51 <
52 < oTheta = if(rp-iTheta, iTheta/M, (PI-r)*(iTheta/(M*(PI-r)))^gamma);
53 <
50 > oTheta = if (forward,
51 >                if(rp-iTheta, iTheta/M, qa*iTheta*iTheta + qb*iTheta + qc),
52 >                if(r-iTheta, iTheta*M, (sqrt(qb*qb - 4*qa*(qc - iTheta)) - qb)/(2*qa))
53 >        );
54                          { normalized "up" vector for rotation }
55   Unf = 1/sqrt(1 - iDot*iDot);
56   nUx = (nCy*niDz - nCz*niDy)*Unf;
# Line 59 | Line 64 | rDx = nCx*rcos + (nUy*nCz - nUz*nCy)*rsin;
64   rDy = nCy*rcos + (nUz*nCx - nUx*nCz)*rsin;
65   rDz = nCz*rcos + (nUx*nCy - nUy*nCx)*rsin;
66                          { substitute approximation in degenerate case }
67 < oDx = if(degen, nCx+(niDx-nCx)/M, rDx);
68 < oDy = if(degen, nCy+(niDy-nCy)/M, rDy);
69 < oDz = if(degen, nCz+(niDz-nCz)/M, rDz);
67 > oDx = if(degen, nCx+(niDx-nCx)*if(forward,1/M,M), rDx);
68 > oDy = if(degen, nCy+(niDy-nCy)*if(forward,1/M,M), rDy);
69 > oDz = if(degen, nCz+(niDz-nCz)*if(forward,1/M,M), rDz);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines