--- ray/src/gen/gensky.c 1992/10/02 16:11:53 2.7 +++ ray/src/gen/gensky.c 1993/06/07 14:51:22 2.11 @@ -1,4 +1,4 @@ -/* Copyright (c) 1986 Regents of the University of California */ +/* Copyright (c) 1992 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -19,9 +19,6 @@ static char SCCSid[] = "$SunId$ LBL"; #include "color.h" -#ifndef atof -extern double atof(); -#endif extern char *strcpy(), *strcat(), *malloc(); extern double stadj(), sdec(), sazi(), salt(); @@ -49,7 +46,7 @@ double gprefl = 0.2; double sundir[3]; double groundbr; double F2; -double solarbr; +double solarbr = -1.0; char *progname; char errmsg[128]; @@ -91,6 +88,9 @@ char *argv[]; cloudy = 0; dosun = argv[i][0] == '+'; break; + case 'r': + solarbr = atof(argv[++i]); + break; case 'c': cloudy = argv[i][0] == '+' ? 2 : 1; dosun = 0; @@ -147,7 +147,17 @@ computesky() /* compute sky parameters */ st = hour + stadj(jd); altitude = salt(sd, st); azimuth = sazi(sd, st); + printf("# Solar altitude and azimuth: %f %f\n", + 180./PI*altitude, 180./PI*azimuth); } + if (!cloudy && altitude > 87.*PI/180.) { + fprintf(stderr, +"%s: warning - sun too close to zenith, reducing altitude to 87 degrees\n", + progname); + printf( +"# warning - sun too close to zenith, reducing altitude to 87 degrees\n"); + altitude = 87.*PI/180.; + } sundir[0] = -sin(azimuth)*cos(altitude); sundir[1] = -cos(azimuth)*cos(altitude); sundir[2] = sin(altitude); @@ -175,12 +185,10 @@ computesky() /* compute sky parameters */ 0.45*sundir[2]*sundir[2]); groundbr = zenithbr*normsc(altitude)/F2/PI; printf("# Ground ambient level: %f\n", groundbr); - if (sundir[2] > 0.0) { - if (sundir[2] > .16) - solarbr = (1.5e9/SUNEFFICACY) * - (1.147 - .147/sundir[2]); - else - solarbr = 1.5e9/SUNEFFICACY*(1.147-.147/.16); + if (sundir[2] > 0.0 && solarbr != 0.0) { + if (solarbr < 0.0) + solarbr = 1.5e9/SUNEFFICACY * + (1.147 - .147/(sundir[2]>.16?sundir[2]:.16)); groundbr += solarbr*6e-5*sundir[2]/PI; } else dosun = 0;