209 |
|
int hitfront = 1; |
210 |
|
BRDFDAT nd; |
211 |
|
RAY sr; |
212 |
– |
double mirtest=0, mirdist; |
213 |
– |
double transtest=0, transdist; |
212 |
|
int hasrefl, hastrans; |
213 |
|
int hastexture; |
214 |
|
COLOR ctmp; |
259 |
|
multcolor(nd.tdiff, nd.mcolor); |
260 |
|
hasrefl = (bright(nd.rdiff) > FTINY); |
261 |
|
hastrans = (bright(nd.tdiff) > FTINY); |
264 |
– |
mirdist = transdist = r->rot; |
262 |
|
/* load cal file */ |
263 |
|
nd.dp = NULL; |
264 |
|
mf = getfunc(m, 9, 0x3f, 0); |
284 |
|
rayvalue(&sr); |
285 |
|
multcolor(sr.rcol, sr.rcoef); |
286 |
|
addcolor(r->rcol, sr.rcol); |
287 |
< |
if (!hastexture || r->crtype & (SHADOW|AMBIENT)) { |
288 |
< |
transtest = 2.0*bright(sr.rcol); |
292 |
< |
transdist = r->rot + sr.rt; |
293 |
< |
} |
287 |
> |
if (!hastexture || r->crtype & (SHADOW|AMBIENT)) |
288 |
> |
r->rxt = r->rot + raydistance(&sr); |
289 |
|
} |
290 |
< |
if (r->crtype & SHADOW) { /* the rest is shadow */ |
296 |
< |
r->rt = transdist; |
290 |
> |
if (r->crtype & SHADOW) /* the rest is shadow */ |
291 |
|
return(1); |
292 |
< |
} |
292 |
> |
|
293 |
|
/* compute reflected ray */ |
294 |
|
setbrdfunc(&nd); |
295 |
|
errno = 0; |
303 |
|
checknorm(sr.rdir); |
304 |
|
rayvalue(&sr); |
305 |
|
multcolor(sr.rcol, sr.rcoef); |
306 |
+ |
copycolor(r->mcol, sr.rcol); |
307 |
|
addcolor(r->rcol, sr.rcol); |
308 |
< |
if (!hastexture && r->ro != NULL && isflat(r->ro->otype)) { |
309 |
< |
mirtest = 2.0*bright(sr.rcol); |
310 |
< |
mirdist = r->rot + sr.rt; |
316 |
< |
} |
308 |
> |
if (r->ro != NULL && isflat(r->ro->otype) && |
309 |
> |
!hastexture | (r->crtype & AMBIENT)) |
310 |
> |
r->rmt = r->rot + raydistance(&sr); |
311 |
|
} |
312 |
|
/* compute ambient */ |
313 |
|
if (hasrefl) { |
333 |
|
} |
334 |
|
if (hasrefl | hastrans || m->oargs.sarg[6][0] != '0') |
335 |
|
direct(r, dirbrdf, &nd); /* add direct component */ |
342 |
– |
|
343 |
– |
d = bright(r->rcol); /* set effective distance */ |
344 |
– |
if (transtest > d) |
345 |
– |
r->rt = transdist; |
346 |
– |
else if (mirtest > d) |
347 |
– |
r->rt = mirdist; |
336 |
|
|
337 |
|
return(1); |
338 |
|
} |