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

Comparing ray/src/rt/pmapmat.c (file contents):
Revision 2.1 by greg, Tue Feb 24 19:39:27 2015 UTC vs.
Revision 2.15 by rschregle, Tue Mar 20 19:55:33 2018 UTC

# Line 1 | Line 1
1 + #ifndef lint
2 + static const char RCSid[] = "$Id$";
3 + #endif
4   /*
5     ==================================================================
6     Photon map support routines for scattering by materials.
7  
8     Roland Schregle (roland.schregle@{hslu.ch, gmail.com})
9     (c) Fraunhofer Institute for Solar Energy Systems,
10 <       Lucerne University of Applied Sciences & Arts
10 >   (c) Lucerne University of Applied Sciences and Arts,
11 >   supported by the Swiss National Science Foundation (SNSF, #147053)
12     ==================================================================
13    
10   $Id$
14   */
15  
16  
# Line 103 | Line 106 | void photonRay (const RAY *rayIn, RAY *rayOut,
106   {
107     rayorigin(rayOut, rayOutType, rayIn, NULL);
108    
109 <   /* Transfer flux */
110 <   copycolor(rayOut -> rcol, rayIn -> rcol);
111 <  
112 <   /* Copy caustic flag & direction for transferred rays */
113 <   if (rayOutType == PMAP_XFER) {
114 <      /* rayOut -> rtype |= rayIn -> rtype & SPECULAR; */
115 <      rayOut -> rtype |= rayIn -> rtype;
116 <      VCOPY(rayOut -> rdir, rayIn -> rdir);
117 <   }
118 <   else if (fluxAtten) {
119 <      /* Attenuate and normalised flux for scattered rays */
120 <      multcolor(rayOut -> rcol, fluxAtten);
121 <      colorNorm(rayOut -> rcol);
122 <   }
109 >   if (rayIn) {
110 >      /* Transfer flux */
111 >      copycolor(rayOut -> rcol, rayIn -> rcol);
112 >      
113 >      /* Copy caustic flag & direction for transferred rays */
114 >      if (rayOutType == PMAP_XFER) {
115 >         /* rayOut -> rtype |= rayIn -> rtype & SPECULAR; */
116 >         rayOut -> rtype |= rayIn -> rtype;
117 >         VCOPY(rayOut -> rdir, rayIn -> rdir);
118 >      }
119 >      else if (fluxAtten) {
120 >         /* Attenuate and normalise flux for scattered rays */
121 >         multcolor(rayOut -> rcol, fluxAtten);
122 >         colorNorm(rayOut -> rcol);
123 >      }
124  
125 <   /* Propagate index of emitting light source */
126 <   rayOut -> rsrc = rayIn -> rsrc;
125 >      /* Propagate index of emitting light source */
126 >      rayOut -> rsrc = rayIn -> rsrc;
127 >      
128 >      /* Update maximum photon path distance */
129 >      rayOut -> rmax = rayIn -> rmax - rayIn -> rot;
130 >   }
131   }
132  
133  
# Line 129 | Line 137 | static void addPhotons (const RAY *r)
137   {
138     if (!r -> rlvl)
139        /* Add direct photon map at primary hitpoint */
140 <      addPhoton(directPmap, r);
140 >      newPhoton(directPmap, r);
141     else {
142        /* Add global or precomputed photon map at indirect hitpoint */
143 <      addPhoton(preCompPmap ? preCompPmap : globalPmap, r);
143 >      newPhoton(preCompPmap ? preCompPmap : globalPmap, r);
144  
145        /* Store caustic photon if specular flag set */
146        if (PMAP_CAUSTICRAY(r))
147 <         addPhoton(causticPmap, r);
147 >         newPhoton(causticPmap, r);
148          
149        /* Store in contribution photon map */
150 <      addPhoton(contribPmap, r);
150 >      newPhoton(contribPmap, r);
151     }
152   }
153  
# Line 198 | Line 206 | static int isoSpecPhotonScatter (NORMDAT *nd, RAY *ray
206     int      niter, i = 0;
207    
208     /* Set up sample coordinates */  
209 <   do {
202 <      v [0] = v [1] = v [2] = 0;
203 <      v [i++] = 1;
204 <      fcross(u, v, nd -> pnorm);
205 <   } while (normalize(u) < FTINY);
206 <  
209 >   getperpendicular(u, nd -> pnorm, 1);  
210     fcross(v, nd -> pnorm, u);
211    
212     if (nd -> specfl & SP_REFL) {
# Line 267 | Line 270 | static void diffPhotonScatter (FVECT normal, RAY* rayO
270     int         i = 0;
271  
272     /* Set up sample coordinates */
273 <   do {
271 <      v [0] = v [1] = v [2] = 0;
272 <      v [i++] = 1;
273 <      fcross(u, v, normal);
274 <   } while (normalize(u) < FTINY);
275 <  
273 >   getperpendicular(u, normal, 1);
274     fcross(v, normal, u);
275    
276     /* Convert theta & phi to cartesian */
# Line 323 | Line 321 | static int normalPhotonScatter (OBJREC *mat, RAY *rayI
321        nd.specfl |= SP_FLAT;  
322        
323     /* Perturb normal */
324 <   if ((hastexture = DOT(rayIn -> pert, rayIn -> pert)) > sqr(FTINY))
324 >   if ((hastexture = (DOT(rayIn -> pert, rayIn -> pert) > sqr(FTINY)) ))
325        nd.pdot = raynormal(nd.pnorm, rayIn);
326     else {
327        VCOPY(nd.pnorm, rayIn -> ron);
# Line 752 | Line 750 | static int dielectricPhotonScatter (OBJREC *mat, RAY *
750     /* get modifiers */
751     raytexture(rayIn, mat -> omod);                      
752    
753 <   if ((hastexture = DOT(rayIn -> pert, rayIn -> pert)) > FTINY * FTINY)
753 >   if ((hastexture = (DOT(rayIn -> pert, rayIn -> pert) > FTINY * FTINY)))
754        /* Perturb normal */
755        cos1 = raynormal(dnorm, rayIn);
756     else {
# Line 899 | Line 897 | static int glassPhotonScatter (OBJREC *mat, RAY *rayIn
897     /* reorient if necessary */
898     if (rayIn -> rod < 0)
899        flipsurface(rayIn);
900 <   if ((hastexture = DOT(rayIn -> pert, rayIn -> pert)) > FTINY * FTINY)
900 >   if ((hastexture = (DOT(rayIn -> pert, rayIn -> pert) > FTINY * FTINY) ))
901        pdot = raynormal(pnorm, rayIn);
902     else {
903        VCOPY(pnorm, rayIn -> ron);
# Line 985 | Line 983 | static int aliasPhotonScatter (OBJREC *mat, RAY *rayIn
983    
984     /* Straight replacement? */
985     if (!mat -> oargs.nsargs) {
986 <      mat = objptr(mat -> omod);
987 <      photonScatter [mat -> otype] (mat, rayIn);
986 >      /* Skip void modifier! */
987 >      if (mat -> omod != OVOID) {  
988 >         mat = objptr(mat -> omod);
989 >         photonScatter [mat -> otype] (mat, rayIn);
990 >      }
991        
992        return 0;
993     }
# Line 1257 | Line 1258 | static int mx_dataPhotonScatter (OBJREC *mat, RAY *ray
1258     if (errno)
1259        objerror(mat, WARNING, "compute error");
1260     else {
1261 <      mat = objptr(mod [pmapRandom(rouletteState) < coef ? 0 : 1]);
1262 <      photonScatter [mat -> otype] (mat, rayIn);
1261 >      OBJECT mxMod = mod [pmapRandom(rouletteState) < coef ? 0 : 1];
1262 >      
1263 >      if (mxMod != OVOID) {
1264 >         mat = objptr(mxMod);
1265 >         photonScatter [mat -> otype] (mat, rayIn);
1266 >      }
1267 >      else {
1268 >         /* Transfer ray if no modifier */
1269 >         RAY rayOut;
1270 >        
1271 >         photonRay(rayIn, &rayOut, PMAP_XFER, NULL);
1272 >         tracePhoton(&rayOut);      
1273 >      }            
1274     }
1275    
1276     return 0;
# Line 1310 | Line 1322 | static int mx_pdataPhotonScatter (OBJREC *mat, RAY *ra
1322     if (errno)
1323        objerror(mat, WARNING, "compute error");
1324     else {
1325 <      mat = objptr(mod [pmapRandom(rouletteState) < coef ? 0 : 1]);
1326 <      photonScatter [mat -> otype] (mat, rayIn);
1325 >      OBJECT mxMod = mod [pmapRandom(rouletteState) < coef ? 0 : 1];
1326 >      
1327 >      if (mxMod != OVOID) {
1328 >         mat = objptr(mxMod);
1329 >         photonScatter [mat -> otype] (mat, rayIn);
1330 >      }
1331 >      else {
1332 >         /* Transfer ray if no modifier */
1333 >         RAY rayOut;
1334 >        
1335 >         photonRay(rayIn, &rayOut, PMAP_XFER, NULL);
1336 >         tracePhoton(&rayOut);      
1337 >      }      
1338     }  
1339    
1340     return 0;
# Line 1350 | Line 1373 | static int mx_funcPhotonScatter (OBJREC *mat, RAY *ray
1373     if (errno)
1374        objerror(mat, WARNING, "compute error");
1375     else {        
1376 <      mat = objptr(mod [pmapRandom(rouletteState) < coef ? 0 : 1]);
1377 <      photonScatter [mat -> otype] (mat, rayIn);
1376 >      OBJECT mxMod = mod [pmapRandom(rouletteState) < coef ? 0 : 1];
1377 >      
1378 >      if (mxMod != OVOID) {
1379 >         mat = objptr(mxMod);
1380 >         photonScatter [mat -> otype] (mat, rayIn);
1381 >      }
1382 >      else {
1383 >         /* Transfer ray if no modifier */
1384 >         RAY rayOut;
1385 >        
1386 >         photonRay(rayIn, &rayOut, PMAP_XFER, NULL);
1387 >         tracePhoton(&rayOut);      
1388 >      }
1389     }
1390    
1391     return 0;
# Line 1383 | Line 1417 | static int pattexPhotonScatter (OBJREC *mat, RAY *rayI
1417  
1418  
1419  
1420 + /*
1421 +   ==================================================================
1422 +   The following code is
1423 +   (c) Lucerne University of Applied Sciences and Arts,
1424 +   supported by the Swiss National Science Foundation (SNSF, #147053)
1425 +   ==================================================================
1426 + */  
1427 +
1428   static int bsdfPhotonScatter (OBJREC *mat, RAY *rayIn)
1429   /* Generate new photon ray for BSDF modifier and recurse. */
1430   {
1431     int      hitFront;
1432     SDError  err;
1433 +   SDValue  bsdfVal;
1434     FVECT           upvec;
1435     MFUNC           *mf;
1436     BSDFDAT      nd;
1437     RAY      rayOut;
1438 <
1438 >   COLOR    bsdfRGB;
1439 >   int      transmitted;
1440 >   double   prDiff, ptDiff, prDiffSD, ptDiffSD, prSpecSD, ptSpecSD,
1441 >            albedo, xi;
1442 >   const double patAlb = bright(rayIn -> pcol);
1443 >  
1444     /* Following code adapted from m_bsdf() */
1445     /* Check arguments */
1446     if (mat -> oargs.nsargs < 6 || mat -> oargs.nfargs > 9 ||
# Line 1408 | Line 1456 | static int bsdfPhotonScatter (OBJREC *mat, RAY *rayIn)
1456          nd.thick = evalue(mf -> ep [0]);
1457          if ((-FTINY <= nd.thick) & (nd.thick <= FTINY))
1458                  nd.thick = .0;
1411                
1412   if (nd.thick != .0 || (!hitFront && !backvis)) {
1413      /* Proxy geometry present, so use it instead and transfer ray */
1414      photonRay(rayIn, &rayOut, PMAP_XFER, NULL);
1415      tracePhoton(&rayOut);
1416      
1417      return 0;
1418   }
1459  
1460     /* Get BSDF data */
1461     nd.sd = loadBSDF(mat -> oargs.sarg [1]);
1462    
1463 <   /* Diffuse reflectance */
1463 >   /* Extra diffuse reflectance from material def */
1464     if (hitFront) {
1465        if (mat -> oargs.nfargs < 3)
1466           setcolor(nd.rdiff, .0, .0, .0);
# Line 1439 | Line 1479 | static int bsdfPhotonScatter (OBJREC *mat, RAY *rayIn)
1479     else setcolor(nd.rdiff, mat -> oargs.farg [3], mat -> oargs.farg [4],
1480                   mat -> oargs.farg [5]);
1481  
1482 <        /* Diffuse transmittance */
1482 >        /* Extra diffuse transmittance from material def */
1483          if (mat -> oargs.nfargs < 9)
1484             setcolor(nd.tdiff, .0, .0, .0);
1485     else setcolor(nd.tdiff, mat -> oargs.farg [6], mat -> oargs.farg [7],
# Line 1506 | Line 1546 | static int bsdfPhotonScatter (OBJREC *mat, RAY *rayIn)
1546        nd.pnorm [1] = -nd.pnorm [1];
1547        nd.pnorm [2] = -nd.pnorm [2];
1548     }
1549 <  
1550 <   /* Following code adapted from SDsampBSDF() */
1551 <   {
1552 <      SDSpectralDF   *rdf, *tdf;
1553 <      SDValue        bsdfVal;
1554 <      double         xi, rhoDiff = 0;
1555 <      float          coef [SDmaxCh];
1556 <      int            i, j, n, nr;
1557 <      SDComponent          *sdc;
1558 <      const SDCDst   **cdarr = NULL;
1559 <      
1560 <      /* Get diffuse albedo (?) */
1561 <      if (hitFront) {
1562 <         bsdfVal = nd.sd -> rLambFront;
1563 <         rdf = nd.sd -> rf;
1564 <         tdf = nd.sd -> tf ? nd.sd -> tf : nd.sd -> tb;
1565 <      }
1566 <      else {
1527 <         bsdfVal = nd.sd -> rLambBack;
1528 <         rdf = nd.sd -> rb;
1529 <         tdf = nd.sd -> tb ? nd.sd -> tb : nd.sd -> tf;
1530 <      }
1531 <      
1532 <      rhoDiff = bsdfVal.cieY;
1533 <      bsdfVal.cieY += nd.sd -> tLamb.cieY;
1534 <      
1535 <      /* Allocate non-diffuse sampling */
1536 <      i = nr = rdf ? rdf -> ncomp : 0;
1537 <      j = tdf ? tdf -> ncomp : 0;
1538 <      n = i + j;
1539 <      
1540 <      if (n > 0 && !(cdarr = (const SDCDst**)malloc(n * sizeof(SDCDst*))))
1541 <         objerror(mat, USER, transSDError(SDEmemory));
1549 >
1550 >   /* Get scatter probabilities (weighted by pattern except for spec refl)
1551 >    * prDiff, ptDiff:      extra diffuse component in material def
1552 >    * prDiffSD, ptDiffSD:  diffuse (constant) component in SDF
1553 >    * prSpecSD, ptSpecSD:  non-diffuse ("specular") component in SDF
1554 >    * albedo:              sum of above, inverse absorption probability */
1555 >   prDiff   = colorAvg(nd.rdiff);
1556 >   ptDiff   = colorAvg(nd.tdiff);
1557 >   prDiffSD = patAlb * SDdirectHemi(nd.vray, SDsampDf | SDsampR, nd.sd);
1558 >   ptDiffSD = patAlb * SDdirectHemi(nd.vray, SDsampDf | SDsampT, nd.sd);
1559 >   prSpecSD = SDdirectHemi(nd.vray, SDsampSp | SDsampR, nd.sd);
1560 >   ptSpecSD = patAlb * SDdirectHemi(nd.vray, SDsampSp | SDsampT, nd.sd);
1561 >   albedo   = prDiff + ptDiff + prDiffSD + ptDiffSD + prSpecSD + ptSpecSD;
1562 >
1563 >   /*    
1564 >   if (albedo > 1)
1565 >      objerror(mat, WARNING, "Invalid albedo");
1566 >   */
1567          
1568 <      while (j-- > 0) {
1569 <         /* Sum up non-diffuse transmittance */
1570 <         cdarr [i + j] = (*tdf -> comp [j].func -> getCDist)(nd.vray, &tdf -> comp [j]);
1571 <        
1572 <         if (!cdarr [i + j])
1548 <            cdarr [i + j] = &SDemptyCD;
1549 <         else bsdfVal.cieY += cdarr [i + j] -> cTotal;
1550 <      }
1568 >   /* Insert direct and indirect photon hits if diffuse component */
1569 >   if (prDiff + ptDiff + prDiffSD + ptDiffSD > FTINY)
1570 >      addPhotons(rayIn);        
1571 >
1572 >   xi = pmapRandom(rouletteState);
1573        
1574 <      while (i-- > 0) {
1575 <         /* Sum up non-diffuse reflectance */
1576 <         cdarr [i] = (*rdf -> comp [i].func -> getCDist)(nd.vray, &rdf -> comp [i]);
1574 >   if (xi > albedo)
1575 >      /* Absorbtion */
1576 >      return 0;
1577 >  
1578 >   transmitted = 0;
1579 >
1580 >   if ((xi -= prDiff) <= 0) {
1581 >      /* Diffuse reflection (extra component in material def) */
1582 >      photonRay(rayIn, &rayOut, PMAP_DIFFREFL, nd.rdiff);
1583 >      diffPhotonScatter(nd.pnorm, &rayOut);
1584 >   }
1585 >  
1586 >   else if ((xi -= ptDiff) <= 0) {
1587 >      /* Diffuse transmission (extra component in material def) */
1588 >      flipsurface(rayIn);
1589 >      nd.thick = -nd.thick;
1590 >      photonRay(rayIn, &rayOut, PMAP_DIFFTRANS, nd.tdiff);
1591 >      diffPhotonScatter(nd.pnorm, &rayOut);
1592 >      transmitted = 1;
1593 >   }
1594 >  
1595 >   else {   /* Sample SDF */
1596 >      if ((xi -= prDiffSD) <= 0) {
1597 >         /* Diffuse SDF reflection (constant component) */
1598 >         if ((err = SDsampBSDF(&bsdfVal, nd.vray, pmapRandom(scatterState),
1599 >                               SDsampDf | SDsampR, nd.sd)))
1600 >            objerror(mat, USER, transSDError(err));
1601          
1602 <         if (!cdarr [i])
1603 <            cdarr [i] = &SDemptyCD;
1604 <         else bsdfVal.cieY += cdarr [i] -> cTotal;
1602 >         /* Apply pattern to spectral component */
1603 >         ccy2rgb(&bsdfVal.spec, bsdfVal.cieY, bsdfRGB);
1604 >         multcolor(bsdfRGB, rayIn -> pcol);
1605 >         photonRay(rayIn, &rayOut, PMAP_DIFFREFL, bsdfRGB);
1606        }
1560      
1561      if (bsdfVal.cieY <= FTINY) {
1562         /* Don't bother sampling, just absorb photon */
1563         if (cdarr)
1564            free(cdarr);
1565         return 0;
1566      }      
1567      
1568      /* Insert direct and indirect photon hits if diffuse component */
1569      if (rhoDiff > FTINY || nd.sd -> tLamb.cieY > FTINY)
1570         addPhotons(rayIn);    
1571        
1572      xi = pmapRandom(rouletteState);
1573      
1574      if ((xi -= rhoDiff) <= 0) {
1575         /* Diffuse reflection */
1576         photonRay(rayIn, &rayOut, PMAP_DIFFREFL, nd.rdiff);
1577         diffPhotonScatter(nd.pnorm, &rayOut);
1578      }
1579      else if ((xi -= nd.sd -> tLamb.cieY) <= 0) {
1580         /* Diffuse transmission */
1581         flipsurface(rayIn);
1582         photonRay(rayIn, &rayOut, PMAP_DIFFTRANS, nd.tdiff);
1583         bsdfVal.spec = nd.sd -> tLamb.spec;
1584         diffPhotonScatter(nd.pnorm, &rayOut);
1585      }
1586      else {
1587         int rayOutType;
1588         COLOR bsdfRGB;
1589            
1590         /* Non-diffuse CDF inversion (?) */
1591         for (i = 0; i < n && (xi -= cdarr [i] -> cTotal) > 0; i++);
1592        
1593         if (i >= n) {
1594            /* Absorbed -- photon went Deer Hunter */
1595            if (cdarr)
1596               free(cdarr);
1597            return 0;
1598         }
1607  
1608 <         if (i < nr) {
1609 <            /* Non-diffuse reflection */
1610 <            sdc = &rdf -> comp [i];
1611 <            rayOutType = PMAP_SPECREFL;
1612 <         }
1605 <         else {
1606 <            /* Non-diffuse transmission */
1607 <            sdc = &tdf -> comp [i - nr];
1608 <            rayOutType = PMAP_SPECTRANS;
1609 <         }
1608 >      else if ((xi -= ptDiffSD) <= 0) {
1609 >         /* Diffuse SDF transmission (constant component) */
1610 >         if ((err = SDsampBSDF(&bsdfVal, nd.vray, pmapRandom(scatterState),
1611 >                               SDsampDf | SDsampT, nd.sd)))
1612 >            objerror(mat, USER, transSDError(err));
1613          
1614 <         /* Generate non-diff sample dir */
1612 <         VCOPY(rayOut.rdir, nd.vray);
1613 <         err = (*sdc -> func -> sampCDist)
1614 <               (rayOut.rdir, pmapRandom(scatterState), cdarr [i]);              
1615 <         if (err)
1616 <            objerror(mat, USER, transSDError(SDEinternal));
1617 <
1618 <         /* Get colour */
1619 <         j = (*sdc -> func -> getBSDFs)(coef, rayOut.rdir, nd.vray, sdc);
1620 <        
1621 <         if (j <= 0) {
1622 <            sprintf(SDerrorDetail, "BSDF \"%s\" sampling value error",
1623 <                    nd.sd -> name);
1624 <            objerror(mat, USER, transSDError(SDEinternal));
1625 <         }
1626 <        
1627 <         bsdfVal.spec = sdc -> cspec [0];
1628 <         rhoDiff = coef [0];
1629 <        
1630 <         while (--j) {
1631 <            c_cmix(&bsdfVal.spec, rhoDiff, &bsdfVal.spec, coef [j],
1632 <                   &sdc -> cspec [j]);
1633 <            rhoDiff += coef [j];
1634 <         }
1635 <        
1636 <         /* ? */
1637 <         c_ccvt(&bsdfVal.spec, C_CSXY + C_CSSPEC);
1614 >         /* Apply pattern to spectral component */
1615           ccy2rgb(&bsdfVal.spec, bsdfVal.cieY, bsdfRGB);
1616 <        
1617 <         /* Xform outgoing dir to world coords */
1618 <         if ((err = SDmapDir(rayOut.rdir, nd.fromloc, rayOut.rdir))) {
1616 >         multcolor(bsdfRGB, rayIn -> pcol);
1617 >         addcolor(bsdfRGB, nd.tdiff);      
1618 >         flipsurface(rayIn);  /* Necessary? */
1619 >         nd.thick = -nd.thick;
1620 >         photonRay(rayIn, &rayOut, PMAP_DIFFTRANS, bsdfRGB);
1621 >         transmitted = 1;
1622 >      }
1623 >
1624 >      else if ((xi -= prSpecSD) <= 0) {
1625 >         /* Non-diffuse ("specular") SDF reflection */
1626 >         if ((err = SDsampBSDF(&bsdfVal, nd.vray, pmapRandom(scatterState),
1627 >                               SDsampSp | SDsampR, nd.sd)))
1628              objerror(mat, USER, transSDError(err));
1643            return 0;
1644         }
1629          
1630 <         photonRay(rayIn, &rayOut, rayOutType, bsdfRGB);
1630 >         ccy2rgb(&bsdfVal.spec, bsdfVal.cieY, bsdfRGB);
1631 >         photonRay(rayIn, &rayOut, PMAP_SPECREFL, bsdfRGB);
1632        }
1633        
1634 <      if (cdarr)
1635 <         free(cdarr);
1634 >      else {
1635 >         /* Non-diffuse ("specular") SDF transmission */
1636 >         if ((err = SDsampBSDF(&bsdfVal, nd.vray, pmapRandom(scatterState),
1637 >                               SDsampSp | SDsampT, nd.sd)))
1638 >            objerror(mat, USER, transSDError(err));
1639 >
1640 >         /* Apply pattern to spectral component */
1641 >         ccy2rgb(&bsdfVal.spec, bsdfVal.cieY, bsdfRGB);
1642 >         multcolor(bsdfRGB, rayIn -> pcol);
1643 >         flipsurface(rayIn);  /* Necessary? */
1644 >         nd.thick = -nd.thick;
1645 >         photonRay(rayIn, &rayOut, PMAP_SPECTRANS, bsdfRGB);
1646 >         transmitted = 1;
1647 >      }      
1648 >      
1649 >      /* Xform outgoing dir to world coords */
1650 >      if ((err = SDmapDir(rayOut.rdir, nd.fromloc, nd.vray))) {
1651 >         objerror(mat, USER, transSDError(err));
1652 >         return 0;
1653 >      }
1654     }
1655 <                        
1656 <   /* Clean up BSDF */
1655 >      
1656 >   /* Clean up */
1657     SDfreeCache(nd.sd);
1658  
1659 +   /* Need to offset ray origin to get past detail geometry? */
1660 +   if (transmitted && nd.thick != 0)
1661 +      VSUM(rayOut.rorg, rayOut.rorg, rayIn -> ron, -nd.thick);
1662 +
1663     tracePhoton(&rayOut);
1664     return 0;
1665   }
# Line 1660 | Line 1667 | static int bsdfPhotonScatter (OBJREC *mat, RAY *rayIn)
1667  
1668  
1669   static int lightPhotonScatter (OBJREC* mat, RAY* ray)
1670 < /* Light sources doan' reflect */
1670 > /* Light sources doan' reflect, mang */
1671   {
1672     return 0;
1673   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines