276 |
|
{ |
277 |
|
static int rdepth = 0; /* ambient recursion */ |
278 |
|
COLOR acol, caustic; |
279 |
< |
int ok; |
279 |
> |
int i, ok; |
280 |
|
double d, l; |
281 |
|
|
282 |
|
/* PMAP: Factor in ambient from photon map, if enabled and ray is |
302 |
|
goto dumbamb; |
303 |
|
|
304 |
|
if (ambacc <= FTINY) { /* no ambient storage */ |
305 |
+ |
FVECT uvd[2]; |
306 |
+ |
float dgrad[2], *dgp = NULL; |
307 |
+ |
|
308 |
+ |
if (nrm != r->ron && DOT(nrm,r->ron) < 0.9999) |
309 |
+ |
dgp = dgrad; /* compute rotational grad. */ |
310 |
|
copycolor(acol, aval); |
311 |
|
rdepth++; |
312 |
|
ok = doambient(acol, r, r->rweight, |
313 |
< |
NULL, NULL, NULL, NULL, NULL); |
313 |
> |
uvd, NULL, NULL, dgp, NULL); |
314 |
|
rdepth--; |
315 |
|
if (!ok) |
316 |
|
goto dumbamb; |
317 |
+ |
if ((ok > 0) & (dgp != NULL)) { /* apply texture */ |
318 |
+ |
FVECT v1; |
319 |
+ |
VCROSS(v1, r->ron, nrm); |
320 |
+ |
d = 1.0; |
321 |
+ |
for (i = 3; i--; ) |
322 |
+ |
d += v1[i] * (dgp[0]*uvd[0][i] + dgp[1]*uvd[1][i]); |
323 |
+ |
if (d >= 0.05) |
324 |
+ |
scalecolor(acol, d); |
325 |
+ |
} |
326 |
|
copycolor(aval, acol); |
327 |
|
|
328 |
|
/* PMAP: add in caustic */ |