217 |
|
EPNODE **exa = wp->mf->ep + 3*(trans != 0); |
218 |
|
double coef; |
219 |
|
/* constant zero check */ |
220 |
< |
if (exa[0]->type == NUM && exa[0]->v.num <= FTINY) { |
221 |
< |
scolorblack(sp->scol); |
222 |
< |
return; |
223 |
< |
} /* need modifier */ |
220 |
> |
if (exa[0]->type == NUM && exa[0]->v.num <= FTINY) |
221 |
> |
goto blackout; |
222 |
> |
/* need modifier */ |
223 |
|
sp->mo.nam = wp->mtp->oargs.sarg[4*(trans != 0)]; |
224 |
|
if (!fill_modval(&sp->mo, wp)) { |
225 |
|
sprintf(errmsg, "unknown specular %s modifier '%s'", |
226 |
|
trans ? "transmission" : "reflection", sp->mo.nam); |
227 |
|
objerror(wp->mtp, USER, errmsg); |
228 |
|
} |
229 |
< |
setWGMDfunc(&sp->mo, wp); |
229 |
> |
if (sintens(sp->mo.pcol) <= FTINY) |
230 |
> |
goto blackout; /* got black pattern */ |
231 |
> |
setWGMDfunc(&sp->mo, wp); /* else compute coefficient */ |
232 |
|
errno = 0; |
233 |
|
coef = evalue(exa[0]); |
234 |
|
if ((errno == EDOM) | (errno == ERANGE)) { |
235 |
|
objerror(wp->mtp, WARNING, "specular compute error"); |
236 |
< |
scolorblack(sp->scol); |
236 |
< |
return; |
236 |
> |
goto blackout; |
237 |
|
} |
238 |
< |
if (coef <= FTINY) { /* negligible value? */ |
239 |
< |
scolorblack(sp->scol); |
240 |
< |
return; |
241 |
< |
} |
238 |
> |
if (coef <= FTINY) /* negligible value? */ |
239 |
> |
goto blackout; |
240 |
|
copyscolor(sp->scol, sp->mo.pcol); |
241 |
|
scalescolor(sp->scol, coef); |
244 |
– |
if (sintens(sp->scol) <= FTINY) { |
245 |
– |
scolorblack(sp->scol); |
246 |
– |
return; /* got black pattern */ |
247 |
– |
} |
242 |
|
errno = 0; /* else get roughness */ |
243 |
|
sp->u_alpha = evalue(exa[1]); |
244 |
|
sp->v_alpha = (sp->u_alpha > FTINY) ? evalue(exa[2]) : 0.0; |
245 |
|
if ((errno == EDOM) | (errno == ERANGE)) { |
246 |
|
objerror(wp->mtp, WARNING, "roughness compute error"); |
247 |
< |
scolorblack(sp->scol); |
254 |
< |
return; |
247 |
> |
goto blackout; |
248 |
|
} /* we have something... */ |
249 |
|
wp->specfl |= trans ? SP_TRAN : SP_REFL; |
250 |
|
if (sp->v_alpha <= FTINY) { /* is it pure specular? */ |
251 |
|
wp->specfl |= trans ? SP_TPURE : SP_RPURE; |
252 |
|
sp->u_alpha = sp->v_alpha = 0.0; |
253 |
|
return; |
254 |
< |
} |
262 |
< |
/* get anisotropic coordinates */ |
254 |
> |
} /* else get aniso coordinates */ |
255 |
|
fcross(sp->v, sp->mo.pnorm, wp->ulocal); |
256 |
|
if (normalize(sp->v) == 0.0) { /* orientation vector==normal? */ |
257 |
|
if (fabs(sp->u_alpha - sp->v_alpha) > 0.001) |
262 |
|
(sp->u_alpha*sp->u_alpha + sp->v_alpha*sp->v_alpha) ); |
263 |
|
} else |
264 |
|
fcross(sp->u, sp->v, sp->mo.pnorm); |
265 |
+ |
return; |
266 |
+ |
blackout: |
267 |
+ |
scolorblack(sp->scol); /* zero out component */ |
268 |
|
} |
269 |
|
|
270 |
|
/* sample anisotropic Gaussian specular */ |