12 |
|
#include "rtotypes.h" |
13 |
|
#include "source.h" |
14 |
|
#include "random.h" |
15 |
+ |
#include "pmap.h" |
16 |
+ |
#include "pmapsrc.h" |
17 |
|
|
18 |
|
#ifndef MAXSSAMP |
19 |
|
#define MAXSSAMP 16 /* maximum samples per ray */ |
135 |
|
source[ns].sflags |= SSKIP; |
136 |
|
} |
137 |
|
} |
136 |
– |
#if SHADCACHE |
137 |
– |
initobscache(ns); |
138 |
– |
#endif |
138 |
|
foundsource += !(source[ns].sflags & SSKIP); |
139 |
|
} |
140 |
|
if (!foundsource) { |
141 |
|
error(WARNING, "no light sources found"); |
142 |
|
return; |
143 |
|
} |
144 |
< |
markvirtuals(); /* find and add virtual sources */ |
144 |
> |
#if SHADCACHE |
145 |
> |
initobscache(ns); |
146 |
> |
#endif |
147 |
> |
/* PMAP: disable virtual sources */ |
148 |
> |
if (!photonMapping) |
149 |
> |
markvirtuals(); /* find and add virtual sources */ |
150 |
> |
|
151 |
|
/* allocate our contribution arrays */ |
152 |
|
maxcntr = nsources + MAXSPART; /* start with this many */ |
153 |
|
srccnt = (CONTRIB *)malloc(maxcntr*sizeof(CONTRIB)); |
383 |
|
int nhits; |
384 |
|
double prob, ourthresh, hwt; |
385 |
|
RAY sr; |
386 |
+ |
|
387 |
+ |
/* PMAP: Factor in direct photons (primarily for debugging/validation) */ |
388 |
+ |
if (directPhotonMapping) { |
389 |
+ |
(*f)(r -> rcol, p, r -> ron, PI); |
390 |
+ |
multDirectPmap(r); |
391 |
+ |
return; |
392 |
+ |
} |
393 |
+ |
|
394 |
|
/* NOTE: srccnt and cntord global so no recursion */ |
395 |
|
if (nsources <= 0) |
396 |
|
return; /* no sources?! */ |
453 |
|
/* compute number to check */ |
454 |
|
nshadcheck = pow((double)ncnts, shadcert) + .5; |
455 |
|
/* modify threshold */ |
456 |
< |
ourthresh = shadthresh / r->rweight; |
456 |
> |
if (ncnts > MINSHADCNT) |
457 |
> |
ourthresh = shadthresh / r->rweight; |
458 |
> |
else |
459 |
> |
ourthresh = 0; |
460 |
|
/* test for shadows */ |
461 |
|
for (nhits = 0, hwt = 0.0, sn = 0; sn < ncnts; |
462 |
|
hwt += (double)source[scp->sno].nhits / |
542 |
|
SRCINDEX si; |
543 |
|
double t, d; |
544 |
|
double re, ge, be; |
545 |
< |
COLOR cvext; |
545 |
> |
COLOR cvext, pmapInscatter; |
546 |
|
int i, j; |
547 |
|
|
548 |
+ |
/* PMAP: do unconditional inscattering for volume photons ? */ |
549 |
+ |
/* if (!volumePhotonMapping) */ |
550 |
|
if (r->slights == NULL || r->slights[0] == 0 |
551 |
|
|| r->gecc >= 1.-FTINY || r->rot >= FHUGE) |
552 |
|
return; |
553 |
+ |
|
554 |
|
if (ssampdist <= FTINY || (nsamps = r->rot/ssampdist + .5) < 1) |
555 |
|
nsamps = 1; |
556 |
|
#if MAXSSAMP |
605 |
|
} |
606 |
|
/* other factors */ |
607 |
|
d *= si.dom * r->rot / (4.*PI*nsamps); |
608 |
+ |
scalecolor(sr.rcol, d); |
609 |
+ |
|
610 |
+ |
/* PMAP: Add ambient inscattering from volume photons once only */ |
611 |
+ |
if (volumePhotonMapping && i == 1) { |
612 |
+ |
inscatterVolumePmap(&sr, pmapInscatter); |
613 |
+ |
scalecolor(pmapInscatter, r -> rot / nsamps); |
614 |
+ |
addcolor(sr.rcol, pmapInscatter); |
615 |
+ |
} |
616 |
+ |
|
617 |
|
multcolor(sr.rcol, r->cext); |
618 |
|
multcolor(sr.rcol, r->albedo); |
591 |
– |
scalecolor(sr.rcol, d); |
619 |
|
multcolor(sr.rcol, cvext); |
620 |
|
addcolor(r->rcol, sr.rcol); /* add it in */ |
621 |
|
} |