osg qt场景中节点去除透明

 

osg qt场景中节点的透明属性消除

 

{
    osg::ref_ptr<osg::StateSet> stateState = north_wall_geode->getOrCreateStateSet();
    stateState->setMode(GL_BLEND, osg::StateAttribute::ON);
    stateState->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON);
    stateState->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);

    stateState->setAttributeAndModes(wall_material2, osg::StateAttribute::ON);

    osg::ref_ptr<osg::BlendColor> blendColor = new osg::BlendColor(osg::Vec4(1.0f, 1.0f, 1.0f, 0.0f));
    osg::ref_ptr<osg::BlendFunc> blendFunc = new osg::BlendFunc();

    stateState->setAttributeAndModes(blendFunc, osg::StateAttribute::ON);
    stateState->setAttributeAndModes(blendColor, osg::StateAttribute::ON);

    blendFunc->setSource(osg::BlendFunc::CONSTANT_ALPHA);
    blendFunc->setDestination(osg::BlendFunc::ONE_MINUS_CONSTANT_ALPHA);

    blendColor->setConstantColor(osg::Vec4(1.0f, 1.0f, 1.0f, 0.999f));
}

 

 

 

 

##############################

posted @ 2024-02-07 22:10  西北逍遥  阅读(14)  评论(0编辑  收藏  举报