--- ray/src/rt/source.c 2015/05/28 09:13:19 2.66 +++ ray/src/rt/source.c 2016/02/23 12:42:41 2.67 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: source.c,v 2.66 2015/05/28 09:13:19 greg Exp $"; +static const char RCSid[] = "$Id: source.c,v 2.67 2016/02/23 12:42:41 rschregle Exp $"; #endif /* * source.c - routines dealing with illumination sources. @@ -12,8 +12,8 @@ static const char RCSid[] = "$Id: source.c,v 2.66 2015 #include "rtotypes.h" #include "source.h" #include "random.h" -#include "pmap.h" #include "pmapsrc.h" +#include "pmapmat.h" #ifndef MAXSSAMP #define MAXSSAMP 16 /* maximum samples per ray */ @@ -683,10 +683,14 @@ weaksrcmat(OBJECT obj) /* identify material */ * The same is true for stray specular samples, since the specular * contribution from light sources is calculated separately. */ - -#define badcomponent(m, r) (r->crtype&(AMBIENT|SPECULAR) && \ +/* PMAP: Also avoid counting sources via transferred ambient rays (e.g. + * through glass) when photon mapping is enabled, as these indirect + * components are already accounted for. + */ +#define badcomponent(m, r) (srcRayInPmap(r) || \ + (r->crtype&(AMBIENT|SPECULAR) && \ !(r->crtype&SHADOW || r->rod < 0.0 || \ - /* not 100% correct */ distglow(m, r, r->rot))) + /* not 100% correct */ distglow(m, r, r->rot)))) /* passillum * *