ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/rpict.c
(Generate patch)

Comparing ray/src/rt/rpict.c (file contents):
Revision 1.22 by greg, Sat Oct 13 21:32:25 1990 UTC vs.
Revision 1.32 by greg, Thu Sep 19 13:55:53 1991 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1986 Regents of the University of California */
1 > /* Copyright (c) 1991 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 24 | Line 24 | static char SCCSid[] = "$SunId$ LBL";
24  
25   #include  "random.h"
26  
27 + int  dimlist[MAXDIM];                   /* sampling dimensions */
28 + int  ndims = 0;                         /* number of sampling dimensions */
29 + int  samplendx;                         /* sample index number */
30 +
31   VIEW  ourview = STDVIEW;                /* view parameters */
32   int  hresolu = 512;                     /* horizontal resolution */
33   int  vresolu = 512;                     /* vertical resolution */
# Line 36 | Line 40 | double  dstrpix = 0.67;                        /* square pixel distribution
40   double  dstrsrc = 0.0;                  /* square source distribution */
41   double  shadthresh = .05;               /* shadow threshold */
42   double  shadcert = .5;                  /* shadow certainty */
43 + int  directrelay = 0;                   /* number of source relays */
44 + int  vspretest = 512;                   /* virtual source pretest density */
45 + int  directinvis = 0;                   /* sources invisible? */
46  
47   int  maxdepth = 6;                      /* maximum recursion depth */
48   double  minweight = 5e-3;               /* minimum ray weight */
# Line 53 | Line 60 | int  ralrm = 0;                                /* seconds between reports */
60  
61   double  pctdone = 0.0;                  /* percentage done */
62  
63 + long  tlastrept = 0L;                   /* time at last report */
64 +
65 + extern long  time();
66 + extern long  tstart;                    /* starting time */
67 +
68   extern long  nrays;                     /* number of rays traced */
69  
70 < #define  MAXDIV         32              /* maximum sample size */
70 > #define  MAXDIV         15              /* maximum sample size */
71  
72   #define  pixjitter()    (.5+dstrpix*(.5-frandom()))
73  
# Line 72 | Line 84 | int  code;
84   }
85  
86  
87 + #ifdef BSD
88   report()                /* report progress */
89   {
77 #ifdef BSD
90          struct rusage  rubuf;
91          double  t;
92  
# Line 87 | Line 99 | report()               /* report progress */
99  
100          sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f CPU hours\n",
101                          nrays, pctdone, t/3600.0);
102 +        eputs(errmsg);
103 +        tlastrept = time((long *)0);
104 + }
105   #else
106 + report()                /* report progress */
107 + {
108          signal(SIGALRM, report);
109 <        sprintf(errmsg, "%ld rays, %4.2f%% done\n", nrays, pctdone);
110 < #endif
109 >        tlastrept = time((long *)0);
110 >        sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f hours\n",
111 >                        nrays, pctdone, (tlastrept-tstart)/3600.0);
112          eputs(errmsg);
95
96        if (ralrm > 0)
97                alarm(ralrm);
113   }
114 + #endif
115  
116  
117   render(zfile, oldfile)                          /* render the scene */
# Line 113 | Line 129 | char  *zfile, *oldfile;
129                                          /* check sampling */
130          if (psample < 1)
131                  psample = 1;
132 <        else if (psample > MAXDIV)
132 >        else if (psample > MAXDIV) {
133 >                sprintf(errmsg, "pixel sampling reduced from %d to %d",
134 >                                psample, MAXDIV);
135 >                error(WARNING, errmsg);
136                  psample = MAXDIV;
137 +        }
138                                          /* allocate scanlines */
139          for (i = 0; i <= psample; i++) {
140                  scanbar[i] = (COLOR *)malloc(hresolu*sizeof(COLOR));
# Line 141 | Line 161 | char  *zfile, *oldfile;
161          fputresolu(YMAJOR|YDECR, hresolu, vresolu, stdout);
162                                          /* recover file and compute first */
163          i = salvage(oldfile);
164 <        if (zfd != -1 && lseek(zfd, (long)i*hresolu*sizeof(float), 0) == -1)
164 >        if (zfd != -1 && i > 0 &&
165 >                        lseek(zfd, (long)i*hresolu*sizeof(float), 0) == -1)
166                  error(SYSTEM, "z file seek error in render");
167 +        pctdone = 100.0*i/vresolu;
168 +        if (ralrm > 0)                  /* report init stats */
169 +                report();
170 + #ifndef  BSD
171 +        else
172 + #endif
173 +        signal(SIGALRM, report);
174          ypos = vresolu-1 - i;
175          fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample);
176          ystep = psample;
177                                                  /* compute scanlines */
178          for (ypos -= ystep; ypos > -ystep; ypos -= ystep) {
151                                                        /* record progress */
152                pctdone = 100.0*(vresolu-1-ypos-ystep)/vresolu;
179                                                          /* bottom adjust? */
180                  if (ypos < 0) {
181                          ystep += ypos;
# Line 166 | Line 192 | char  *zfile, *oldfile;
192                                                          /* fill bar */
193                  fillscanbar(scanbar, zbar, hresolu, ypos, ystep);
194                                                          /* write it out */
195 + #ifndef  BSD
196 +                signal(SIGALRM, SIG_IGN);       /* don't interrupt writes */
197 + #endif
198                  for (i = ystep; i > 0; i--) {
199                          if (zfd != -1 && write(zfd, (char *)zbar[i],
200                                          hresolu*sizeof(float))
# Line 176 | Line 205 | char  *zfile, *oldfile;
205                  }
206                  if (fflush(stdout) == EOF)
207                          goto writerr;
208 +                                                        /* record progress */
209 +                pctdone = 100.0*(vresolu-1-ypos)/vresolu;
210 +                if (ralrm > 0 && time((long *)0) >= tlastrept+ralrm)
211 +                        report();
212 + #ifndef  BSD
213 +                else
214 +                        signal(SIGALRM, report);
215 + #endif
216          }
217                                                  /* clean up */
218          if (zfd != -1) {
# Line 318 | Line 355 | pixvalue(col, x, y)            /* compute pixel value */
355   COLOR  col;                     /* returned color */
356   int  x, y;                      /* pixel position */
357   {
358 <        static RAY  thisray;    /* our ray for this pixel */
358 >        static RAY  thisray;
359  
360          if (viewray(thisray.rorg, thisray.rdir, &ourview,
361                          (x+pixjitter())/hresolu, (y+pixjitter())/vresolu) < 0) {
# Line 327 | Line 364 | int  x, y;                     /* pixel position */
364          }
365  
366          rayorigin(&thisray, NULL, PRIMARY, 1.0);
367 <        
367 >
368 >        samplendx = pixnumber(x,y,hresolu,vresolu);     /* set pixel index */
369 >
370          rayvalue(&thisray);                     /* trace ray */
371  
372          copycolor(col, thisray.rcol);           /* return color */
# Line 385 | Line 424 | char  *oldfile;
424          return(y);
425   writerr:
426          error(SYSTEM, "write error in salvage");
427 + }
428 +
429 +
430 + int
431 + pixnumber(x, y, xres, yres)             /* compute pixel index (brushed) */
432 + register int  x, y;
433 + int  xres, yres;
434 + {
435 +        x -= y;
436 +        while (x < 0)
437 +                x += xres;
438 +        return((((x>>2)*yres + y) << 2) + (x & 3));
439   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines