ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/pmapamb.c
Revision: 2.7
Committed: Tue Sep 1 16:27:52 2015 UTC (8 years, 9 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R0
Changes since 2.6: +1 -2 lines
Log Message:
Removed redundant $Id: in file

File Contents

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