使用对数深度缓存可以在一定程度上解决z冲突(Z-Fighting),osgEarth也支持使用对数深度缓存,方法是:
if ( useLogDepth )
{
OE_INFO << LC << "Activating logarithmic depth buffer (vertex-only) on main camera" << std::endl;
osgEarth::Util::LogarithmicDepthBuffer logDepth;
logDepth.setUseFragDepth( false );
logDepth.install( view->getCamera() );
}
else if ( useLogDepth2 )
{
OE_INFO << LC << "Activating logarithmic depth buffer (precise) on main camera" << std::endl;
osgEarth::Util::LogarithmicDepthBuffer logDepth;
logDepth.setUseFragDepth( true );
logDepth.install( view->getCamera() );
}