#endif
#include <osg/AlphaFunc>
+#include <osg/Depth>
#include <osg/Program>
#include <osg/Uniform>
#include <osg/ref_ptr>
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;
#include <osg/Array>
#include <osg/BlendFunc>
#include <osg/CullFace>
+#include <osg/Depth>
#include <osg/ShadeModel>
#include <osg/Texture2D>
#include <osg/TexEnv>
_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);
}
}
class AlphaFunc;
class BlendFunc;
class CullFace;
+class Depth;
class ShadeModel;
class Texture2D;
class TexEnv;
// 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;
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