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

Comparing ray/src/rt/aniso.c (file contents):
Revision 2.33 by gwlarson, Wed Dec 16 18:14:57 1998 UTC vs.
Revision 2.40 by greg, Thu Aug 28 03:22:16 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1998 Silicon Graphics, Inc. */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ SGI";
2 > static const char RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  Shading functions for anisotropic materials.
6   */
7  
8 + #include "copyright.h"
9 +
10   #include  "ray.h"
11  
12 + #include  "ambient.h"
13 +
14   #include  "otypes.h"
15  
16   #include  "func.h"
17  
18   #include  "random.h"
19  
19 extern double  specthresh;              /* specular sampling threshold */
20 extern double  specjitter;              /* specular sampling jitter */
21
22 extern int  backvis;                    /* back faces visible? */
23
20   #ifndef  MAXITER
21   #define  MAXITER        10              /* maximum # specular ray attempts */
22   #endif
23  
28 static  agaussamp(), getacoords();
29
24   /*
25   *      This routine implements the anisotropic Gaussian
26   *  model described by Ward in Siggraph `92 article.
# Line 68 | Line 62 | typedef struct {
62          double  pdot;           /* perturbed dot product */
63   }  ANISODAT;            /* anisotropic material data */
64  
65 + static void     getacoords();
66 + static void     agaussamp();
67  
68 +
69 + static void
70   diraniso(cval, np, ldir, omega)         /* compute source contribution */
71   COLOR  cval;                    /* returned coefficient */
72   register ANISODAT  *np;         /* material data */
# Line 182 | Line 180 | double  omega;                 /* light source size */
180   }
181  
182  
183 + int
184   m_aniso(m, r)                   /* shade ray that hit something anisotropic */
185   register OBJREC  *m;
186   register RAY  *r;
# Line 195 | Line 194 | register RAY  *r;
194  
195          if (m->oargs.nfargs != (m->otype == MAT_TRANS2 ? 8 : 6))
196                  objerror(m, USER, "bad number of real arguments");
197 +                                                /* check for back side */
198 +        if (r->rod < 0.0) {
199 +                if (!backvis && m->otype != MAT_TRANS2) {
200 +                        raytrans(r);
201 +                        return(1);
202 +                }
203 +                raytexture(r, m->omod);
204 +                flipsurface(r);                 /* reorient if backvis */
205 +        } else
206 +                raytexture(r, m->omod);
207 +                                                /* get material color */
208          nd.mp = m;
209          nd.rp = r;
200                                                /* get material color */
210          setcolor(nd.mcolor, m->oargs.farg[0],
211                             m->oargs.farg[1],
212                             m->oargs.farg[2]);
# Line 207 | Line 216 | register RAY  *r;
216          nd.v_alpha = m->oargs.farg[5];
217          if (nd.u_alpha < FTINY || nd.v_alpha <= FTINY)
218                  objerror(m, USER, "roughness too small");
219 <                                                /* check for back side */
211 <        if (r->rod < 0.0) {
212 <                if (!backvis && m->otype != MAT_TRANS2) {
213 <                        raytrans(r);
214 <                        return(1);
215 <                }
216 <                flipsurface(r);                 /* reorient if backvis */
217 <        }
218 <                                                /* get modifiers */
219 <        raytexture(r, m->omod);
219 >
220          nd.pdot = raynormal(nd.pnorm, r);       /* perturb normal */
221          if (nd.pdot < .001)
222                  nd.pdot = .001;                 /* non-zero for diraniso() */
# Line 307 | Line 307 | register RAY  *r;
307   }
308  
309  
310 < static
310 > static void
311   getacoords(r, np)               /* set up coordinate system */
312   RAY  *r;
313   register ANISODAT  *np;
# Line 320 | Line 320 | register ANISODAT  *np;
320          errno = 0;
321          for (i = 0; i < 3; i++)
322                  np->u[i] = evalue(mf->ep[i]);
323 <        if (errno) {
323 >        if (errno == EDOM || errno == ERANGE) {
324                  objerror(np->mp, WARNING, "compute error");
325                  np->specfl |= SP_BADU;
326                  return;
# Line 337 | Line 337 | register ANISODAT  *np;
337   }
338  
339  
340 < static
340 > static void
341   agaussamp(r, np)                /* sample anisotropic gaussian specular */
342   RAY  *r;
343   register ANISODAT  *np;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines