@ -1964,11 +1964,17 @@ namespace NifOsg
return texEnv ;
return texEnv ;
}
}
void handleDepthFlags ( osg : : StateSet * stateset , bool depthTest , bool depthWrite ,
void handleDepthFlags ( osg : : StateSet * stateset , bool depthTest , bool depthWrite )
osg : : Depth : : Function depthFunction = osg : : Depth : : LESS )
{
{
stateset - > setMode ( GL_DEPTH_TEST , depthTest ? osg : : StateAttribute : : ON : osg : : StateAttribute : : OFF ) ;
if ( ! depthWrite & & ! depthTest )
osg : : ref_ptr < osg : : Depth > depth = new osg : : Depth ( depthFunction , 0.0 , 1.0 , depthWrite ) ;
{
stateset - > setMode ( GL_DEPTH_TEST , osg : : StateAttribute : : OFF ) ;
return ;
}
osg : : ref_ptr < osg : : Depth > depth = new osg : : Depth ;
depth - > setWriteMask ( depthWrite ) ;
if ( ! depthTest )
depth - > setFunction ( osg : : Depth : : ALWAYS ) ;
depth = shareAttribute ( depth ) ;
depth = shareAttribute ( depth ) ;
stateset - > setAttributeAndModes ( depth , osg : : StateAttribute : : ON ) ;
stateset - > setAttributeAndModes ( depth , osg : : StateAttribute : : ON ) ;
}
}
@ -2328,10 +2334,8 @@ namespace NifOsg
{
{
const Nif : : NiZBufferProperty * zprop = static_cast < const Nif : : NiZBufferProperty * > ( property ) ;
const Nif : : NiZBufferProperty * zprop = static_cast < const Nif : : NiZBufferProperty * > ( property ) ;
osg : : StateSet * stateset = node - > getOrCreateStateSet ( ) ;
osg : : StateSet * stateset = node - > getOrCreateStateSet ( ) ;
// Morrowind ignores depth test function, unless a NiStencilProperty is present, in which case it
// The test function from this property seems to be ignored.
// uses a fixed depth function of GL_ALWAYS.
handleDepthFlags ( stateset , zprop - > depthTest ( ) , zprop - > depthWrite ( ) ) ;
osg : : Depth : : Function depthFunction = hasStencilProperty ? osg : : Depth : : ALWAYS : osg : : Depth : : LESS ;
handleDepthFlags ( stateset , zprop - > depthTest ( ) , zprop - > depthWrite ( ) , depthFunction ) ;
break ;
break ;
}
}
// OSG groups the material properties that NIFs have separate, so we have to parse them all again when
// OSG groups the material properties that NIFs have separate, so we have to parse them all again when
@ -2370,7 +2374,6 @@ namespace NifOsg
textureSet , texprop - > mClamp , node - > getName ( ) , stateset , imageManager , boundTextures ) ;
textureSet , texprop - > mClamp , node - > getName ( ) , stateset , imageManager , boundTextures ) ;
}
}
handleTextureControllers ( texprop , composite , imageManager , stateset , animflags ) ;
handleTextureControllers ( texprop , composite , imageManager , stateset , animflags ) ;
handleDepthFlags ( stateset , texprop - > depthTest ( ) , texprop - > depthWrite ( ) ) ;
break ;
break ;
}
}
case Nif : : RC_BSShaderNoLightingProperty :
case Nif : : RC_BSShaderNoLightingProperty :