- Fix a couple oops's in cloud.cxx
- In sky.cxx blend low density cloud layers (few/scattered) into nothing (but don't touch visibility distance) as we approach them so we can fly through clean. - For high density cloud layers (broken/overcast) we do not fade the layers out, but we fade visibility to nearly nothing as we approach the layer.
This commit is contained in:
parent
01608b7e18
commit
efce88ff12
@ -633,25 +633,25 @@ bool SGCloudLayer::repaint( sgVec3 fog_color ) {
|
|||||||
for ( int i = 0; i < 4; i++ ) {
|
for ( int i = 0; i < 4; i++ ) {
|
||||||
color = cl[i]->get( 0 );
|
color = cl[i]->get( 0 );
|
||||||
sgCopyVec3( color, fog_color );
|
sgCopyVec3( color, fog_color );
|
||||||
color[3] = (i == 0) ? 0.0f : 0.15f;
|
color[3] = (i == 0) ? 0.0f : cloud_alpha * 0.15f;
|
||||||
|
|
||||||
for ( int j = 0; j < 4; ++j ) {
|
for ( int j = 0; j < 4; ++j ) {
|
||||||
color = cl[i]->get( (2*j) );
|
|
||||||
sgCopyVec3( color, fog_color );
|
|
||||||
color[3] =
|
|
||||||
((j == 0) || (i == 3)) ?
|
|
||||||
((j == 0) && (i == 3)) ? 0.0f : 0.15f : 1.0f;
|
|
||||||
|
|
||||||
color = cl[i]->get( (2*j) + 1 );
|
color = cl[i]->get( (2*j) + 1 );
|
||||||
sgCopyVec3( color, fog_color );
|
sgCopyVec3( color, fog_color );
|
||||||
|
color[3] =
|
||||||
|
((j == 0) || (i == 3)) ?
|
||||||
|
((j == 0) && (i == 3)) ? 0.0f : cloud_alpha * 0.15f : cloud_alpha;
|
||||||
|
|
||||||
|
color = cl[i]->get( (2*j) + 2 );
|
||||||
|
sgCopyVec3( color, fog_color );
|
||||||
color[3] =
|
color[3] =
|
||||||
((j == 3) || (i == 0)) ?
|
((j == 3) || (i == 0)) ?
|
||||||
((j == 3) && (i == 0)) ? 0.0f : 0.15f : 1.0f;
|
((j == 3) && (i == 0)) ? 0.0f : cloud_alpha * 0.15f : cloud_alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
color = cl[i]->get( 9 );
|
color = cl[i]->get( 9 );
|
||||||
sgCopyVec3( color, fog_color );
|
sgCopyVec3( color, fog_color );
|
||||||
color[3] = (i == 3) ? 0.0f : 0.15f;
|
color[3] = (i == 3) ? 0.0f : cloud_alpha * 0.15f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,10 +266,7 @@ void SGSky::modify_vis( float alt, float time_factor ) {
|
|||||||
|
|
||||||
double ratio = 1.0;
|
double ratio = 1.0;
|
||||||
|
|
||||||
if ( cloud_layers[i]->getCoverage() == SGCloudLayer::SG_CLOUD_CLEAR ||
|
if ( cloud_layers[i]->getCoverage() == SGCloudLayer::SG_CLOUD_CLEAR ) {
|
||||||
cloud_layers[i]->getCoverage() == SGCloudLayer::SG_CLOUD_FEW ||
|
|
||||||
cloud_layers[i]->getCoverage() == SGCloudLayer::SG_CLOUD_SCATTERED)
|
|
||||||
{
|
|
||||||
// less than 50% coverage -- assume we're in the clear for now
|
// less than 50% coverage -- assume we're in the clear for now
|
||||||
ratio = 1.0;
|
ratio = 1.0;
|
||||||
} else if ( alt < asl - transition ) {
|
} else if ( alt < asl - transition ) {
|
||||||
@ -289,13 +286,33 @@ void SGSky::modify_vis( float alt, float time_factor ) {
|
|||||||
ratio = 1.0;
|
ratio = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the alpha fade value for the cloud layer
|
if ( cloud_layers[i]->getCoverage() == SGCloudLayer::SG_CLOUD_CLEAR ) {
|
||||||
float temp = ratio * 2.0;
|
// do nothing, clear layers aren't drawn, don't affect
|
||||||
if ( temp > 1.0 ) { temp = 1.0; }
|
// visibility andn dont' need to be faded in or out.
|
||||||
cloud_layers[i]->setAlpha( temp );
|
} else if ( (cloud_layers[i]->getCoverage() ==
|
||||||
|
SGCloudLayer::SG_CLOUD_FEW)
|
||||||
|
|| (cloud_layers[i]->getCoverage() ==
|
||||||
|
SGCloudLayer::SG_CLOUD_SCATTERED) )
|
||||||
|
{
|
||||||
|
// set the alpha fade value for the cloud layer. For less
|
||||||
|
// dense cloud layers we fade the layer to nothing as we
|
||||||
|
// approach it because we stay clear visibility-wise as we
|
||||||
|
// pass through it.
|
||||||
|
float temp = ratio * 2.0;
|
||||||
|
if ( temp > 1.0 ) { temp = 1.0; }
|
||||||
|
cloud_layers[i]->setAlpha( temp );
|
||||||
|
|
||||||
// accumulate effects from multiple cloud layers
|
// don't touch visibility
|
||||||
effvis *= ratio;
|
} else {
|
||||||
|
// maintain full alpha for denser cloud layer types.
|
||||||
|
// Let's set the value explicitly in case someone changed
|
||||||
|
// the layer type.
|
||||||
|
cloud_layers[i]->setAlpha( 1.0 );
|
||||||
|
|
||||||
|
// lower visibility as we approach the cloud layer.
|
||||||
|
// accumulate effects from multiple cloud layers
|
||||||
|
effvis *= ratio;
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if ( ratio < 1.0 ) {
|
if ( ratio < 1.0 ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user