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

Comparing ray/src/rt/pmap.c (file contents):
Revision 2.16 by rschregle, Wed Nov 21 19:33:30 2018 UTC vs.
Revision 2.17 by rschregle, Tue Dec 18 22:14:04 2018 UTC

# Line 50 | Line 50 | static int photonParticipate (RAY *ray)
50     or 0 if absorbed and $*%&ed. Analogon to rayparticipate(). */
51   {
52     int i;
53 <   RREAL cosTheta, cosPhi, du, dv;
53 >   RREAL xi1, cosTheta, phi, du, dv;
54     const float cext = colorAvg(ray -> cext),
55                 albedo = colorAvg(ray -> albedo),
56 <               gecc2 = ray -> gecc * ray -> gecc;
56 >               gecc = ray -> gecc, gecc2 = sqr(gecc);
57     FVECT u, v;
58     COLOR cvext;
59  
# Line 86 | Line 86 | static int photonParticipate (RAY *ray)
86        /* Store volume photons unconditionally in mist to also account for
87           direct inscattering from sources */
88        if (albedo > FTINY)
89 < #endif      
89 > #endif
90           /* Add to volume photon map */
91           newPhoton(volumePmap, ray);
92          
# Line 99 | Line 99 | static int photonParticipate (RAY *ray)
99        scalecolor(ray -> rcol, 1 / albedo);    
100        
101        /* Scatter photon */
102 +      xi1 = pmapRandom(scatterState);
103        cosTheta = ray -> gecc <= FTINY
104 <                    ? 2 * pmapRandom(scatterState) - 1
105 <                    : 0.5 * (1 + gecc2 -
106 <                         (1 - gecc2) / (1 - ray -> gecc + 2 * ray -> gecc *
107 <                         pmapRandom(scatterState))) / ray -> gecc;
108 <                                                  
109 <      cosPhi = cos(2 * PI * pmapRandom(scatterState));
110 <      du = dv = sqrt(1 - cosTheta * cosTheta);   /* sin(theta) */
111 <      du *= cosPhi;
112 <      dv *= sqrt(1 - cosPhi * cosPhi);           /* sin(phi) */
104 >                    ? 2 * xi1 - 1
105 >                    : 0.5 / gecc *
106 >                      (1 + gecc2 - sqr((1 - gecc2) /
107 >                                       (1 + gecc * (2 * xi1 - 1))));
108 >
109 >      phi = 2 * PI * pmapRandom(scatterState);
110 >      du = dv = sqrt(1 - sqr(cosTheta));     /* sin(theta) */
111 >      du *= cos(phi);
112 >      dv *= sin(phi);
113        
114        /* Get axes u & v perpendicular to photon direction */
115        i = 0;
# Line 122 | Line 123 | static int photonParticipate (RAY *ray)
123        for (i = 0; i < 3; i++)
124           ray -> rdir [i] = du * u [i] + dv * v [i] +
125                             cosTheta * ray -> rdir [i];
126 +
127        ray -> rlvl++;
128        ray -> rmax = -log(pmapRandom(mediumState)) / cext;
129     }  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines