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.69 by greg, Tue Feb 24 19:39:26 2015 UTC vs.
Revision 2.78 by greg, Wed Feb 13 01:00:31 2019 UTC

# Line 112 | Line 112 | dirnorm(               /* compute source contribution */
112                  scalecolor(ctmp, dtmp);
113                  addcolor(cval, ctmp);
114          }
115 <        
115 >
116          if (ldot < -FTINY && ltdiff > FTINY) {
117                  /*
118                   *  Compute diffuse transmission.
# Line 122 | Line 122 | dirnorm(               /* compute source contribution */
122                  scalecolor(ctmp, dtmp);
123                  addcolor(cval, ctmp);
124          }
125 <        
126 <        /* PMAP: skip direct specular via ambient bounce if already accounted for
127 <         * in photon map */
125 >
126          if (ambRayInPmap(np->rp))
127 <                return;
127 >                return;         /* specular already in photon map */
128  
129          if (ldot > FTINY && (np->specfl&(SP_REFL|SP_PURE)) == SP_REFL) {
130                  /*
# Line 184 | Line 182 | m_normal(                      /* color a ray that hit something normal *
182   {
183          NORMDAT  nd;
184          double  fest;
187        double  transtest, transdist;
188        double  mirtest, mirdist;
185          int     hastexture;
186          double  d;
187          COLOR  ctmp;
188          int  i;
189  
190          /* PMAP: skip transmitted shadow ray if accounted for in photon map */
191 <        if (shadowRayInPmap(r))
192 <                return(1);
191 >        /* No longer needed?
192 >        if (shadowRayInPmap(r) || ambRayInPmap(r))
193 >                return(1); */          
194 >                
195                                                  /* easy shadow test */
196          if (r->crtype & SHADOW && m->otype != MAT_TRANS)
197                  return(1);
# 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 <                                for (i = 0; i < 3; i++)         /* perturb */
256 <                                        nd.prdir[i] = r->rdir[i] - r->pert[i];
255 >                                                        /* perturb */
256 >                                VSUB(nd.prdir, r->rdir, r->pert);
257                                  if (DOT(nd.prdir, r->ron) < -FTINY)
258                                          normalize(nd.prdir);    /* OK */
259                                  else
# Line 269 | Line 264 | m_normal(                      /* color a ray that hit something normal *
264                  nd.tdiff = nd.tspec = nd.trans = 0.0;
265                                                  /* transmitted ray */
266  
267 <        /* PMAP: skip indirect specular trans via ambient bounce if already
273 <         * accounted for in photon map */
274 <        if (!ambRayInPmap(r) &&
275 <                    (nd.specfl&(SP_TRAN|SP_PURE|SP_TBLT)) == (SP_TRAN|SP_PURE)) {
267 >        if ((nd.specfl&(SP_TRAN|SP_PURE|SP_TBLT)) == (SP_TRAN|SP_PURE)) {
268                  RAY  lr;
269                  copycolor(lr.rcoef, nd.mcolor); /* modified by color */
270                  scalecolor(lr.rcoef, nd.tspec);
# Line 281 | Line 273 | m_normal(                      /* color a ray that hit something normal *
273                          rayvalue(&lr);
274                          multcolor(lr.rcol, lr.rcoef);
275                          addcolor(r->rcol, lr.rcol);
276 <                        transtest *= bright(lr.rcol);
277 <                        transdist = r->rot + lr.rt;
276 >                        if (nd.tspec >= 1.0-FTINY) {
277 >                                                /* completely transparent */
278 >                                multcolor(lr.mcol, lr.rcoef);
279 >                                copycolor(r->mcol, lr.mcol);
280 >                                r->rmt = r->rot + lr.rmt;
281 >                                r->rxt = r->rot + lr.rxt;
282 >                        } else
283 >                                r->rxt = r->rot + raydistance(&lr);
284                  }
285 <        } else
288 <                transtest = 0;
285 >        }
286  
287 <        if (r->crtype & SHADOW) {               /* the rest is shadow */
291 <                r->rt = transdist;
287 >        if (r->crtype & SHADOW)                 /* the rest is shadow */
288                  return(1);
293        }
289                                                  /* get specular reflection */
290          if (nd.rspec > FTINY) {
291                  nd.specfl |= SP_REFL;
# Line 317 | Line 312 | m_normal(                      /* color a ray that hit something normal *
312                  checknorm(nd.vrefl);
313          }
314                                                  /* reflected ray */
315 <        /* PMAP: skip indirect specular refl via ambient ray if already accounted
321 <         * for in photon map */
322 <        if (!ambRayInPmap(r) &&
323 <                    (nd.specfl&(SP_REFL|SP_PURE|SP_RBLT)) == (SP_REFL|SP_PURE)) {
315 >        if ((nd.specfl&(SP_REFL|SP_PURE|SP_RBLT)) == (SP_REFL|SP_PURE)) {
316                  RAY  lr;
317                  if (rayorigin(&lr, REFLECTED, r, nd.scolor) == 0) {
318                          VCOPY(lr.rdir, nd.vrefl);
319                          rayvalue(&lr);
320                          multcolor(lr.rcol, lr.rcoef);
321 +                        copycolor(r->mcol, lr.rcol);
322                          addcolor(r->rcol, lr.rcol);
323                          if (nd.specfl & SP_FLAT &&
324 <                                        !hastexture | (r->crtype & AMBIENT)) {
325 <                                mirtest = 2.*bright(lr.rcol);
333 <                                mirdist = r->rot + lr.rt;
334 <                        }
324 >                                        !hastexture | (r->crtype & AMBIENT))
325 >                                r->rmt = r->rot + raydistance(&lr);
326                  }
327          }
328                                                  /* diffuse reflection */
# Line 340 | Line 331 | m_normal(                      /* color a ray that hit something normal *
331          if (nd.specfl & SP_PURE && nd.rdiff <= FTINY && nd.tdiff <= FTINY)
332                  return(1);                      /* 100% pure specular */
333  
334 <        /* PMAP: skip indirect gaussian via ambient bounce if already accounted
335 <         * for in photon map */
345 <        if (!ambRayInPmap(r))  
346 <                if (!(nd.specfl & SP_PURE))
347 <                        gaussamp(&nd);          /* checks *BLT flags */
334 >        if (!(nd.specfl & SP_PURE))
335 >                gaussamp(&nd);                  /* checks *BLT flags */
336  
337          if (nd.rdiff > FTINY) {         /* ambient from this side */
338                  copycolor(ctmp, nd.mcolor);     /* modified by material color */
# Line 374 | Line 362 | m_normal(                      /* color a ray that hit something normal *
362          }
363                                          /* add direct component */
364          direct(r, dirnorm, &nd);
377                                        /* check distance */
378        d = bright(r->rcol);
379        if (transtest > d)
380                r->rt = transdist;
381        else if (mirtest > d)
382                r->rt = mirdist;
365  
366          return(1);
367   }
# Line 402 | Line 384 | gaussamp(                      /* sample Gaussian specular */
384                          (np->specfl & (SP_TRAN|SP_TBLT)) != SP_TRAN)
385                  return;
386                                          /* set up sample coordinates */
387 <        getperpendicular(u, np->pnorm);
387 >        getperpendicular(u, np->pnorm, rand_samp);
388          fcross(v, np->pnorm, u);
389                                          /* compute reflection */
390          if ((np->specfl & (SP_REFL|SP_RBLT)) == SP_REFL &&

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines