24 |
|
|
25 |
|
COLOR *mypixel; /* pixels being rendered */ |
26 |
|
float *myweight; /* weights (used to compute final pixels) */ |
27 |
+ |
float *mydepth; /* depth values (visibility culling) */ |
28 |
|
int hres, vres; /* current horizontal and vertical res. */ |
29 |
|
|
30 |
|
extern int nowarn; /* turn warnings off? */ |
50 |
|
case 'p': /* pixel aspect/exposure */ |
51 |
|
if (badarg(argc-i-1,argv+i+1,"f")) |
52 |
|
goto userr; |
53 |
< |
if (argv[i][1] == 'a') |
53 |
> |
if (argv[i][2] == 'a') |
54 |
|
pixaspect = atof(argv[++i]); |
55 |
< |
else if (argv[i][1] == 'e') { |
55 |
> |
else if (argv[i][2] == 'e') { |
56 |
|
expval = atof(argv[++i]); |
57 |
|
if (argv[i][0] == '-' | argv[i][0] == '+') |
58 |
|
expval = pow(2., expval); |
80 |
|
seqstart = atoi(argv[++i]); |
81 |
|
break; |
82 |
|
case 'v': /* view file */ |
83 |
< |
if (argv[i][1]!='f' || badarg(argc-i-1,argv+i+1,"s")) |
83 |
> |
if (argv[i][2]!='f' || badarg(argc-i-1,argv+i+1,"s")) |
84 |
|
goto userr; |
85 |
|
rval = viewfile(argv[++i], &myview, NULL); |
86 |
|
if (rval < 0) { |
98 |
|
} |
99 |
|
} |
100 |
|
/* open holodeck file */ |
101 |
< |
if (i >= argc) |
101 |
> |
if (i != argc-1) |
102 |
|
goto userr; |
103 |
< |
hdkfile = argv[i++]; |
103 |
> |
hdkfile = argv[i]; |
104 |
|
initialize(); |
105 |
|
/* render picture(s) */ |
106 |
|
if (seqstart <= 0) |
145 |
|
sprintf(errmsg, "error writing frame %d", fn); |
146 |
|
error(SYSTEM, errmsg); |
147 |
|
} |
148 |
+ |
#ifdef DEBUG |
149 |
|
if (blist.nb > 0 & rval > 0) { |
150 |
< |
sprintf(errmsg, "%.1f%% unrendered pixels in frame %d", |
151 |
< |
100.*rval/(hres*vres), fn); |
150 |
> |
sprintf(errmsg, "%d unrendered pixels in frame %d (%.1f%%)", |
151 |
> |
rval, fn, 100.*rval/(hres*vres)); |
152 |
|
error(WARNING, errmsg); |
153 |
|
} |
154 |
+ |
#endif |
155 |
|
} |
156 |
|
|
157 |
|
|
159 |
|
register PACKHEAD *bl; |
160 |
|
int nb; |
161 |
|
{ |
162 |
< |
extern int render_beam(); |
162 |
> |
extern int pixBeam(); |
163 |
|
register HDBEAMI *bil; |
164 |
|
register int i; |
165 |
|
|
170 |
|
bil[i].h = hdlist[bl[i].hd]; |
171 |
|
bil[i].b = bl[i].bi; |
172 |
|
} |
173 |
< |
hdloadbeams(bil, nb, render_beam); |
173 |
> |
hdloadbeams(bil, nb, pixBeam); |
174 |
> |
pixFlush(); |
175 |
|
free((char *)bil); |
176 |
|
} |
177 |
|
|
213 |
|
/* prepare image buffers */ |
214 |
|
bzero((char *)mypixel, hres*vres*sizeof(COLOR)); |
215 |
|
bzero((char *)myweight, hres*vres*sizeof(float)); |
216 |
+ |
bzero((char *)mydepth, hres*vres*sizeof(float)); |
217 |
|
} |
218 |
|
|
219 |
|
|
220 |
|
int |
221 |
|
endpicture() /* finish and write out pixels */ |
222 |
|
{ |
223 |
< |
int nunrend = 0; |
224 |
< |
int v; |
223 |
> |
int lastr = -1, nunrend = 0; |
224 |
> |
int4 lastp, lastrp; |
225 |
> |
register int4 p; |
226 |
|
register double d; |
221 |
– |
register int p; |
227 |
|
/* compute final pixel values */ |
228 |
|
for (p = hres*vres; p--; ) { |
229 |
|
if (myweight[p] <= FTINY) { |
230 |
+ |
if (lastr >= 0) |
231 |
+ |
if (p/hres == lastp/hres) |
232 |
+ |
copycolor(mypixel[p], mypixel[lastp]); |
233 |
+ |
else |
234 |
+ |
copycolor(mypixel[p], mypixel[lastrp]); |
235 |
|
nunrend++; |
236 |
|
continue; |
237 |
|
} |
238 |
|
d = expval/myweight[p]; |
239 |
|
scalecolor(mypixel[p], d); |
240 |
+ |
if ((lastp=p)/hres != lastr) |
241 |
+ |
lastr = (lastrp=p)/hres; |
242 |
|
} |
243 |
|
/* write each scanline */ |
244 |
< |
for (v = vres; v--; ) |
245 |
< |
if (fwritescan(mypixel+v*hres, hres, stdout) < 0) |
244 |
> |
for (p = vres; p--; ) |
245 |
> |
if (fwritescan(mypixel+p*hres, hres, stdout) < 0) |
246 |
|
return(-1); |
247 |
|
if (fflush(stdout) == EOF) |
248 |
|
return(-1); |
281 |
|
/* allocate picture buffer */ |
282 |
|
mypixel = (COLOR *)bmalloc(xres*yres*sizeof(COLOR)); |
283 |
|
myweight = (float *)bmalloc(xres*yres*sizeof(float)); |
284 |
< |
if (mypixel == NULL | myweight == NULL) |
284 |
> |
mydepth = (float *)bmalloc(xres*yres*sizeof(float)); |
285 |
> |
if (mypixel == NULL | myweight == NULL | mydepth == NULL) |
286 |
|
error(SYSTEM, "out of memory in initialize"); |
287 |
|
} |
288 |
|
|