| 18 |
|
VIEW myview = STDVIEW; /* current output view */ |
| 19 |
|
int xres = 512, yres = 512; /* max. horizontal and vertical resolution */ |
| 20 |
|
char *outspec = NULL; /* output file specification */ |
| 21 |
+ |
int randflag = 0; /* random resampling algorithm? */ |
| 22 |
|
double pixaspect = 1.; /* pixel aspect ratio */ |
| 23 |
|
int seqstart = 0; /* sequence start frame */ |
| 24 |
|
double expval = 1.; /* exposure value */ |
| 25 |
|
|
| 26 |
|
COLOR *mypixel; /* pixels being rendered */ |
| 27 |
|
float *myweight; /* weights (used to compute final pixels) */ |
| 28 |
+ |
float *mydepth; /* depth values (visibility culling) */ |
| 29 |
|
int hres, vres; /* current horizontal and vertical res. */ |
| 30 |
|
|
| 31 |
|
extern int nowarn; /* turn warnings off? */ |
| 51 |
|
case 'p': /* pixel aspect/exposure */ |
| 52 |
|
if (badarg(argc-i-1,argv+i+1,"f")) |
| 53 |
|
goto userr; |
| 54 |
< |
if (argv[i][1] == 'a') |
| 54 |
> |
if (argv[i][2] == 'a') |
| 55 |
|
pixaspect = atof(argv[++i]); |
| 56 |
< |
else if (argv[i][1] == 'e') { |
| 56 |
> |
else if (argv[i][2] == 'e') { |
| 57 |
|
expval = atof(argv[++i]); |
| 58 |
|
if (argv[i][0] == '-' | argv[i][0] == '+') |
| 59 |
|
expval = pow(2., expval); |
| 75 |
|
goto userr; |
| 76 |
|
outspec = argv[++i]; |
| 77 |
|
break; |
| 78 |
+ |
case 'r': /* random sampling */ |
| 79 |
+ |
randflag = 1; |
| 80 |
+ |
break; |
| 81 |
+ |
case 's': /* smooth sampling */ |
| 82 |
+ |
randflag = 0; |
| 83 |
+ |
break; |
| 84 |
|
case 'S': /* sequence start */ |
| 85 |
|
if (badarg(argc-i-1,argv+i+1,"i")) |
| 86 |
|
goto userr; |
| 87 |
|
seqstart = atoi(argv[++i]); |
| 88 |
|
break; |
| 89 |
|
case 'v': /* view file */ |
| 90 |
< |
if (argv[i][1]!='f' || badarg(argc-i-1,argv+i+1,"s")) |
| 90 |
> |
if (argv[i][2]!='f' || badarg(argc-i-1,argv+i+1,"s")) |
| 91 |
|
goto userr; |
| 92 |
|
rval = viewfile(argv[++i], &myview, NULL); |
| 93 |
|
if (rval < 0) { |
| 105 |
|
} |
| 106 |
|
} |
| 107 |
|
/* open holodeck file */ |
| 108 |
< |
if (i >= argc) |
| 108 |
> |
if (i != argc-1) |
| 109 |
|
goto userr; |
| 110 |
< |
hdkfile = argv[i++]; |
| 110 |
> |
hdkfile = argv[i]; |
| 111 |
|
initialize(); |
| 112 |
|
/* render picture(s) */ |
| 113 |
|
if (seqstart <= 0) |
| 118 |
|
quit(0); /* all done! */ |
| 119 |
|
userr: |
| 120 |
|
fprintf(stderr, |
| 121 |
< |
"Usage: %s [-w][-pa pa][-pe ex][-x hr][-y vr][-S stfn][-o outp][view] input.hdk\n", |
| 121 |
> |
"Usage: %s [-w][-r|-s][-pa pa][-pe ex][-x hr][-y vr][-S stfn][-o outp][view] input.hdk\n", |
| 122 |
|
progname); |
| 123 |
|
quit(1); |
| 124 |
|
} |
| 152 |
|
sprintf(errmsg, "error writing frame %d", fn); |
| 153 |
|
error(SYSTEM, errmsg); |
| 154 |
|
} |
| 155 |
+ |
#ifdef DEBUG |
| 156 |
|
if (blist.nb > 0 & rval > 0) { |
| 157 |
< |
sprintf(errmsg, "%.1f%% unrendered pixels in frame %d", |
| 158 |
< |
100.*rval/(hres*vres), fn); |
| 157 |
> |
sprintf(errmsg, "%d unrendered pixels in frame %d (%.1f%%)", |
| 158 |
> |
rval, fn, 100.*rval/(hres*vres)); |
| 159 |
|
error(WARNING, errmsg); |
| 160 |
|
} |
| 161 |
+ |
#endif |
| 162 |
|
} |
| 163 |
|
|
| 164 |
|
|
| 166 |
|
register PACKHEAD *bl; |
| 167 |
|
int nb; |
| 168 |
|
{ |
| 169 |
< |
extern int render_beam(); |
| 169 |
> |
extern int pixBeam(); |
| 170 |
|
register HDBEAMI *bil; |
| 171 |
|
register int i; |
| 172 |
|
|
| 177 |
|
bil[i].h = hdlist[bl[i].hd]; |
| 178 |
|
bil[i].b = bl[i].bi; |
| 179 |
|
} |
| 180 |
< |
hdloadbeams(bil, nb, render_beam); |
| 180 |
> |
hdloadbeams(bil, nb, pixBeam); |
| 181 |
> |
pixFinish(randflag); |
| 182 |
|
free((char *)bil); |
| 183 |
|
} |
| 184 |
|
|
| 220 |
|
/* prepare image buffers */ |
| 221 |
|
bzero((char *)mypixel, hres*vres*sizeof(COLOR)); |
| 222 |
|
bzero((char *)myweight, hres*vres*sizeof(float)); |
| 223 |
+ |
bzero((char *)mydepth, hres*vres*sizeof(float)); |
| 224 |
|
} |
| 225 |
|
|
| 226 |
|
|
| 227 |
|
int |
| 228 |
|
endpicture() /* finish and write out pixels */ |
| 229 |
|
{ |
| 230 |
< |
int nunrend = 0; |
| 231 |
< |
int v; |
| 230 |
> |
int lastr = -1, nunrend = 0; |
| 231 |
> |
int4 lastp, lastrp; |
| 232 |
> |
register int4 p; |
| 233 |
|
register double d; |
| 221 |
– |
register int p; |
| 234 |
|
/* compute final pixel values */ |
| 235 |
|
for (p = hres*vres; p--; ) { |
| 236 |
|
if (myweight[p] <= FTINY) { |
| 237 |
+ |
if (lastr >= 0) |
| 238 |
+ |
if (p/hres == lastp/hres) |
| 239 |
+ |
copycolor(mypixel[p], mypixel[lastp]); |
| 240 |
+ |
else |
| 241 |
+ |
copycolor(mypixel[p], mypixel[lastrp]); |
| 242 |
|
nunrend++; |
| 243 |
|
continue; |
| 244 |
|
} |
| 245 |
|
d = expval/myweight[p]; |
| 246 |
|
scalecolor(mypixel[p], d); |
| 247 |
+ |
if ((lastp=p)/hres != lastr) |
| 248 |
+ |
lastr = (lastrp=p)/hres; |
| 249 |
|
} |
| 250 |
|
/* write each scanline */ |
| 251 |
< |
for (v = vres; v--; ) |
| 252 |
< |
if (fwritescan(mypixel+v*hres, hres, stdout) < 0) |
| 251 |
> |
for (p = vres; p--; ) |
| 252 |
> |
if (fwritescan(mypixel+p*hres, hres, stdout) < 0) |
| 253 |
|
return(-1); |
| 254 |
|
if (fflush(stdout) == EOF) |
| 255 |
|
return(-1); |
| 288 |
|
/* allocate picture buffer */ |
| 289 |
|
mypixel = (COLOR *)bmalloc(xres*yres*sizeof(COLOR)); |
| 290 |
|
myweight = (float *)bmalloc(xres*yres*sizeof(float)); |
| 291 |
< |
if (mypixel == NULL | myweight == NULL) |
| 291 |
> |
mydepth = (float *)bmalloc(xres*yres*sizeof(float)); |
| 292 |
> |
if (mypixel == NULL | myweight == NULL | mydepth == NULL) |
| 293 |
|
error(SYSTEM, "out of memory in initialize"); |
| 294 |
|
} |
| 295 |
|
|