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.70 by greg, Tue Sep 28 17:54:19 2004 UTC vs.
Revision 2.81 by greg, Mon May 11 21:46:31 2009 UTC

# Line 9 | Line 9 | static const char RCSid[] = "$Id$";
9  
10   #include  <sys/types.h>
11  
12 < #ifndef NON_POSIX
13 < #ifdef BSD
14 < #include  <sys/time.h>
15 < #include  <sys/resource.h>
12 > #include  "platform.h"
13 > #ifdef NON_POSIX
14 > #ifdef MINGW
15 >  #include  <sys/time.h>
16 > #endif
17   #else
18 < #include  <sys/times.h>
19 < #include  <unistd.h>
18 > #ifdef BSD
19 >  #include  <sys/time.h>
20 >  #include  <sys/resource.h>
21 > #else
22 >  #include  <sys/times.h>
23 >  #include  <unistd.h>
24 > #endif
25   #endif
20 #endif
26  
27   #include  <time.h>
28   #include  <signal.h>
29  
25 #include  "platform.h"
30   #include  "ray.h"
31   #include  "paths.h"
32   #include  "ambient.h"
# Line 61 | Line 65 | double dstrpix = 0.67;                 /* square pixel distribution
65  
66   double  mblur = 0.;                     /* motion blur parameter */
67  
68 + double  dblur = 0.;                     /* depth-of-field blur parameter */
69 +
70   void  (*trace)() = NULL;                /* trace call */
71  
72   int  do_irrad = 0;                      /* compute irradiance? */
73  
74 + int  rand_samp = 0;                     /* pure Monte Carlo sampling? */
75 +
76   double  dstrsrc = 0.0;                  /* square source distribution */
77   double  shadthresh = .05;               /* shadow threshold */
78   double  shadcert = .5;                  /* shadow certainty */
# Line 94 | Line 102 | int  ambres = 64;                      /* ambient resolution */
102   int  ambdiv = 512;                      /* ambient divisions */
103   int  ambssamp = 128;                    /* ambient super-samples */
104   int  ambounce = 0;                      /* ambient bounces */
105 < char  *amblist[128];                    /* ambient include/exclude list */
105 > char  *amblist[AMBLLEN];                /* ambient include/exclude list */
106   int  ambincl = -1;                      /* include == 1, exclude == 0 */
107  
108   int  ralrm = 0;                         /* seconds between reports */
# Line 202 | Line 210 | report(int dummy)              /* report progress */
210   }
211   #else
212   static void
213 < report(int)             /* report progress */
213 > report(int dummy)               /* report progress */
214   {
215          tlastrept = time((time_t *)NULL);
216          sprintf(errmsg, "%lu rays, %4.2f%% after %5.4f hours\n",
# Line 662 | Line 670 | pixvalue(              /* compute pixel value */
670   {
671          RAY  thisray;
672          FVECT   lorg, ldir;
673 <        double  hpos, vpos, lmax;
673 >        double  hpos, vpos, vdist, lmax;
674 >        register int    i;
675                                                  /* compute view ray */
676          hpos = (x+pixjitter())/hres;
677          vpos = (y+pixjitter())/vres;
# Line 671 | Line 680 | pixvalue(              /* compute pixel value */
680                  setcolor(col, 0.0, 0.0, 0.0);
681                  return(0.0);
682          }
683 <
684 <        samplendx = pixnumber(x,y,hres,vres);   /* set pixel index */
685 <
683 >        vdist = ourview.vdist;
684 >                                                /* set pixel index */
685 >        samplendx = pixnumber(x,y,hres,vres);
686                                                  /* optional motion blur */
687          if (lastview.type && mblur > FTINY && (lmax = viewray(lorg, ldir,
688                                          &lastview, hpos, vpos)) >= -FTINY) {
680                register int    i;
689                  register double  d = mblur*(.5-urand(281+samplendx));
690  
691                  thisray.rmax = (1.-d)*thisray.rmax + d*lmax;
# Line 687 | Line 695 | pixvalue(              /* compute pixel value */
695                  }
696                  if (normalize(thisray.rdir) == 0.0)
697                          return(0.0);
698 +                vdist = (1.-d)*vdist + d*lastview.vdist;
699          }
700 +                                                /* optional depth-of-field */
701 +        if (dblur > FTINY && vdist > FTINY) {
702 +                double  vc, dfh, dfv;
703 +                                                /* square/circle conv. */
704 +                dfh = vc = frandom();
705 +                dfv = frandom();
706 +                dfh *= .5*dblur*sqrt(1. - .5*dfv*dfv);
707 +                dfv *= .5*dblur*sqrt(1. - .5*vc*vc);
708 +                if (ourview.type == VT_PER || ourview.type == VT_PAR) {
709 +                        dfh /= sqrt(ourview.hn2);
710 +                        dfv /= sqrt(ourview.vn2);
711 +                        for (i = 3; i--; ) {
712 +                                vc = thisray.rorg[i] + vdist*thisray.rdir[i];
713 +                                thisray.rorg[i] += dfh*ourview.hvec[i] +
714 +                                                        dfv*ourview.vvec[i] ;
715 +                                thisray.rdir[i] = vc - thisray.rorg[i];
716 +                        }
717 +                } else {                        /* non-standard view case */
718 +                        double  dfd = PI/4.*dblur*(.5 - frandom());
719 +                        if (ourview.type != VT_ANG && ourview.type != VT_PLS) {
720 +                                if (ourview.type != VT_CYL)
721 +                                        dfh /= sqrt(ourview.hn2);
722 +                                dfv /= sqrt(ourview.vn2);
723 +                        }
724 +                        for (i = 3; i--; ) {
725 +                                vc = thisray.rorg[i] + vdist*thisray.rdir[i];
726 +                                thisray.rorg[i] += dfh*ourview.hvec[i] +
727 +                                                        dfv*ourview.vvec[i] +
728 +                                                        dfd*ourview.vdir[i] ;
729 +                                thisray.rdir[i] = vc - thisray.rorg[i];
730 +                        }
731 +                }
732 +                if (normalize(thisray.rdir) == 0.0)
733 +                        return(0.0);
734 +        }
735  
736 <        rayorigin(&thisray, NULL, PRIMARY, 1.0);
736 >        rayorigin(&thisray, PRIMARY, NULL, NULL);
737  
738          rayvalue(&thisray);                     /* trace ray */
739  
# Line 758 | Line 802 | writerr:
802          error(SYSTEM, errmsg);
803          return -1; /* pro forma return */
804   }
761
805  
806   static int
807   pixnumber(              /* compute pixel index (brushed) */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines