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.4 by greg, Tue Jan 14 15:33:08 1992 UTC vs.
Revision 2.5 by greg, Tue Jan 14 16:16:45 1992 UTC

# Line 20 | Line 20 | static char SCCSid[] = "$SunId$ LBL";
20  
21   #include  "random.h"
22  
23 + extern double  specthresh;              /* specular sampling threshold */
24 + extern double  specjitter;              /* specular sampling jitter */
25 +
26   /*
27   *      This routine uses portions of the reflection
28   *  model described by Cook and Torrance.
# Line 42 | Line 45 | static char SCCSid[] = "$SunId$ LBL";
45   #define  SP_TRAN        02              /* has transmitted specular */
46   #define  SP_PURE        010             /* purely specular (zero roughness) */
47   #define  SP_FLAT        020             /* flat reflecting surface */
48 + #define  SP_RBLT        040             /* reflection below sample threshold */
49 + #define  SP_TBLT        0100            /* transmission below threshold */
50  
51   typedef struct {
52          OBJREC  *mp;            /* material pointer */
# Line 186 | Line 191 | register RAY  *r;
191                  for (i = 0; i < 3; i++)
192                          colval(nd.scolor,i) += (1.0-colval(nd.scolor,i))*dtmp;
193                  nd.rspec += (1.0-nd.rspec)*dtmp;
194 +                                                /* check threshold */
195 +                if (nd.rspec <= specthresh+FTINY)
196 +                        nd.specfl |= SP_RBLT;
197                                                  /* compute reflected ray */
198                  for (i = 0; i < 3; i++)
199                          nd.vrefl[i] = r->rdir[i] + 2.0*nd.pdot*nd.pnorm[i];
# Line 207 | Line 215 | register RAY  *r;
215                  nd.tdiff = nd.trans - nd.tspec;
216                  if (nd.tspec > FTINY) {
217                          nd.specfl |= SP_TRAN;
218 +                                                        /* check threshold */
219 +                        if (nd.tspec <= specthresh+FTINY)
220 +                                nd.specfl |= SP_TBLT;
221                          if (r->crtype & SHADOW ||
222                                          DOT(r->pert,r->pert) <= FTINY*FTINY) {
223                                  VCOPY(nd.prdir, r->rdir);
# Line 250 | Line 261 | register RAY  *r;
261  
262          if (nd.rdiff > FTINY) {         /* ambient from this side */
263                  ambient(ctmp, r);
264 <                scalecolor(ctmp, nd.rdiff);
264 >                if (nd.specfl & SP_RBLT)
265 >                        scalecolor(ctmp, 1.0-nd.trans);
266 >                else
267 >                        scalecolor(ctmp, nd.rdiff);
268                  multcolor(ctmp, nd.mcolor);     /* modified by material color */
269                  addcolor(r->rcol, ctmp);        /* add to returned color */
270          }
271          if (nd.tdiff > FTINY) {         /* ambient from other side */
272                  flipsurface(r);
273                  ambient(ctmp, r);
274 <                scalecolor(ctmp, nd.tdiff);
274 >                if (nd.specfl & SP_TBLT)
275 >                        scalecolor(ctmp, nd.trans);
276 >                else
277 >                        scalecolor(ctmp, nd.tdiff);
278                  multcolor(ctmp, nd.mcolor);     /* modified by color */
279                  addcolor(r->rcol, ctmp);
280                  flipsurface(r);
# Line 291 | Line 308 | register NORMDAT  *np;
308          normalize(u);
309          fcross(v, np->pnorm, u);
310                                          /* compute reflection */
311 <        if (np->specfl & SP_REFL &&
311 >        if ((np->specfl & (SP_REFL|SP_RBLT)) == SP_REFL &&
312                          rayorigin(&sr, r, SPECULAR, np->rspec) == 0) {
313                  dimlist[ndims++] = (int)np->mp;
314                  for (ntries = 0; ntries < 10; ntries++) {
# Line 301 | Line 318 | register NORMDAT  *np;
318                          d = 2.0*PI * rv[0];
319                          cosp = cos(d);
320                          sinp = sin(d);
321 +                        rv[1] = 1.0 - specjitter*rv[1];
322                          if (rv[1] <= FTINY)
323                                  d = 1.0;
324                          else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines