1 |
+ |
#ifndef lint |
2 |
+ |
static const char RCSid[] = "$Id$"; |
3 |
+ |
#endif |
4 |
|
/* |
5 |
|
================================================================== |
6 |
|
Photon map support routines for emission from light sources |
10 |
|
(c) Lucerne University of Applied Sciences and Arts, |
11 |
|
supported by the Swiss National Science Foundation (SNSF, #147053) |
12 |
|
================================================================== |
13 |
< |
|
11 |
< |
$Id$ |
13 |
> |
|
14 |
|
*/ |
15 |
|
|
16 |
|
|
534 |
|
for (i = 0; i < nobjects; i++) { |
535 |
|
obj = objptr(i); |
536 |
|
|
537 |
< |
if (inset(ambset, obj -> omod)) { |
537 |
> |
/* Check if object is a surface and NOT a light source (duh) and |
538 |
> |
* resolve its material via any aliases, then check for inclusion in |
539 |
> |
* port modifier list */ |
540 |
> |
if (issurface(obj -> otype) && !islight(obj -> otype) && |
541 |
> |
inset(ambset, objndx(findmaterial(obj)))) { |
542 |
|
/* Add photon port */ |
543 |
|
photonPorts = (SRCREC*)realloc(photonPorts, |
544 |
|
(numPhotonPorts + 1) * |
598 |
|
unsigned i, t, p; |
599 |
|
double phi, cosTheta, sinTheta, du, dv, dOmega, thetaScale; |
600 |
|
EmissionSample* sample; |
601 |
< |
const OBJREC* mod = objptr(emap -> src -> so -> omod); |
601 |
> |
const OBJREC* mod = findmaterial(emap -> src -> so); |
602 |
|
static RAY r; |
603 |
|
#if 0 |
604 |
|
static double lastCosNorm = FHUGE; |
605 |
|
static SRCREC *lastSrc = NULL, *lastPort = NULL; |
606 |
|
#endif |
607 |
|
|
608 |
+ |
setcolor(emap -> partFlux, 0, 0, 0); |
609 |
+ |
|
610 |
|
photonOrigin [emap -> src -> so -> otype] (emap); |
611 |
|
cosTheta = DOT(emap -> ws, emap -> wh); |
612 |
|
|
629 |
|
#endif |
630 |
|
|
631 |
|
/* Need to recompute flux & PDF */ |
624 |
– |
setcolor(emap -> partFlux, 0, 0, 0); |
632 |
|
emap -> cdf = 0; |
633 |
|
emap -> numSamples = 0; |
634 |
|
|
677 |
|
|
678 |
|
VCOPY(r.rorg, emap -> photonOrg); |
679 |
|
VCOPY(r.rop, emap -> photonOrg); |
680 |
< |
r.rmax = FHUGE; |
680 |
> |
r.rmax = 0; |
681 |
|
|
682 |
|
for (t = 0; t < emap -> numTheta; t++) { |
683 |
|
for (p = 0; p < emap -> numPhi; p++) { |
747 |
|
unsigned long i, lo, hi; |
748 |
|
const EmissionSample* sample = emap -> samples; |
749 |
|
RREAL du, dv, cosTheta, cosThetaSqr, sinTheta, phi; |
750 |
< |
const OBJREC* mod = objptr(emap -> src -> so -> omod); |
750 |
> |
const OBJREC* mod = findmaterial(emap -> src -> so); |
751 |
|
|
752 |
|
/* Choose a new origin within current partition for every |
753 |
|
emitted photon to break up clustering artifacts */ |
754 |
|
photonOrigin [emap -> src -> so -> otype] ((EmissionMap*)emap); |
755 |
+ |
/* If we have a local glow source with a maximum radius, then |
756 |
+ |
restrict our photon to the specified distance (otherwise no limit) */ |
757 |
+ |
if (mod -> otype == MAT_GLOW && !(emap -> src -> sflags & SDISTANT) |
758 |
+ |
&& mod -> oargs.farg[3] > FTINY) |
759 |
+ |
ray -> rmax = mod -> oargs.farg[3]; |
760 |
+ |
else |
761 |
+ |
ray -> rmax = 0; |
762 |
|
rayorigin(ray, PRIMARY, NULL, NULL); |
749 |
– |
ray -> rmax = FHUGE; |
763 |
|
|
764 |
|
if (!emap -> numSamples) { |
765 |
|
/* Source is unmodified and has no port, and either local with |