24 |
|
|
25 |
|
#include "random.h" |
26 |
|
|
27 |
+ |
int dimlist[MAXDIM]; /* sampling dimensions */ |
28 |
+ |
int ndims = 0; /* number of sampling dimensions */ |
29 |
+ |
int samplendx; /* sample index number */ |
30 |
+ |
|
31 |
|
VIEW ourview = STDVIEW; /* view parameters */ |
32 |
|
int hresolu = 512; /* horizontal resolution */ |
33 |
|
int vresolu = 512; /* vertical resolution */ |
40 |
|
double dstrsrc = 0.0; /* square source distribution */ |
41 |
|
double shadthresh = .05; /* shadow threshold */ |
42 |
|
double shadcert = .5; /* shadow certainty */ |
43 |
+ |
int directrelay = 0; /* number of source relays */ |
44 |
+ |
int vspretest = 512; /* virtual source pretest density */ |
45 |
+ |
int directinvis = 0; /* sources invisible? */ |
46 |
|
|
47 |
|
int maxdepth = 6; /* maximum recursion depth */ |
48 |
|
double minweight = 5e-3; /* minimum ray weight */ |
67 |
|
|
68 |
|
extern long nrays; /* number of rays traced */ |
69 |
|
|
70 |
< |
#define MAXDIV 32 /* maximum sample size */ |
70 |
> |
#define MAXDIV 15 /* maximum sample size */ |
71 |
|
|
72 |
|
#define pixjitter() (.5+dstrpix*(.5-frandom())) |
73 |
|
|
129 |
|
/* check sampling */ |
130 |
|
if (psample < 1) |
131 |
|
psample = 1; |
132 |
< |
else if (psample > MAXDIV) |
132 |
> |
else if (psample > MAXDIV) { |
133 |
> |
sprintf(errmsg, "pixel sampling reduced from %d to %d", |
134 |
> |
psample, MAXDIV); |
135 |
> |
error(WARNING, errmsg); |
136 |
|
psample = MAXDIV; |
137 |
+ |
} |
138 |
|
/* allocate scanlines */ |
139 |
|
for (i = 0; i <= psample; i++) { |
140 |
|
scanbar[i] = (COLOR *)malloc(hresolu*sizeof(COLOR)); |
344 |
|
COLOR col; /* returned color */ |
345 |
|
int x, y; /* pixel position */ |
346 |
|
{ |
347 |
< |
static RAY thisray; /* our ray for this pixel */ |
347 |
> |
static RAY thisray; |
348 |
|
|
349 |
|
if (viewray(thisray.rorg, thisray.rdir, &ourview, |
350 |
|
(x+pixjitter())/hresolu, (y+pixjitter())/vresolu) < 0) { |
353 |
|
} |
354 |
|
|
355 |
|
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
356 |
< |
|
356 |
> |
|
357 |
> |
samplendx = pixnumber(x,y,hresolu,vresolu); /* set pixel index */ |
358 |
> |
|
359 |
|
rayvalue(&thisray); /* trace ray */ |
360 |
|
|
361 |
|
copycolor(col, thisray.rcol); /* return color */ |
413 |
|
return(y); |
414 |
|
writerr: |
415 |
|
error(SYSTEM, "write error in salvage"); |
416 |
+ |
} |
417 |
+ |
|
418 |
+ |
|
419 |
+ |
int |
420 |
+ |
pixnumber(x, y, xres, yres) /* compute pixel index (brushed) */ |
421 |
+ |
register int x, y; |
422 |
+ |
int xres, yres; |
423 |
+ |
{ |
424 |
+ |
x -= y; |
425 |
+ |
while (x < 0) |
426 |
+ |
x += xres; |
427 |
+ |
return((((x>>2)*yres + y) << 2) + (x & 3)); |
428 |
|
} |