71 |
|
) |
72 |
|
{ |
73 |
|
double cos1, cos2, nratio; |
74 |
< |
COLOR ctrans; |
75 |
< |
COLOR talb; |
74 |
> |
COLOR pcol, ctrans, talb; |
75 |
|
int hastexture; |
76 |
|
int flatsurface; |
77 |
|
double refl, trans; |
104 |
|
nratio = m->oargs.farg[3] + m->oargs.farg[4]/MLAMBDA; |
105 |
|
else |
106 |
|
nratio = m->oargs.farg[3] / m->oargs.farg[7]; |
107 |
< |
|
107 |
> |
|
108 |
> |
scolor_rgb(pcol, r->pcol); |
109 |
|
if (cos1 < 0.0) { /* inside */ |
110 |
|
hastexture = -hastexture; |
111 |
|
cos1 = -cos1; |
112 |
|
dnorm[0] = -dnorm[0]; |
113 |
|
dnorm[1] = -dnorm[1]; |
114 |
|
dnorm[2] = -dnorm[2]; |
115 |
< |
setcolor(r->cext, -mylog(m->oargs.farg[0]*colval(r->pcol,RED)), |
116 |
< |
-mylog(m->oargs.farg[1]*colval(r->pcol,GRN)), |
117 |
< |
-mylog(m->oargs.farg[2]*colval(r->pcol,BLU))); |
115 |
> |
setcolor(r->cext, -mylog(m->oargs.farg[0]*colval(pcol,RED)), |
116 |
> |
-mylog(m->oargs.farg[1]*colval(pcol,GRN)), |
117 |
> |
-mylog(m->oargs.farg[2]*colval(pcol,BLU))); |
118 |
|
setcolor(r->albedo, 0., 0., 0.); |
119 |
|
r->gecc = 0.; |
120 |
|
if (m->otype == MAT_INTERFACE) { |
121 |
|
setcolor(ctrans, |
122 |
< |
-mylog(m->oargs.farg[4]*colval(r->pcol,RED)), |
123 |
< |
-mylog(m->oargs.farg[5]*colval(r->pcol,GRN)), |
124 |
< |
-mylog(m->oargs.farg[6]*colval(r->pcol,BLU))); |
122 |
> |
-mylog(m->oargs.farg[4]*colval(pcol,RED)), |
123 |
> |
-mylog(m->oargs.farg[5]*colval(pcol,GRN)), |
124 |
> |
-mylog(m->oargs.farg[6]*colval(pcol,BLU))); |
125 |
|
setcolor(talb, 0., 0., 0.); |
126 |
|
} else { |
127 |
|
copycolor(ctrans, cextinction); |
130 |
|
} else { /* outside */ |
131 |
|
nratio = 1.0 / nratio; |
132 |
|
|
133 |
< |
setcolor(ctrans, -mylog(m->oargs.farg[0]*colval(r->pcol,RED)), |
134 |
< |
-mylog(m->oargs.farg[1]*colval(r->pcol,GRN)), |
135 |
< |
-mylog(m->oargs.farg[2]*colval(r->pcol,BLU))); |
133 |
> |
setcolor(ctrans, -mylog(m->oargs.farg[0]*colval(pcol,RED)), |
134 |
> |
-mylog(m->oargs.farg[1]*colval(pcol,GRN)), |
135 |
> |
-mylog(m->oargs.farg[2]*colval(pcol,BLU))); |
136 |
|
setcolor(talb, 0., 0., 0.); |
137 |
|
if (m->otype == MAT_INTERFACE) { |
138 |
|
setcolor(r->cext, |
139 |
< |
-mylog(m->oargs.farg[4]*colval(r->pcol,RED)), |
140 |
< |
-mylog(m->oargs.farg[5]*colval(r->pcol,GRN)), |
141 |
< |
-mylog(m->oargs.farg[6]*colval(r->pcol,BLU))); |
139 |
> |
-mylog(m->oargs.farg[4]*colval(pcol,RED)), |
140 |
> |
-mylog(m->oargs.farg[5]*colval(pcol,GRN)), |
141 |
> |
-mylog(m->oargs.farg[6]*colval(pcol,BLU))); |
142 |
|
setcolor(r->albedo, 0., 0., 0.); |
143 |
|
r->gecc = 0.; |
144 |
|
} |
168 |
|
|
169 |
|
trans *= nratio*nratio; /* solid angle ratio */ |
170 |
|
|
171 |
< |
setcolor(p.rcoef, trans, trans, trans); |
171 |
> |
setscolor(p.rcoef, trans, trans, trans); |
172 |
|
|
173 |
|
if (rayorigin(&p, REFRACTED, r, p.rcoef) == 0) { |
174 |
|
|
199 |
|
copycolor(p.cext, ctrans); |
200 |
|
copycolor(p.albedo, talb); |
201 |
|
rayvalue(&p); |
202 |
< |
multcolor(p.rcol, p.rcoef); |
203 |
< |
addcolor(r->rcol, p.rcol); |
202 |
> |
smultscolor(p.rcol, p.rcoef); |
203 |
> |
saddscolor(r->rcol, p.rcol); |
204 |
|
/* virtual distance */ |
205 |
|
if (flatsurface || |
206 |
|
(1.-FTINY <= nratio) & |
209 |
|
} |
210 |
|
} |
211 |
|
} |
212 |
< |
setcolor(p.rcoef, refl, refl, refl); |
212 |
> |
setscolor(p.rcoef, refl, refl, refl); |
213 |
|
|
214 |
|
if (!(r->crtype & SHADOW) && |
215 |
|
rayorigin(&p, REFLECTED, r, p.rcoef) == 0) { |
222 |
|
checknorm(p.rdir); |
223 |
|
rayvalue(&p); /* reflected ray value */ |
224 |
|
|
225 |
< |
multcolor(p.rcol, p.rcoef); /* color contribution */ |
226 |
< |
copycolor(r->mcol, p.rcol); |
227 |
< |
addcolor(r->rcol, p.rcol); |
225 |
> |
smultscolor(p.rcol, p.rcoef); /* color contribution */ |
226 |
> |
copyscolor(r->mcol, p.rcol); |
227 |
> |
saddscolor(r->rcol, p.rcol); |
228 |
|
/* virtual distance */ |
229 |
+ |
r->rmt = r->rot; |
230 |
|
if (flatsurface) |
231 |
< |
r->rmt = r->rot + raydistance(&p); |
231 |
> |
r->rmt += raydistance(&p); |
232 |
|
} |
233 |
|
/* rayvalue() computes absorption */ |
234 |
|
return(1); |
361 |
|
if (l2 < 0) |
362 |
|
continue; |
363 |
|
/* compute color from spectrum */ |
364 |
< |
if (l1 < l2) |
364 |
> |
if (l1 < l2) /* XXX should use direct spectral xfer */ |
365 |
|
spec_rgb(ctmp, l1, l2); |
366 |
|
else |
367 |
|
spec_rgb(ctmp, l2, l1); |
368 |
< |
multcolor(ctmp, sray.rcol); |
368 |
> |
multscolor(ctmp, sray.rcol); |
369 |
|
scalecolor(ctmp, tr); |
370 |
< |
addcolor(r->rcol, ctmp); |
370 |
> |
saddcolor(r->rcol, ctmp); |
371 |
|
success++; |
372 |
|
} |
373 |
|
return(success); |