--- ray/src/rt/normal.c 2003/02/25 02:47:22 2.39 +++ ray/src/rt/normal.c 2003/08/28 03:22:16 2.46 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: normal.c,v 2.39 2003/02/25 02:47:22 greg Exp $"; +static const char RCSid[] = "$Id: normal.c,v 2.46 2003/08/28 03:22:16 greg Exp $"; #endif /* * normal.c - shading function for normal materials. @@ -15,6 +15,8 @@ static const char RCSid[] = "$Id: normal.c,v 2.39 2003 #include "ray.h" +#include "ambient.h" + #include "otypes.h" #include "random.h" @@ -23,7 +25,7 @@ static const char RCSid[] = "$Id: normal.c,v 2.39 2003 #define MAXITER 10 /* maximum # specular ray attempts */ #endif /* estimate of Fresnel function */ -#define FRESNE(ci) (exp(-6.0*(ci)) - 0.00247875217) +#define FRESNE(ci) (exp(-5.85*(ci)) - 0.00287989916) static void gaussamp(); @@ -87,7 +89,7 @@ double omega; /* light source size */ /* Fresnel estimate */ ldiff = np->rdiff; - if (np->specfl & SP_PURE && (np->rspec > FTINY & ldiff > FTINY)) + if (np->specfl & SP_PURE && (np->rspec > FTINY) & (ldiff > FTINY)) ldiff *= 1. - FRESNE(fabs(ldot)); if (ldot > FTINY && ldiff > FTINY) { @@ -182,8 +184,10 @@ register RAY *r; raytrans(r); return(1); } + raytexture(r, m->omod); flipsurface(r); /* reorient if backvis */ - } + } else + raytexture(r, m->omod); nd.mp = m; nd.rp = r; /* get material color */ @@ -195,16 +199,15 @@ register RAY *r; nd.alpha2 = m->oargs.farg[4]; if ((nd.alpha2 *= nd.alpha2) <= FTINY) nd.specfl |= SP_PURE; - if (r->ro != NULL && isflat(r->ro->otype)) - nd.specfl |= SP_FLAT; - /* get modifiers */ - raytexture(r, m->omod); - if (hastexture = DOT(r->pert,r->pert) > FTINY*FTINY) + + if ( (hastexture = (DOT(r->pert,r->pert) > FTINY*FTINY)) ) { nd.pdot = raynormal(nd.pnorm, r); /* perturb normal */ - else { + } else { VCOPY(nd.pnorm, r->ron); nd.pdot = r->rod; } + if (r->ro != NULL && isflat(r->ro->otype)) + nd.specfl |= SP_FLAT; if (nd.pdot < .001) nd.pdot = .001; /* non-zero for dirnorm() */ multcolor(nd.mcolor, r->pcol); /* modify material color */