1 |
|
#ifndef lint |
2 |
< |
static const char RCSid[] = "$Id$"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
4 |
|
/* |
5 |
|
* normal.c - shading function for normal materials. |
15 |
|
|
16 |
|
#include "ray.h" |
17 |
|
|
18 |
+ |
#include "ambient.h" |
19 |
+ |
|
20 |
|
#include "otypes.h" |
21 |
|
|
22 |
|
#include "random.h" |
25 |
|
#define MAXITER 10 /* maximum # specular ray attempts */ |
26 |
|
#endif |
27 |
|
/* estimate of Fresnel function */ |
28 |
< |
#define FRESNE(ci) (exp(-6.0*(ci)) - 0.00247875217) |
28 |
> |
#define FRESNE(ci) (exp(-5.85*(ci)) - 0.00287989916) |
29 |
|
|
30 |
|
static void gaussamp(); |
31 |
|
|
89 |
|
|
90 |
|
/* Fresnel estimate */ |
91 |
|
ldiff = np->rdiff; |
92 |
< |
if (np->specfl & SP_PURE && (np->rspec > FTINY & ldiff > FTINY)) |
92 |
> |
if (np->specfl & SP_PURE && (np->rspec > FTINY) & (ldiff > FTINY)) |
93 |
|
ldiff *= 1. - FRESNE(fabs(ldot)); |
94 |
|
|
95 |
|
if (ldot > FTINY && ldiff > FTINY) { |
184 |
|
raytrans(r); |
185 |
|
return(1); |
186 |
|
} |
187 |
+ |
raytexture(r, m->omod); |
188 |
|
flipsurface(r); /* reorient if backvis */ |
189 |
< |
} |
189 |
> |
} else |
190 |
> |
raytexture(r, m->omod); |
191 |
|
nd.mp = m; |
192 |
|
nd.rp = r; |
193 |
|
/* get material color */ |
199 |
|
nd.alpha2 = m->oargs.farg[4]; |
200 |
|
if ((nd.alpha2 *= nd.alpha2) <= FTINY) |
201 |
|
nd.specfl |= SP_PURE; |
202 |
< |
if (r->ro != NULL && isflat(r->ro->otype)) |
203 |
< |
nd.specfl |= SP_FLAT; |
200 |
< |
/* get modifiers */ |
201 |
< |
raytexture(r, m->omod); |
202 |
< |
if (hastexture = DOT(r->pert,r->pert) > FTINY*FTINY) |
202 |
> |
|
203 |
> |
if ( (hastexture = (DOT(r->pert,r->pert) > FTINY*FTINY)) ) { |
204 |
|
nd.pdot = raynormal(nd.pnorm, r); /* perturb normal */ |
205 |
< |
else { |
205 |
> |
} else { |
206 |
|
VCOPY(nd.pnorm, r->ron); |
207 |
|
nd.pdot = r->rod; |
208 |
|
} |
209 |
+ |
if (r->ro != NULL && isflat(r->ro->otype)) |
210 |
+ |
nd.specfl |= SP_FLAT; |
211 |
|
if (nd.pdot < .001) |
212 |
|
nd.pdot = .001; /* non-zero for dirnorm() */ |
213 |
|
multcolor(nd.mcolor, r->pcol); /* modify material color */ |