Bugfix: remove SGSky minimum distance check.

Without this, various sky rendering modes exhibit artefacts in low-
visibility conditions. The cost of always rendering the dome is 
negligible. (And Rembrandt already had to work this way)
This commit is contained in:
James Turner
2013-12-19 17:20:06 +00:00
parent 4d931b6109
commit fb54386f8d
2 changed files with 10 additions and 47 deletions
+8 -22
View File
@@ -39,7 +39,6 @@
// Constructor // Constructor
SGSky::SGSky( void ) { SGSky::SGSky( void ) {
effective_visibility = visibility = 10000.0; effective_visibility = visibility = 10000.0;
minimum_sky_visibility = 1000;
// near cloud visibility state variables // near cloud visibility state variables
in_puff = false; in_puff = false;
@@ -62,10 +61,8 @@ SGSky::SGSky( void ) {
cloud_root = new osg::Group; cloud_root = new osg::Group;
cloud_root->setNodeMask(simgear::MODEL_BIT); cloud_root->setNodeMask(simgear::MODEL_BIT);
cloud_root->setName("SGSky-cloud-root"); cloud_root->setName("SGSky-cloud-root");
pre_selector = new osg::Switch;
pre_transform = new osg::Group; pre_transform = new osg::Group;
_ephTransform = new osg::MatrixTransform; _ephTransform = new osg::MatrixTransform;
// Set up a RNG that is repeatable within 10 minutes to ensure that clouds // Set up a RNG that is repeatable within 10 minutes to ensure that clouds
@@ -103,9 +100,7 @@ void SGSky::build( double h_radius_m, double v_radius_m,
oursun = new SGSun; oursun = new SGSun;
_ephTransform->addChild( oursun->build(tex_path, sun_size, property_tree_node ) ); _ephTransform->addChild( oursun->build(tex_path, sun_size, property_tree_node ) );
pre_selector->addChild( pre_transform.get() ); pre_root->addChild( pre_transform.get() );
pre_root->addChild( pre_selector.get() );
} }
@@ -118,8 +113,6 @@ void SGSky::build( double h_radius_m, double v_radius_m,
// 180 degrees = darkest midnight // 180 degrees = darkest midnight
bool SGSky::repaint( const SGSkyColor &sc, const SGEphemeris& eph ) bool SGSky::repaint( const SGSkyColor &sc, const SGEphemeris& eph )
{ {
if ( effective_visibility > minimum_sky_visibility ) {
enable();
dome->repaint( sc.adj_sky_color, sc.sky_color, sc.fog_color, dome->repaint( sc.adj_sky_color, sc.sky_color, sc.fog_color,
sc.sun_angle, effective_visibility ); sc.sun_angle, effective_visibility );
@@ -133,10 +126,7 @@ bool SGSky::repaint( const SGSkyColor &sc, const SGEphemeris& eph )
cloud_layers[i]->repaint( sc.cloud_color ); cloud_layers[i]->repaint( sc.cloud_color );
} }
} }
} else {
// turn off sky
disable();
}
SGCloudField::updateFog((double)effective_visibility, SGCloudField::updateFog((double)effective_visibility,
osg::Vec4f(toOsg(sc.fog_color), 1.0f)); osg::Vec4f(toOsg(sc.fog_color), 1.0f));
return true; return true;
@@ -195,6 +185,12 @@ bool SGSky::reposition( const SGSkyState &st, const SGEphemeris& eph, double dt
return true; return true;
} }
void
SGSky::set_visibility( float v )
{
visibility = std::max(v, 25.0f);
}
void void
SGSky::add_cloud_layer( SGCloudLayer * layer ) SGSky::add_cloud_layer( SGCloudLayer * layer )
{ {
@@ -297,16 +293,6 @@ void SGSky::set_3dCloudUseImpostors(bool imp)
SGCloudField::setUseImpostors(imp); SGCloudField::setUseImpostors(imp);
} }
float SGSky::get_minimum_sky_visibility() const
{
return minimum_sky_visibility;
}
void SGSky::set_minimum_sky_visibility( float value )
{
minimum_sky_visibility = value;
}
void SGSky::texture_path( const string& path ) { void SGSky::texture_path( const string& path ) {
tex_path = SGPath( path ); tex_path = SGPath( path );
} }
+2 -25
View File
@@ -43,7 +43,6 @@
#include <osg/ref_ptr> #include <osg/ref_ptr>
#include <osg/MatrixTransform> #include <osg/MatrixTransform>
#include <osg/Node> #include <osg/Node>
#include <osg/Switch>
#include <simgear/ephemeris/ephemeris.hxx> #include <simgear/ephemeris/ephemeris.hxx>
#include <simgear/math/SGMath.hxx> #include <simgear/math/SGMath.hxx>
@@ -224,7 +223,6 @@ private:
layer_list_type cloud_layers; layer_list_type cloud_layers;
osg::ref_ptr<osg::Group> pre_root, cloud_root; osg::ref_ptr<osg::Group> pre_root, cloud_root;
osg::ref_ptr<osg::Switch> pre_selector;
osg::ref_ptr<osg::Group> pre_transform; osg::ref_ptr<osg::Group> pre_transform;
osg::ref_ptr<osg::MatrixTransform> _ephTransform; osg::ref_ptr<osg::MatrixTransform> _ephTransform;
@@ -234,7 +232,6 @@ private:
// visibility // visibility
float visibility; float visibility;
float effective_visibility; float effective_visibility;
float minimum_sky_visibility;
int in_cloud; int in_cloud;
@@ -357,19 +354,6 @@ public:
*/ */
void texture_path( const string& path ); void texture_path( const string& path );
/** Enable drawing of the sky. */
inline void enable() {
pre_selector->setValue(0, 1);
}
/**
* Disable drawing of the sky in the scene graph. The leaf node is still
* there, how ever it won't be traversed on by ssgCullandRender()
*/
inline void disable() {
pre_selector->setValue(0, 0);
}
/** /**
* Get the current sun color * Get the current sun color
*/ */
@@ -421,14 +405,12 @@ public:
/** @return current effective visibility */ /** @return current effective visibility */
inline float get_visibility() const { return effective_visibility; } float get_visibility() const { return effective_visibility; }
/** Set desired clear air visibility. /** Set desired clear air visibility.
* @param v visibility in meters * @param v visibility in meters
*/ */
inline void set_visibility( float v ) { void set_visibility( float v );
effective_visibility = visibility = (v <= 25.0) ? 25.0 : v;
}
/** Get 3D cloud density */ /** Get 3D cloud density */
double get_3dCloudDensity() const; double get_3dCloudDensity() const;
@@ -487,10 +469,5 @@ public:
void set_3dCloudWrap(bool wrap); void set_3dCloudWrap(bool wrap);
/** Get minimum sky visibility */
float get_minimum_sky_visibility() const;
/** Set minimum sky visibility */
void set_minimum_sky_visibility( float value );
}; };
#endif // _SG_SKY_HXX #endif // _SG_SKY_HXX