当面片重合的时候,会出现Z-Fighting闪烁现象,可以通过glPolygonOffset来解决
但是一个几何体Geode自身部分面片重合,例如飞机盘旋飞行对应的高度面,就需要使用GL_SAMPLE_ALPHA_TO_COVERAGE_ARB替换GL_BLEND
//geom->getOrCreateStateSet()->setMode(GL_BLEND,osg::StateAttribute::ON | osg::StateAttribute::PROTECTED | osg::StateAttribute::OVERRIDE); geom->getOrCreateStateSet()->setMode(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB, osg::StateAttribute::ON | osg::StateAttribute::PROTECTED | osg::StateAttribute::OVERRIDE);
有时候可能需要设置
osg::DisplaySettings::instance()->setNumMultiSamples(4);//多重采样设置反走样
或者
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits(); traits->samples = 4;//多重采样设置反走样 traits->windowDecoration = false; traits->x = nX; traits->y = nY; traits->width = nW; traits->height = nH; traits->doubleBuffer = true; traits->inheritedWindowData = pInheritedWindowData;
|