19 |
|
#include "otypes.h" |
20 |
|
#include "source.h" |
21 |
|
#include "rcontrib.h" |
22 |
+ |
#include "random.h" |
23 |
|
|
24 |
|
|
25 |
|
|
230 |
|
} |
231 |
|
|
232 |
|
/* Reject photon if normal faces away (ignored for volume photons) */ |
233 |
< |
if (norm && DOT(norm, p -> norm) <= 0) |
233 |
> |
if (norm && DOT(norm, p -> norm) <= 0.5 * frandom()) |
234 |
|
return; |
235 |
|
|
236 |
|
if (isContribPmap(pmap) && pmap -> srcContrib) { |
241 |
|
if (srcIdx < 0 || srcIdx >= nsources) |
242 |
|
error(INTERNAL, "invalid light source index in photon map"); |
243 |
|
|
244 |
< |
srcMod = objptr(source [srcIdx].so -> omod); |
244 |
> |
srcMod = findmaterial(source [srcIdx].so); |
245 |
|
|
246 |
|
/* Reject photon if contributions from light source which emitted it |
247 |
|
* are not sought */ |
456 |
|
dv [2] = pos [2] - p -> pos [2]; |
457 |
|
d2 = DOT(dv, dv); |
458 |
|
|
459 |
< |
if (d2 < pmap -> maxDist && DOT(norm, p -> norm) > 0) { |
459 |
> |
if (d2 < pmap -> maxDist && DOT(norm, p -> norm) > 0.5 * frandom()) { |
460 |
|
/* Closest photon so far with similar normal */ |
461 |
|
pmap -> maxDist = d2; |
462 |
|
*photon = p; |