| 38 |
|
* Arguments for MAT_TFUNC are: |
| 39 |
|
* 2+ func funcfile transform |
| 40 |
|
* 0 |
| 41 |
< |
* 4+ red grn blu rspec trans tspec A7 .. |
| 41 |
> |
* 6+ red grn blu rspec trans tspec A7 .. |
| 42 |
|
* |
| 43 |
|
* Arguments for MAT_TDATA are: |
| 44 |
|
* 4+ func datafile funcfile v0 .. transform |
| 45 |
|
* 0 |
| 46 |
< |
* 4+ red grn blu rspec trans tspec A7 .. |
| 46 |
> |
* 6+ red grn blu rspec trans tspec A7 .. |
| 47 |
|
* |
| 48 |
|
* Arguments for the more general MAT_BRTDF are: |
| 49 |
|
* 10+ rrefl grefl brefl |
| 77 |
|
} BRDFDAT; /* BRDF material data */ |
| 78 |
|
|
| 79 |
|
|
| 80 |
< |
static srcdirf_t dirbrdf; |
| 81 |
< |
static int setbrdfunc(BRDFDAT *np); |
| 80 |
> |
static int setbrdfunc(BRDFDAT *np); |
| 81 |
|
|
| 82 |
|
|
| 83 |
|
static void |
| 88 |
|
double omega /* light source size */ |
| 89 |
|
) |
| 90 |
|
{ |
| 91 |
< |
register BRDFDAT *np = nnp; |
| 91 |
> |
BRDFDAT *np = nnp; |
| 92 |
|
double ldot; |
| 93 |
|
double dtmp; |
| 94 |
|
COLOR ctmp; |
| 95 |
|
FVECT ldx; |
| 96 |
|
static double vldx[5], pt[MAXDIM]; |
| 97 |
< |
register char **sa; |
| 98 |
< |
register int i; |
| 97 |
> |
char **sa; |
| 98 |
> |
int i; |
| 99 |
|
#define lddx (vldx+1) |
| 100 |
|
|
| 101 |
|
setcolor(cval, 0.0, 0.0, 0.0); |
| 140 |
|
lddx[3] = omega; |
| 141 |
|
/* compute BRTDF */ |
| 142 |
|
if (np->mp->otype == MAT_BRTDF) { |
| 143 |
< |
if (sa[6][0] == '0') /* special case */ |
| 143 |
> |
if (sa[6][0] == '0' && !sa[6][1]) /* special case */ |
| 144 |
|
colval(ctmp,RED) = 0.0; |
| 145 |
|
else |
| 146 |
|
colval(ctmp,RED) = funvalue(sa[6], 4, lddx); |
| 147 |
< |
if (sa[7][0] == '0') |
| 147 |
> |
if (sa[7][0] == '0' && !sa[7][1]) |
| 148 |
|
colval(ctmp,GRN) = 0.0; |
| 149 |
|
else if (!strcmp(sa[7],sa[6])) |
| 150 |
|
colval(ctmp,GRN) = colval(ctmp,RED); |
| 151 |
|
else |
| 152 |
|
colval(ctmp,GRN) = funvalue(sa[7], 4, lddx); |
| 153 |
< |
if (!strcmp(sa[8],sa[6])) |
| 153 |
> |
if (sa[8][0] == '0' && !sa[8][1]) |
| 154 |
> |
colval(ctmp,BLU) = 0.0; |
| 155 |
> |
else if (!strcmp(sa[8],sa[6])) |
| 156 |
|
colval(ctmp,BLU) = colval(ctmp,RED); |
| 157 |
|
else if (!strcmp(sa[8],sa[7])) |
| 158 |
|
colval(ctmp,BLU) = colval(ctmp,GRN); |
| 198 |
|
} |
| 199 |
|
|
| 200 |
|
|
| 201 |
< |
extern int |
| 201 |
> |
int |
| 202 |
|
m_brdf( /* color a ray that hit a BRDTfunc material */ |
| 203 |
< |
register OBJREC *m, |
| 204 |
< |
register RAY *r |
| 203 |
> |
OBJREC *m, |
| 204 |
> |
RAY *r |
| 205 |
|
) |
| 206 |
|
{ |
| 207 |
|
int hitfront = 1; |
| 208 |
|
BRDFDAT nd; |
| 209 |
|
RAY sr; |
| 210 |
|
double mirtest=0, mirdist=0; |
| 211 |
< |
double transtest, transdist; |
| 211 |
> |
double transtest=0, transdist=0; |
| 212 |
|
int hasrefl, hastrans; |
| 213 |
|
int hastexture; |
| 214 |
|
COLOR ctmp; |
| 215 |
|
FVECT vtmp; |
| 216 |
|
double d; |
| 217 |
< |
register MFUNC *mf; |
| 218 |
< |
register int i; |
| 217 |
> |
MFUNC *mf; |
| 218 |
> |
int i; |
| 219 |
|
/* check arguments */ |
| 220 |
|
if ((m->oargs.nsargs < 10) | (m->oargs.nfargs < 9)) |
| 221 |
|
objerror(m, USER, "bad # arguments"); |
| 272 |
|
objerror(m, WARNING, "compute error"); |
| 273 |
|
else if (rayorigin(&sr, TRANS, r, ctmp) == 0) { |
| 274 |
|
if (!(r->crtype & SHADOW) && hastexture) { |
| 275 |
< |
for (i = 0; i < 3; i++) /* perturb direction */ |
| 276 |
< |
sr.rdir[i] = r->rdir[i] - .75*r->pert[i]; |
| 275 |
> |
/* perturb direction */ |
| 276 |
> |
VSUM(sr.rdir, r->rdir, r->pert, -.75); |
| 277 |
|
if (normalize(sr.rdir) == 0.0) { |
| 278 |
|
objerror(m, WARNING, "illegal perturbation"); |
| 279 |
|
VCOPY(sr.rdir, r->rdir); |
| 300 |
|
if ((errno == EDOM) | (errno == ERANGE)) |
| 301 |
|
objerror(m, WARNING, "compute error"); |
| 302 |
|
else if (rayorigin(&sr, REFLECTED, r, ctmp) == 0) { |
| 303 |
< |
for (i = 0; i < 3; i++) |
| 303 |
< |
sr.rdir[i] = r->rdir[i] + 2.0*nd.pdot*nd.pnorm[i]; |
| 303 |
> |
VSUM(sr.rdir, r->rdir, nd.pnorm, 2.*nd.pdot); |
| 304 |
|
checknorm(sr.rdir); |
| 305 |
|
rayvalue(&sr); |
| 306 |
|
multcolor(sr.rcol, sr.rcoef); |
| 346 |
|
|
| 347 |
|
|
| 348 |
|
|
| 349 |
< |
extern int |
| 349 |
> |
int |
| 350 |
|
m_brdf2( /* color a ray that hit a BRDF material */ |
| 351 |
< |
register OBJREC *m, |
| 352 |
< |
register RAY *r |
| 351 |
> |
OBJREC *m, |
| 352 |
> |
RAY *r |
| 353 |
|
) |
| 354 |
|
{ |
| 355 |
|
BRDFDAT nd; |
| 365 |
|
objerror(m, USER, "bad # arguments"); |
| 366 |
|
/* check for back side */ |
| 367 |
|
if (r->rod < 0.0) { |
| 368 |
< |
if (!backvis && m->otype != MAT_TFUNC |
| 369 |
< |
&& m->otype != MAT_TDATA) { |
| 368 |
> |
if (!backvis) { |
| 369 |
|
raytrans(r); |
| 370 |
|
return(1); |
| 371 |
|
} |
| 434 |
|
|
| 435 |
|
static int |
| 436 |
|
setbrdfunc( /* set up brdf function and variables */ |
| 437 |
< |
register BRDFDAT *np |
| 437 |
> |
BRDFDAT *np |
| 438 |
|
) |
| 439 |
|
{ |
| 440 |
|
FVECT vec; |