--- ray/src/rt/rpict.c 1989/04/10 09:32:55 1.2 +++ ray/src/rt/rpict.c 1989/09/29 08:16:41 1.9 @@ -24,18 +24,19 @@ static char SCCSid[] = "$SunId$ LBL"; VIEW ourview = STDVIEW(512); /* view parameters */ int psample = 4; /* pixel sample size */ - double maxdiff = .05; /* max. difference for interpolation */ - double dstrpix = 0.67; /* square pixel distribution */ + double dstrsrc = 0.0; /* square source distribution */ +double shadthresh = .05; /* shadow threshold */ +double shadcert = .5; /* shadow certainty */ int maxdepth = 6; /* maximum recursion depth */ double minweight = 5e-3; /* minimum ray weight */ COLOR ambval = BLKCOLOR; /* ambient value */ double ambacc = 0.2; /* ambient accuracy */ -int ambres = 128; /* ambient resolution */ +int ambres = 32; /* ambient resolution */ int ambdiv = 128; /* ambient divisions */ int ambssamp = 0; /* ambient super-samples */ int ambounce = 0; /* ambient bounces */ @@ -93,46 +94,53 @@ char *oldfile; { COLOR *scanbar[MAXDIV+1]; /* scanline arrays of pixel values */ int ypos; /* current scanline */ + int xres, yres; /* rendered x and y resolution */ COLOR *colptr; register int i; - - if (psample < 1) + /* set rendered resolution */ + xres = ourview.hresolu; + yres = ourview.vresolu; + /* adjust for sampling */ + if (psample <= 1) psample = 1; - else if (psample > MAXDIV) - psample = MAXDIV; - - ourview.hresolu -= ourview.hresolu % psample; - ourview.vresolu -= ourview.vresolu % psample; - + else { + if (psample > MAXDIV) + psample = MAXDIV; + /* rendered resolution may be larger */ + xres += psample-1 - ((ourview.hresolu-2)%psample); + yres += psample-1 - ((ourview.vresolu-2)%psample); + } + /* allocate scanlines */ for (i = 0; i <= psample; i++) { - scanbar[i] = (COLOR *)malloc((ourview.hresolu+1)*sizeof(COLOR)); + scanbar[i] = (COLOR *)malloc(xres*sizeof(COLOR)); if (scanbar[i] == NULL) error(SYSTEM, "out of memory in render"); } - /* write out boundaries */ - printf("-Y %d +X %d\n", ourview.vresolu, ourview.hresolu); + fputresolu(YMAJOR|YDECR, ourview.hresolu, ourview.vresolu, stdout); - ypos = ourview.vresolu - salvage(oldfile); /* find top line */ - fillscanline(scanbar[0], ypos, psample); /* top scan */ + ypos = ourview.vresolu-1 - salvage(oldfile); /* find top line */ + fillscanline(scanbar[0], xres, ypos, psample); /* top scan */ for (ypos -= psample; ypos > -psample; ypos -= psample) { - colptr = scanbar[psample]; /* get last scanline */ + pctdone = 100.0*(ourview.vresolu-ypos+psample)/ourview.vresolu; + + colptr = scanbar[psample]; /* move base to top */ scanbar[psample] = scanbar[0]; scanbar[0] = colptr; - fillscanline(scanbar[0], ypos, psample); /* base scan */ + fillscanline(scanbar[0], xres, ypos, psample); /* fill base */ - fillscanbar(scanbar, ypos, psample); + fillscanbar(scanbar, xres, ypos, psample); /* fill bar */ - for (i = psample-1; i >= 0; i--) + for (i = psample; (ypos>0) ? i > 0 : ypos+i >= 0; i--) if (fwritescan(scanbar[i], ourview.hresolu, stdout) < 0) goto writerr; if (fflush(stdout) == EOF) goto writerr; - pctdone = 100.0*(ourview.vresolu-ypos)/ourview.vresolu; } + pctdone = 100.0; for (i = 0; i <= psample; i++) free((char *)scanbar[i]); @@ -142,16 +150,16 @@ writerr: } -fillscanline(scanline, y, xstep) /* fill scan line at y */ +fillscanline(scanline, xres, y, xstep) /* fill scan line at y */ register COLOR *scanline; -int y, xstep; +int xres, y, xstep; { int b = xstep; register int i; pixvalue(scanline[0], 0, y); - for (i = xstep; i <= ourview.hresolu; i += xstep) { + for (i = xstep; i < xres; i += xstep) { pixvalue(scanline[i], i, y); @@ -160,15 +168,15 @@ int y, xstep; } -fillscanbar(scanbar, y, ysize) /* fill interior */ +fillscanbar(scanbar, xres, y, ysize) /* fill interior */ register COLOR *scanbar[]; -int y, ysize; +int xres, y, ysize; { COLOR vline[MAXDIV+1]; int b = ysize; register int i, j; - for (i = 0; i < ourview.hresolu; i++) { + for (i = 0; i < xres; i++) { copycolor(vline[0], scanbar[0][i]); copycolor(vline[ysize], scanbar[ysize][i]); @@ -254,7 +262,8 @@ char *oldfile; if (oldfile == NULL) return(0); - else if ((fp = fopen(oldfile, "r")) == NULL) { + + if ((fp = fopen(oldfile, "r")) == NULL) { sprintf(errmsg, "cannot open recover file \"%s\"", oldfile); error(WARNING, errmsg); return(0); @@ -262,7 +271,7 @@ char *oldfile; /* discard header */ getheader(fp, NULL); /* get picture size */ - if (fscanf(fp, "-Y %d +X %d\n", &y, &x) != 2) { + if (fgetresolu(&x, &y, fp) != (YMAJOR|YDECR)) { sprintf(errmsg, "bad recover file \"%s\"", oldfile); error(WARNING, errmsg); fclose(fp); @@ -273,7 +282,6 @@ char *oldfile; sprintf(errmsg, "resolution mismatch in recover file \"%s\"", oldfile); error(USER, errmsg); - return(0); } scanline = (COLR *)malloc(ourview.hresolu*sizeof(COLR));