13 |
|
#include "source.h" |
14 |
|
#include "paths.h" |
15 |
|
|
16 |
< |
#ifndef NBSDFSAMPS |
17 |
< |
#define NBSDFSAMPS 256 /* BSDF resampling count */ |
16 |
> |
#ifndef R_EPS |
17 |
> |
#define R_EPS 0.005 /* relative epsilon for ray origin */ |
18 |
|
#endif |
19 |
|
|
20 |
|
COLORV * distarr = NULL; /* distribution array */ |
287 |
|
dim[0] = random(); |
288 |
|
/* sample polygon */ |
289 |
|
nallow = 5*n*il->nsamps; |
290 |
< |
epsilon = .005*sqrt(fa->area); |
290 |
> |
epsilon = R_EPS*sqrt(fa->area); |
291 |
|
for (dim[1] = 0; dim[1] < n; dim[1]++) |
292 |
|
for (i = 0; i < il->nsamps; i++) { |
293 |
|
/* randomize direction */ |
446 |
|
int dim[2]; |
447 |
|
int n, nalt, nazi, alti; |
448 |
|
double sp[2], r1, r2, r3; |
449 |
+ |
double epsilon; |
450 |
|
int h; |
451 |
|
FVECT dn, org, dir; |
452 |
|
FVECT u, v; |
453 |
|
MAT4 xfm; |
454 |
|
CONE *co; |
455 |
|
int i, j; |
456 |
< |
/* get/check arguments */ |
456 |
> |
/* get/check arguments */ |
457 |
|
co = getcone(ob, 0); |
458 |
< |
/* set up sampling */ |
458 |
> |
if (co == NULL) |
459 |
> |
objerror(ob, USER, "cannot create illum"); |
460 |
> |
/* set up sampling */ |
461 |
|
if (il->sampdens <= 0) { |
462 |
|
nalt = nazi = 1; /* diffuse assumption */ |
463 |
|
} else { |
465 |
|
nalt = sqrt(n/PI) + .5; |
466 |
|
nazi = PI*nalt + .5; |
467 |
|
} |
468 |
+ |
epsilon = R_EPS*CO_R1(co); |
469 |
|
n = nazi*nalt; |
470 |
|
newdist(n); |
471 |
|
mkaxes(u, v, co->ad); |
490 |
|
r2 = 2.*PI*sp[1]; |
491 |
|
r1 = r3*cos(r2); |
492 |
|
r2 = r3*sin(r2); |
489 |
– |
r3 = 5.*FTINY; |
493 |
|
for (j = 0; j < 3; j++) |
494 |
|
org[j] = CO_P0(co)[j] + r1*u[j] + r2*v[j] + |
495 |
< |
r3*co->ad[j]; |
495 |
> |
epsilon*co->ad[j]; |
496 |
|
/* send sample */ |
497 |
|
raysamp(dim[1], org, dir); |
498 |
|
} |
520 |
|
for (j = 0; j < 3; j++) |
521 |
|
org[j] = CO_P0(co)[j] + r1*u[j] + r2*v[j]; |
522 |
|
/* sample source rays */ |
523 |
< |
srcsamps(il, org, 5.*FTINY, ixfm); |
523 |
> |
srcsamps(il, org, epsilon, ixfm); |
524 |
|
} |
525 |
|
} |
526 |
|
/* wait for all rays to finish */ |