--- ray/src/rt/rpict.c 1996/01/23 16:27:31 2.42 +++ ray/src/rt/rpict.c 1996/04/17 14:02:05 2.46 @@ -6,8 +6,6 @@ static char SCCSid[] = "$SunId$ LBL"; /* * rpict.c - routines and variables for picture generation. - * - * 8/14/85 */ #include "ray.h" @@ -20,7 +18,6 @@ static char SCCSid[] = "$SunId$ LBL"; #include #else #include -#include #include #endif #endif @@ -65,7 +62,7 @@ int directvis = 1; /* sources visible? */ double srcsizerat = .25; /* maximum ratio source size/dist. */ COLOR cextinction = BLKCOLOR; /* global extinction coefficient */ -double salbedo = 0.; /* global scattering albedo */ +COLOR salbedo = BLKCOLOR; /* global scattering albedo */ double seccg = 0.; /* global scattering eccentricity */ double ssampdist = 0.; /* scatter sampling distance */ @@ -78,6 +75,7 @@ int maxdepth = 6; /* maximum recursion depth */ double minweight = 5e-3; /* minimum ray weight */ COLOR ambval = BLKCOLOR; /* ambient value */ +int ambvwt = 0; /* initial weight for ambient value */ double ambacc = 0.2; /* ambient accuracy */ int ambres = 32; /* ambient resolution */ int ambdiv = 128; /* ambient divisions */ @@ -140,15 +138,13 @@ int code; #ifndef NIX report() /* report progress */ { + extern char *myhostname(); double u, s; #ifdef BSD - char hostname[257]; struct rusage rubuf; #else struct tms tbuf; - struct utsname nambuf; double period; -#define hostname nambuf.nodename #endif tlastrept = time((time_t *)NULL); @@ -159,7 +155,6 @@ report() /* report progress */ getrusage(RUSAGE_CHILDREN, &rubuf); u += rubuf.ru_utime.tv_sec + rubuf.ru_utime.tv_usec/1e6; s += rubuf.ru_stime.tv_sec + rubuf.ru_stime.tv_usec/1e6; - gethostname(hostname, sizeof(hostname)); #else times(&tbuf); #ifdef _SC_CLK_TCK @@ -169,17 +164,15 @@ report() /* report progress */ #endif u = ( tbuf.tms_utime + tbuf.tms_cutime ) * period; s = ( tbuf.tms_stime + tbuf.tms_cstime ) * period; - uname(&nambuf); #endif sprintf(errmsg, "%lu rays, %4.2f%% after %.3fu %.3fs %.3fr hours on %s\n", nrays, pctdone, u/3600., s/3600., - (tlastrept-tstart)/3600., hostname); + (tlastrept-tstart)/3600., myhostname()); eputs(errmsg); #ifndef BSD signal(SIGCONT, report); -#undef hostname #endif } #else @@ -430,6 +423,9 @@ char *zfile, *oldfile; hres, ypos, hstep); /* fill bar */ fillscanbar(scanbar, zbar, hres, ypos, ystep); + /* add bitty sources */ + drawsources(&ourview, hres, vres, scanbar, zbar, + 0, hres, ypos, ystep, psample); /* write it out */ #ifndef BSD signal(SIGCONT, SIG_IGN); /* don't interrupt writes */ @@ -494,7 +490,7 @@ int xres, y, xstep; int bl = xstep, b = xstep; double z; register int i; - + z = pixvalue(scanline[0], 0, y); if (zline) zline[0] = z; /* zig-zag start for quincunx pattern */ @@ -528,19 +524,17 @@ int xres, y, ysize; float zline[MAXDIV+1]; int b = ysize; register int i, j; - + for (i = 0; i < xres; i++) { - copycolor(vline[0], scanbar[0][i]); copycolor(vline[ysize], scanbar[ysize][i]); if (zbar[0]) { zline[0] = zbar[0][i]; zline[ysize] = zbar[ysize][i]; } - b = fillsample(vline, zbar[0] ? zline : (float *)NULL, i, y, 0, ysize, b/2); - + for (j = 1; j < ysize; j++) copycolor(scanbar[j][i], vline[j]); if (zbar[0]) @@ -563,25 +557,23 @@ int b; COLOR ctmp; int ncut; register int len; - + if (xlen > 0) /* x or y length is zero */ len = xlen; else len = ylen; - + if (len <= 1) /* limit recursion */ return(0); - - if (b > 0 - || (zline && 2.*fabs(zline[0]-zline[len]) > maxdiff*(zline[0]+zline[len])) + + if (b > 0 || + (zline && 2.*fabs(zline[0]-zline[len]) > maxdiff*(zline[0]+zline[len])) || bigdiff(colline[0], colline[len], maxdiff)) { - + z = pixvalue(colline[len>>1], x + (xlen>>1), y + (ylen>>1)); if (zline) zline[len>>1] = z; ncut = 1; - } else { /* interpolate */ - copycolor(colline[len>>1], colline[len]); ratio = (double)(len>>1) / len; scalecolor(colline[len>>1], ratio); @@ -595,7 +587,7 @@ int b; } /* recurse */ ncut += fillsample(colline, zline, x, y, xlen>>1, ylen>>1, (b-1)/2); - + ncut += fillsample(colline+(len>>1), zline ? zline+(len>>1) : (float *)NULL, x+(xlen>>1), y+(ylen>>1), @@ -625,7 +617,7 @@ int x, y; /* pixel position */ rayvalue(&thisray); /* trace ray */ copycolor(col, thisray.rcol); /* return color */ - + return(thisray.rt); /* return distance */ }