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

Comparing ray/src/gen/gendaymtx.c (file contents):
Revision 2.2 by greg, Fri Jan 18 19:56:03 2013 UTC vs.
Revision 2.3 by greg, Sat Jan 19 20:38:36 2013 UTC

# Line 246 | Line 246 | static const ModelCoeff DirectLumEff[8] =
246          { 101.18,  1.58, -1.10,  -8.29 }
247   };
248  
249 + #ifndef NSUNPATCH
250 + #define NSUNPATCH       4               /* # patches to spread sun into */
251 + #endif
252 +
253   extern int jdate(int month, int day);
254   extern double stadj(int  jd);
255   extern double sdec(int  jd);
# Line 455 | Line 459 | main(int argc, char *argv[])
459                  switch (outfmt) {
460                  case 'a':
461                          for (j = 0; j < ntsteps; j++) {
462 <                                printf("%.3e %.3e %.3e\n", mtx_data[mtx_offset],
462 >                                printf("%.3g %.3g %.3g\n", mtx_data[mtx_offset],
463                                                  mtx_data[mtx_offset+1],
464                                                  mtx_data[mtx_offset+2]);
465                                  mtx_offset += 3*nskypatch;
# Line 558 | Line 562 | ComputeSky(float *parr)
562                  return;
563          }
564          /* Compute ground radiance (include solar contribution if any) */
565 <        parr[0] = diff_illum * (1./PI/WHTEFFICACY);
565 >        parr[0] = diff_illum;
566          if (altitude > 0)
567 <                parr[0] += dir_illum * sin(altitude) * (1./PI/WHTEFFICACY);
568 <        parr[2] = parr[1] = parr[0];
567 >                parr[0] += dir_illum * sin(altitude);
568 >        parr[2] = parr[1] = parr[0] *= grefl*(1./PI/WHTEFFICACY);
569  
570          /* Calculate Perez sky model parameters */
571          CalcPerezParam(sun_zenith, sky_clearness, sky_brightness, index);
# Line 593 | Line 597 | void
597   AddDirect(float *parr)
598   {
599          FVECT   svec;
600 <        double  near_dprod[4];
601 <        int     near_patch[4];
602 <        double  wta[4], wtot;
600 >        double  near_dprod[NSUNPATCH];
601 >        int     near_patch[NSUNPATCH];
602 >        double  wta[NSUNPATCH], wtot;
603          int     i, j, p;
604  
605          if (!do_sun || dir_illum < 1e-4)
606                  return;
607 <                                        /* identify 4 closest patches */
608 <        for (i = 4; i--; )
607 >                                        /* identify NSUNPATCH closest patches */
608 >        for (i = NSUNPATCH; i--; )
609                  near_dprod[i] = -1.;
610          vector(svec, altitude, azimuth);
611          for (p = 1; p < nskypatch; p++) {
# Line 609 | Line 613 | AddDirect(float *parr)
613                  double  dprod;
614                  rh_vector(pvec, p);
615                  dprod = DOT(pvec, svec);
616 <                for (i = 0; i < 4; i++)
616 >                for (i = 0; i < NSUNPATCH; i++)
617                          if (dprod > near_dprod[i]) {
618 <                                for (j = 4; --j > i; ) {
618 >                                for (j = NSUNPATCH; --j > i; ) {
619                                          near_dprod[j] = near_dprod[j-1];
620                                          near_patch[j] = near_patch[j-1];
621                                  }
# Line 621 | Line 625 | AddDirect(float *parr)
625                          }
626          }
627          wtot = 0;                       /* weight by proximity */
628 <        for (i = 4; i--; )
628 >        for (i = NSUNPATCH; i--; )
629                  wtot += wta[i] = 1./(1.002 - near_dprod[i]);
630                                          /* add to nearest patch radiances */
631 <        for (i = 4; i--; ) {
631 >        for (i = NSUNPATCH; i--; ) {
632                  float   *pdest = parr + 3*near_patch[i];
633                  float   val_add = wta[i] * dir_illum /
634                                  (WHTEFFICACY * wtot * rh_dom[near_patch[i]]);
# Line 665 | Line 669 | rh_init(void)
669          for (i = 0; i < NROW*rhsubdiv; i++) {
670                  const float     ralt = alpha*(i + .5);
671                  const int       ninrow = tnaz[i/rhsubdiv]*rhsubdiv;
672 <                const float     dom = (sin(alpha*(i+1)) - sin(alpha*i))/ninrow;
672 >                const float     dom = 2.*PI*(sin(alpha*(i+1)) - sin(alpha*i)) /
673 >                                                (double)ninrow;
674                  for (j = 0; j < ninrow; j++) {
675                          rh_palt[p] = ralt;
676                          rh_pazi[p] = 2.*PI * j / (double)ninrow;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines