--- ray/src/rt/normal.c 2003/03/12 17:26:58 2.42 +++ ray/src/rt/normal.c 2004/03/30 16:13:01 2.47 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: normal.c,v 2.42 2003/03/12 17:26:58 greg Exp $"; +static const char RCSid[] = "$Id: normal.c,v 2.47 2004/03/30 16:13:01 schorsch Exp $"; #endif /* * normal.c - shading function for normal materials. @@ -14,18 +14,18 @@ static const char RCSid[] = "$Id: normal.c,v 2.42 2003 #include "copyright.h" #include "ray.h" - +#include "ambient.h" +#include "source.h" #include "otypes.h" - +#include "rtotypes.h" #include "random.h" #ifndef MAXITER #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(); /* * This routine implements the isotropic Gaussian @@ -64,14 +64,19 @@ typedef struct { double pdot; /* perturbed dot product */ } NORMDAT; /* normal material data */ +static srcdirf_t dirnorm; +static void gaussamp(RAY *r, NORMDAT *np); + static void -dirnorm(cval, np, ldir, omega) /* compute source contribution */ -COLOR cval; /* returned coefficient */ -register NORMDAT *np; /* material data */ -FVECT ldir; /* light source direction */ -double omega; /* light source size */ +dirnorm( /* compute source contribution */ + COLOR cval, /* returned coefficient */ + void *nnp, /* material data */ + FVECT ldir, /* light source direction */ + double omega /* light source size */ +) { + register NORMDAT *np = nnp; double ldot; double ldiff; double dtmp, d2; @@ -87,7 +92,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) { @@ -157,10 +162,11 @@ double omega; /* light source size */ } -int -m_normal(m, r) /* color a ray that hit something normal */ -register OBJREC *m; -register RAY *r; +extern int +m_normal( /* color a ray that hit something normal */ + register OBJREC *m, + register RAY *r +) { NORMDAT nd; double fest; @@ -198,7 +204,7 @@ register RAY *r; if ((nd.alpha2 *= nd.alpha2) <= FTINY) nd.specfl |= SP_PURE; - 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 { VCOPY(nd.pnorm, r->ron); @@ -351,9 +357,10 @@ register RAY *r; static void -gaussamp(r, np) /* sample gaussian specular */ -RAY *r; -register NORMDAT *np; +gaussamp( /* sample gaussian specular */ + RAY *r, + register NORMDAT *np +) { RAY sr; FVECT u, v, h;