--- ray/src/rt/dielectric.c 2013/08/07 05:10:09 2.23 +++ ray/src/rt/dielectric.c 2015/05/20 13:12:06 2.26 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: dielectric.c,v 2.23 2013/08/07 05:10:09 greg Exp $"; +static const char RCSid[] = "$Id: dielectric.c,v 2.26 2015/05/20 13:12:06 rschregle Exp $"; #endif /* * dielectric.c - shading function for transparent materials. @@ -10,6 +10,7 @@ static const char RCSid[] = "$Id: dielectric.c,v 2.23 #include "ray.h" #include "otypes.h" #include "rtotypes.h" +#include "pmapmat.h" #ifdef DISPERSE #include "source.h" @@ -50,8 +51,8 @@ static double mylog(double x); #define MINCOS 0.997 /* minimum dot product for dispersion */ - -static double +static +double mylog( /* special log for extinction coefficients */ double x ) @@ -64,10 +65,10 @@ mylog( /* special log for extinction coefficients */ } -extern int +int m_dielectric( /* color a ray which hit a dielectric interface */ OBJREC *m, - register RAY *r + RAY *r ) { double cos1, cos2, nratio; @@ -81,8 +82,13 @@ m_dielectric( /* color a ray which hit a dielectric in FVECT dnorm; double d1, d2; RAY p; - register int i; + int i; + /* PMAP: skip refracted shadow or ambient ray if accounted for in + photon map */ + if (shadowRayInPmap(r) || ambRayInPmap(r)) + return(1); + if (m->oargs.nfargs != (m->otype==MAT_DIELECTRIC ? 5 : 8)) objerror(m, USER, "bad arguments"); @@ -94,7 +100,8 @@ m_dielectric( /* color a ray which hit a dielectric in VCOPY(dnorm, r->ron); cos1 = r->rod; } - flatsurface = !hastexture && r->ro != NULL && isflat(r->ro->otype); + flatsurface = r->ro != NULL && isflat(r->ro->otype) && + !hastexture | (r->crtype & AMBIENT); /* index of refraction */ if (m->otype == MAT_DIELECTRIC) @@ -199,8 +206,8 @@ m_dielectric( /* color a ray which hit a dielectric in addcolor(r->rcol, p.rcol); /* virtual distance */ if (flatsurface || - (1.-FTINY <= nratio && - nratio <= 1.+FTINY)) { + (1.-FTINY <= nratio) & + (nratio <= 1.+FTINY)) { transtest = 2*bright(p.rcol); transdist = r->rot + p.rt; } @@ -380,7 +387,7 @@ disperse( /* check light sources for dispersion */ static int lambda( /* compute lambda for material */ - register OBJREC *m, + OBJREC *m, FVECT v2, FVECT dv, FVECT lr