ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/source.c
(Generate patch)

Comparing ray/src/rt/source.c (file contents):
Revision 2.63 by greg, Mon Sep 15 00:54:39 2014 UTC vs.
Revision 2.64 by greg, Tue Feb 24 19:39:27 2015 UTC

# Line 12 | Line 12 | static const char RCSid[] = "$Id$";
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 */
# Line 142 | Line 144 | marksources(void)                      /* find and mark source objects */
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));
# Line 378 | Line 384 | direct(                                        /* add direct component */
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?! */
# Line 529 | Line 543 | srcscatter(                    /* compute source scattering into ray */
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
# Line 589 | Line 606 | srcscatter(                    /* compute source scattering into ray */
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);
594                        scalecolor(sr.rcol, d);
620                          multcolor(sr.rcol, cvext);
621                          addcolor(r->rcol, sr.rcol);     /* add it in */
622                  }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines