--- ray/src/hd/rhpict.c 1999/03/04 10:30:04 3.1 +++ ray/src/hd/rhpict.c 1999/03/09 10:55:24 3.4 @@ -24,6 +24,7 @@ double expval = 1.; /* exposure value */ COLOR *mypixel; /* pixels being rendered */ float *myweight; /* weights (used to compute final pixels) */ +float *mydepth; /* depth values (visibility culling) */ int hres, vres; /* current horizontal and vertical res. */ extern int nowarn; /* turn warnings off? */ @@ -49,9 +50,9 @@ char *argv[]; case 'p': /* pixel aspect/exposure */ if (badarg(argc-i-1,argv+i+1,"f")) goto userr; - if (argv[i][1] == 'a') + if (argv[i][2] == 'a') pixaspect = atof(argv[++i]); - else if (argv[i][1] == 'e') { + else if (argv[i][2] == 'e') { expval = atof(argv[++i]); if (argv[i][0] == '-' | argv[i][0] == '+') expval = pow(2., expval); @@ -79,7 +80,7 @@ char *argv[]; seqstart = atoi(argv[++i]); break; case 'v': /* view file */ - if (argv[i][1]!='f' || badarg(argc-i-1,argv+i+1,"s")) + if (argv[i][2]!='f' || badarg(argc-i-1,argv+i+1,"s")) goto userr; rval = viewfile(argv[++i], &myview, NULL); if (rval < 0) { @@ -97,9 +98,9 @@ char *argv[]; } } /* open holodeck file */ - if (i >= argc) + if (i != argc-1) goto userr; - hdkfile = argv[i++]; + hdkfile = argv[i]; initialize(); /* render picture(s) */ if (seqstart <= 0) @@ -144,11 +145,13 @@ int fn; sprintf(errmsg, "error writing frame %d", fn); error(SYSTEM, errmsg); } +#ifdef DEBUG if (blist.nb > 0 & rval > 0) { - sprintf(errmsg, "%.1f%% unrendered pixels in frame %d", - 100.*rval/(hres*vres), fn); + sprintf(errmsg, "%d unrendered pixels in frame %d (%.1f%%)", + rval, fn, 100.*rval/(hres*vres)); error(WARNING, errmsg); } +#endif } @@ -156,7 +159,7 @@ render_frame(bl, nb) /* render frame from beam values register PACKHEAD *bl; int nb; { - extern int render_beam(); + extern int pixBeam(); register HDBEAMI *bil; register int i; @@ -167,7 +170,8 @@ int nb; bil[i].h = hdlist[bl[i].hd]; bil[i].b = bl[i].bi; } - hdloadbeams(bil, nb, render_beam); + hdloadbeams(bil, nb, pixBeam); + pixFlush(); free((char *)bil); } @@ -209,28 +213,36 @@ int fn; /* prepare image buffers */ bzero((char *)mypixel, hres*vres*sizeof(COLOR)); bzero((char *)myweight, hres*vres*sizeof(float)); + bzero((char *)mydepth, hres*vres*sizeof(float)); } int endpicture() /* finish and write out pixels */ { - int nunrend = 0; - int v; + int lastr = -1, nunrend = 0; + int4 lastp, lastrp; + register int4 p; register double d; - register int p; /* compute final pixel values */ for (p = hres*vres; p--; ) { if (myweight[p] <= FTINY) { + if (lastr >= 0) + if (p/hres == lastp/hres) + copycolor(mypixel[p], mypixel[lastp]); + else + copycolor(mypixel[p], mypixel[lastrp]); nunrend++; continue; } d = expval/myweight[p]; scalecolor(mypixel[p], d); + if ((lastp=p)/hres != lastr) + lastr = (lastrp=p)/hres; } /* write each scanline */ - for (v = vres; v--; ) - if (fwritescan(mypixel+v*hres, hres, stdout) < 0) + for (p = vres; p--; ) + if (fwritescan(mypixel+p*hres, hres, stdout) < 0) return(-1); if (fflush(stdout) == EOF) return(-1); @@ -269,7 +281,8 @@ initialize() /* initialize holodeck and buffers */ /* allocate picture buffer */ mypixel = (COLOR *)bmalloc(xres*yres*sizeof(COLOR)); myweight = (float *)bmalloc(xres*yres*sizeof(float)); - if (mypixel == NULL | myweight == NULL) + mydepth = (float *)bmalloc(xres*yres*sizeof(float)); + if (mypixel == NULL | myweight == NULL | mydepth == NULL) error(SYSTEM, "out of memory in initialize"); }