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

Comparing ray/src/rt/glass.c (file contents):
Revision 2.28 by greg, Fri Apr 19 19:01:32 2019 UTC vs.
Revision 2.29 by greg, Wed Nov 15 18:02:52 2023 UTC

# Line 49 | Line 49 | m_glass(               /* color a ray which hit a thin glass surfac
49   )
50   {
51          COLOR  mcolor;
52 +        SCOLOR  scoef;
53 +        double  ctemp[3];
54          double  pdot;
55          FVECT  pnorm;
56          double  rindex=0, cos2;
55        COLOR  trans, refl;
57          int  hastexture, hastrans;
58          double  d, r1e, r1m;
59          RAY  p;
# Line 87 | Line 88 | m_glass(               /* color a ray which hit a thin glass surfac
88          if (r->rod < 0.0)                       /* reorient if necessary */
89                  flipsurface(r);
90                                                  /* perturb normal */
91 <        if ( (hastexture = (DOT(r->pert,r->pert) > FTINY*FTINY)) ) {
91 >        hastexture = (DOT(r->pert,r->pert) > FTINY*FTINY);
92 >        if (hastexture) {
93                  pdot = raynormal(pnorm, r);
94          } else {
95                  VCOPY(pnorm, r->ron);
# Line 110 | Line 112 | m_glass(               /* color a ray which hit a thin glass surfac
112          if (hastrans) {
113                  for (i = 0; i < 3; i++) {
114                          d = colval(mcolor, i);
115 <                        colval(trans,i) = .5*(1.0-r1e)*(1.0-r1e)*d /
116 <                                                        (1.0-r1e*r1e*d*d);
117 <                        colval(trans,i) += .5*(1.0-r1m)*(1.0-r1m)*d /
115 >                        ctemp[i] = .5*(1.0-r1e)*(1.0-r1e)*d /
116 >                                                        (1.0-r1e*r1e*d*d) +
117 >                                        .5*(1.0-r1m)*(1.0-r1m)*d /
118                                                          (1.0-r1m*r1m*d*d);
119                  }
120 <                multcolor(trans, r->pcol);      /* modify by pattern */
120 >                setscolor(scoef, ctemp[RED], ctemp[GRN], ctemp[BLU]);
121 >                smultscolor(scoef, r->pcol);    /* modify by pattern */
122                                                  /* transmitted ray */
123 <                if (rayorigin(&p, TRANS, r, trans) == 0) {
123 >                if (rayorigin(&p, TRANS, r, scoef) == 0) {
124                          if (!(r->crtype & (SHADOW|AMBIENT)) && hastexture) {
125                                  VSUM(p.rdir, r->rdir, r->pert, 2.*(1.-rindex));
126                                  if (normalize(p.rdir) == 0.0) {
# Line 128 | Line 131 | m_glass(               /* color a ray which hit a thin glass surfac
131                                  VCOPY(p.rdir, r->rdir);
132                          }
133                          rayvalue(&p);
134 <                        multcolor(p.rcol, p.rcoef);
135 <                        addcolor(r->rcol, p.rcol);
134 >                        smultscolor(p.rcol, p.rcoef);
135 >                        saddscolor(r->rcol, p.rcol);
136                          if (!hastexture || r->crtype & (SHADOW|AMBIENT))
137                                  r->rxt = r->rot + raydistance(&p);
138                  }
# Line 140 | Line 143 | m_glass(               /* color a ray which hit a thin glass surfac
143          for (i = 0; i < 3; i++) {
144                  d = colval(mcolor, i);
145                  d *= d;
146 <                colval(refl,i) = .5*r1e*(1.0+(1.0-2.0*r1e)*d)/(1.0-r1e*r1e*d);
147 <                colval(refl,i) += .5*r1m*(1.0+(1.0-2.0*r1m)*d)/(1.0-r1m*r1m*d);
146 >                ctemp[i] = .5*r1e*(1.0+(1.0-2.0*r1e)*d)/(1.0-r1e*r1e*d) +
147 >                                .5*r1m*(1.0+(1.0-2.0*r1m)*d)/(1.0-r1m*r1m*d);
148          }
149 +        setscolor(scoef, ctemp[RED], ctemp[GRN], ctemp[BLU]);
150                                                  /* reflected ray */
151 <        if (rayorigin(&p, REFLECTED, r, refl) == 0) {
151 >        if (rayorigin(&p, REFLECTED, r, scoef) == 0) {
152                  VSUM(p.rdir, r->rdir, pnorm, 2.*pdot);
153                  checknorm(p.rdir);
154                  rayvalue(&p);
155 <                multcolor(p.rcol, p.rcoef);
156 <                copycolor(r->mcol, p.rcol);
157 <                addcolor(r->rcol, p.rcol);
155 >                smultscolor(p.rcol, p.rcoef);
156 >                copyscolor(r->mcol, p.rcol);
157 >                saddscolor(r->rcol, p.rcol);
158                  r->rmt = r->rot;
159                  if (r->ro != NULL && isflat(r->ro->otype) &&
160                                  !hastexture | (r->crtype & AMBIENT))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines