Turn off z buffer writes for clouds.
This is standard practice for semi-transparent objects and should cut down on the flickering and other sorting artifacts.
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#endif
|
||||
|
||||
#include <osg/AlphaFunc>
|
||||
#include <osg/Depth>
|
||||
#include <osg/Program>
|
||||
#include <osg/Uniform>
|
||||
#include <osg/ref_ptr>
|
||||
@@ -183,7 +184,10 @@ SGNewCloud::SGNewCloud(string type,
|
||||
|
||||
stateSet->setTextureAttributeAndModes(0, tex, osg::StateAttribute::ON );
|
||||
stateSet->setRenderBinDetails(osg::StateSet::TRANSPARENT_BIN, "DepthSortedBin");
|
||||
|
||||
// Turn off z buffer writes. Standard hack for
|
||||
// semi-transparent geometry to avoid sorting / flickering
|
||||
// artifacts.
|
||||
stateSet->setAttributeAndModes(attribFactory->getDepthWritesDisabled());
|
||||
static ref_ptr<AlphaFunc> alphaFunc;
|
||||
static ref_ptr<Program> program;
|
||||
static ref_ptr<Uniform> baseTextureSampler;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <osg/Array>
|
||||
#include <osg/BlendFunc>
|
||||
#include <osg/CullFace>
|
||||
#include <osg/Depth>
|
||||
#include <osg/ShadeModel>
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/TexEnv>
|
||||
@@ -70,6 +71,8 @@ StateAttributeFactory::StateAttributeFactory()
|
||||
_cullFaceFront->setDataVariance(Object::STATIC);
|
||||
_cullFaceBack = new CullFace(CullFace::BACK);
|
||||
_cullFaceBack->setDataVariance(Object::STATIC);
|
||||
_depthWritesDisabled = new Depth(Depth::LESS, 0.0, 1.0, false);
|
||||
_depthWritesDisabled->setDataVariance(Object::STATIC);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace osg
|
||||
class AlphaFunc;
|
||||
class BlendFunc;
|
||||
class CullFace;
|
||||
class Depth;
|
||||
class ShadeModel;
|
||||
class Texture2D;
|
||||
class TexEnv;
|
||||
@@ -59,6 +60,8 @@ public:
|
||||
// cull front and back facing polygons
|
||||
osg::CullFace* getCullFaceFront() { return _cullFaceFront.get(); }
|
||||
osg::CullFace* getCullFaceBack() { return _cullFaceBack.get(); }
|
||||
// Standard depth with writes disabled.
|
||||
osg::Depth* getDepthWritesDisabled() { return _depthWritesDisabled.get(); }
|
||||
StateAttributeFactory();
|
||||
protected:
|
||||
osg::ref_ptr<osg::AlphaFunc> _standardAlphaFunc;
|
||||
@@ -70,6 +73,7 @@ protected:
|
||||
osg::ref_ptr<osg::Vec4Array> _white;
|
||||
osg::ref_ptr<osg::CullFace> _cullFaceFront;
|
||||
osg::ref_ptr<osg::CullFace> _cullFaceBack;
|
||||
osg::ref_ptr<osg::Depth> _depthWritesDisabled;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user