ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/pmaprand.h
Revision: 2.8
Committed: Mon Aug 14 21:12:10 2017 UTC (6 years, 9 months ago) by rschregle
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R4, rad5R2, rad5R3, rad5R1, HEAD
Changes since 2.7: +26 -19 lines
Log Message:
Updated photon map code for Windows; no multproc or ooC for now

File Contents

# User Rev Content
1 rschregle 2.8 /* RCSid $Id: pmaprand.h,v 2.7 2016/05/17 17:39:47 rschregle Exp $ */
2 greg 2.1
3     /*
4 rschregle 2.8 ======================================================================
5 greg 2.1 Random number generators for photon distribution
6    
7     Roland Schregle (roland.schregle@{hslu.ch, gmail.com})
8     (c) Fraunhofer Institute for Solar Energy Systems,
9 rschregle 2.3 (c) Lucerne University of Applied Sciences and Arts,
10 rschregle 2.8 supported by the Swiss National Science Foundation (SNSF, #147053)
11     ======================================================================
12 greg 2.1
13 rschregle 2.8 $Id: pmaprand.h,v 2.7 2016/05/17 17:39:47 rschregle Exp $
14 greg 2.1 */
15    
16    
17    
18 rschregle 2.7 #ifndef PMAPRAND_H
19     #define PMAPRAND_H
20    
21 rschregle 2.8 /* According to the analytical validation, skipping sequential samples
22     * when sharing a single RNG among multiple sampling domains introduces
23     * overlapping photon rays (reported as 'duplicate keys' when building
24     * the underlying data structure) and therefore bias. This is aggravated
25     * when running parallel photon distribution subprocesses, where photon
26     * rays from different subprocesses may correlate.
27     * We therefore maintain a separate RNG state for each sampling domain
28     * (e.g. photon emission, scattering, and russian roulette). With
29     * multiprocessing, each subprocess has its own instance of the RNG
30     * state, which is independently seeded for decorellation -- see
31     * distribPhotons() and distribPhotonContrib().
32     * The pmapSeed() and pmapRandom() macros below can be adapted to
33     * platform-specific RNGs if necessary. */
34     #if defined(_WIN32) || defined(_WIN64)
35     /* Use standard RNG without state management; the generated sequences
36     * will be suboptimal */
37     #include "random.h"
38     #define pmapSeed(seed, state) srandom(seed)
39     #define pmapRandom(state) frandom()
40 greg 2.2 #else
41 rschregle 2.8 /* Assume NIX and manage RNG state via erand48() */
42 greg 2.2 #define pmapSeed(seed, state) (state [0] += seed, state [1] += seed, \
43     state [2] += seed)
44 rschregle 2.8 #define pmapRandom(state) erand48(state)
45 greg 2.2 #endif
46 greg 2.1
47 rschregle 2.7
48     extern unsigned short partState [3], emitState [3], cntState [3],
49     mediumState [3], scatterState [3], rouletteState [3],
50     randSeed;
51 greg 2.1 #endif
52 greg 2.2