diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 30849e49b..f65e85e53 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -1597,12 +1597,9 @@ namespace NifOsg { const Nif::NiZBufferProperty* zprop = static_cast(property); // VER_MW doesn't support a DepthFunction according to NifSkope - static osg::ref_ptr depth; - if (!depth) - { - depth = new osg::Depth; - depth->setWriteMask((zprop->flags>>1)&1); - } + osg::ref_ptr depth = new osg::Depth; + depth->setWriteMask((zprop->flags>>1)&1); + depth = shareAttribute(depth); node->getOrCreateStateSet()->setAttributeAndModes(depth, osg::StateAttribute::ON); break; }