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.33 by greg, Mon Jan 6 21:22:46 2020 UTC

# Line 81 | Line 81 | static const char RCSid[] = "$Id$";
81  
82   /* Include files */
83   #define _USE_MATH_DEFINES
84 #include <stdio.h>
84   #include <stdlib.h>
86 #include <string.h>
85   #include <ctype.h>
86 + #include "platform.h"
87   #include "rtmath.h"
88 + #include "rtio.h"
89   #include "color.h"
90 + #include "sun.h"
91  
92   char *progname;                                                         /* Program name */
93   char errmsg[128];                                                       /* Error message buffer */
# Line 108 | Line 109 | double sky_clearness;                  /* Sky clearness */
109   double solar_rad;                       /* Solar radiance */
110   double sun_zenith;                      /* Sun zenith angle (radians) */
111   int     input = 0;                              /* Input type */
112 + int     output = 0;                             /* Output type */
113  
114   extern double dmax( double, double );
115   extern double CalcAirMass();
# Line 208 | Line 210 | static const CategoryBounds SkyClearCat[8] =
210          { 1.950, 2.800 },
211          { 2.800, 4.500 },
212          { 4.500, 6.200 },
213 <        { 6.200, 12.00 }        /* Clear */
213 >        { 6.200, 12.01 }        /* Clear */
214   };
215  
216   /* Luminous efficacy model coefficients */
# Line 246 | Line 248 | static const ModelCoeff DirectLumEff[8] =
248          { 101.18,  1.58, -1.10,  -8.29 }
249   };
250  
251 < extern int jdate(int month, int day);
252 < extern double stadj(int  jd);
253 < extern double sdec(int  jd);
252 < extern double salt(double sd, double st);
253 < extern double sazi(double sd, double st);
254 <                                        /* sun calculation constants */
255 < extern double  s_latitude;
256 < extern double  s_longitude;
257 < extern double  s_meridian;
251 > #ifndef NSUNPATCH
252 > #define NSUNPATCH       4               /* max. # patches to spread sun into */
253 > #endif
254  
255 < double          grefl = 0.2;            /* diffuse ground reflectance */
255 > int             nsuns = NSUNPATCH;      /* number of sun patches to use */
256 > double          fixed_sun_sa = -1;      /* fixed solid angle per sun? */
257  
258   int             verbose = 0;            /* progress reports to stderr? */
259  
# Line 264 | Line 261 | int            outfmt = 'a';           /* output format */
261  
262   int             rhsubdiv = 1;           /* Reinhart sky subdivisions */
263  
264 < float           skycolor[3] = {.96, 1.004, 1.118};      /* sky coloration */
264 > COLOR           skycolor = {.96, 1.004, 1.118}; /* sky coloration */
265 > COLOR           suncolor = {1., 1., 1.};        /* sun color */
266 > COLOR           grefl = {.2, .2, .2};           /* ground reflectance */
267  
269 int             do_sun = 1;             /* output direct solar contribution? */
270
268   int             nskypatch;              /* number of Reinhart patches */
269   float           *rh_palt;               /* sky patch altitudes (radians) */
270   float           *rh_pazi;               /* sky patch azimuths (radians) */
# Line 286 | Line 283 | extern int     rh_init(void);
283   extern float *  resize_dmatrix(float *mtx_data, int nsteps, int npatch);
284   extern void     AddDirect(float *parr);
285  
286 +
287 + static const char *
288 + getfmtname(int fmt)
289 + {
290 +        switch (fmt) {
291 +        case 'a':
292 +                return("ascii");
293 +        case 'f':
294 +                return("float");
295 +        case 'd':
296 +                return("double");
297 +        }
298 +        return("unknown");
299 + }
300 +
301 +
302   int
303   main(int argc, char *argv[])
304   {
305          char    buf[256];
306 +        int     doheader = 1;           /* output header? */
307 +        double  rotation = 0;           /* site rotation (degrees) */
308          double  elevation;              /* site elevation (meters) */
309          int     dir_is_horiz;           /* direct is meas. on horizontal? */
310          float   *mtx_data = NULL;       /* our matrix data */
311 <        int     ntsteps = 0;            /* number of rows in matrix */
311 >        int     avgSky = 0;             /* compute average sky r.t. matrix? */
312 >        int     ntsteps = 0;            /* number of time steps */
313 >        int     tstorage = 0;           /* number of allocated time steps */
314 >        int     nstored = 0;            /* number of time steps in matrix */
315          int     last_monthly = 0;       /* month of last report */
316          int     mo, da;                 /* month (1-12) and day (1-31) */
317          double  hr;                     /* hour (local standard time) */
# Line 305 | Line 323 | main(int argc, char *argv[])
323                                          /* get options */
324          for (i = 1; i < argc && argv[i][0] == '-'; i++)
325                  switch (argv[i][1]) {
326 <                case 'g':
327 <                        grefl = atof(argv[++i]);
326 >                case 'g':                       /* ground reflectance */
327 >                        grefl[0] = atof(argv[++i]);
328 >                        grefl[1] = atof(argv[++i]);
329 >                        grefl[2] = atof(argv[++i]);
330                          break;
331 <                case 'v':
331 >                case 'v':                       /* verbose progress reports */
332                          verbose++;
333                          break;
334 <                case 'o':
334 >                case 'h':                       /* turn off header */
335 >                        doheader = 0;
336 >                        break;
337 >                case 'o':                       /* output format */
338                          switch (argv[i][2]) {
339                          case 'f':
340                          case 'd':
# Line 322 | Line 345 | main(int argc, char *argv[])
345                                  goto userr;
346                          }
347                          break;
348 <                case 'm':
348 >                case 'O':                       /* output type */
349 >                        switch (argv[i][2]) {
350 >                        case '0':
351 >                                output = 0;
352 >                                break;
353 >                        case '1':
354 >                                output = 1;
355 >                                break;
356 >                        default:
357 >                                goto userr;
358 >                        }
359 >                        if (argv[i][3])
360 >                                goto userr;
361 >                        break;
362 >                case 'm':                       /* Reinhart subdivisions */
363                          rhsubdiv = atoi(argv[++i]);
364                          break;
365 <                case 'c':
365 >                case 'c':                       /* sky color */
366                          skycolor[0] = atof(argv[++i]);
367                          skycolor[1] = atof(argv[++i]);
368                          skycolor[2] = atof(argv[++i]);
369                          break;
370 <                case 'd':
334 <                        do_sun = 1;
370 >                case 'd':                       /* solar (direct) only */
371                          skycolor[0] = skycolor[1] = skycolor[2] = 0;
372 +                        grefl[0] = grefl[1] = grefl[2] = 0;
373                          break;
374 <                case 's':
375 <                        do_sun = 0;
339 <                        if (skycolor[1] <= 1e-4)
340 <                                skycolor[0] = skycolor[1] = skycolor[2] = 1;
374 >                case 's':                       /* sky only (no direct) */
375 >                        suncolor[0] = suncolor[1] = suncolor[2] = 0;
376                          break;
377 +                case 'r':                       /* rotate distribution */
378 +                        if (argv[i][2] && argv[i][2] != 'z')
379 +                                goto userr;
380 +                        rotation = atof(argv[++i]);
381 +                        break;
382 +                case '5':                       /* 5-phase calculation */
383 +                        nsuns = 1;
384 +                        fixed_sun_sa = PI/360.*atof(argv[++i]);
385 +                        if (fixed_sun_sa <= 0) {
386 +                                fprintf(stderr, "%s: missing solar disk size argument for '-5' option\n",
387 +                                                argv[0]);
388 +                                exit(1);
389 +                        }
390 +                        fixed_sun_sa *= fixed_sun_sa*PI;
391 +                        break;
392 +                case 'A':                       /* compute average sky */
393 +                        avgSky = 1;
394 +                        break;
395                  default:
396                          goto userr;
397                  }
# Line 393 | Line 446 | main(int argc, char *argv[])
446                                  progname, s_latitude, s_longitude);
447                  fprintf(stderr, "%s: %d sky patches per time step\n",
448                                  progname, nskypatch);
449 +                if (rotation != 0)
450 +                        fprintf(stderr, "%s: rotating output %.0f degrees\n",
451 +                                        progname, rotation);
452          }
453                                          /* convert quantities to radians */
454          s_latitude = DegToRad(s_latitude);
455          s_longitude = DegToRad(s_longitude);
456          s_meridian = DegToRad(s_meridian);
457 +                                        /* initial allocation */
458 +        mtx_data = resize_dmatrix(mtx_data, tstorage=2, nskypatch);
459                                          /* process each time step in tape */
460          while (scanf("%d %d %lf %lf %lf\n", &mo, &da, &hr, &dir, &dif) == 5) {
461                  double          sda, sta;
462 <                                        /* make space for next time step */
463 <                mtx_offset = 3*nskypatch*ntsteps++;
464 <                mtx_data = resize_dmatrix(mtx_data, ntsteps, nskypatch);
462 >
463 >                mtx_offset = 3*nskypatch*nstored;
464 >                nstored += !avgSky | !nstored;
465 >                                        /* make space for next row */
466 >                if (nstored > tstorage) {
467 >                        tstorage += (tstorage>>1) + nstored + 7;
468 >                        mtx_data = resize_dmatrix(mtx_data, tstorage, nskypatch);
469 >                }
470 >                ntsteps++;              /* keep count of time steps */
471                  if (dif <= 1e-4) {
472 <                        memset(mtx_data+mtx_offset, 0, sizeof(float)*3*nskypatch);
472 >                        if (!avgSky | !mtx_offset)
473 >                                memset(mtx_data+mtx_offset, 0, sizeof(float)*3*nskypatch);
474                          continue;
475                  }
476                  if (verbose && mo != last_monthly)
# Line 416 | Line 481 | main(int argc, char *argv[])
481                  sda = sdec(julian_date);
482                  sta = stadj(julian_date);
483                  altitude = salt(sda, hr+sta);
484 <                azimuth = sazi(sda, hr+sta) + PI;
484 >                azimuth = sazi(sda, hr+sta) + PI - DegToRad(rotation);
485                                          /* convert measured values */
486                  if (dir_is_horiz && altitude > 0.)
487                          dir /= sin(altitude);
# Line 429 | Line 494 | main(int argc, char *argv[])
494                  }
495                                          /* compute sky patch values */
496                  ComputeSky(mtx_data+mtx_offset);
497 <                if (do_sun)
498 <                        AddDirect(mtx_data+mtx_offset);
497 >                AddDirect(mtx_data+mtx_offset);
498 >                                        /* update cumulative sky? */
499 >                for (i = 3*nskypatch*(avgSky&(ntsteps>1)); i--; )
500 >                        mtx_data[i] += mtx_data[mtx_offset+i];
501          }
502                                          /* check for junk at end */
503          while ((i = fgetc(stdin)) != EOF)
# Line 442 | Line 509 | main(int argc, char *argv[])
509                          fputs(buf, stderr); fputc('\n', stderr);
510                          break;
511                  }
512 +        if (!ntsteps) {
513 +                fprintf(stderr, "%s: no valid time steps on input\n", progname);
514 +                exit(1);
515 +        }
516 +        dif = 1./(double)ntsteps;       /* average sky? */
517 +        for (i = 3*nskypatch*(avgSky&(ntsteps>1)); i--; )
518 +                mtx_data[i] *= dif;
519                                          /* write out matrix */
520 +        if (outfmt != 'a')
521 +                SET_FILE_BINARY(stdout);
522   #ifdef getc_unlocked
523          flockfile(stdout);
524   #endif
525          if (verbose)
526                  fprintf(stderr, "%s: writing %smatrix with %d time steps...\n",
527 <                                progname, outfmt=='a' ? "" : "binary ", ntsteps);
527 >                                progname, outfmt=='a' ? "" : "binary ", nstored);
528 >        if (doheader) {
529 >                newheader("RADIANCE", stdout);
530 >                printargs(argc, argv, stdout);
531 >                printf("LATLONG= %.8f %.8f\n", RadToDeg(s_latitude),
532 >                                        -RadToDeg(s_longitude));
533 >                printf("NROWS=%d\n", nskypatch);
534 >                printf("NCOLS=%d\n", nstored);
535 >                printf("NCOMP=3\n");
536 >                if ((outfmt == 'f') | (outfmt == 'd'))
537 >                        fputendian(stdout);
538 >                fputformat((char *)getfmtname(outfmt), stdout);
539 >                putchar('\n');
540 >        }
541                                          /* patches are rows (outer sort) */
542          for (i = 0; i < nskypatch; i++) {
543                  mtx_offset = 3*i;
544                  switch (outfmt) {
545                  case 'a':
546 <                        for (j = 0; j < ntsteps; j++) {
547 <                                printf("%.3e %.3e %.3e\n", mtx_data[mtx_offset],
546 >                        for (j = 0; j < nstored; j++) {
547 >                                printf("%.3g %.3g %.3g\n", mtx_data[mtx_offset],
548                                                  mtx_data[mtx_offset+1],
549                                                  mtx_data[mtx_offset+2]);
550                                  mtx_offset += 3*nskypatch;
551                          }
552 <                        if (ntsteps > 1)
552 >                        if (nstored > 1)
553                                  fputc('\n', stdout);
554                          break;
555                  case 'f':
556 <                        for (j = 0; j < ntsteps; j++) {
557 <                                fwrite(mtx_data+mtx_offset, sizeof(float), 3,
556 >                        for (j = 0; j < nstored; j++) {
557 >                                putbinary(mtx_data+mtx_offset, sizeof(float), 3,
558                                                  stdout);
559                                  mtx_offset += 3*nskypatch;
560                          }
561                          break;
562                  case 'd':
563 <                        for (j = 0; j < ntsteps; j++) {
563 >                        for (j = 0; j < nstored; j++) {
564                                  double  ment[3];
565                                  ment[0] = mtx_data[mtx_offset];
566                                  ment[1] = mtx_data[mtx_offset+1];
567                                  ment[2] = mtx_data[mtx_offset+2];
568 <                                fwrite(ment, sizeof(double), 3, stdout);
568 >                                putbinary(ment, sizeof(double), 3, stdout);
569                                  mtx_offset += 3*nskypatch;
570                          }
571                          break;
# Line 490 | Line 579 | main(int argc, char *argv[])
579                  fprintf(stderr, "%s: done.\n", progname);
580          exit(0);
581   userr:
582 <        fprintf(stderr, "Usage: %s [-v][-d|-s][-m N][-g refl][-c r g b][-o{f|d}] [tape.wea]\n",
582 >        fprintf(stderr, "Usage: %s [-v][-h][-A][-d|-s][-r deg][-m N][-g r g b][-c r g b][-o{f|d}][-O{0|1}] [tape.wea]\n",
583                          progname);
584          exit(1);
585   fmterr:
# Line 511 | Line 600 | ComputeSky(float *parr)
600   {
601          int index;                      /* Category index */
602          double norm_diff_illum;         /* Normalized diffuse illuimnance */
514        double zlumin;                  /* Zenith luminance */
603          int i;
604          
605          /* Calculate atmospheric precipitable water content */
606          apwc = CalcPrecipWater(dew_point);
607  
608 <        /* Limit solar altitude to keep circumsolar off zenith */
609 <        if (altitude > DegToRad(87.0))
610 <                altitude = DegToRad(87.0);
608 >        /* Calculate sun zenith angle (don't let it dip below horizon) */
609 >        /* Also limit minimum angle to keep circumsolar off zenith */
610 >        if (altitude <= 0.0)
611 >                sun_zenith = DegToRad(90.0);
612 >        else if (altitude >= DegToRad(87.0))
613 >                sun_zenith = DegToRad(3.0);
614 >        else
615 >                sun_zenith = DegToRad(90.0) - altitude;
616  
524        /* Calculate sun zenith angle */
525        sun_zenith = DegToRad(90.0) - altitude;
526
617          /* Compute the inputs for the calculation of the sky distribution */
618          
619          if (input == 0)                                 /* XXX never used */
# Line 542 | Line 632 | ComputeSky(float *parr)
632                  sky_brightness = CalcSkyBrightness();
633                  sky_clearness =  CalcSkyClearness();
634  
635 +                /* Limit sky clearness */
636 +                if (sky_clearness > 11.9)
637 +                        sky_clearness = 11.9;
638 +
639 +                /* Limit sky brightness */
640 +                if (sky_brightness < 0.01)
641 +                        sky_brightness = 0.01;
642 +
643                  /* Calculate illuminance */
644                  index = GetCategoryIndex();
645                  diff_illum = diff_irrad * CalcDiffuseIllumRatio(index);
# Line 553 | Line 651 | ComputeSky(float *parr)
651                  index = CalcSkyParamFromIllum();
652          }
653  
654 <        if (bright(skycolor) <= 1e-4) {                 /* 0 sky component? */
655 <                memset(parr, 0, sizeof(float)*3*nskypatch);
656 <                return;
654 >        if (output == 1) {                      /* hack for solar radiance */
655 >                diff_illum = diff_irrad * WHTEFFICACY;
656 >                dir_illum = dir_irrad * WHTEFFICACY;
657          }
658          /* Compute ground radiance (include solar contribution if any) */
659 <        parr[0] = diff_illum * (1./PI/WHTEFFICACY);
659 >        parr[0] = diff_illum;
660          if (altitude > 0)
661 <                parr[0] += dir_illum * sin(altitude) * (1./PI/WHTEFFICACY);
662 <        parr[2] = parr[1] = parr[0];
661 >                parr[0] += dir_illum * sin(altitude);
662 >        parr[2] = parr[1] = parr[0] *= (1./PI/WHTEFFICACY);
663 >        multcolor(parr, grefl);
664  
665 +        if (bright(skycolor) <= 1e-4) {                 /* 0 sky component? */
666 +                memset(parr+3, 0, sizeof(float)*3*(nskypatch-1));
667 +                return;
668 +        }
669          /* Calculate Perez sky model parameters */
670          CalcPerezParam(sun_zenith, sky_clearness, sky_brightness, index);
671  
# Line 572 | Line 675 | ComputeSky(float *parr)
675          /* Calculate relative horizontal illuminance */
676          norm_diff_illum = CalcRelHorzIllum(parr);
677  
678 +        /* Check for zero sky -- make uniform in that case */
679 +        if (norm_diff_illum <= FTINY) {
680 +                for (i = 1; i < nskypatch; i++)
681 +                        setcolor(parr+3*i, 1., 1., 1.);
682 +                norm_diff_illum = PI;
683 +        }
684          /* Normalization coefficient */
685          norm_diff_illum = diff_illum / norm_diff_illum;
686  
578        /* Calculate relative zenith luminance */
579        zlumin = CalcRelLuminance(sun_zenith, 0.0);
580
581        /* Calculate absolute zenith illuminance */
582        zlumin *= norm_diff_illum;
583
687          /* Apply to sky patches to get absolute radiance values */
688          for (i = 1; i < nskypatch; i++) {
689 <                scalecolor(parr+3*i, zlumin*(1./WHTEFFICACY));
689 >                scalecolor(parr+3*i, norm_diff_illum*(1./WHTEFFICACY));
690                  multcolor(parr+3*i, skycolor);
691          }
692   }
# Line 593 | Line 696 | void
696   AddDirect(float *parr)
697   {
698          FVECT   svec;
699 <        double  near_dprod[4];
700 <        int     near_patch[4];
701 <        double  wta[4], wtot;
699 >        double  near_dprod[NSUNPATCH];
700 >        int     near_patch[NSUNPATCH];
701 >        double  wta[NSUNPATCH], wtot;
702          int     i, j, p;
703  
704 <        if (!do_sun || dir_illum < 1e-4)
704 >        if (dir_illum <= 1e-4 || bright(suncolor) <= 1e-4)
705                  return;
706 <                                        /* identify 4 closest patches */
707 <        for (i = 4; i--; )
706 >                                        /* identify nsuns closest patches */
707 >        if (nsuns > NSUNPATCH)
708 >                nsuns = NSUNPATCH;
709 >        else if (nsuns <= 0)
710 >                nsuns = 1;
711 >        for (i = nsuns; i--; )
712                  near_dprod[i] = -1.;
713          vector(svec, altitude, azimuth);
714          for (p = 1; p < nskypatch; p++) {
# Line 609 | Line 716 | AddDirect(float *parr)
716                  double  dprod;
717                  rh_vector(pvec, p);
718                  dprod = DOT(pvec, svec);
719 <                for (i = 0; i < 4; i++)
719 >                for (i = 0; i < nsuns; i++)
720                          if (dprod > near_dprod[i]) {
721 <                                for (j = 4; --j > i; ) {
721 >                                for (j = nsuns; --j > i; ) {
722                                          near_dprod[j] = near_dprod[j-1];
723                                          near_patch[j] = near_patch[j-1];
724                                  }
# Line 621 | Line 728 | AddDirect(float *parr)
728                          }
729          }
730          wtot = 0;                       /* weight by proximity */
731 <        for (i = 4; i--; )
731 >        for (i = nsuns; i--; )
732                  wtot += wta[i] = 1./(1.002 - near_dprod[i]);
733                                          /* add to nearest patch radiances */
734 <        for (i = 4; i--; ) {
734 >        for (i = nsuns; i--; ) {
735                  float   *pdest = parr + 3*near_patch[i];
736 <                float   val_add = wta[i] * dir_illum /
737 <                                (WHTEFFICACY * wtot * rh_dom[near_patch[i]]);
738 <                *pdest++ += val_add;
739 <                *pdest++ += val_add;
740 <                *pdest++ += val_add;
736 >                float   val_add = wta[i] * dir_illum / (WHTEFFICACY * wtot);
737 >
738 >                val_add /= (fixed_sun_sa > 0)   ? fixed_sun_sa
739 >                                                : rh_dom[near_patch[i]] ;
740 >                *pdest++ += val_add*suncolor[0];
741 >                *pdest++ += val_add*suncolor[1];
742 >                *pdest++ += val_add*suncolor[2];
743          }
744   }
745  
# Line 665 | Line 774 | rh_init(void)
774          for (i = 0; i < NROW*rhsubdiv; i++) {
775                  const float     ralt = alpha*(i + .5);
776                  const int       ninrow = tnaz[i/rhsubdiv]*rhsubdiv;
777 <                const float     dom = (sin(alpha*(i+1)) - sin(alpha*i))/ninrow;
777 >                const float     dom = 2.*PI*(sin(alpha*(i+1)) - sin(alpha*i)) /
778 >                                                (double)ninrow;
779                  for (j = 0; j < ninrow; j++) {
780                          rh_palt[p] = ralt;
781                          rh_pazi[p] = 2.*PI * j / (double)ninrow;
# Line 770 | Line 880 | double CalcSkyClearness()
880          double sz_cubed;        /* Sun zenith angle cubed */
881  
882          /* Calculate sun zenith angle cubed */
883 <        sz_cubed = pow(sun_zenith, 3.0);
883 >        sz_cubed = sun_zenith*sun_zenith*sun_zenith;
884  
885          return ((diff_irrad + dir_irrad) / diff_irrad + 1.041 *
886                          sz_cubed) / (1.0 + 1.041 * sz_cubed);
# Line 801 | Line 911 | double CalcDiffuseIrradiance()
911   double CalcDirectIrradiance()
912   {
913          return CalcDiffuseIrradiance() * ((sky_clearness - 1.0) * (1 + 1.041
914 <                        * pow(sun_zenith, 3.0)));
914 >                        * sun_zenith*sun_zenith*sun_zenith));
915   }
916  
917   /* Calculate sky brightness and clearness from illuminance values */
# Line 827 | Line 937 | int CalcSkyParamFromIllum()
937                  sky_clearness = 12.0;
938  
939          /* Limit sky brightness */
940 <        if (sky_brightness < 0.05)
940 >        if (sky_brightness < 0.01)
941                          sky_brightness = 0.01;
942  
943          while (((fabs(diff_irrad - test1) > 10.0) ||
# Line 840 | Line 950 | int CalcSkyParamFromIllum()
950                  /* Convert illuminance to irradiance */
951                  index = GetCategoryIndex();
952                  diff_irrad = diff_illum / CalcDiffuseIllumRatio(index);
953 <                dir_irrad = dir_illum / CalcDirectIllumRatio(index);
953 >                dir_irrad = CalcDirectIllumRatio(index);
954 >                if (dir_irrad > 0.1)
955 >                        dir_irrad = dir_illum / dir_irrad;
956          
957                  /* Calculate sky brightness and clearness */
958                  sky_brightness = CalcSkyBrightness();
# Line 851 | Line 963 | int CalcSkyParamFromIllum()
963                          sky_clearness = 12.0;
964          
965                  /* Limit sky brightness */
966 <                if (sky_brightness < 0.05)
966 >                if (sky_brightness < 0.01)
967                          sky_brightness = 0.01;
968          }
969  
# Line 937 | Line 1049 | double CalcRelHorzIllum( float *parr )
1049          double rh_illum = 0.0;  /* Relative horizontal illuminance */
1050  
1051          for (i = 1; i < nskypatch; i++)
1052 <                rh_illum += parr[3*i+1] * rh_cos(i);
1052 >                rh_illum += parr[3*i+1] * rh_cos(i) * rh_dom[i];
1053  
1054 <        return rh_illum * (2.0 * PI / (nskypatch-1));
1054 >        return rh_illum;
1055   }
1056  
1057   /* Calculate earth orbit eccentricity correction factor */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines