19 |
|
#include "otypes.h" |
20 |
|
#include "rtotypes.h" |
21 |
|
#include "random.h" |
22 |
+ |
#include "pmapmat.h" |
23 |
|
|
24 |
|
#ifndef MAXITER |
25 |
|
#define MAXITER 10 /* maximum # specular ray attempts */ |
112 |
|
scalecolor(ctmp, dtmp); |
113 |
|
addcolor(cval, ctmp); |
114 |
|
} |
115 |
+ |
|
116 |
+ |
if (ldot < -FTINY && ltdiff > FTINY) { |
117 |
+ |
/* |
118 |
+ |
* Compute diffuse transmission. |
119 |
+ |
*/ |
120 |
+ |
copycolor(ctmp, np->mcolor); |
121 |
+ |
dtmp = -ldot * omega * ltdiff * (1.0/PI); |
122 |
+ |
scalecolor(ctmp, dtmp); |
123 |
+ |
addcolor(cval, ctmp); |
124 |
+ |
} |
125 |
+ |
|
126 |
+ |
if (ambRayInPmap(np->rp)) |
127 |
+ |
return; /* specular already in photon map */ |
128 |
+ |
|
129 |
|
if (ldot > FTINY && (np->specfl&(SP_REFL|SP_PURE)) == SP_REFL) { |
130 |
|
/* |
131 |
|
* Compute specular reflection coefficient using |
152 |
|
addcolor(cval, ctmp); |
153 |
|
} |
154 |
|
} |
155 |
< |
if (ldot < -FTINY && ltdiff > FTINY) { |
156 |
< |
/* |
142 |
< |
* Compute diffuse transmission. |
143 |
< |
*/ |
144 |
< |
copycolor(ctmp, np->mcolor); |
145 |
< |
dtmp = -ldot * omega * ltdiff * (1.0/PI); |
146 |
< |
scalecolor(ctmp, dtmp); |
147 |
< |
addcolor(cval, ctmp); |
148 |
< |
} |
155 |
> |
|
156 |
> |
|
157 |
|
if (ldot < -FTINY && (np->specfl&(SP_TRAN|SP_PURE)) == SP_TRAN) { |
158 |
|
/* |
159 |
|
* Compute specular transmission. Specular transmission |
188 |
|
double d; |
189 |
|
COLOR ctmp; |
190 |
|
int i; |
191 |
+ |
|
192 |
+ |
/* PMAP: skip transmitted shadow ray if accounted for in photon map */ |
193 |
+ |
/* No longer needed? |
194 |
+ |
if (shadowRayInPmap(r) || ambRayInPmap(r)) |
195 |
+ |
return(1); */ |
196 |
+ |
|
197 |
|
/* easy shadow test */ |
198 |
|
if (r->crtype & SHADOW && m->otype != MAT_TRANS) |
199 |
|
return(1); |
253 |
|
if (!(nd.specfl & SP_PURE) && |
254 |
|
specthresh >= nd.tspec-FTINY) |
255 |
|
nd.specfl |= SP_TBLT; |
256 |
< |
if (!hastexture || r->crtype & SHADOW) { |
256 |
> |
if (!hastexture || r->crtype & (SHADOW|AMBIENT)) { |
257 |
|
VCOPY(nd.prdir, r->rdir); |
258 |
|
transtest = 2; |
259 |
|
} else { |
268 |
|
} else |
269 |
|
nd.tdiff = nd.tspec = nd.trans = 0.0; |
270 |
|
/* transmitted ray */ |
271 |
+ |
|
272 |
|
if ((nd.specfl&(SP_TRAN|SP_PURE|SP_TBLT)) == (SP_TRAN|SP_PURE)) { |
273 |
|
RAY lr; |
274 |
|
copycolor(lr.rcoef, nd.mcolor); /* modified by color */ |
321 |
|
rayvalue(&lr); |
322 |
|
multcolor(lr.rcol, lr.rcoef); |
323 |
|
addcolor(r->rcol, lr.rcol); |
324 |
< |
if (!hastexture && nd.specfl & SP_FLAT) { |
324 |
> |
if (nd.specfl & SP_FLAT && |
325 |
> |
!hastexture | (r->crtype & AMBIENT)) { |
326 |
|
mirtest = 2.*bright(lr.rcol); |
327 |
|
mirdist = r->rot + lr.rt; |
328 |
|
} |
335 |
|
return(1); /* 100% pure specular */ |
336 |
|
|
337 |
|
if (!(nd.specfl & SP_PURE)) |
338 |
< |
gaussamp(&nd); /* checks *BLT flags */ |
338 |
> |
gaussamp(&nd); /* checks *BLT flags */ |
339 |
|
|
340 |
|
if (nd.rdiff > FTINY) { /* ambient from this side */ |
341 |
|
copycolor(ctmp, nd.mcolor); /* modified by material color */ |
393 |
|
(np->specfl & (SP_TRAN|SP_TBLT)) != SP_TRAN) |
394 |
|
return; |
395 |
|
/* set up sample coordinates */ |
396 |
< |
v[0] = v[1] = v[2] = 0.0; |
381 |
< |
for (i = 0; i < 3; i++) |
382 |
< |
if (np->pnorm[i] < 0.6 && np->pnorm[i] > -0.6) |
383 |
< |
break; |
384 |
< |
v[i] = 1.0; |
385 |
< |
fcross(u, v, np->pnorm); |
386 |
< |
normalize(u); |
396 |
> |
getperpendicular(u, np->pnorm, rand_samp); |
397 |
|
fcross(v, np->pnorm, u); |
398 |
|
/* compute reflection */ |
399 |
|
if ((np->specfl & (SP_REFL|SP_RBLT)) == SP_REFL && |