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