當面片重合的時候,會出現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;