ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/dielectric.c
(Generate patch)

Comparing ray/src/rt/dielectric.c (file contents):
Revision 2.18 by schorsch, Tue Mar 30 16:13:01 2004 UTC vs.
Revision 2.19 by greg, Thu Sep 9 06:46:07 2004 UTC

# Line 74 | Line 74 | m_dielectric(  /* color a ray which hit a dielectric in
74          COLOR  ctrans;
75          COLOR  talb;
76          int  hastexture;
77 +        double  transdist, transtest=0;
78 +        double  mirdist, mirtest=0;
79 +        int     flatsurface;
80          double  refl, trans;
81          FVECT  dnorm;
82          double  d1, d2;
# Line 91 | Line 94 | m_dielectric(  /* color a ray which hit a dielectric in
94                  VCOPY(dnorm, r->ron);
95                  cos1 = r->rod;
96          }
97 +        flatsurface = !hastexture && r->ro != NULL && isflat(r->ro->otype);
98 +
99                                                  /* index of refraction */
100          if (m->otype == MAT_DIELECTRIC)
101                  nratio = m->oargs.farg[3] + m->oargs.farg[4]/MLAMBDA;
# Line 189 | Line 194 | m_dielectric(  /* color a ray which hit a dielectric in
194                                  rayvalue(&p);
195                                  scalecolor(p.rcol, trans);
196                                  addcolor(r->rcol, p.rcol);
197 <                                if (nratio >= 1.0-FTINY && nratio <= 1.0+FTINY)
198 <                                        r->rt = r->rot + p.rt;
197 >                                                /* virtual distance */
198 >                                if (flatsurface ||
199 >                                        (1.-FTINY <= nratio &&
200 >                                                nratio <= 1.+FTINY)) {
201 >                                        transtest = 2*bright(p.rcol);
202 >                                        transdist = r->rot + p.rt;
203 >                                }
204                          }
205                  }
206          }
# Line 210 | Line 220 | m_dielectric(  /* color a ray which hit a dielectric in
220  
221                  scalecolor(p.rcol, refl);       /* color contribution */
222                  addcolor(r->rcol, p.rcol);
223 +                                                /* virtual distance */
224 +                if (flatsurface) {
225 +                        mirtest = 2*bright(p.rcol);
226 +                        mirdist = r->rot + p.rt;
227 +                }
228          }
229 +                                /* check distance to return */
230 +        d1 = bright(r->rcol);
231 +        if (transtest > d1)
232 +                r->rt = transdist;
233 +        else if (mirtest > d1)
234 +                r->rt = mirdist;
235                                  /* rayvalue() computes absorption */
236          return(1);
237   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines