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.9 by greg, Wed Jan 12 16:52:08 1994 UTC vs.
Revision 2.14 by greg, Tue Jan 25 10:18:25 1994 UTC

# Line 98 | Line 98 | RAY  *r;
98          else if (sourcehit(r))
99                  gotmat = rayshade(r, r->ro->omod);
100  
101 <        if (!gotmat)
101 >        if (r->ro != NULL && !gotmat)
102                  objerror(r->ro, USER, "material not found");
103  
104          if (trace != NULL)
# Line 188 | Line 188 | int  mod;
188                  }
189                  ******/
190                  if ((*ofun[m->otype].funp)(m, r))
191 <                        objerror(USER, r->ro, "conflicting materials");
191 >                        objerror(r->ro, USER, "conflicting materials");
192          }
193          depth--;                        /* end here */
194   }
# 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 != foremat)
222 <                objerror(USER, r->ro, "mixing material with non-material");
223 <                                        /* sum perturbations */
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 >                                        /* 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);
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