ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/pmapamb.c
Revision: 2.3
Committed: Wed May 27 16:23:41 2015 UTC (8 years, 11 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.2: +3 -2 lines
Log Message:
Added back caustic map contributions to ambient

File Contents

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