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 2.85 by greg, Mon Nov 26 07:04:07 2012 UTC vs.
Revision 2.87 by greg, Tue Feb 18 12:13:42 2014 UTC

# Line 33 | Line 33 | static const char RCSid[] = "$Id$";
33   #include  "view.h"
34   #include  "random.h"
35   #include  "paths.h"
36 < #include  "rtmisc.h" /* myhostname() */
36 > #include  "hilbert.h"
37  
38  
39   #define  RFTEMPLATE     "rfXXXXXX"
# Line 663 | Line 663 | pixvalue(              /* compute pixel value */
663          int  y
664   )
665   {
666 +        extern void  SDsquare2disk(double ds[2], double seedx, double seedy);
667          RAY  thisray;
668          FVECT   lorg, ldir;
669          double  hpos, vpos, vdist, lmax;
# Line 694 | Line 695 | pixvalue(              /* compute pixel value */
695          }
696                                                  /* optional depth-of-field */
697          if (dblur > FTINY) {
698 <                double  vc, dfh, dfv;
699 <                                                /* square/circle conv. */
700 <                dfh = vc = 1. - 2.*frandom();
701 <                dfv = 1. - 2.*frandom();
702 <                dfh *= .5*dblur*sqrt(1. - .5*dfv*dfv);
702 <                dfv *= .5*dblur*sqrt(1. - .5*vc*vc);
698 >                double  vc, df[2];
699 >                                                /* random point on disk */
700 >                SDsquare2disk(df, frandom(), frandom());
701 >                df[0] *= .5*dblur;
702 >                df[1] *= .5*dblur;
703                  if ((ourview.type == VT_PER) | (ourview.type == VT_PAR)) {
704                          double  adj = 1.0;
705                          if (ourview.type == VT_PER)
706                                  adj /= DOT(thisray.rdir, ourview.vdir);
707 <                        dfh /= sqrt(ourview.hn2);
708 <                        dfv /= sqrt(ourview.vn2);
707 >                        df[0] /= sqrt(ourview.hn2);
708 >                        df[1] /= sqrt(ourview.vn2);
709                          for (i = 3; i--; ) {
710                                  vc = ourview.vp[i] + adj*vdist*thisray.rdir[i];
711 <                                thisray.rorg[i] += dfh*ourview.hvec[i] +
712 <                                                        dfv*ourview.vvec[i] ;
711 >                                thisray.rorg[i] += df[0]*ourview.hvec[i] +
712 >                                                        df[1]*ourview.vvec[i] ;
713                                  thisray.rdir[i] = vc - thisray.rorg[i];
714                          }
715                  } else {                        /* non-standard view case */
716                          double  dfd = PI/4.*dblur*(.5 - frandom());
717                          if ((ourview.type != VT_ANG) & (ourview.type != VT_PLS)) {
718                                  if (ourview.type != VT_CYL)
719 <                                        dfh /= sqrt(ourview.hn2);
720 <                                dfv /= sqrt(ourview.vn2);
719 >                                        df[0] /= sqrt(ourview.hn2);
720 >                                df[1] /= sqrt(ourview.vn2);
721                          }
722                          for (i = 3; i--; ) {
723                                  vc = ourview.vp[i] + vdist*thisray.rdir[i];
724 <                                thisray.rorg[i] += dfh*ourview.hvec[i] +
725 <                                                        dfv*ourview.vvec[i] +
724 >                                thisray.rorg[i] += df[0]*ourview.hvec[i] +
725 >                                                        df[1]*ourview.vvec[i] +
726                                                          dfd*ourview.vdir[i] ;
727                                  thisray.rdir[i] = vc - thisray.rorg[i];
728                          }
# Line 802 | Line 802 | writerr:
802   }
803  
804   static int
805 < pixnumber(              /* compute pixel index (brushed) */
805 > pixnumber(              /* compute pixel index (screen door) */
806          int  x,
807          int  y,
808          int  xres,
809          int  yres
810   )
811   {
812 <        x -= y;
813 <        while (x < 0)
814 <                x += xres;
815 <        return((((x>>2)*yres + y) << 2) + (x & 3));
812 >        unsigned        nbits = 0;
813 >        bitmask_t       coord[2];
814 >
815 >        if (xres < yres) xres = yres;
816 >        while (xres > 0) {
817 >                xres >>= 1;
818 >                ++nbits;
819 >        }
820 >        coord[0] = x; coord[1] = y;
821 >        return ((int)hilbert_c2i(2, nbits, coord));
822   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines