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