--- ray/src/util/findglare.c 1991/03/21 17:11:46 1.11 +++ ray/src/util/findglare.c 1991/04/10 15:59:07 1.16 @@ -40,11 +40,15 @@ int hlim; /* central limit of horizontal */ struct illum *indirect; /* array of indirect illuminances */ +long npixinvw; /* number of pixels in view */ +long npixmiss; /* number of pixels missed */ + main(argc, argv) int argc; char *argv[]; { + int combine = 1; int gotview = 0; int rval, i; char *err; @@ -98,6 +102,9 @@ char *argv[]; case 'p': picture = argv[++i]; break; + case 'c': + combine = !combine; + break; case 'd': case 'l': rtargv[rtargc++] = argv[i]; @@ -176,6 +183,8 @@ char *argv[]; if (threshold <= FTINY) comp_thresh(); /* compute glare threshold */ analyze(); /* analyze view */ + if (combine) + absorb_specks(); /* eliminate tiny sources */ cleanup(); /* tidy up */ /* print header */ printargs(argc, argv, stdout); @@ -223,6 +232,7 @@ init() /* initialize global variables */ indirect = (struct illum *)calloc(nglardirs, sizeof(struct illum)); if (indirect == NULL) memerr("indirect illuminances"); + npixinvw = npixmiss = 0L; copystruct(&leftview, &ourview); copystruct(&rightview, &ourview); spinvector(leftview.vdir, ourview.vdir, ourview.vup, maxtheta); @@ -276,6 +286,9 @@ cleanup() /* close files, wait for children */ close_pict(); if (octree != NULL) done_rtrace(); + if (npixinvw < 100*npixmiss) + fprintf(stderr, "%s: warning -- missing %ld%% of samples\n", + progname, 100L*npixmiss/npixinvw); } @@ -283,19 +296,32 @@ compdir(vd, x, y) /* compute direction for x,y */ FVECT vd; int x, y; { + static int cury = 10000; + static double err, cmpval; + long t; FVECT org; /* dummy variable */ if (x <= -hlim) /* left region */ return(viewray(org, vd, &leftview, - (x+hlim)/(2.*sampdens)+.5, - y/(2.*sampdens)+.5)); + (double)(x+hlim)/(2*sampdens)+.5, + (double)y/(2*sampdens)+.5)); if (x >= hlim) /* right region */ return(viewray(org, vd, &rightview, - (x-hlim)/(2.*sampdens)+.5, - y/(2.*sampdens)+.5)); - /* central region */ - if (viewray(org, vd, &ourview, .5, y/(2.*sampdens)+.5) < 0) + (double)(x-hlim)/(2*sampdens)+.5, + (double)y/(2*sampdens)+.5)); + /* central region */ + /* avoid over-counting of poles */ + if (cury != y) { + err = 0.0; + cmpval = sqrt(1.0 - (double)((long)y*y)/((long)vsize*vsize)); + cury = y; + } + err += cmpval; + if (err <= 0.5) return(-1); + err -= 1.0; + if (viewray(org, vd, &ourview, .5, (double)y/(2*sampdens)+.5) < 0) + return(-1); spinvector(vd, vd, ourview.vup, h_theta(x)); return(0); } @@ -328,7 +354,8 @@ printillum() /* print out indirect illuminances */ printf("BEGIN indirect illuminance\n"); for (i = 0; i < nglardirs; i++) - printf("\t%.0f\t%f\n", (180.0/PI)*indirect[i].theta, - PI * indirect[i].sum / indirect[i].n); + if (indirect[i].n > FTINY) + printf("\t%.0f\t%f\n", (180.0/PI)*indirect[i].theta, + PI * indirect[i].sum / indirect[i].n); printf("END indirect illuminance\n"); }