73 |
|
return(-1); /* illegal continuation */ |
74 |
|
} |
75 |
|
r->rlvl = ro->rlvl; |
76 |
+ |
r->rsrc = ro->rsrc; |
77 |
|
if (rt & RAYREFL) { |
78 |
|
r->rlvl++; |
79 |
< |
r->rsrc = -1; |
79 |
> |
if (r->rsrc >= 0) /* malfunctioning material? */ |
80 |
> |
r->rsrc = -1; |
81 |
|
r->clipset = ro->clipset; |
82 |
|
r->rmax = 0.0; |
83 |
|
} else { |
82 |
– |
r->rsrc = ro->rsrc; |
84 |
|
r->clipset = ro->newcset; |
85 |
< |
r->rmax = ro->rmax <= FTINY ? 0.0 : ro->rmax - ro->rot; |
85 |
> |
r->rmax = (ro->rmax > FTINY)*(ro->rmax - ro->rot); |
86 |
|
} |
87 |
|
r->revf = ro->revf; |
88 |
|
copycolor(r->cext, ro->cext); |
213 |
|
RAY *r |
214 |
|
) |
215 |
|
{ |
216 |
< |
if (ofun[m->otype].flags & (T_M|T_X) && m->otype != MAT_CLIP) { |
217 |
< |
if (istransp(m->otype) || isBSDFproxy(m)) { |
216 |
> |
if (m->otype != MAT_CLIP && ismaterial(m->otype)) { |
217 |
> |
if (istransp(m) || isBSDFproxy(m)) { |
218 |
|
raytrans(r); |
219 |
|
return(1); |
220 |
|
} |
261 |
|
RAY *r |
262 |
|
) |
263 |
|
{ |
264 |
< |
SCOLOR ce, ca; |
264 |
> |
COLOR ce; |
265 |
|
double re, ge, be; |
266 |
|
|
267 |
|
if (intens(r->cext) <= 1./FHUGE) |
274 |
|
ge *= 1. - colval(r->albedo,GRN); |
275 |
|
be *= 1. - colval(r->albedo,BLU); |
276 |
|
} |
277 |
< |
setscolor(ce, re<=FTINY ? 1. : re>92. ? 0. : exp(-re), |
277 |
> |
setcolor(ce, re<=FTINY ? 1. : re>92. ? 0. : exp(-re), |
278 |
|
ge<=FTINY ? 1. : ge>92. ? 0. : exp(-ge), |
279 |
|
be<=FTINY ? 1. : be>92. ? 0. : exp(-be)); |
280 |
< |
smultscolor(r->rcol, ce); /* path extinction */ |
280 |
> |
smultcolor(r->rcol, ce); /* path extinction */ |
281 |
|
if (r->crtype & SHADOW || intens(r->albedo) <= FTINY) |
282 |
|
return; /* no scattering */ |
283 |
|
|
284 |
|
/* PMAP: indirect inscattering accounted for by volume photons? */ |
285 |
|
if (!volumePhotonMapping) { |
286 |
+ |
SCOLOR ca; |
287 |
|
setscolor(ca, |
288 |
|
colval(r->albedo,RED)*colval(ambval,RED)*(1.-colval(ce,RED)), |
289 |
|
colval(r->albedo,GRN)*colval(ambval,GRN)*(1.-colval(ce,GRN)), |
290 |
|
colval(r->albedo,BLU)*colval(ambval,BLU)*(1.-colval(ce,BLU))); |
291 |
< |
saddscolor(r->rcol, ca); /* ambient in scattering */ |
291 |
> |
saddscolor(r->rcol, ca); /* ambient in scattering */ |
292 |
|
} |
293 |
|
|
294 |
|
srcscatter(r); /* source in scattering */ |
412 |
|
) |
413 |
|
{ |
414 |
|
static int warnedPM = 0; |
415 |
+ |
double re, ge, be; |
416 |
+ |
SCOLOR ce; |
417 |
|
|
418 |
|
setscolor(rc, 1., 1., 1.); |
419 |
+ |
re = ge = be = 0.; |
420 |
|
|
421 |
|
while (r != NULL && r->crtype&flags) { |
422 |
+ |
/* include this ray coefficient */ |
423 |
|
smultscolor(rc, r->rcoef); |
424 |
< |
/* check for participating medium */ |
425 |
< |
if (!warnedPM && (bright(r->cext) > FTINY) | |
420 |
< |
(bright(r->albedo) > FTINY)) { |
424 |
> |
/* check participating medium */ |
425 |
> |
if (!warnedPM && bright(r->albedo) > FTINY) { |
426 |
|
error(WARNING, |
427 |
|
"ray contribution calculation does not support participating media"); |
428 |
|
warnedPM++; |
429 |
|
} |
430 |
+ |
/* sum PM extinction */ |
431 |
+ |
re += r->rot*colval(r->cext,RED); |
432 |
+ |
ge += r->rot*colval(r->cext,GRN); |
433 |
+ |
be += r->rot*colval(r->cext,BLU); |
434 |
+ |
/* descend the tree */ |
435 |
|
r = r->parent; |
436 |
|
} |
437 |
+ |
/* cumulative extinction */ |
438 |
+ |
setscolor(ce, re<=FTINY ? 1. : re>92. ? 0. : exp(-re), |
439 |
+ |
ge<=FTINY ? 1. : ge>92. ? 0. : exp(-ge), |
440 |
+ |
be<=FTINY ? 1. : be>92. ? 0. : exp(-be)); |
441 |
+ |
smultscolor(rc, ce); |
442 |
|
} |
443 |
|
|
444 |
|
|
469 |
|
return(r->rod); |
470 |
|
} |
471 |
|
newdot = -DOT(norm, r->rdir); |
472 |
< |
if ((newdot > 0.0) != (r->rod > 0.0)) { /* fix orientation */ |
472 |
> |
if ((newdot > 0.0) ^ (r->rod > 0.0)) { /* fix orientation */ |
473 |
|
for (i = 0; i < 3; i++) |
474 |
|
norm[i] += 2.0*newdot*r->rdir[i]; |
475 |
|
newdot = -newdot; |
558 |
|
return(1); /* old has material, new does not */ |
559 |
|
} else if (mray == NULL) { |
560 |
|
return(0); /* new has material, old does not */ |
561 |
< |
} else if (istransp(mnew->otype)) { |
562 |
< |
if (!istransp(mray->otype)) |
561 |
> |
} else if (istransp(mnew)) { |
562 |
> |
if (!istransp(mray)) |
563 |
|
return(1); /* new is transparent, old is not */ |
564 |
< |
} else if (istransp(mray->otype)) { |
564 |
> |
} else if (istransp(mray)) { |
565 |
|
return(0); /* old is transparent, new is not */ |
566 |
|
} |
567 |
|
if (rod <= 0) { /* check which side we hit */ |