Tweaked the sky coloring a bit to build in structures to allow finer rgb
control.
This commit is contained in:
parent
67f36724dd
commit
feabb5024a
3 changed files with 74 additions and 49 deletions
|
@ -103,8 +103,8 @@ void fgSkyVerticesInit() {
|
|||
void fgSkyColorsInit() {
|
||||
struct fgLIGHT *l;
|
||||
float sun_angle, diff;
|
||||
float outer_red_param, outer_red_amt, outer_red_diff;
|
||||
float middle_red_param, middle_red_amt, middle_red_diff;
|
||||
float outer_param[3], outer_amt[3], outer_diff[3];
|
||||
float middle_param[3], middle_amt[3], middle_diff[3];
|
||||
int i, j;
|
||||
|
||||
l = &cur_light_params;
|
||||
|
@ -117,46 +117,55 @@ void fgSkyColorsInit() {
|
|||
|
||||
if ( (sun_angle > 80.0) && (sun_angle < 100.0) ) {
|
||||
/* 0.0 - 0.4 */
|
||||
outer_red_param = (10.0 - fabs(90.0 - sun_angle)) / 25.0;
|
||||
outer_red_diff = outer_red_param / 6.0;
|
||||
} else {
|
||||
outer_red_param = 0.0;
|
||||
outer_red_diff = 0.0;
|
||||
}
|
||||
printf(" outer_red_param = %.2f outer_red_diff = %.2f\n",
|
||||
outer_red_param, outer_red_diff);
|
||||
outer_param[0] = (10.0 - fabs(90.0 - sun_angle)) / 25.0;
|
||||
outer_param[1] = (10.0 - fabs(90.0 - sun_angle)) / 45.0;
|
||||
outer_param[2] = 0.0;
|
||||
|
||||
if ( (sun_angle > 85.0) && (sun_angle < 95.0) ) {
|
||||
/* 0.0 - 0.4 */
|
||||
middle_red_param = (5.0 - fabs(90.0 - sun_angle)) / 12.5;
|
||||
middle_red_diff = middle_red_param / 6.0;
|
||||
middle_param[0] = (10.0 - fabs(90.0 - sun_angle)) / 40.0;
|
||||
middle_param[1] = (10.0 - fabs(90.0 - sun_angle)) / 60.0;
|
||||
middle_param[2] = 0.0;
|
||||
|
||||
outer_diff[0] = outer_param[0] / 6.0;
|
||||
outer_diff[1] = outer_param[1] / 6.0;
|
||||
outer_diff[2] = outer_param[2] / 6.0;
|
||||
|
||||
middle_diff[0] = middle_param[0] / 6.0;
|
||||
middle_diff[1] = middle_param[1] / 6.0;
|
||||
middle_diff[2] = middle_param[2] / 6.0;
|
||||
} else {
|
||||
middle_red_param = 0.0;
|
||||
middle_red_diff = 0.0;
|
||||
outer_param[0] = outer_param[1] = outer_param[2] = 0.0;
|
||||
middle_param[0] = middle_param[1] = middle_param[2] = 0.0;
|
||||
|
||||
outer_diff[0] = outer_diff[1] = outer_diff[2] = 0.0;
|
||||
middle_diff[0] = middle_diff[1] = middle_diff[2] = 0.0;
|
||||
}
|
||||
printf(" middle_red_param = %.2f middle_red_diff = %.2f\n",
|
||||
middle_red_param, middle_red_diff);
|
||||
/* printf(" outer_red_param = %.2f outer_red_diff = %.2f\n",
|
||||
outer_red_param, outer_red_diff); */
|
||||
|
||||
/* calculate transition colors between sky and fog */
|
||||
outer_red_amt = outer_red_param;
|
||||
middle_red_amt = middle_red_param;
|
||||
for ( j = 0; j < 3; j++ ) {
|
||||
outer_amt[j] = outer_param[j];
|
||||
middle_amt[j] = middle_param[j];
|
||||
}
|
||||
|
||||
for ( i = 0; i < 6; i++ ) {
|
||||
for ( j = 0; j < 3; j++ ) {
|
||||
diff = l->sky_color[j] - l->fog_color[j];
|
||||
|
||||
inner_color[i][j] = l->sky_color[j] - diff * 0.3;
|
||||
middle_color[i][j] = l->sky_color[j] - diff * 0.9;
|
||||
outer_color[i][j] = l->fog_color[j];
|
||||
middle_color[i][j] = l->sky_color[j] - diff * 0.9 + middle_amt[j];
|
||||
outer_color[i][j] = l->fog_color[j] + outer_amt[j];
|
||||
|
||||
if ( middle_color[i][j] > 1.0 ) { middle_color[i][j] = 1.0; }
|
||||
if ( outer_color[i][j] > 1.0 ) { outer_color[i][j] = 1.0; }
|
||||
}
|
||||
outer_color[i][0] += outer_red_amt;
|
||||
middle_color[i][0] += middle_red_amt;
|
||||
if ( outer_color[i][0] > 1.0 ) { outer_color[i][0] = 1.0; }
|
||||
if ( middle_color[i][0] > 1.0 ) { middle_color[i][0] = 1.0; }
|
||||
inner_color[i][3] = middle_color[i][3] = outer_color[i][3] =
|
||||
l->sky_color[3];
|
||||
|
||||
outer_red_amt -= outer_red_diff;
|
||||
middle_red_amt -= middle_red_diff;
|
||||
for ( j = 0; j < 3; j++ ) {
|
||||
outer_amt[j] -= outer_diff[j];
|
||||
middle_amt[j] -= middle_diff[j];
|
||||
}
|
||||
|
||||
printf("inner_color[%d] = %.2f %.2f %.2f %.2f\n", i, inner_color[i][0],
|
||||
inner_color[i][1], inner_color[i][2], inner_color[i][3]);
|
||||
|
@ -168,26 +177,30 @@ void fgSkyColorsInit() {
|
|||
outer_color[i][3]);
|
||||
}
|
||||
|
||||
outer_red_amt = 0.0;
|
||||
middle_red_amt = 0.0;
|
||||
for ( j = 0; j < 3; j++ ) {
|
||||
outer_amt[j] = 0.0;
|
||||
middle_amt[j] = 0.0;
|
||||
}
|
||||
|
||||
for ( i = 6; i < 12; i++ ) {
|
||||
|
||||
for ( j = 0; j < 3; j++ ) {
|
||||
diff = l->sky_color[j] - l->fog_color[j];
|
||||
|
||||
inner_color[i][j] = l->sky_color[j] - diff * 0.3;
|
||||
middle_color[i][j] = l->sky_color[j] - diff * 0.9;
|
||||
outer_color[i][j] = l->fog_color[j];
|
||||
middle_color[i][j] = l->sky_color[j] - diff * 0.9 + middle_amt[j];
|
||||
outer_color[i][j] = l->fog_color[j] + outer_amt[j];
|
||||
|
||||
if ( middle_color[i][j] > 1.0 ) { middle_color[i][j] = 1.0; }
|
||||
if ( outer_color[i][j] > 1.0 ) { outer_color[i][j] = 1.0; }
|
||||
}
|
||||
outer_color[i][0] += outer_red_amt;
|
||||
middle_color[i][0] += middle_red_amt;
|
||||
if ( outer_color[i][0] > 1.0 ) { outer_color[i][0] = 1.0; }
|
||||
if ( middle_color[i][0] > 1.0 ) { middle_color[i][0] = 1.0; }
|
||||
inner_color[i][3] = middle_color[i][3] = outer_color[i][3] =
|
||||
l->sky_color[3];
|
||||
|
||||
outer_red_amt += outer_red_diff;
|
||||
middle_red_amt += middle_red_diff;
|
||||
for ( j = 0; j < 3; j++ ) {
|
||||
outer_amt[j] += outer_diff[j];
|
||||
middle_amt[j] += middle_diff[j];
|
||||
}
|
||||
|
||||
printf("inner_color[%d] = %.2f %.2f %.2f %.2f\n", i, inner_color[i][0],
|
||||
inner_color[i][1], inner_color[i][2], inner_color[i][3]);
|
||||
|
@ -302,9 +315,13 @@ void fgSkyRender() {
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.7 1997/12/22 23:45:48 curt
|
||||
/* First stab at sunset/sunrise sky glow effects.
|
||||
/* Revision 1.8 1997/12/23 04:58:38 curt
|
||||
/* Tweaked the sky coloring a bit to build in structures to allow finer rgb
|
||||
/* control.
|
||||
/*
|
||||
* Revision 1.7 1997/12/22 23:45:48 curt
|
||||
* First stab at sunset/sunrise sky glow effects.
|
||||
*
|
||||
* Revision 1.6 1997/12/22 04:14:34 curt
|
||||
* Aligned sky with sun so dusk/dawn effects can be correct relative to the sun.
|
||||
*
|
||||
|
|
|
@ -232,8 +232,8 @@ void fgTimeUpdate(struct fgFLIGHT *f, struct fgTIME *t) {
|
|||
|
||||
/* get current Unix calendar time (in seconds) */
|
||||
/* warp = 60; */
|
||||
warp += 0;
|
||||
t->cur_time = time(NULL) + (0) * 60 * 60;
|
||||
warp += 100;
|
||||
t->cur_time = time(NULL) + (-3.5) * 60 * 60;
|
||||
t->cur_time += warp;
|
||||
printf("Current Unix calendar time = %ld warp = %ld\n", t->cur_time, warp);
|
||||
|
||||
|
@ -285,10 +285,14 @@ void fgTimeUpdate(struct fgFLIGHT *f, struct fgTIME *t) {
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.20 1997/12/15 23:55:06 curt
|
||||
/* Add xgl wrappers for debugging.
|
||||
/* Generate terrain normals on the fly.
|
||||
/* Revision 1.21 1997/12/23 04:58:39 curt
|
||||
/* Tweaked the sky coloring a bit to build in structures to allow finer rgb
|
||||
/* control.
|
||||
/*
|
||||
* Revision 1.20 1997/12/15 23:55:06 curt
|
||||
* Add xgl wrappers for debugging.
|
||||
* Generate terrain normals on the fly.
|
||||
*
|
||||
* Revision 1.19 1997/12/15 20:59:10 curt
|
||||
* Misc. tweaks.
|
||||
*
|
||||
|
|
|
@ -301,7 +301,7 @@ void fgUpdateSunPos(struct fgCartesianPoint scenery_center) {
|
|||
l->sun_vec[3] = 0.0;
|
||||
l->sun_vec_inv[3] = 0.0;
|
||||
|
||||
/* calculate thesun's relative angle to local up */
|
||||
/* calculate the sun's relative angle to local up */
|
||||
MAT3_COPY_VEC(nup, v->local_up);
|
||||
nsun[0] = l->fg_sunpos.x;
|
||||
nsun[1] = l->fg_sunpos.y;
|
||||
|
@ -316,10 +316,14 @@ void fgUpdateSunPos(struct fgCartesianPoint scenery_center) {
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.17 1997/12/15 23:55:08 curt
|
||||
/* Add xgl wrappers for debugging.
|
||||
/* Generate terrain normals on the fly.
|
||||
/* Revision 1.18 1997/12/23 04:58:40 curt
|
||||
/* Tweaked the sky coloring a bit to build in structures to allow finer rgb
|
||||
/* control.
|
||||
/*
|
||||
* Revision 1.17 1997/12/15 23:55:08 curt
|
||||
* Add xgl wrappers for debugging.
|
||||
* Generate terrain normals on the fly.
|
||||
*
|
||||
* Revision 1.16 1997/12/11 04:43:57 curt
|
||||
* Fixed sun vector and lighting problems. I thing the moon is now lit
|
||||
* correctly.
|
||||
|
|
Loading…
Reference in a new issue