--- ray/src/rt/aniso.c 2014/12/04 05:26:28 2.57 +++ ray/src/rt/aniso.c 2015/02/24 19:39:26 2.58 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: aniso.c,v 2.57 2014/12/04 05:26:28 greg Exp $"; +static const char RCSid[] = "$Id: aniso.c,v 2.58 2015/02/24 19:39:26 greg Exp $"; #endif /* * Shading functions for anisotropic materials. @@ -14,6 +14,7 @@ static const char RCSid[] = "$Id: aniso.c,v 2.57 2014/ #include "source.h" #include "func.h" #include "random.h" +#include "pmapmat.h" #ifndef MAXITER #define MAXITER 10 /* maximum # specular ray attempts */ @@ -97,6 +98,22 @@ diraniso( /* compute source contribution */ scalecolor(ctmp, dtmp); addcolor(cval, ctmp); } + + if ((ldot < -FTINY) & (np->tdiff > FTINY)) { + /* + * Compute diffuse transmission. + */ + copycolor(ctmp, np->mcolor); + dtmp = -ldot * omega * np->tdiff * (1.0/PI); + scalecolor(ctmp, dtmp); + addcolor(cval, ctmp); + } + + /* PMAP: skip direct specular refl via ambient bounce if already + * accounted for in photon map */ + if (ambRayInPmap(np->rp)) + return; + if (ldot > FTINY && np->specfl&SP_REFL) { /* * Compute specular reflection coefficient using @@ -130,15 +147,7 @@ diraniso( /* compute source contribution */ addcolor(cval, ctmp); } } - if ((ldot < -FTINY) & (np->tdiff > FTINY)) { - /* - * Compute diffuse transmission. - */ - copycolor(ctmp, np->mcolor); - dtmp = -ldot * omega * np->tdiff * (1.0/PI); - scalecolor(ctmp, dtmp); - addcolor(cval, ctmp); - } + if (ldot < -FTINY && np->specfl&SP_TRAN) { /* * Compute specular transmission. Specular transmission @@ -267,7 +276,9 @@ m_aniso( /* shade ray that hit something anisotropic getacoords(&nd); /* set up coordinates */ - if (nd.specfl & (SP_REFL|SP_TRAN)) + /* PMAP: skip indirect specular via ambient bounce if already accounted + * for in photon map */ + if (!ambRayInPmap(r) && nd.specfl & (SP_REFL|SP_TRAN)) agaussamp(&nd); if (nd.rdiff > FTINY) { /* ambient from this side */ @@ -278,6 +289,7 @@ m_aniso( /* shade ray that hit something anisotropic multambient(ctmp, r, nd.pnorm); addcolor(r->rcol, ctmp); /* add to returned color */ } + if (nd.tdiff > FTINY) { /* ambient from other side */ FVECT bnorm; @@ -299,7 +311,6 @@ m_aniso( /* shade ray that hit something anisotropic return(1); } - static void getacoords( /* set up coordinate system */