41 |
|
#define SP_FLAT 04 /* reflecting surface is flat */ |
42 |
|
#define SP_RBLT 010 /* reflection below sample threshold */ |
43 |
|
#define SP_TBLT 020 /* transmission below threshold */ |
44 |
– |
#define SP_BADU 040 /* bad u direction calculation */ |
44 |
|
|
45 |
|
typedef struct { |
46 |
|
OBJREC *mp; /* material pointer */ |
97 |
|
scalecolor(ctmp, dtmp); |
98 |
|
addcolor(cval, ctmp); |
99 |
|
} |
100 |
< |
if (ldot > FTINY && (np->specfl&(SP_REFL|SP_BADU)) == SP_REFL) { |
100 |
> |
if (ldot > FTINY && np->specfl&SP_REFL) { |
101 |
|
/* |
102 |
|
* Compute specular reflection coefficient using |
103 |
|
* anisotropic Gaussian distribution model. |
139 |
|
scalecolor(ctmp, dtmp); |
140 |
|
addcolor(cval, ctmp); |
141 |
|
} |
142 |
< |
if (ldot < -FTINY && (np->specfl&(SP_TRAN|SP_BADU)) == SP_TRAN) { |
142 |
> |
if (ldot < -FTINY && np->specfl&SP_TRAN) { |
143 |
|
/* |
144 |
|
* Compute specular transmission. Specular transmission |
145 |
|
* is always modified by material color. |
267 |
|
|
268 |
|
getacoords(&nd); /* set up coordinates */ |
269 |
|
|
270 |
< |
if (nd.specfl & (SP_REFL|SP_TRAN) && !(nd.specfl & SP_BADU)) |
270 |
> |
if (nd.specfl & (SP_REFL|SP_TRAN)) |
271 |
|
agaussamp(&nd); |
272 |
|
|
273 |
|
if (nd.rdiff > FTINY) { /* ambient from this side */ |
314 |
|
errno = 0; |
315 |
|
for (i = 0; i < 3; i++) |
316 |
|
np->u[i] = evalue(mf->ep[i]); |
317 |
< |
if ((errno == EDOM) | (errno == ERANGE)) { |
318 |
< |
objerror(np->mp, WARNING, "compute error"); |
320 |
< |
np->specfl |= SP_BADU; |
321 |
< |
return; |
322 |
< |
} |
317 |
> |
if ((errno == EDOM) | (errno == ERANGE)) |
318 |
> |
np->u[0] = np->u[1] = np->u[2] = 0.0; |
319 |
|
if (mf->fxp != &unitxf) |
320 |
|
multv3(np->u, np->u, mf->fxp->xfm); |
321 |
|
fcross(np->v, np->pnorm, np->u); |
322 |
|
if (normalize(np->v) == 0.0) { |
323 |
< |
objerror(np->mp, WARNING, "illegal orientation vector"); |
324 |
< |
np->specfl |= SP_BADU; |
325 |
< |
return; |
326 |
< |
} |
327 |
< |
fcross(np->u, np->v, np->pnorm); |
323 |
> |
if (fabs(np->u_alpha - np->v_alpha) > 0.001) |
324 |
> |
objerror(np->mp, WARNING, "illegal orientation vector"); |
325 |
> |
getperpendicular(np->u, np->pnorm); /* punting */ |
326 |
> |
fcross(np->v, np->pnorm, np->u); |
327 |
> |
np->u_alpha = np->v_alpha = sqrt( 0.5 * |
328 |
> |
(np->u_alpha*np->u_alpha + np->v_alpha*np->v_alpha) ); |
329 |
> |
} else |
330 |
> |
fcross(np->u, np->v, np->pnorm); |
331 |
|
} |
332 |
|
|
333 |
|
|