28 |
|
double dstrpix = 0.67; /* square pixel distribution */ |
29 |
|
|
30 |
|
double dstrsrc = 0.0; /* square source distribution */ |
31 |
< |
double shadthresh = .01; /* shadow threshold */ |
31 |
> |
double shadthresh = .05; /* shadow threshold */ |
32 |
> |
double shadcert = .5; /* shadow certainty */ |
33 |
|
|
34 |
|
int maxdepth = 6; /* maximum recursion depth */ |
35 |
|
double minweight = 5e-3; /* minimum ray weight */ |
36 |
|
|
37 |
|
COLOR ambval = BLKCOLOR; /* ambient value */ |
38 |
|
double ambacc = 0.2; /* ambient accuracy */ |
39 |
< |
int ambres = 128; /* ambient resolution */ |
39 |
> |
int ambres = 32; /* ambient resolution */ |
40 |
|
int ambdiv = 128; /* ambient divisions */ |
41 |
|
int ambssamp = 0; /* ambient super-samples */ |
42 |
|
int ambounce = 0; /* ambient bounces */ |
49 |
|
|
50 |
|
extern long nrays; /* number of rays traced */ |
51 |
|
|
52 |
+ |
static int xres, yres; /* output x and y resolution */ |
53 |
+ |
|
54 |
|
#define MAXDIV 32 /* maximum sample size */ |
55 |
|
|
56 |
|
#define pixjitter() (.5+dstrpix*(.5-frandom())) |
103 |
|
psample = 1; |
104 |
|
else if (psample > MAXDIV) |
105 |
|
psample = MAXDIV; |
106 |
+ |
/* output resolution may be smaller */ |
107 |
+ |
xres = ourview.hresolu - (ourview.hresolu % psample); |
108 |
+ |
yres = ourview.vresolu - (ourview.vresolu % psample); |
109 |
|
|
104 |
– |
ourview.hresolu -= ourview.hresolu % psample; |
105 |
– |
ourview.vresolu -= ourview.vresolu % psample; |
106 |
– |
|
110 |
|
for (i = 0; i <= psample; i++) { |
111 |
< |
scanbar[i] = (COLOR *)malloc((ourview.hresolu+1)*sizeof(COLOR)); |
111 |
> |
scanbar[i] = (COLOR *)malloc((xres+1)*sizeof(COLOR)); |
112 |
|
if (scanbar[i] == NULL) |
113 |
|
error(SYSTEM, "out of memory in render"); |
114 |
|
} |
112 |
– |
|
115 |
|
/* write out boundaries */ |
116 |
< |
printf("-Y %d +X %d\n", ourview.vresolu, ourview.hresolu); |
116 |
> |
fputresolu(YMAJOR|YDECR, xres, yres, stdout); |
117 |
|
|
118 |
< |
ypos = ourview.vresolu - salvage(oldfile); /* find top line */ |
118 |
> |
ypos = yres - salvage(oldfile); /* find top line */ |
119 |
|
fillscanline(scanbar[0], ypos, psample); /* top scan */ |
120 |
|
|
121 |
|
for (ypos -= psample; ypos > -psample; ypos -= psample) { |
129 |
|
fillscanbar(scanbar, ypos, psample); |
130 |
|
|
131 |
|
for (i = psample-1; i >= 0; i--) |
132 |
< |
if (fwritescan(scanbar[i], ourview.hresolu, stdout) < 0) |
132 |
> |
if (fwritescan(scanbar[i], xres, stdout) < 0) |
133 |
|
goto writerr; |
134 |
|
if (fflush(stdout) == EOF) |
135 |
|
goto writerr; |
136 |
< |
pctdone = 100.0*(ourview.vresolu-ypos)/ourview.vresolu; |
136 |
> |
pctdone = 100.0*(yres-ypos)/yres; |
137 |
|
} |
138 |
|
|
139 |
|
for (i = 0; i <= psample; i++) |
153 |
|
|
154 |
|
pixvalue(scanline[0], 0, y); |
155 |
|
|
156 |
< |
for (i = xstep; i <= ourview.hresolu; i += xstep) { |
156 |
> |
for (i = xstep; i <= xres; i += xstep) { |
157 |
|
|
158 |
|
pixvalue(scanline[i], i, y); |
159 |
|
|
170 |
|
int b = ysize; |
171 |
|
register int i, j; |
172 |
|
|
173 |
< |
for (i = 0; i < ourview.hresolu; i++) { |
173 |
> |
for (i = 0; i < xres; i++) { |
174 |
|
|
175 |
|
copycolor(vline[0], scanbar[0][i]); |
176 |
|
copycolor(vline[ysize], scanbar[ysize][i]); |
264 |
|
/* discard header */ |
265 |
|
getheader(fp, NULL); |
266 |
|
/* get picture size */ |
267 |
< |
if (fscanf(fp, "-Y %d +X %d\n", &y, &x) != 2) { |
267 |
> |
if (fgetresolu(&x, &y, fp) != (YMAJOR|YDECR)) { |
268 |
|
sprintf(errmsg, "bad recover file \"%s\"", oldfile); |
269 |
|
error(WARNING, errmsg); |
270 |
|
fclose(fp); |
271 |
|
return(0); |
272 |
|
} |
273 |
|
|
274 |
< |
if (x != ourview.hresolu || y != ourview.vresolu) { |
274 |
> |
if (x != xres || y != yres) { |
275 |
|
sprintf(errmsg, "resolution mismatch in recover file \"%s\"", |
276 |
|
oldfile); |
277 |
|
error(USER, errmsg); |
278 |
|
return(0); |
279 |
|
} |
280 |
|
|
281 |
< |
scanline = (COLR *)malloc(ourview.hresolu*sizeof(COLR)); |
281 |
> |
scanline = (COLR *)malloc(xres*sizeof(COLR)); |
282 |
|
if (scanline == NULL) |
283 |
|
error(SYSTEM, "out of memory in salvage"); |
284 |
< |
for (y = 0; y < ourview.vresolu; y++) { |
285 |
< |
if (freadcolrs(scanline, ourview.hresolu, fp) < 0) |
284 |
> |
for (y = 0; y < yres; y++) { |
285 |
> |
if (freadcolrs(scanline, xres, fp) < 0) |
286 |
|
break; |
287 |
< |
if (fwritecolrs(scanline, ourview.hresolu, stdout) < 0) |
287 |
> |
if (fwritecolrs(scanline, xres, stdout) < 0) |
288 |
|
goto writerr; |
289 |
|
} |
290 |
|
if (fflush(stdout) == EOF) |