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.3 by greg, Mon Jan 6 18:01:41 1992 UTC vs.
Revision 2.4 by greg, Tue Jan 14 16:16:48 1992 UTC

# Line 16 | Line 16 | static char SCCSid[] = "$SunId$ LBL";
16  
17   #include  "random.h"
18  
19 + extern double  specthresh;              /* specular sampling threshold */
20 + extern double  specjitter;              /* specular sampling jitter */
21 +
22   /*
23   *      This anisotropic reflection model uses a variant on the
24   *  exponential Gaussian used in normal.c.
# Line 37 | Line 40 | static char SCCSid[] = "$SunId$ LBL";
40   #define  SP_REFL        01              /* has reflected specular component */
41   #define  SP_TRAN        02              /* has transmitted specular */
42   #define  SP_PURE        010             /* purely specular (zero roughness) */
43 < #define  SP_BADU        020             /* bad u direction calculation */
44 < #define  SP_FLAT        040             /* reflecting surface is flat */
43 > #define  SP_FLAT        020             /* reflecting surface is flat */
44 > #define  SP_RBLT        040             /* reflection below sample threshold */
45 > #define  SP_TBLT        0100            /* transmission below threshold */
46 > #define  SP_BADU        0200            /* bad u direction calculation */
47  
48   typedef struct {
49          OBJREC  *mp;            /* material pointer */
# Line 200 | Line 205 | register RAY  *r;
205                  for (i = 0; i < 3; i++)
206                          colval(nd.scolor,i) += (1.0-colval(nd.scolor,i))*dtmp;
207                  nd.rspec += (1.0-nd.rspec)*dtmp;
208 +                                                /* check threshold */
209 +                if (nd.rspec <= specthresh+FTINY)
210 +                        nd.specfl |= SP_RBLT;
211  
212                  if (!(r->crtype & SHADOW) && nd.specfl & SP_PURE) {
213                          RAY  lr;
# Line 220 | Line 228 | register RAY  *r;
228                  nd.tdiff = nd.trans - nd.tspec;
229                  if (nd.tspec > FTINY) {
230                          nd.specfl |= SP_TRAN;
231 +                                                        /* check threshold */
232 +                        if (nd.tspec <= specthresh+FTINY)
233 +                                nd.specfl |= SP_TBLT;
234                          if (r->crtype & SHADOW ||
235                                          DOT(r->pert,r->pert) <= FTINY*FTINY) {
236                                  VCOPY(nd.prdir, r->rdir);
# Line 255 | Line 266 | register RAY  *r;
266          if (nd.specfl & SP_PURE && nd.rdiff <= FTINY && nd.tdiff <= FTINY)
267                  return;                         /* 100% pure specular */
268  
269 +        if (r->ro->otype == OBJ_FACE || r->ro->otype == OBJ_RING)
270 +                nd.specfl |= SP_FLAT;
271 +
272          getacoords(r, &nd);                     /* set up coordinates */
273  
274          if (nd.specfl & (SP_REFL|SP_TRAN) && !(nd.specfl & (SP_PURE|SP_BADU)))
# Line 262 | Line 276 | register RAY  *r;
276  
277          if (nd.rdiff > FTINY) {         /* ambient from this side */
278                  ambient(ctmp, r);
279 <                scalecolor(ctmp, nd.rdiff);
279 >                if (nd.specfl & SP_RBLT)
280 >                        scalecolor(ctmp, 1.0-nd.trans);
281 >                else
282 >                        scalecolor(ctmp, nd.rdiff);
283                  multcolor(ctmp, nd.mcolor);     /* modified by material color */
284                  addcolor(r->rcol, ctmp);        /* add to returned color */
285          }
286          if (nd.tdiff > FTINY) {         /* ambient from other side */
287                  flipsurface(r);
288                  ambient(ctmp, r);
289 <                scalecolor(ctmp, nd.tdiff);
289 >                if (nd.specfl & SP_TBLT)
290 >                        scalecolor(ctmp, nd.trans);
291 >                else
292 >                        scalecolor(ctmp, nd.tdiff);
293                  multcolor(ctmp, nd.mcolor);     /* modified by color */
294                  addcolor(r->rcol, ctmp);
295                  flipsurface(r);
# Line 323 | Line 343 | register ANISODAT  *np;
343          int  ntries;
344          register int  i;
345                                          /* compute reflection */
346 <        if (np->specfl & SP_REFL &&
346 >        if ((np->specfl & (SP_REFL|SP_RBLT)) == SP_REFL &&
347                          rayorigin(&sr, r, SPECULAR, np->rspec) == 0) {
348                  dimlist[ndims++] = (int)np->mp;
349                  for (ntries = 0; ntries < 10; ntries++) {
# Line 336 | Line 356 | register ANISODAT  *np;
356                          d = sqrt(cosp*cosp + sinp*sinp);
357                          cosp /= d;
358                          sinp /= d;
359 +                        rv[1] = 1.0 - specjitter*rv[1];
360                          if (rv[1] <= FTINY)
361                                  d = 1.0;
362                          else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines