| 22 |
|
extern void SDsquare2disk(double ds[2], double seedx, double seedy); |
| 23 |
|
|
| 24 |
|
typedef struct { |
| 25 |
+ |
COLOR v; /* hemisphere sample value */ |
| 26 |
+ |
FVECT p; /* intersection point */ |
| 27 |
+ |
} AMBSAMP; /* sample value */ |
| 28 |
+ |
|
| 29 |
+ |
typedef struct { |
| 30 |
|
RAY *rp; /* originating ray sample */ |
| 31 |
|
FVECT ux, uy; /* tangent axis unit vectors */ |
| 32 |
|
int ns; /* number of samples per axis */ |
| 33 |
|
COLOR acoef; /* division contribution coefficient */ |
| 34 |
< |
struct s_ambsamp { |
| 30 |
< |
COLOR v; /* hemisphere sample value */ |
| 31 |
< |
FVECT p; /* intersection point */ |
| 32 |
< |
} sa[1]; /* sample array (extends struct) */ |
| 34 |
> |
AMBSAMP sa[1]; /* sample array (extends struct) */ |
| 35 |
|
} AMBHEMI; /* ambient sample hemisphere */ |
| 36 |
|
|
| 35 |
– |
typedef struct s_ambsamp AMBSAMP; |
| 36 |
– |
|
| 37 |
|
#define ambsam(h,i,j) (h)->sa[(i)*(h)->ns + (j)] |
| 38 |
|
|
| 39 |
|
typedef struct { |
| 161 |
|
static float * |
| 162 |
|
getambdiffs(AMBHEMI *hp) |
| 163 |
|
{ |
| 164 |
< |
float *earr = calloc(hp->ns*hp->ns, sizeof(float)); |
| 164 |
> |
float *earr = (float *)calloc(hp->ns*hp->ns, sizeof(float)); |
| 165 |
|
float *ep; |
| 166 |
|
AMBSAMP *ap; |
| 167 |
|
double b, d2; |
| 606 |
|
) |
| 607 |
|
{ |
| 608 |
|
AMBHEMI *hp = inithemi(rcol, r, wt); |
| 609 |
< |
int cnt = 0; |
| 609 |
> |
int cnt; |
| 610 |
|
FVECT my_uv[2]; |
| 611 |
|
double d, K, acol[3]; |
| 612 |
|
AMBSAMP *ap; |
| 624 |
|
dg[0] = dg[1] = 0.0; |
| 625 |
|
/* sample the hemisphere */ |
| 626 |
|
acol[0] = acol[1] = acol[2] = 0.0; |
| 627 |
+ |
cnt = 0; |
| 628 |
|
for (i = hp->ns; i--; ) |
| 629 |
|
for (j = hp->ns; j--; ) |
| 630 |
|
if ((ap = ambsample(hp, i, j)) != NULL) { |
| 649 |
|
free(hp); |
| 650 |
|
return(-1); /* no radius or gradient calc. */ |
| 651 |
|
} |
| 652 |
< |
if (bright(acol) > FTINY) { /* normalize Y values */ |
| 653 |
< |
d = 0.99*cnt/bright(acol); |
| 652 |
> |
if ((d = bright(acol)) > FTINY) { /* normalize Y values */ |
| 653 |
> |
d = 0.99*(hp->ns*hp->ns)/d; |
| 654 |
|
K = 0.01; |
| 655 |
< |
} else { /* geometric Hessian fall-back */ |
| 655 |
< |
d = 0.0; |
| 655 |
> |
} else { /* or fall back on geometric Hessian */ |
| 656 |
|
K = 1.0; |
| 657 |
|
pg = NULL; |
| 658 |
|
dg = NULL; |