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

Comparing ray/src/px/pcond4.c (file contents):
Revision 3.8 by greg, Tue Oct 8 12:48:00 1996 UTC vs.
Revision 3.12 by greg, Fri Jan 10 13:06:54 1997 UTC

# Line 14 | Line 14 | static char SCCSid[] = "$SunId$ LBL";
14  
15   #define VADAPT          0.08            /* fraction of adaptation from veil */
16  
17 < extern COLOR    *fovimg;                /* foveal (1 degree) averaged image */
18 < extern short    fvxr, fvyr;             /* foveal image resolution */
17 > static COLOR    *veilimg = NULL;        /* veiling image */
18  
20 #define fovscan(y)      (fovimg+(y)*fvxr)
21
22 static COLOR    *veilimg;               /* veiling image */
23
19   #define veilscan(y)     (veilimg+(y)*fvxr)
20  
21   static float    (*raydir)[3] = NULL;    /* ray direction for each pixel */
# Line 83 | Line 78 | compveil()                             /* compute veiling image */
78          COLOR   ctmp, vsum;
79          int     px, py;
80          register int    x, y;
81 +
82 +        if (veilimg != NULL)            /* already done? */
83 +                return;
84                                          /* compute ray directions */
85          compraydir();
86                                          /* compute veil image */
# Line 100 | Line 98 | compveil()                             /* compute veiling image */
98                                                          rdirscan(y)[x]);
99                                          if (t2 <= FTINY) continue;
100                                          /*      use approximation instead
101 <                                        t2 = acos(t2);
102 <                                        t2 = 1./(t2*t2);
101 >                                        t3 = acos(t2);
102 >                                        t2 = t2/(t3*t3);
103                                          */
104 <                                        t2 = .5 / (1. - t2);
104 >                                        t2 *= .5 / (1. - t2);
105                                          copycolor(ctmp, fovscan(y)[x]);
106                                          scalecolor(ctmp, t2);
107                                          addcolor(vsum, ctmp);
# Line 113 | Line 111 | compveil()                             /* compute veiling image */
111                          scalecolor(vsum, VADAPT/t2sum);
112                          copycolor(veilscan(py)[px], vsum);
113                  }
114 +                                        /* modify FOV sample image */
115 +        for (y = 0; y < fvyr; y++)
116 +                for (x = 0; x < fvxr; x++) {
117 +                        scalecolor(fovscan(y)[x], 1.-VADAPT);
118 +                        addcolor(fovscan(y)[x], veilscan(y)[x]);
119 +                }
120 +        comphist();                     /* recompute histogram */
121   }
122  
123  
# Line 241 | Line 246 | int    y;
246          register int    x;
247                                          /* compute foveal y position */
248          iy = dy = (y+.5)/numscans(&inpres)*fvyr - .5;
249 <        if (iy >= fvyr-1) iy--;
249 >        while (iy >= fvyr-1) iy--;
250          dy -= (double)iy;
251          for (x = 0; x < scanlen(&inpres); x++) {
252                                          /* compute foveal x position */
253                  ix = dx = (x+.5)/scanlen(&inpres)*fvxr - .5;
254 <                if (ix >= fvxr-1) ix--;
254 >                while (ix >= fvxr-1) ix--;
255                  dx -= (double)ix;
256                                          /* interpolate sample rate */
257                  sr = (1.-dy)*((1.-dx)*tsampr(ix,iy) + dx*tsampr(ix+1,iy)) +
# Line 302 | Line 307 | SCANBAR        *sb;
307          dy -= (double)iy;
308                                          /* get scanlines */
309          sl0 = getascan(sb, iy);
310 + #ifdef DEBUG
311          if (sl0 == NULL) {
312                  fprintf(stderr, "%s: internal - cannot backspace in ascanval\n",
313                                  progname);
314 <                exit(1);
314 >                abort();
315          }
316 + #endif
317          sl1 = getascan(sb, iy+1);
318                                          /* 2D linear interpolation */
319          copycolor(col, sl0[ix]);
# Line 322 | Line 329 | SCANBAR        *sb;
329          scalecolor(col, 1.-dy);
330          scalecolor(c1y, dy);
331          addcolor(col, c1y);
332 +        for (ix = 0; ix < 3; ix++)      /* make sure no negative */
333 +                if (colval(col,ix) < 0.)
334 +                        colval(col,ix) = 0.;
335   }
336  
337  
338   SCANBAR *
339 < sballoc(sr, ns, sl)             /* allocate scanbar */
340 < int     sr;             /* sampling rate */
339 > sballoc(se, ns, sl)             /* allocate scanbar */
340 > int     se;             /* sampling rate exponent */
341   int     ns;             /* number of scanlines */
342   int     sl;             /* original scanline length */
343   {
344          SCANBAR *sbarr;
345          register SCANBAR        *sb;
346  
347 <        sbarr = sb = (SCANBAR *)malloc((sr+1)*sizeof(SCANBAR));
347 >        sbarr = sb = (SCANBAR *)malloc((se+1)*sizeof(SCANBAR));
348          if (sb == NULL)
349                  syserror("malloc");
350          do {
351 <                sb->sdata = (COLOR *)malloc((sl>>sr)*ns*sizeof(COLOR));
351 >                sb->sampe = se;
352 >                sb->len = sl>>se;
353 >                sb->nscans = ns;
354 >                sb->sdata = (COLOR *)malloc(sb->len*ns*sizeof(COLOR));
355                  if (sb->sdata == NULL)
356                          syserror("malloc");
344                sb->sampe = sr;
345                sb->nscans = ns;
346                sb->len = sl>>sr;
357                  sb->nread = 0;
358                  ns <<= 1;
359                  sb++;
360 <        } while (--sr >= 0);
360 >        } while (--se >= 0);
361          return(sbarr);
362   }
363  
# Line 376 | Line 386 | initacuity()                   /* initialize variable acuity sampling
386                          }
387                          fcross(cp, diffx, diffy);
388                          omega = 0.5 * sqrt(DOT(cp,cp));
389 <                        if (omega <= FTINY)
389 >                        if (omega <= FTINY*FTINY)
390                                  tsampr(x,y) = 1.;
391                          else if ((tsampr(x,y) = PI/180. / sqrt(omega) /
392                                          hacuity(plum(fovscan(y)[x]))) > maxsr)
# Line 388 | Line 398 | initacuity()                   /* initialize variable acuity sampling
398                  tsampr(x,fvyr-1) = tsampr(x,fvyr-2);
399          }
400          for (y = 0; y < fvyr; y++) {
401 <                tsampr(y,0) = tsampr(y,1);
402 <                tsampr(y,fvxr-1) = tsampr(y,fvxr-2);
401 >                tsampr(0,y) = tsampr(1,y);
402 >                tsampr(fvxr-1,y) = tsampr(fvxr-2,y);
403          }
404                                          /* initialize with next power of two */
405          rootbar = sballoc((int)(log(maxsr)/log(2.))+1, 2, scanlen(&inpres));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines