| 12 |
|
#include "rtotypes.h" |
| 13 |
|
#include "source.h" |
| 14 |
|
#include "random.h" |
| 15 |
+ |
#include "pmapsrc.h" |
| 16 |
+ |
#include "pmapmat.h" |
| 17 |
|
|
| 16 |
– |
extern double ssampdist; /* scatter sampling distance */ |
| 17 |
– |
|
| 18 |
|
#ifndef MAXSSAMP |
| 19 |
|
#define MAXSSAMP 16 /* maximum samples per ray */ |
| 20 |
|
#endif |
| 42 |
|
static int cntcmp(const void *p1, const void *p2); |
| 43 |
|
|
| 44 |
|
|
| 45 |
< |
extern OBJREC * /* find an object's actual material */ |
| 46 |
< |
findmaterial(register OBJREC *o) |
| 45 |
> |
OBJREC * /* find an object's actual material */ |
| 46 |
> |
findmaterial(OBJREC *o) |
| 47 |
|
{ |
| 48 |
|
while (!ismaterial(o->otype)) { |
| 49 |
|
if (o->otype == MOD_ALIAS && o->oargs.nsargs) { |
| 55 |
|
ao = objptr(aobj); |
| 56 |
|
if (ismaterial(ao->otype)) |
| 57 |
|
return(ao); |
| 58 |
+ |
if (ao->otype == MOD_ALIAS) { |
| 59 |
+ |
o = ao; |
| 60 |
+ |
continue; |
| 61 |
+ |
} |
| 62 |
|
} |
| 63 |
|
if (o->omod == OVOID) |
| 64 |
|
return(NULL); |
| 68 |
|
} |
| 69 |
|
|
| 70 |
|
|
| 71 |
< |
extern void |
| 71 |
> |
void |
| 72 |
|
marksources(void) /* find and mark source objects */ |
| 73 |
|
{ |
| 74 |
|
int foundsource = 0; |
| 75 |
|
int i; |
| 76 |
< |
register OBJREC *o, *m; |
| 77 |
< |
register int ns; |
| 76 |
> |
OBJREC *o, *m; |
| 77 |
> |
int ns; |
| 78 |
|
/* initialize dispatch table */ |
| 79 |
|
initstypes(); |
| 80 |
|
/* find direct sources */ |
| 86 |
|
continue; |
| 87 |
|
/* find material */ |
| 88 |
|
m = findmaterial(objptr(o->omod)); |
| 89 |
< |
if (m == NULL || !islight(m->otype)) |
| 89 |
> |
if (m == NULL) |
| 90 |
> |
continue; |
| 91 |
> |
if (m->otype == MAT_CLIP) { |
| 92 |
> |
markclip(m); /* special case for antimatter */ |
| 93 |
> |
continue; |
| 94 |
> |
} |
| 95 |
> |
if (!islight(m->otype)) |
| 96 |
|
continue; /* not source modifier */ |
| 97 |
|
|
| 98 |
|
if (m->oargs.nfargs != (m->otype == MAT_GLOW ? 4 : |
| 99 |
|
m->otype == MAT_SPOT ? 7 : 3)) |
| 100 |
|
objerror(m, USER, "bad # arguments"); |
| 101 |
|
|
| 92 |
– |
if (m->otype == MAT_GLOW && |
| 93 |
– |
o->otype != OBJ_SOURCE && |
| 94 |
– |
m->oargs.farg[3] <= FTINY) |
| 95 |
– |
continue; /* don't bother */ |
| 102 |
|
if (m->oargs.farg[0] <= FTINY && m->oargs.farg[1] <= FTINY && |
| 103 |
|
m->oargs.farg[2] <= FTINY) |
| 104 |
|
continue; /* don't bother */ |
| 105 |
< |
|
| 105 |
> |
if (m->otype == MAT_GLOW && |
| 106 |
> |
o->otype != OBJ_SOURCE && |
| 107 |
> |
m->oargs.farg[3] <= FTINY) { |
| 108 |
> |
foundsource += (ambounce > 0); |
| 109 |
> |
continue; /* don't track these */ |
| 110 |
> |
} |
| 111 |
|
if (sfun[o->otype].of == NULL || |
| 112 |
|
sfun[o->otype].of->setsrc == NULL) |
| 113 |
|
objerror(o, USER, "illegal material"); |
| 120 |
|
if (m->otype == MAT_GLOW) { |
| 121 |
|
source[ns].sflags |= SPROX; |
| 122 |
|
source[ns].sl.prox = m->oargs.farg[3]; |
| 123 |
< |
if (source[ns].sflags & SDISTANT) |
| 123 |
> |
if (source[ns].sflags & SDISTANT) { |
| 124 |
|
source[ns].sflags |= SSKIP; |
| 125 |
+ |
foundsource += (ambounce > 0); |
| 126 |
+ |
} |
| 127 |
|
} else if (m->otype == MAT_SPOT) { |
| 128 |
|
source[ns].sflags |= SSPOT; |
| 129 |
|
if ((source[ns].sl.s = makespot(m)) == NULL) |
| 135 |
|
source[ns].sflags |= SSKIP; |
| 136 |
|
} |
| 137 |
|
} |
| 138 |
< |
#if SHADCACHE |
| 126 |
< |
initobscache(ns); |
| 127 |
< |
#endif |
| 128 |
< |
if (!(source[ns].sflags & SSKIP)) |
| 129 |
< |
foundsource++; |
| 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 |
> |
for (ns = 0; ns < nsources; ns++) /* initialize obstructor cache */ |
| 146 |
> |
initobscache(ns); |
| 147 |
> |
#endif |
| 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)); |
| 161 |
|
} |
| 162 |
|
|
| 163 |
|
|
| 164 |
< |
extern void |
| 164 |
> |
void |
| 165 |
|
freesources(void) /* free all source structures */ |
| 166 |
|
{ |
| 167 |
|
if (nsources > 0) { |
| 173 |
|
source = NULL; |
| 174 |
|
nsources = 0; |
| 175 |
|
} |
| 176 |
+ |
markclip(NULL); |
| 177 |
|
if (maxcntr <= 0) |
| 178 |
|
return; |
| 179 |
|
free((void *)srccnt); |
| 184 |
|
} |
| 185 |
|
|
| 186 |
|
|
| 187 |
< |
extern int |
| 187 |
> |
int |
| 188 |
|
srcray( /* send a ray to a source, return domega */ |
| 189 |
< |
register RAY *sr, /* returned source ray */ |
| 189 |
> |
RAY *sr, /* returned source ray */ |
| 190 |
|
RAY *r, /* ray which hit object */ |
| 191 |
|
SRCINDEX *si /* source sample index */ |
| 192 |
|
) |
| 193 |
|
{ |
| 194 |
< |
double d; /* distance to source */ |
| 195 |
< |
register SRCREC *srcp; |
| 194 |
> |
double d; /* distance to source */ |
| 195 |
> |
SRCREC *srcp; |
| 196 |
|
|
| 197 |
< |
rayorigin(sr, SHADOW, r, NULL); /* ignore limits */ |
| 197 |
> |
rayorigin(sr, SHADOW, r, NULL); /* ignore limits */ |
| 198 |
|
|
| 199 |
< |
while ((d = nextssamp(sr, si)) != 0.0) { |
| 200 |
< |
sr->rsrc = si->sn; /* remember source */ |
| 201 |
< |
srcp = source + si->sn; |
| 202 |
< |
if (srcp->sflags & SDISTANT) { |
| 203 |
< |
if (srcp->sflags & SSPOT && spotout(sr, srcp->sl.s)) |
| 204 |
< |
continue; |
| 205 |
< |
return(1); /* sample OK */ |
| 206 |
< |
} |
| 199 |
> |
if (r == NULL) |
| 200 |
> |
sr->rmax = 0.0; |
| 201 |
> |
|
| 202 |
> |
while ((d = nextssamp(sr, si)) != 0.0) { |
| 203 |
> |
sr->rsrc = si->sn; /* remember source */ |
| 204 |
> |
srcp = source + si->sn; |
| 205 |
> |
if (srcp->sflags & SDISTANT) { |
| 206 |
> |
if (srcp->sflags & SSPOT && spotout(sr, srcp->sl.s)) |
| 207 |
> |
continue; |
| 208 |
> |
return(1); /* sample OK */ |
| 209 |
> |
} |
| 210 |
|
/* local source */ |
| 211 |
|
/* check proximity */ |
| 212 |
< |
if (srcp->sflags & SPROX && d > srcp->sl.prox) |
| 193 |
< |
continue; |
| 194 |
< |
/* check angle */ |
| 195 |
< |
if (srcp->sflags & SSPOT) { |
| 196 |
< |
if (spotout(sr, srcp->sl.s)) |
| 212 |
> |
if (srcp->sflags & SPROX && d > srcp->sl.prox) |
| 213 |
|
continue; |
| 214 |
+ |
/* check angle */ |
| 215 |
+ |
if (srcp->sflags & SSPOT) { |
| 216 |
+ |
if (spotout(sr, srcp->sl.s)) |
| 217 |
+ |
continue; |
| 218 |
|
/* adjust solid angle */ |
| 219 |
< |
si->dom *= d*d; |
| 220 |
< |
d += srcp->sl.s->flen; |
| 221 |
< |
si->dom /= d*d; |
| 219 |
> |
si->dom *= d*d; |
| 220 |
> |
d += srcp->sl.s->flen; |
| 221 |
> |
si->dom /= d*d; |
| 222 |
> |
} |
| 223 |
> |
return(1); /* sample OK */ |
| 224 |
|
} |
| 225 |
< |
return(1); /* sample OK */ |
| 204 |
< |
} |
| 205 |
< |
return(0); /* no more samples */ |
| 225 |
> |
return(0); /* no more samples */ |
| 226 |
|
} |
| 227 |
|
|
| 228 |
|
|
| 229 |
< |
extern void |
| 229 |
> |
void |
| 230 |
|
srcvalue( /* punch ray to source and compute value */ |
| 231 |
< |
register RAY *r |
| 231 |
> |
RAY *r |
| 232 |
|
) |
| 233 |
|
{ |
| 234 |
< |
register SRCREC *sp; |
| 234 |
> |
SRCREC *sp; |
| 235 |
|
|
| 236 |
|
sp = &source[r->rsrc]; |
| 237 |
|
if (sp->sflags & SVIRTUAL) { /* virtual source */ |
| 283 |
|
} |
| 284 |
|
|
| 285 |
|
|
| 286 |
< |
extern int |
| 286 |
> |
int |
| 287 |
|
sourcehit( /* check to see if ray hit distant source */ |
| 288 |
< |
register RAY *r |
| 288 |
> |
RAY *r |
| 289 |
|
) |
| 290 |
|
{ |
| 291 |
|
int glowsrc = -1; |
| 292 |
|
int transrc = -1; |
| 293 |
|
int first, last; |
| 294 |
< |
register int i; |
| 294 |
> |
int i; |
| 295 |
|
|
| 296 |
|
if (r->rsrc >= 0) { /* check only one if aimed */ |
| 297 |
|
first = last = r->rsrc; |
| 316 |
|
* If it's a glow or transparent illum, just remember it. |
| 317 |
|
*/ |
| 318 |
|
if (source[i].sflags & SSKIP) { |
| 319 |
< |
glowsrc = i; |
| 319 |
> |
if (glowsrc < 0) |
| 320 |
> |
glowsrc = i; |
| 321 |
|
continue; |
| 322 |
|
} |
| 323 |
|
if (transillum(source[i].so->omod)) { |
| 324 |
< |
transrc = i; |
| 324 |
> |
if (transrc < 0) |
| 325 |
> |
transrc = i; |
| 326 |
|
continue; |
| 327 |
|
} |
| 328 |
|
r->ro = source[i].so; /* otherwise, use first hit */ |
| 359 |
|
const void *p2 |
| 360 |
|
) |
| 361 |
|
{ |
| 362 |
< |
register const CNTPTR *sc1 = (const CNTPTR *)p1; |
| 363 |
< |
register const CNTPTR *sc2 = (const CNTPTR *)p2; |
| 362 |
> |
const CNTPTR *sc1 = (const CNTPTR *)p1; |
| 363 |
> |
const CNTPTR *sc2 = (const CNTPTR *)p2; |
| 364 |
|
|
| 365 |
|
if (sc1->brt > sc2->brt) |
| 366 |
|
return(-1); |
| 370 |
|
} |
| 371 |
|
|
| 372 |
|
|
| 373 |
< |
extern void |
| 373 |
> |
void |
| 374 |
|
direct( /* add direct component */ |
| 375 |
|
RAY *r, /* ray that hit surface */ |
| 376 |
|
srcdirf_t *f, /* direct component coefficient function */ |
| 377 |
|
void *p /* data for f */ |
| 378 |
|
) |
| 379 |
|
{ |
| 380 |
< |
register int sn; |
| 381 |
< |
register CONTRIB *scp; |
| 380 |
> |
int sn; |
| 381 |
> |
CONTRIB *scp; |
| 382 |
|
SRCINDEX si; |
| 383 |
|
int nshadcheck, ncnts; |
| 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?! */ |
| 412 |
|
scp->sno = sr.rsrc; |
| 413 |
|
/* compute coefficient */ |
| 414 |
|
(*f)(scp->coef, p, sr.rdir, si.dom); |
| 415 |
< |
cntord[sn].brt = bright(scp->coef); |
| 415 |
> |
cntord[sn].brt = intens(scp->coef); |
| 416 |
|
if (cntord[sn].brt <= 0.0) |
| 417 |
|
continue; |
| 418 |
|
#if SHADCACHE |
| 429 |
|
rayvalue(&sr); |
| 430 |
|
multcolor(sr.rcol, sr.rcoef); |
| 431 |
|
copycolor(scp->val, sr.rcol); |
| 432 |
< |
cntord[sn].brt = bright(scp->val); |
| 432 |
> |
cntord[sn].brt = bright(sr.rcol); |
| 433 |
|
} |
| 434 |
|
/* sort contributions */ |
| 435 |
|
qsort(cntord, sn, sizeof(CNTPTR), cntcmp); |
| 436 |
|
{ /* find last */ |
| 437 |
< |
register int l, m; |
| 437 |
> |
int l, m; |
| 438 |
|
|
| 439 |
|
ncnts = l = sn; |
| 440 |
|
sn = 0; |
| 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 / |
| 470 |
|
break; |
| 471 |
|
scp = srccnt + cntord[sn].sndx; |
| 472 |
|
/* test for hit */ |
| 473 |
< |
rayorigin(&sr, SHADOW, r, scp->coef); |
| 473 |
> |
rayorigin(&sr, SHADOW, r, NULL); |
| 474 |
> |
copycolor(sr.rcoef, scp->coef); |
| 475 |
|
VCOPY(sr.rdir, scp->dir); |
| 476 |
|
sr.rsrc = scp->sno; |
| 477 |
|
/* keep statistics */ |
| 486 |
|
raycont(&sr); |
| 487 |
|
if (trace != NULL) |
| 488 |
|
(*trace)(&sr); /* trace execution */ |
| 455 |
– |
rayparticipate(&sr); |
| 489 |
|
if (bright(sr.rcol) <= FTINY) { |
| 490 |
|
#if SHADCACHE |
| 491 |
|
if ((scp <= srccnt || scp[-1].sno != scp->sno) |
| 495 |
|
#endif |
| 496 |
|
continue; /* missed! */ |
| 497 |
|
} |
| 498 |
+ |
rayparticipate(&sr); |
| 499 |
|
multcolor(sr.rcol, sr.rcoef); |
| 500 |
|
copycolor(scp->val, sr.rcol); |
| 501 |
|
} else if (trace != NULL && |
| 532 |
|
} |
| 533 |
|
|
| 534 |
|
|
| 535 |
< |
extern void |
| 535 |
> |
void |
| 536 |
|
srcscatter( /* compute source scattering into ray */ |
| 537 |
< |
register RAY *r |
| 537 |
> |
RAY *r |
| 538 |
|
) |
| 539 |
|
{ |
| 540 |
|
int oldsampndx; |
| 546 |
|
COLOR cvext; |
| 547 |
|
int i, j; |
| 548 |
|
|
| 549 |
< |
if (r->slights == NULL || r->slights[0] == 0 |
| 550 |
< |
|| r->gecc >= 1.-FTINY || r->rot >= FHUGE) |
| 549 |
> |
if (r->rot >= FHUGE || r->gecc >= 1.-FTINY) |
| 550 |
> |
return; /* this can never work */ |
| 551 |
> |
/* PMAP: do unconditional inscattering for volume photons */ |
| 552 |
> |
if (!volumePhotonMapping && (r->slights == NULL || r->slights[0] == 0)) |
| 553 |
|
return; |
| 554 |
+ |
|
| 555 |
|
if (ssampdist <= FTINY || (nsamps = r->rot/ssampdist + .5) < 1) |
| 556 |
|
nsamps = 1; |
| 557 |
|
#if MAXSSAMP |
| 560 |
|
#endif |
| 561 |
|
oldsampndx = samplendx; |
| 562 |
|
samplendx = random()&0x7fff; /* randomize */ |
| 563 |
< |
for (i = r->slights[0]; i > 0; i--) { /* for each source */ |
| 563 |
> |
for (i = volumePhotonMapping ? 1 : r->slights[0]; i > 0; i--) { |
| 564 |
> |
/* for each source OR once if volume photon map enabled */ |
| 565 |
|
for (j = 0; j < nsamps; j++) { /* for each sample position */ |
| 566 |
|
samplendx++; |
| 567 |
|
t = r->rot * (j+frandom())/nsamps; |
| 577 |
|
sr.rorg[0] = r->rorg[0] + r->rdir[0]*t; |
| 578 |
|
sr.rorg[1] = r->rorg[1] + r->rdir[1]*t; |
| 579 |
|
sr.rorg[2] = r->rorg[2] + r->rdir[2]*t; |
| 580 |
< |
sr.rmax = 0.; |
| 581 |
< |
initsrcindex(&si); /* sample ray to this source */ |
| 582 |
< |
si.sn = r->slights[i]; |
| 583 |
< |
nopart(&si, &sr); |
| 584 |
< |
if (!srcray(&sr, NULL, &si) || |
| 585 |
< |
sr.rsrc != r->slights[i]) |
| 586 |
< |
continue; /* no path */ |
| 580 |
> |
|
| 581 |
> |
if (!volumePhotonMapping) { |
| 582 |
> |
initsrcindex(&si); /* sample ray to this source */ |
| 583 |
> |
si.sn = r->slights[i]; |
| 584 |
> |
nopart(&si, &sr); |
| 585 |
> |
if (!srcray(&sr, NULL, &si) || |
| 586 |
> |
sr.rsrc != r->slights[i]) |
| 587 |
> |
continue; /* no path */ |
| 588 |
|
#if SHADCACHE |
| 589 |
< |
if (srcblocked(&sr)) /* check shadow cache */ |
| 590 |
< |
continue; |
| 589 |
> |
if (srcblocked(&sr)) /* check shadow cache */ |
| 590 |
> |
continue; |
| 591 |
|
#endif |
| 592 |
< |
copycolor(sr.cext, r->cext); |
| 593 |
< |
copycolor(sr.albedo, r->albedo); |
| 594 |
< |
sr.gecc = r->gecc; |
| 595 |
< |
sr.slights = r->slights; |
| 596 |
< |
rayvalue(&sr); /* eval. source ray */ |
| 597 |
< |
if (bright(sr.rcol) <= FTINY) { |
| 592 |
> |
copycolor(sr.cext, r->cext); |
| 593 |
> |
copycolor(sr.albedo, r->albedo); |
| 594 |
> |
sr.gecc = r->gecc; |
| 595 |
> |
sr.slights = r->slights; |
| 596 |
> |
rayvalue(&sr); /* eval. source ray */ |
| 597 |
> |
if (bright(sr.rcol) <= FTINY) { |
| 598 |
|
#if SHADCACHE |
| 599 |
< |
srcblocker(&sr); /* add blocker to cache */ |
| 599 |
> |
srcblocker(&sr); /* add blocker to cache */ |
| 600 |
|
#endif |
| 601 |
< |
continue; |
| 602 |
< |
} |
| 603 |
< |
if (r->gecc <= FTINY) /* compute P(theta) */ |
| 604 |
< |
d = 1.; |
| 605 |
< |
else { |
| 606 |
< |
d = DOT(r->rdir, sr.rdir); |
| 607 |
< |
d = 1. + r->gecc*r->gecc - 2.*r->gecc*d; |
| 608 |
< |
d = (1. - r->gecc*r->gecc) / (d*sqrt(d)); |
| 609 |
< |
} |
| 601 |
> |
continue; |
| 602 |
> |
} |
| 603 |
> |
if (r->gecc <= FTINY) /* compute P(theta) */ |
| 604 |
> |
d = 1.; |
| 605 |
> |
else { |
| 606 |
> |
d = DOT(r->rdir, sr.rdir); |
| 607 |
> |
d = 1. + r->gecc*r->gecc - 2.*r->gecc*d; |
| 608 |
> |
d = (1. - r->gecc*r->gecc) / (d*sqrt(d)); |
| 609 |
> |
} |
| 610 |
|
/* other factors */ |
| 611 |
< |
d *= si.dom * r->rot / (4.*PI*nsamps); |
| 611 |
> |
d *= si.dom * r->rot / (4.*PI*nsamps); |
| 612 |
> |
scalecolor(sr.rcol, d); |
| 613 |
> |
} else { |
| 614 |
> |
/* PMAP: Add ambient inscattering from |
| 615 |
> |
* volume photons; note we reverse the |
| 616 |
> |
* incident ray direction since we're |
| 617 |
> |
* now in *backward* raytracing mode! */ |
| 618 |
> |
sr.rdir [0] = -r -> rdir [0]; |
| 619 |
> |
sr.rdir [1] = -r -> rdir [1]; |
| 620 |
> |
sr.rdir [2] = -r -> rdir [2]; |
| 621 |
> |
sr.gecc = r -> gecc; |
| 622 |
> |
inscatterVolumePmap(&sr, sr.rcol); |
| 623 |
> |
scalecolor(sr.rcol, r -> rot / nsamps); |
| 624 |
> |
} |
| 625 |
|
multcolor(sr.rcol, r->cext); |
| 626 |
|
multcolor(sr.rcol, r->albedo); |
| 575 |
– |
scalecolor(sr.rcol, d); |
| 627 |
|
multcolor(sr.rcol, cvext); |
| 628 |
|
addcolor(r->rcol, sr.rcol); /* add it in */ |
| 629 |
|
} |
| 690 |
|
* The same is true for stray specular samples, since the specular |
| 691 |
|
* contribution from light sources is calculated separately. |
| 692 |
|
*/ |
| 693 |
< |
|
| 694 |
< |
#define badcomponent(m, r) (r->crtype&(AMBIENT|SPECULAR) && \ |
| 693 |
> |
/* PMAP: Also avoid counting sources via transferred ambient rays (e.g. |
| 694 |
> |
* through glass) when photon mapping is enabled, as these indirect |
| 695 |
> |
* components are already accounted for. |
| 696 |
> |
*/ |
| 697 |
> |
#define badcomponent(m, r) (srcRayInPmap(r) || \ |
| 698 |
> |
(r->crtype&(AMBIENT|SPECULAR) && \ |
| 699 |
|
!(r->crtype&SHADOW || r->rod < 0.0 || \ |
| 700 |
< |
/* not 100% correct */ distglow(m, r, r->rot))) |
| 700 |
> |
/* not 100% correct */ distglow(m, r, r->rot)))) |
| 701 |
|
|
| 702 |
|
/* passillum * |
| 703 |
|
* |
| 719 |
|
distglow(m, r, raydist(r,PRIMARY))) |
| 720 |
|
|
| 721 |
|
|
| 722 |
< |
extern int |
| 722 |
> |
int |
| 723 |
|
m_light( /* ray hit a light source */ |
| 724 |
< |
register OBJREC *m, |
| 725 |
< |
register RAY *r |
| 724 |
> |
OBJREC *m, |
| 725 |
> |
RAY *r |
| 726 |
|
) |
| 727 |
|
{ |
| 728 |
|
/* check for over-counting */ |