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.23 by rschregle, Wed Jan 20 19:44:15 2021 UTC vs.
Revision 2.24 by rschregle, Mon Feb 22 13:27:49 2021 UTC

# Line 2 | Line 2
2   static const char RCSid[] = "$Id$";
3   #endif
4   /*
5 <   ==================================================================
5 >
6 >   ======================================================================
7     Photon map support routines for scattering by materials.
8  
9     Roland Schregle (roland.schregle@{hslu.ch, gmail.com})
10     (c) Fraunhofer Institute for Solar Energy Systems,
11 +       supported by the German Research Foundation
12 +       (DFG LU-204/10-2, "Fassadenintegrierte Regelsysteme FARESYS")
13     (c) Lucerne University of Applied Sciences and Arts,
14 <   supported by the Swiss National Science Foundation (SNSF, #147053)
15 <   ==================================================================
14 >       supported by the Swiss National Science Foundation
15 >       (SNSF #147053, "Daylight Redirecting Components")
16 >   ======================================================================
17    
18   */
19  
# Line 1711 | Line 1715 | int brdf2PhotonScatter (OBJREC *mat, RAY *rayIn)
1715  
1716  
1717   /*
1718 <   ==================================================================
1718 >   ======================================================================
1719     The following code is
1720     (c) Lucerne University of Applied Sciences and Arts,
1721 <   supported by the Swiss National Science Foundation (SNSF, #147053)
1722 <   ==================================================================
1721 >       supported by the Swiss National Science Foundation
1722 >       (SNSF #147053, "Daylight Redirecting Components")
1723 >   ======================================================================
1724   */
1725  
1726   static int bsdfPhotonScatter (OBJREC *mat, RAY *rayIn)
1727   /* Generate new photon ray for BSDF modifier and recurse. */
1728   {
1729 <   int      hasthick = (mat->otype == MAT_BSDF);
1730 <   int      hitFront;
1731 <   SDError  err;
1732 <   SDValue  bsdfVal;
1733 <   FVECT           upvec;
1734 <   MFUNC           *mf;
1735 <   BSDFDAT      nd;
1736 <   RAY      rayOut;
1737 <   COLOR    bsdfRGB;
1738 <   int      transmitted;
1739 <   double   prDiff, ptDiff, prDiffSD, ptDiffSD, prSpecSD, ptSpecSD,
1740 <            albedo, xi;
1741 <   const double patAlb = bright(rayIn -> pcol);
1729 >   int            hasthick = (mat->otype == MAT_BSDF);
1730 >   int            hitFront;
1731 >   SDError        err;
1732 >   SDValue        bsdfVal;
1733 >   FVECT          upvec;
1734 >   MFUNC          *mf;
1735 >   BSDFDAT        nd;
1736 >   RAY            rayOut;
1737 >   COLOR          bsdfRGB;
1738 >   int            transmitted;
1739 >   double         prDiff, ptDiff, prDiffSD, ptDiffSD, prSpecSD, ptSpecSD,
1740 >                  albedo, xi;
1741 >   const double   patAlb = bright(rayIn -> pcol);
1742    
1743     /* Following code adapted from m_bsdf() */
1744     /* Check arguments */
1745 <   if (mat -> oargs.nsargs < hasthick+5 || mat -> oargs.nfargs > 9 ||
1746 <       mat -> oargs.nfargs % 3)
1745 >   if (
1746 >      mat -> oargs.nsargs < hasthick+5 ||
1747 >      mat -> oargs.nfargs > 9 || mat -> oargs.nfargs % 3
1748 >   )
1749        objerror(mat, USER, "bad # arguments");
1750        
1751     hitFront = (rayIn -> rod > 0);
# Line 1749 | Line 1756 | static int bsdfPhotonScatter (OBJREC *mat, RAY *rayIn)
1756     /* Get thickness */
1757     nd.thick = 0;
1758     if (hasthick) {
1759 <   nd.thick = evalue(mf -> ep [0]);
1760 <   if ((-FTINY <= nd.thick) & (nd.thick <= FTINY))
1761 <      nd.thick = .0;
1759 >      nd.thick = evalue(mf -> ep [0]);
1760 >      if ((-FTINY <= nd.thick) & (nd.thick <= FTINY))
1761 >         nd.thick = .0;
1762     }
1763  
1764     /* Get BSDF data */
# Line 1761 | Line 1768 | static int bsdfPhotonScatter (OBJREC *mat, RAY *rayIn)
1768     if (hitFront) {
1769        if (mat -> oargs.nfargs < 3)
1770           setcolor(nd.rdiff, .0, .0, .0);
1771 <      else setcolor(nd.rdiff, mat -> oargs.farg [0], mat -> oargs.farg [1],
1772 <                    mat -> oargs.farg [2]);
1771 >      else setcolor(
1772 >         nd.rdiff,
1773 >         mat -> oargs.farg [0], mat -> oargs.farg [1], mat -> oargs.farg [2]
1774 >      );
1775     }    
1776     else if (mat -> oargs.nfargs < 6) {
1777        /* Check for absorbing backside */
# Line 1773 | Line 1782 | static int bsdfPhotonScatter (OBJREC *mat, RAY *rayIn)
1782        
1783        setcolor(nd.rdiff, .0, .0, .0);
1784     }
1785 <   else setcolor(nd.rdiff, mat -> oargs.farg [3], mat -> oargs.farg [4],
1786 <                 mat -> oargs.farg [5]);
1785 >   else setcolor(
1786 >      nd.rdiff,
1787 >      mat -> oargs.farg [3], mat -> oargs.farg [4], mat -> oargs.farg [5]
1788 >   );
1789  
1790     /* Extra diffuse transmittance from material def */
1791     if (mat -> oargs.nfargs < 9)
1792        setcolor(nd.tdiff, .0, .0, .0);
1793 <   else setcolor(nd.tdiff, mat -> oargs.farg [6], mat -> oargs.farg [7],
1794 <                 mat -> oargs.farg [8]);
1793 >   else setcolor(
1794 >      nd.tdiff,
1795 >      mat -> oargs.farg [6], mat -> oargs.farg [7], mat -> oargs.farg [8]
1796 >   );
1797                
1798     nd.mp = mat;
1799     nd.pr = rayIn;
# Line 1829 | Line 1842 | static int bsdfPhotonScatter (OBJREC *mat, RAY *rayIn)
1842     }
1843    
1844     /* Determine BSDF resolution */
1845 <   err = SDsizeBSDF(nd.sr_vpsa, nd.vray, NULL,
1846 <                    SDqueryMin + SDqueryMax, nd.sd);
1845 >   err = SDsizeBSDF(
1846 >      nd.sr_vpsa, nd.vray, NULL, SDqueryMin + SDqueryMax, nd.sd
1847 >   );
1848    
1849     if (err)
1850        objerror(mat, USER, transSDError(err));
# Line 1891 | Line 1905 | static int bsdfPhotonScatter (OBJREC *mat, RAY *rayIn)
1905     else {   /* Sample SDF */
1906        if ((xi -= prDiffSD) <= 0) {
1907           /* Diffuse SDF reflection (constant component) */
1908 <         if ((err = SDsampBSDF(&bsdfVal, nd.vray, pmapRandom(scatterState),
1909 <                               SDsampDf | SDsampR, nd.sd)))
1908 >         if ((err = SDsampBSDF(
1909 >            &bsdfVal, nd.vray, pmapRandom(scatterState),
1910 >            SDsampDf | SDsampR, nd.sd
1911 >         )))
1912              objerror(mat, USER, transSDError(err));
1913          
1914           /* Apply pattern to spectral component */
# Line 1903 | Line 1919 | static int bsdfPhotonScatter (OBJREC *mat, RAY *rayIn)
1919  
1920        else if ((xi -= ptDiffSD) <= 0) {
1921           /* Diffuse SDF transmission (constant component) */
1922 <         if ((err = SDsampBSDF(&bsdfVal, nd.vray, pmapRandom(scatterState),
1923 <                               SDsampDf | SDsampT, nd.sd)))
1922 >         if ((err = SDsampBSDF(
1923 >            &bsdfVal, nd.vray, pmapRandom(scatterState),
1924 >            SDsampDf | SDsampT, nd.sd
1925 >         )))
1926              objerror(mat, USER, transSDError(err));
1927          
1928           /* Apply pattern to spectral component */
# Line 1917 | Line 1935 | static int bsdfPhotonScatter (OBJREC *mat, RAY *rayIn)
1935  
1936        else if ((xi -= prSpecSD) <= 0) {
1937           /* Non-diffuse ("specular") SDF reflection */
1938 <         if ((err = SDsampBSDF(&bsdfVal, nd.vray, pmapRandom(scatterState),
1939 <                               SDsampSp | SDsampR, nd.sd)))
1938 >         if ((err = SDsampBSDF(
1939 >            &bsdfVal, nd.vray, pmapRandom(scatterState),
1940 >            SDsampSp | SDsampR, nd.sd
1941 >         )))
1942              objerror(mat, USER, transSDError(err));
1943          
1944           ccy2rgb(&bsdfVal.spec, bsdfVal.cieY, bsdfRGB);
# Line 1927 | Line 1947 | static int bsdfPhotonScatter (OBJREC *mat, RAY *rayIn)
1947        
1948        else {
1949           /* Non-diffuse ("specular") SDF transmission */
1950 <         if ((err = SDsampBSDF(&bsdfVal, nd.vray, pmapRandom(scatterState),
1951 <                               SDsampSp | SDsampT, nd.sd)))
1950 >         if ((err = SDsampBSDF(
1951 >            &bsdfVal, nd.vray, pmapRandom(scatterState),
1952 >            SDsampSp | SDsampT, nd.sd
1953 >         )))
1954              objerror(mat, USER, transSDError(err));
1955  
1956           /* Apply pattern to spectral component */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines