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 |
> |
|
101 |
> |
if ((ldot < -FTINY) & (np->tdiff > FTINY)) { |
102 |
|
/* |
103 |
+ |
* Compute diffuse transmission. |
104 |
+ |
*/ |
105 |
+ |
copycolor(ctmp, np->mcolor); |
106 |
+ |
dtmp = -ldot * omega * np->tdiff * (1.0/PI); |
107 |
+ |
scalecolor(ctmp, dtmp); |
108 |
+ |
addcolor(cval, ctmp); |
109 |
+ |
} |
110 |
+ |
|
111 |
+ |
if (ldot > FTINY && np->specfl&SP_REFL) { |
112 |
+ |
/* |
113 |
|
* Compute specular reflection coefficient using |
114 |
|
* anisotropic Gaussian distribution model. |
115 |
|
*/ |
141 |
|
addcolor(cval, ctmp); |
142 |
|
} |
143 |
|
} |
144 |
< |
if ((ldot < -FTINY) & (np->tdiff > FTINY)) { |
144 |
> |
|
145 |
> |
if (ldot < -FTINY && np->specfl&SP_TRAN) { |
146 |
|
/* |
136 |
– |
* Compute diffuse transmission. |
137 |
– |
*/ |
138 |
– |
copycolor(ctmp, np->mcolor); |
139 |
– |
dtmp = -ldot * omega * np->tdiff * (1.0/PI); |
140 |
– |
scalecolor(ctmp, dtmp); |
141 |
– |
addcolor(cval, ctmp); |
142 |
– |
} |
143 |
– |
if (ldot < -FTINY && (np->specfl&(SP_TRAN|SP_BADU)) == SP_TRAN) { |
144 |
– |
/* |
147 |
|
* Compute specular transmission. Specular transmission |
148 |
|
* is always modified by material color. |
149 |
|
*/ |
196 |
|
objerror(m, USER, "bad number of real arguments"); |
197 |
|
/* check for back side */ |
198 |
|
if (r->rod < 0.0) { |
199 |
< |
if (!backvis && m->otype != MAT_TRANS2) { |
199 |
> |
if (!backvis) { |
200 |
|
raytrans(r); |
201 |
|
return(1); |
202 |
|
} |
270 |
|
|
271 |
|
getacoords(&nd); /* set up coordinates */ |
272 |
|
|
273 |
< |
if (nd.specfl & (SP_REFL|SP_TRAN) && !(nd.specfl & SP_BADU)) |
273 |
> |
if (nd.specfl & (SP_REFL|SP_TRAN)) |
274 |
|
agaussamp(&nd); |
275 |
|
|
276 |
|
if (nd.rdiff > FTINY) { /* ambient from this side */ |
281 |
|
multambient(ctmp, r, nd.pnorm); |
282 |
|
addcolor(r->rcol, ctmp); /* add to returned color */ |
283 |
|
} |
284 |
+ |
|
285 |
|
if (nd.tdiff > FTINY) { /* ambient from other side */ |
286 |
|
FVECT bnorm; |
287 |
|
|
304 |
|
return(1); |
305 |
|
} |
306 |
|
|
304 |
– |
|
307 |
|
static void |
308 |
|
getacoords( /* set up coordinate system */ |
309 |
|
ANISODAT *np |
317 |
|
errno = 0; |
318 |
|
for (i = 0; i < 3; i++) |
319 |
|
np->u[i] = evalue(mf->ep[i]); |
320 |
< |
if ((errno == EDOM) | (errno == ERANGE)) { |
321 |
< |
objerror(np->mp, WARNING, "compute error"); |
320 |
< |
np->specfl |= SP_BADU; |
321 |
< |
return; |
322 |
< |
} |
320 |
> |
if ((errno == EDOM) | (errno == ERANGE)) |
321 |
> |
np->u[0] = np->u[1] = np->u[2] = 0.0; |
322 |
|
if (mf->fxp != &unitxf) |
323 |
|
multv3(np->u, np->u, mf->fxp->xfm); |
324 |
|
fcross(np->v, np->pnorm, np->u); |
325 |
|
if (normalize(np->v) == 0.0) { |
326 |
< |
objerror(np->mp, WARNING, "illegal orientation vector"); |
327 |
< |
np->specfl |= SP_BADU; |
328 |
< |
return; |
329 |
< |
} |
330 |
< |
fcross(np->u, np->v, np->pnorm); |
326 |
> |
if (fabs(np->u_alpha - np->v_alpha) > 0.001) |
327 |
> |
objerror(np->mp, WARNING, "illegal orientation vector"); |
328 |
> |
getperpendicular(np->u, np->pnorm, 1); /* punting */ |
329 |
> |
fcross(np->v, np->pnorm, np->u); |
330 |
> |
np->u_alpha = np->v_alpha = sqrt( 0.5 * |
331 |
> |
(np->u_alpha*np->u_alpha + np->v_alpha*np->v_alpha) ); |
332 |
> |
} else |
333 |
> |
fcross(np->u, np->v, np->pnorm); |
334 |
|
} |
335 |
|
|
336 |
|
|