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

Comparing ray/src/rt/raytrace.c (file contents):
Revision 2.23 by greg, Fri Dec 8 18:49:09 1995 UTC vs.
Revision 2.24 by greg, Thu Mar 21 15:33:05 1996 UTC

# Line 109 | Line 109 | raytrace(r)                    /* trace a ray and compute its value */
109   RAY  *r;
110   {
111          extern int  (*trace)();
112        int  gotmat;
112  
113          if (localhit(r, &thescene))
114 <                gotmat = raycont(r);    /* hit local surface, evaluate */
114 >                raycont(r);             /* hit local surface, evaluate */
115          else if (r->ro == &Aftplane) {
116                  r->ro = NULL;           /* hit aft clipping plane */
117                  r->rot = FHUGE;
118          } else if (sourcehit(r))
119 <                gotmat = rayshade(r, r->ro->omod);      /* distant source */
119 >                rayshade(r, r->ro->omod);       /* distant source */
120  
122        if (r->ro != NULL && !gotmat)
123                objerror(r->ro, USER, "material not found");
124
121          rayparticipate(r);              /* for participating medium */
122  
123          if (trace != NULL)
# Line 133 | Line 129 | raycont(r)                     /* check for clipped object and continue
129   register RAY  *r;
130   {
131          if ((r->clipset != NULL && inset(r->clipset, r->ro->omod)) ||
132 <                        r->ro->omod == OVOID) {
132 >                        !rayshade(r, r->ro->omod))
133                  raytrans(r);
138                return(1);
139        }
140        return(rayshade(r, r->ro->omod));
134   }
135  
136  
# Line 260 | Line 253 | double  coef;
253          RAY  fr, br;
254          int  foremat, backmat;
255          register int  i;
256 <                                        /* clip coefficient */
256 >                                        /* bound coefficient */
257          if (coef > 1.0)
258                  coef = 1.0;
259          else if (coef < 0.0)
260                  coef = 0.0;
261                                          /* compute foreground and background */
262 <        foremat = backmat = -1;
262 >        foremat = backmat = 0;
263                                          /* foreground */
264          copystruct(&fr, r);
265 <        if (fore != OVOID && coef > FTINY)
265 >        if (coef > FTINY)
266                  foremat = rayshade(&fr, fore);
267                                          /* background */
268          copystruct(&br, r);
269 <        if (back != OVOID && coef < 1.0-FTINY)
269 >        if (coef < 1.0-FTINY)
270                  backmat = rayshade(&br, back);
271 <                                        /* check */
272 <        if (foremat < 0)
273 <                if (backmat < 0)
274 <                        foremat = backmat = 0;
271 >                                        /* check for transparency */
272 >        if (backmat ^ foremat)
273 >                if (backmat)
274 >                        raytrans(&fr);
275                  else
276 <                        foremat = backmat;
284 <        else if (backmat < 0)
285 <                backmat = foremat;
286 <        if ((foremat==0) != (backmat==0))
287 <                objerror(r->ro, USER, "mixing material with non-material");
276 >                        raytrans(&br);
277                                          /* mix perturbations */
278          for (i = 0; i < 3; i++)
279                  r->pert[i] = coef*fr.pert[i] + (1.0-coef)*br.pert[i];
# Line 293 | Line 282 | double  coef;
282          scalecolor(br.pcol, 1.0-coef);
283          copycolor(r->pcol, fr.pcol);
284          addcolor(r->pcol, br.pcol);
296                                        /* mix returned ray values */
297        if (foremat) {
298                scalecolor(fr.rcol, coef);
299                scalecolor(br.rcol, 1.0-coef);
300                copycolor(r->rcol, fr.rcol);
301                addcolor(r->rcol, br.rcol);
302                r->rt = bright(fr.rcol) > bright(br.rcol) ? fr.rt : br.rt;
303        }
285                                          /* return value tells if material */
286 <        return(foremat);
286 >        if (!foremat & !backmat)
287 >                return(0);
288 >                                        /* mix returned ray values */
289 >        scalecolor(fr.rcol, coef);
290 >        scalecolor(br.rcol, 1.0-coef);
291 >        copycolor(r->rcol, fr.rcol);
292 >        addcolor(r->rcol, br.rcol);
293 >        r->rt = bright(fr.rcol) > bright(br.rcol) ? fr.rt : br.rt;
294 >        return(1);
295   }
296  
297  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines