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.65 by greg, Wed Aug 1 15:26:36 2012 UTC vs.
Revision 2.71 by greg, Tue May 26 13:21:07 2015 UTC

# Line 19 | Line 19 | static const char RCSid[] = "$Id$";
19   #include  "otypes.h"
20   #include  "rtotypes.h"
21   #include  "random.h"
22 + #include  "pmapmat.h"
23  
24   #ifndef  MAXITER
25   #define  MAXITER        10              /* maximum # specular ray attempts */
# Line 111 | Line 112 | dirnorm(               /* compute source contribution */
112                  scalecolor(ctmp, dtmp);
113                  addcolor(cval, ctmp);
114          }
115 +        
116 +        if (ldot < -FTINY && ltdiff > FTINY) {
117 +                /*
118 +                 *  Compute diffuse transmission.
119 +                 */
120 +                copycolor(ctmp, np->mcolor);
121 +                dtmp = -ldot * omega * ltdiff * (1.0/PI);
122 +                scalecolor(ctmp, dtmp);
123 +                addcolor(cval, ctmp);
124 +        }
125 +        
126          if (ldot > FTINY && (np->specfl&(SP_REFL|SP_PURE)) == SP_REFL) {
127                  /*
128                   *  Compute specular reflection coefficient using
# Line 137 | Line 149 | dirnorm(               /* compute source contribution */
149                          addcolor(cval, ctmp);
150                  }
151          }
152 <        if (ldot < -FTINY && ltdiff > FTINY) {
153 <                /*
142 <                 *  Compute diffuse transmission.
143 <                 */
144 <                copycolor(ctmp, np->mcolor);
145 <                dtmp = -ldot * omega * ltdiff * (1.0/PI);
146 <                scalecolor(ctmp, dtmp);
147 <                addcolor(cval, ctmp);
148 <        }
152 >        
153 >
154          if (ldot < -FTINY && (np->specfl&(SP_TRAN|SP_PURE)) == SP_TRAN) {
155                  /*
156                   *  Compute specular transmission.  Specular transmission
# Line 180 | Line 185 | m_normal(                      /* color a ray that hit something normal *
185          double  d;
186          COLOR  ctmp;
187          int  i;
188 +
189 +        /* PMAP: skip transmitted shadow ray if accounted for in photon map */
190 +        if (shadowRayInPmap(r))
191 +                return(1);
192                                                  /* easy shadow test */
193          if (r->crtype & SHADOW && m->otype != MAT_TRANS)
194                  return(1);
# Line 188 | Line 197 | m_normal(                      /* color a ray that hit something normal *
197                  objerror(m, USER, "bad number of arguments");
198                                                  /* check for back side */
199          if (r->rod < 0.0) {
200 <                if (!backvis && m->otype != MAT_TRANS) {
200 >                if (!backvis) {
201                          raytrans(r);
202                          return(1);
203                  }
# Line 239 | Line 248 | m_normal(                      /* color a ray that hit something normal *
248                          if (!(nd.specfl & SP_PURE) &&
249                                          specthresh >= nd.tspec-FTINY)
250                                  nd.specfl |= SP_TBLT;
251 <                        if (!hastexture || r->crtype & SHADOW) {
251 >                        if (!hastexture || r->crtype & (SHADOW|AMBIENT)) {
252                                  VCOPY(nd.prdir, r->rdir);
253                                  transtest = 2;
254                          } else {
# Line 254 | Line 263 | m_normal(                      /* color a ray that hit something normal *
263          } else
264                  nd.tdiff = nd.tspec = nd.trans = 0.0;
265                                                  /* transmitted ray */
266 +
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 */
# Line 306 | Line 316 | m_normal(                      /* color a ray that hit something normal *
316                          rayvalue(&lr);
317                          multcolor(lr.rcol, lr.rcoef);
318                          addcolor(r->rcol, lr.rcol);
319 <                        if (!hastexture && nd.specfl & SP_FLAT) {
319 >                        if (nd.specfl & SP_FLAT &&
320 >                                        !hastexture | (r->crtype & AMBIENT)) {
321                                  mirtest = 2.*bright(lr.rcol);
322                                  mirdist = r->rot + lr.rt;
323                          }
# Line 319 | Line 330 | m_normal(                      /* color a ray that hit something normal *
330                  return(1);                      /* 100% pure specular */
331  
332          if (!(nd.specfl & SP_PURE))
333 <                gaussamp(&nd);          /* checks *BLT flags */
333 >                gaussamp(&nd);                  /* checks *BLT flags */
334  
335          if (nd.rdiff > FTINY) {         /* ambient from this side */
336                  copycolor(ctmp, nd.mcolor);     /* modified by material color */
# Line 377 | Line 388 | gaussamp(                      /* sample Gaussian specular */
388                          (np->specfl & (SP_TRAN|SP_TBLT)) != SP_TRAN)
389                  return;
390                                          /* set up sample coordinates */
391 <        v[0] = v[1] = v[2] = 0.0;
381 <        for (i = 0; i < 3; i++)
382 <                if (np->pnorm[i] < 0.6 && np->pnorm[i] > -0.6)
383 <                        break;
384 <        v[i] = 1.0;
385 <        fcross(u, v, np->pnorm);
386 <        normalize(u);
391 >        getperpendicular(u, np->pnorm, rand_samp);
392          fcross(v, np->pnorm, u);
393                                          /* compute reflection */
394          if ((np->specfl & (SP_REFL|SP_RBLT)) == SP_REFL &&

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines