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.76 by greg, Wed Jan 10 04:08:50 2018 UTC vs.
Revision 2.81 by greg, Mon Mar 6 22:35:17 2023 UTC

# Line 25 | Line 25 | static const char RCSid[] = "$Id$";
25   #define  MAXITER        10              /* maximum # specular ray attempts */
26   #endif
27                                          /* estimate of Fresnel function */
28 < #define  FRESNE(ci)     (exp(-5.85*(ci)) - 0.00287989916)
28 > #define  FRESNE(ci)     (exp(-6.2*(ci)) - 0.00202943064)
29   #define  FRESTHRESH     0.017999        /* minimum specularity for approx. */
30  
31  
# Line 182 | Line 182 | m_normal(                      /* color a ray that hit something normal *
182   {
183          NORMDAT  nd;
184          double  fest;
185        double  transtest, transdist;
186        double  mirtest, mirdist;
185          int     hastexture;
186          double  d;
187          COLOR  ctmp;
# Line 233 | Line 231 | m_normal(                      /* color a ray that hit something normal *
231          if (nd.pdot < .001)
232                  nd.pdot = .001;                 /* non-zero for dirnorm() */
233          multcolor(nd.mcolor, r->pcol);          /* modify material color */
236        mirtest = transtest = 0;
237        mirdist = transdist = r->rot;
234          nd.rspec = m->oargs.farg[3];
235                                                  /* compute Fresnel approx. */
236          if (nd.specfl & SP_PURE && nd.rspec >= FRESTHRESH) {
# Line 255 | Line 251 | m_normal(                      /* color a ray that hit something normal *
251                                  nd.specfl |= SP_TBLT;
252                          if (!hastexture || r->crtype & (SHADOW|AMBIENT)) {
253                                  VCOPY(nd.prdir, r->rdir);
258                                transtest = 2;
254                          } else {
255                                                          /* perturb */
256                                  VSUB(nd.prdir, r->rdir, r->pert);
# Line 267 | Line 262 | m_normal(                      /* color a ray that hit something normal *
262                  }
263          } else
264                  nd.tdiff = nd.tspec = nd.trans = 0.0;
265 +                                                /* diffuse reflection */
266 +        nd.rdiff = 1.0 - nd.trans - nd.rspec;
267                                                  /* transmitted ray */
271
268          if ((nd.specfl&(SP_TRAN|SP_PURE|SP_TBLT)) == (SP_TRAN|SP_PURE)) {
269                  RAY  lr;
270                  copycolor(lr.rcoef, nd.mcolor); /* modified by color */
# Line 278 | Line 274 | m_normal(                      /* color a ray that hit something normal *
274                          rayvalue(&lr);
275                          multcolor(lr.rcol, lr.rcoef);
276                          addcolor(r->rcol, lr.rcol);
277 <                        transtest *= bright(lr.rcol);
278 <                        transdist = r->rot + lr.rt;
277 >                        if (nd.tspec >= 1.0-FTINY) {
278 >                                                /* completely transparent */
279 >                                multcolor(lr.mcol, lr.rcoef);
280 >                                copycolor(r->mcol, lr.mcol);
281 >                                r->rmt = r->rot + lr.rmt;
282 >                                r->rxt = r->rot + lr.rxt;
283 >                        } else if (nd.tspec > nd.tdiff + nd.rdiff)
284 >                                r->rxt = r->rot + raydistance(&lr);
285                  }
286 <        } else
285 <                transtest = 0;
286 >        }
287  
288 <        if (r->crtype & SHADOW) {               /* the rest is shadow */
288 <                r->rt = transdist;
288 >        if (r->crtype & SHADOW)                 /* the rest is shadow */
289                  return(1);
290        }
290                                                  /* get specular reflection */
291          if (nd.rspec > FTINY) {
292                  nd.specfl |= SP_REFL;
# Line 320 | Line 319 | m_normal(                      /* color a ray that hit something normal *
319                          VCOPY(lr.rdir, nd.vrefl);
320                          rayvalue(&lr);
321                          multcolor(lr.rcol, lr.rcoef);
322 +                        copycolor(r->mcol, lr.rcol);
323                          addcolor(r->rcol, lr.rcol);
324 +                        r->rmt = r->rot;
325                          if (nd.specfl & SP_FLAT &&
326 <                                        !hastexture | (r->crtype & AMBIENT)) {
327 <                                mirtest = 2.*bright(lr.rcol);
327 <                                mirdist = r->rot + lr.rt;
328 <                        }
326 >                                        !hastexture | (r->crtype & AMBIENT))
327 >                                r->rmt += raydistance(&lr);
328                  }
329          }
331                                                /* diffuse reflection */
332        nd.rdiff = 1.0 - nd.trans - nd.rspec;
330  
331 <        if (nd.specfl & SP_PURE && nd.rdiff <= FTINY && nd.tdiff <= FTINY) {
335 <                if (mirtest > transtest+FTINY)
336 <                        r->rt = mirdist;
337 <                else if (transtest > FTINY)
338 <                        r->rt = transdist;
331 >        if (nd.specfl & SP_PURE && nd.rdiff <= FTINY && nd.tdiff <= FTINY)
332                  return(1);                      /* 100% pure specular */
333 <        }
333 >
334          if (!(nd.specfl & SP_PURE))
335                  gaussamp(&nd);                  /* checks *BLT flags */
336  
# Line 369 | Line 362 | m_normal(                      /* color a ray that hit something normal *
362          }
363                                          /* add direct component */
364          direct(r, dirnorm, &nd);
372                                        /* check distance */
373        d = bright(r->rcol);
374        if (transtest > d)
375                r->rt = transdist;
376        else if (mirtest > d)
377                r->rt = mirdist;
365  
366          return(1);
367   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines