92 |
|
srcsamps( /* sample sources from this surface position */ |
93 |
|
struct illum_args *il, |
94 |
|
FVECT org, |
95 |
< |
FVECT nrm, |
95 |
> |
double eps, |
96 |
|
MAT4 ixfm |
97 |
|
) |
98 |
|
{ |
111 |
|
initsrcindex(&si); /* loop over (sub)sources */ |
112 |
|
for ( ; ; ) { |
113 |
|
VCOPY(sr.rorg, org); /* pick side to shoot from */ |
114 |
– |
d = 5.*FTINY; |
115 |
– |
VSUM(sr.rorg, sr.rorg, nrm, d); |
114 |
|
samplendx++; /* increment sample counter */ |
115 |
|
if (!srcray(&sr, NULL, &si)) |
116 |
|
break; /* end of sources */ |
120 |
|
else |
121 |
|
VCOPY(v, sr.rdir); |
122 |
|
if (v[2] >= -FTINY) |
123 |
< |
continue; /* only sample transmission */ |
123 |
> |
continue; /* only sample transmission */ |
124 |
|
v[0] = -v[0]; v[1] = -v[1]; v[2] = -v[2]; |
125 |
|
sr.rno = flatindex(v, nalt, nazi); |
126 |
|
d = nalt*nazi*(1./PI) * v[2]; |
127 |
|
d *= si.dom; /* solid angle correction */ |
128 |
|
scalecolor(sr.rcoef, d); |
129 |
+ |
VSUM(sr.rorg, sr.rorg, sr.rdir, -eps); |
130 |
|
process_ray(&sr, ray_pqueue(&sr)); |
131 |
|
} |
132 |
|
} |
149 |
|
FVECT n |
150 |
|
) |
151 |
|
{ |
152 |
< |
register int i; |
154 |
< |
|
155 |
< |
v[0] = v[1] = v[2] = 0.0; |
156 |
< |
for (i = 0; i < 3; i++) |
157 |
< |
if (n[i] < 0.6 && n[i] > -0.6) |
158 |
< |
break; |
159 |
< |
v[i] = 1.0; |
160 |
< |
fcross(u, v, n); |
161 |
< |
normalize(u); |
152 |
> |
getperpendicular(u, n, 1); |
153 |
|
fcross(v, n, u); |
154 |
|
} |
155 |
|
|
156 |
|
|
157 |
|
static void |
158 |
|
rounddir( /* compute uniform spherical direction */ |
159 |
< |
register FVECT dv, |
159 |
> |
FVECT dv, |
160 |
|
double alt, |
161 |
|
double azi |
162 |
|
) |
237 |
|
FVECT dn, org, dir; |
238 |
|
FVECT u, v; |
239 |
|
double ur[2], vr[2]; |
240 |
+ |
double epsilon; |
241 |
|
MAT4 xfm; |
242 |
|
char xfrot[64]; |
243 |
|
int nallow; |
287 |
|
dim[0] = random(); |
288 |
|
/* sample polygon */ |
289 |
|
nallow = 5*n*il->nsamps; |
290 |
+ |
epsilon = .005*sqrt(fa->area); |
291 |
|
for (dim[1] = 0; dim[1] < n; dim[1]++) |
292 |
|
for (i = 0; i < il->nsamps; i++) { |
293 |
|
/* randomize direction */ |
315 |
|
freeface(ob); |
316 |
|
return(my_default(ob, il, nm)); |
317 |
|
} |
318 |
< |
r1 = 5.*FTINY; |
326 |
< |
for (j = 0; j < 3; j++) |
327 |
< |
org[j] += r1*fa->norm[j]; |
318 |
> |
VSUM(org, org, dir, -epsilon); |
319 |
|
/* send sample */ |
320 |
|
raysamp(dim[1], org, dir); |
321 |
|
} |
350 |
|
return(my_default(ob, il, nm)); |
351 |
|
} |
352 |
|
/* sample source rays */ |
353 |
< |
srcsamps(il, org, fa->norm, ixfm); |
353 |
> |
srcsamps(il, org, epsilon, ixfm); |
354 |
|
} |
355 |
|
} |
356 |
|
/* wait for all rays to finish */ |
370 |
|
|
371 |
|
int |
372 |
|
my_sphere( /* make an illum sphere */ |
373 |
< |
register OBJREC *ob, |
373 |
> |
OBJREC *ob, |
374 |
|
struct illum_args *il, |
375 |
|
char *nm |
376 |
|
) |
380 |
|
double sp[4], r1, r2, r3; |
381 |
|
FVECT org, dir; |
382 |
|
FVECT u, v; |
383 |
< |
register int i, j; |
383 |
> |
int i, j; |
384 |
|
/* check arguments */ |
385 |
|
if (ob->oargs.nfargs != 4) |
386 |
|
objerror(ob, USER, "bad # of arguments"); |
517 |
|
for (j = 0; j < 3; j++) |
518 |
|
org[j] = CO_P0(co)[j] + r1*u[j] + r2*v[j]; |
519 |
|
/* sample source rays */ |
520 |
< |
srcsamps(il, org, co->ad, ixfm); |
520 |
> |
srcsamps(il, org, 5.*FTINY, ixfm); |
521 |
|
} |
522 |
|
} |
523 |
|
/* wait for all rays to finish */ |