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.11 by greg, Thu Jan 13 09:45:11 1994 UTC vs.
Revision 2.13 by greg, Mon Jan 24 11:51:31 1994 UTC

# Line 200 | Line 200 | OBJECT  fore, back;
200   double  coef;
201   {
202          RAY  fr, br;
203        COLOR  ctmp;
203          int  foremat, backmat;
204          register int  i;
205                                          /* clip coefficient */
# Line 208 | Line 207 | double  coef;
207                  coef = 1.0;
208          else if (coef < 0.0)
209                  coef = 0.0;
210 +                                        /* compute foreground and background */
211 +        foremat = backmat = -1;
212                                          /* foreground */
213          copystruct(&fr, r);
213        fr.pert[0] = fr.pert[1] = fr.pert[2] = 0.0;
214        setcolor(fr.pcol, 1.0, 1.0, 1.0);
215        setcolor(fr.rcol, 0.0, 0.0, 0.0);
214          if (fore != OVOID && coef > FTINY)
215                  foremat = rayshade(&fr, fore);
218        else
219                foremat = 0;
216                                          /* background */
217          copystruct(&br, r);
222        br.pert[0] = br.pert[1] = br.pert[2] = 0.0;
223        setcolor(br.pcol, 1.0, 1.0, 1.0);
224        setcolor(br.rcol, 0.0, 0.0, 0.0);
218          if (back != OVOID && coef < 1.0-FTINY)
219                  backmat = rayshade(&br, back);
227        else
228                backmat = foremat;
220                                          /* check */
221 <        if ((backmat==0) != (foremat==0))
221 >        if (foremat < 0)
222 >                if (backmat < 0)
223 >                        foremat = backmat = 0;
224 >                else
225 >                        foremat = backmat;
226 >        else if (backmat < 0)
227 >                backmat = foremat;
228 >        if ((foremat==0) != (backmat==0))
229                  objerror(r->ro, USER, "mixing material with non-material");
230 <                                        /* sum perturbations */
230 >                                        /* mix perturbations */
231          for (i = 0; i < 3; i++)
232 <                r->pert[i] += coef*fr.pert[i] + (1.0-coef)*br.pert[i];
233 <                                        /* multiply pattern colors */
232 >                r->pert[i] = coef*fr.pert[i] + (1.0-coef)*br.pert[i];
233 >                                        /* mix pattern colors */
234          scalecolor(fr.pcol, coef);
235          scalecolor(br.pcol, 1.0-coef);
236 <        copycolor(ctmp, fr.pcol);
237 <        addcolor(ctmp, br.pcol);
238 <        multcolor(r->pcol, ctmp);
239 <                                        /* sum returned ray values */
240 <        scalecolor(fr.rcol, coef);
241 <        scalecolor(br.rcol, 1.0-coef);
242 <        addcolor(r->rcol, fr.rcol);
243 <        addcolor(r->rcol, br.rcol);
246 <        if (foremat)
236 >        copycolor(r->pcol, fr.pcol);
237 >        addcolor(r->pcol, br.pcol);
238 >                                        /* mix returned ray values */
239 >        if (foremat) {
240 >                scalecolor(fr.rcol, coef);
241 >                scalecolor(br.rcol, 1.0-coef);
242 >                copycolor(r->rcol, fr.rcol);
243 >                addcolor(r->rcol, br.rcol);
244                  r->rt = bright(fr.rcol) > bright(br.rcol) ? fr.rt : br.rt;
245 +        }
246                                          /* return value tells if material */
247          return(foremat);
248   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines