ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/pmapamb.c
Revision: 2.8
Committed: Tue May 17 17:39:47 2016 UTC (7 years, 11 months ago) by rschregle
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R4, rad5R2, rad5R3, rad5R1, HEAD
Changes since 2.7: +4 -2 lines
Log Message:
Initial import of ooC photon map

File Contents

# User Rev Content
1 greg 2.6 #ifndef lint
2 greg 2.7 static const char RCSid[] = "$Id: pmapamb.c,v 2.6 2015/08/18 18:45:55 greg Exp $";
3 greg 2.6 #endif
4 rschregle 2.8
5 greg 2.1 /*
6     ==================================================================
7     Photon map interface to RADIANCE ambient calculation
8    
9     Roland Schregle (roland.schregle@{hslu.ch, gmail.com})
10     (c) Fraunhofer Institute for Solar Energy Systems,
11 rschregle 2.2 (c) Lucerne University of Applied Sciences and Arts,
12     supported by the Swiss National Science Foundation (SNSF, #147053)
13 greg 2.1 ==================================================================
14    
15 rschregle 2.8 $Id: pmapamb.c,v 1.8 2015/08/10 14:10:16 taschreg Exp taschreg $
16 greg 2.1 */
17    
18    
19     #include "pmapamb.h"
20     #include "pmap.h"
21    
22    
23     int ambPmap (COLOR aval, RAY *r, int rdepth)
24     /* Factor irradiance from photon map into ambient coefficient aval;
25     * return 1 on success, else 0 (with aval unmodified) */
26     {
27     COLOR rcoef, photonIrrad;
28     /* Handle precedence in case of multiple photon maps:
29     * contrib > precomp > global */
30     PhotonMap *pmap = contribPhotonMapping ? contribPmap
31     : preCompPmap ? preCompPmap
32     : globalPmap;
33 rschregle 2.8
34 greg 2.1 /* Get photon irradiance either via 1 ambient bounce (final
35     * gather) if ambounce > 0, or directly if ambounce < 0. */
36     if (pmap && (rdepth || ambounce < 0)) {
37     /* Temporarily factor ambient value into ray coefficient
38     * (required for contribution photon map) */
39     copycolor(rcoef, r -> rcoef);
40     multcolor(r -> rcoef, aval);
41    
42     /* Get photon irradiance via callback */
43     pmap -> lookupFlags = 0;
44     (pmap -> lookup)(pmap, r, photonIrrad);
45    
46     /* Factor irradiance into ambient value and restore ray coeficient */
47     multcolor(aval, photonIrrad);
48     copycolor(r -> rcoef, rcoef);
49    
50     return 1;
51     }
52    
53     return 0;
54     }
55    
56    
57     int ambPmapCaustic (COLOR aval, RAY *r, int rdepth)
58     /* Factor specular-diffuse (caustic) irradiance from photon map into ambient
59     * coeff aval; return 1 if successful, else 0 (with aval set to zero) */
60     {
61     COLOR rcoef, photonIrrad;
62     /* Handle precedence in case of multiple photon maps: contrib > caustic */
63     PhotonMap *pmap = contribPhotonMapping ? contribPmap : causticPmap;
64    
65 greg 2.4 /* Get caustic photon density estimate at primary rays or when
66     * filling in ambient rays that have no global photon map to use */
67     if (pmap && (!rdepth || !globalPmap & !contribPmap & !preCompPmap)) {
68 greg 2.1 /* Temporarily factor ambient value into ray coefficient
69     * (required for contribution photon map) */
70     copycolor(rcoef, r -> rcoef);
71     multcolor(r -> rcoef, aval);
72    
73     /* Set caustic flag and get photon irradiance via callback */
74 rschregle 2.8 pmap -> lookupCaustic = 1;
75 greg 2.1 (pmap -> lookup)(pmap, r, photonIrrad);
76    
77     /* Factor irradiance into ambient value and restore ray coeficient */
78     multcolor(aval, photonIrrad);
79     copycolor(r -> rcoef, rcoef);
80    
81     return 1;
82     }
83    
84     setcolor(aval, 0, 0, 0);
85    
86     return 0;
87     }