18 |
|
|
19 |
|
#include "random.h" |
20 |
|
|
21 |
< |
#define OCTSCALE 0.5 /* ceil((valid rad.)/(cube size)) */ |
21 |
> |
#define OCTSCALE 1.0 /* ceil((valid rad.)/(cube size)) */ |
22 |
|
|
23 |
|
typedef struct ambtree { |
24 |
|
AMBVAL *alist; /* ambient value list */ |
48 |
|
#endif |
49 |
|
#endif |
50 |
|
#ifndef SORT_INTVL |
51 |
< |
#define SORT_INTVL (SORT_THRESH*32) |
51 |
> |
#define SORT_INTVL (SORT_THRESH*256) |
52 |
|
#endif |
53 |
|
#ifndef MAX_SORT_INTVL |
54 |
< |
#define MAX_SORT_INTVL (SORT_INTVL<<8) |
54 |
> |
#define MAX_SORT_INTVL (SORT_INTVL<<4) |
55 |
|
#endif |
56 |
|
|
57 |
|
static unsigned long ambclock = 0; /* ambient access clock */ |
89 |
|
maxarad = thescene.cusize / 2.0; |
90 |
|
} else { |
91 |
|
minarad = thescene.cusize / ar; |
92 |
< |
maxarad = 16 * minarad; /* heuristic */ |
92 |
> |
maxarad = 64 * minarad; /* heuristic */ |
93 |
|
if (maxarad > thescene.cusize / 2.0) |
94 |
|
maxarad = thescene.cusize / 2.0; |
95 |
|
} |
234 |
|
int i; |
235 |
|
register int j; |
236 |
|
register AMBVAL *av; |
237 |
< |
/* do this node */ |
237 |
> |
|
238 |
|
wsum = 0.0; |
239 |
+ |
/* do this node */ |
240 |
|
for (av = at->alist; av != NULL; av = av->next) { |
241 |
|
if (tracktime) |
242 |
|
av->latick = ambclock++; |
250 |
|
/* |
251 |
|
* Ambient radius test. |
252 |
|
*/ |
253 |
< |
e1 = 0.0; |
254 |
< |
for (j = 0; j < 3; j++) { |
255 |
< |
d = av->pos[j] - r->rop[j]; |
256 |
< |
e1 += d * d; |
257 |
< |
} |
253 |
> |
d = av->pos[0] - r->rop[0]; |
254 |
> |
e1 = d * d; |
255 |
> |
d = av->pos[1] - r->rop[1]; |
256 |
> |
e1 += d * d; |
257 |
> |
d = av->pos[2] - r->rop[2]; |
258 |
> |
e1 += d * d; |
259 |
|
e1 /= av->rad * av->rad; |
260 |
|
if (e1 > ambacc*ambacc*1.21) |
261 |
|
continue; |
279 |
|
* Jittering final test reduces image artifacts. |
280 |
|
*/ |
281 |
|
wt = sqrt(e1) + sqrt(e2); |
282 |
< |
wt *= .9 + .2*urand(9015+samplendx); |
281 |
< |
if (wt > ambacc) |
282 |
> |
if (wt > ambacc*(.9+.2*urand(9015+samplendx))) |
283 |
|
continue; |
284 |
|
if (wt <= 1e-3) |
285 |
|
wt = 1e3; |
631 |
|
* when we're thrashing, which is when we need to do it. |
632 |
|
*/ |
633 |
|
#ifdef DEBUG |
634 |
< |
sprintf(errmsg, "sorting %u ambient values...", nambvals); |
634 |
> |
sprintf(errmsg, "sorting %u ambient values at ambclock=%lu...", |
635 |
> |
nambvals, ambclock); |
636 |
|
eputs(errmsg); |
637 |
|
#endif |
638 |
|
i_avlist = 0; |