ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/normal.c
(Generate patch)

Comparing ray/src/rt/normal.c (file contents):
Revision 2.41 by greg, Wed Mar 12 04:59:05 2003 UTC vs.
Revision 2.47 by schorsch, Tue Mar 30 16:13:01 2004 UTC

# Line 14 | Line 14 | static const char RCSid[] = "$Id$";
14   #include "copyright.h"
15  
16   #include  "ray.h"
17 <
17 > #include  "ambient.h"
18 > #include  "source.h"
19   #include  "otypes.h"
20 <
20 > #include  "rtotypes.h"
21   #include  "random.h"
22  
23   #ifndef  MAXITER
24   #define  MAXITER        10              /* maximum # specular ray attempts */
25   #endif
26                                          /* estimate of Fresnel function */
27 < #define  FRESNE(ci)     (exp(-6.0*(ci)) - 0.00247875217)
27 > #define  FRESNE(ci)     (exp(-5.85*(ci)) - 0.00287989916)
28  
28 static void  gaussamp();
29  
30   /*
31   *      This routine implements the isotropic Gaussian
# Line 64 | Line 64 | typedef struct {
64          double  pdot;           /* perturbed dot product */
65   }  NORMDAT;             /* normal material data */
66  
67 + static srcdirf_t dirnorm;
68 + static void gaussamp(RAY  *r, NORMDAT  *np);
69  
70 +
71   static void
72 < dirnorm(cval, np, ldir, omega)          /* compute source contribution */
73 < COLOR  cval;                    /* returned coefficient */
74 < register NORMDAT  *np;          /* material data */
75 < FVECT  ldir;                    /* light source direction */
76 < double  omega;                  /* light source size */
72 > dirnorm(                /* compute source contribution */
73 >        COLOR  cval,                    /* returned coefficient */
74 >        void  *nnp,             /* material data */
75 >        FVECT  ldir,                    /* light source direction */
76 >        double  omega                   /* light source size */
77 > )
78   {
79 +        register NORMDAT *np = nnp;
80          double  ldot;
81          double  ldiff;
82          double  dtmp, d2;
# Line 87 | Line 92 | double  omega;                 /* light source size */
92  
93                                  /* Fresnel estimate */
94          ldiff = np->rdiff;
95 <        if (np->specfl & SP_PURE && (np->rspec > FTINY & ldiff > FTINY))
95 >        if (np->specfl & SP_PURE && (np->rspec > FTINY) & (ldiff > FTINY))
96                  ldiff *= 1. - FRESNE(fabs(ldot));
97  
98          if (ldot > FTINY && ldiff > FTINY) {
# Line 157 | Line 162 | double  omega;                 /* light source size */
162   }
163  
164  
165 < int
166 < m_normal(m, r)                  /* color a ray that hit something normal */
167 < register OBJREC  *m;
168 < register RAY  *r;
165 > extern int
166 > m_normal(                       /* color a ray that hit something normal */
167 >        register OBJREC  *m,
168 >        register RAY  *r
169 > )
170   {
171          NORMDAT  nd;
172          double  fest;
# Line 198 | Line 204 | register RAY  *r;
204          if ((nd.alpha2 *= nd.alpha2) <= FTINY)
205                  nd.specfl |= SP_PURE;
206  
207 <        if (hastexture = (DOT(r->pert,r->pert) > FTINY*FTINY)) {
207 >        if ( (hastexture = (DOT(r->pert,r->pert) > FTINY*FTINY)) ) {
208                  nd.pdot = raynormal(nd.pnorm, r);       /* perturb normal */
209          } else {
210                  VCOPY(nd.pnorm, r->ron);
211                  nd.pdot = r->rod;
206                if (r->ro != NULL && isflat(r->ro->otype))
207                        nd.specfl |= SP_FLAT;
212          }
213 +        if (r->ro != NULL && isflat(r->ro->otype))
214 +                nd.specfl |= SP_FLAT;
215          if (nd.pdot < .001)
216                  nd.pdot = .001;                 /* non-zero for dirnorm() */
217          multcolor(nd.mcolor, r->pcol);          /* modify material color */
# Line 351 | Line 357 | register RAY  *r;
357  
358  
359   static void
360 < gaussamp(r, np)                 /* sample gaussian specular */
361 < RAY  *r;
362 < register NORMDAT  *np;
360 > gaussamp(                       /* sample gaussian specular */
361 >        RAY  *r,
362 >        register NORMDAT  *np
363 > )
364   {
365          RAY  sr;
366          FVECT  u, v, h;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines