41 |
|
#define SP_REFL 01 /* has reflected specular component */ |
42 |
|
#define SP_TRAN 02 /* has transmitted specular */ |
43 |
|
#define SP_PURE 010 /* purely specular (zero roughness) */ |
44 |
+ |
#define SP_FLAT 020 /* flat reflecting surface */ |
45 |
|
|
46 |
|
typedef struct { |
47 |
|
OBJREC *mp; /* material pointer */ |
67 |
|
{ |
68 |
|
double ldot; |
69 |
|
double dtmp; |
70 |
+ |
int i; |
71 |
|
COLOR ctmp; |
72 |
|
|
73 |
|
setcolor(cval, 0.0, 0.0, 0.0); |
93 |
|
* Compute specular reflection coefficient using |
94 |
|
* gaussian distribution model. |
95 |
|
*/ |
96 |
< |
/* roughness + source */ |
97 |
< |
dtmp = 2.0*np->alpha2 + omega/(2.0*PI); |
96 |
> |
/* roughness */ |
97 |
> |
dtmp = 2.0*np->alpha2; |
98 |
> |
/* + source if flat */ |
99 |
> |
if (np->specfl & SP_FLAT) |
100 |
> |
dtmp += omega/(2.0*PI); |
101 |
|
/* gaussian */ |
102 |
|
dtmp = exp((DOT(np->vrefl,ldir)-1.)/dtmp)/(2.*PI)/dtmp; |
103 |
|
/* worth using? */ |
241 |
|
|
242 |
|
if (nd.specfl & SP_PURE && nd.rdiff <= FTINY && nd.tdiff <= FTINY) |
243 |
|
return; /* 100% pure specular */ |
244 |
+ |
|
245 |
+ |
if (r->ro->otype == OBJ_FACE || r->ro->otype == OBJ_RING) |
246 |
+ |
nd.specfl |= SP_FLAT; |
247 |
|
|
248 |
|
if (nd.specfl & (SP_REFL|SP_TRAN) && !(nd.specfl & SP_PURE)) |
249 |
|
gaussamp(r, &nd); |