16 |
|
|
17 |
|
#include "func.h" |
18 |
|
|
19 |
+ |
extern int backvis; /* back faces visible? */ |
20 |
+ |
|
21 |
|
/* |
22 |
|
* Arguments to this material include the color and specularity. |
23 |
|
* String arguments include the reflection function and files. |
24 |
|
* The BRDF is currently used just for the specular component to light |
25 |
|
* sources. Reflectance values or data coordinates are functions |
26 |
< |
* of the direction to the light source. |
26 |
> |
* of the direction to the light source. (Data modification functions |
27 |
> |
* are passed the source direction as args 2-4.) |
28 |
|
* We orient the surface towards the incoming ray, so a single |
29 |
|
* surface can be used to represent an infinitely thin object. |
30 |
|
* |
91 |
|
COLOR ctmp; |
92 |
|
FVECT ldx; |
93 |
|
double lddx[3], pt[MAXDIM]; |
94 |
+ |
double vldx[4]; |
95 |
|
register char **sa; |
96 |
|
register int i; |
97 |
|
|
157 |
|
} else { |
158 |
|
for (i = 0; i < np->dp->nd; i++) |
159 |
|
pt[i] = funvalue(sa[3+i], 3, lddx); |
160 |
< |
dtmp = datavalue(np->dp, pt); |
161 |
< |
dtmp = funvalue(sa[0], 1, &dtmp); |
160 |
> |
vldx[0] = datavalue(np->dp, pt); |
161 |
> |
vldx[1] = lddx[0]; vldx[2] = lddx[1]; vldx[3] = lddx[2]; |
162 |
> |
dtmp = funvalue(sa[0], 4, vldx); |
163 |
|
setcolor(ctmp, dtmp, dtmp, dtmp); |
164 |
|
} |
165 |
|
if (errno) { |
199 |
|
double transtest, transdist; |
200 |
|
int hasrefl, hastrans; |
201 |
|
COLOR ctmp; |
197 |
– |
double dtmp; |
202 |
|
register MFUNC *mf; |
203 |
|
register int i; |
204 |
|
/* check arguments */ |
243 |
|
/* compute transmitted ray */ |
244 |
|
setbrdfunc(&nd); |
245 |
|
transtest = 0; |
246 |
+ |
transdist = r->rot; |
247 |
|
errno = 0; |
248 |
|
setcolor(ctmp, evalue(mf->ep[3]), |
249 |
|
evalue(mf->ep[4]), |
270 |
|
transdist = r->rot + sr.rt; |
271 |
|
} |
272 |
|
if (r->crtype & SHADOW) /* the rest is shadow */ |
273 |
< |
return; |
273 |
> |
return(1); |
274 |
|
/* compute reflected ray */ |
275 |
|
setbrdfunc(&nd); |
276 |
|
errno = 0; |
310 |
|
/* check distance */ |
311 |
|
if (transtest > bright(r->rcol)) |
312 |
|
r->rt = transdist; |
313 |
+ |
|
314 |
+ |
return(1); |
315 |
|
} |
316 |
|
|
317 |
|
|
325 |
|
double dtmp; |
326 |
|
/* always a shadow */ |
327 |
|
if (r->crtype & SHADOW) |
328 |
< |
return; |
328 |
> |
return(1); |
329 |
|
/* check arguments */ |
330 |
|
if (m->oargs.nsargs < (hasdata(m->otype)?4:2) | m->oargs.nfargs < |
331 |
|
(m->otype==MAT_TFUNC|m->otype==MAT_TDATA?6:4)) |
351 |
|
/* compute reflectance */ |
352 |
|
dtmp = 1.0 - nd.trans - nd.rspec; |
353 |
|
setcolor(nd.rdiff, dtmp, dtmp, dtmp); |
354 |
< |
/* fix orientation */ |
355 |
< |
if (r->rod < 0.0) |
356 |
< |
flipsurface(r); |
354 |
> |
/* check for back side */ |
355 |
> |
if (r->rod < 0.0) { |
356 |
> |
if (!backvis && m->otype != MAT_TFUNC |
357 |
> |
&& m->otype != MAT_TDATA) { |
358 |
> |
raytrans(r); |
359 |
> |
return(1); |
360 |
> |
} |
361 |
> |
flipsurface(r); /* reorient if backvis */ |
362 |
> |
} |
363 |
|
/* get modifiers */ |
364 |
|
raytexture(r, m->omod); |
365 |
|
nd.pdot = raynormal(nd.pnorm, r); /* perturb normal */ |
391 |
|
} |
392 |
|
/* add direct component */ |
393 |
|
direct(r, dirbrdf, &nd); |
394 |
+ |
|
395 |
+ |
return(1); |
396 |
|
} |
397 |
|
|
398 |
|
|