osg fbx模型中任何一个节点染色(着色)

 

void setNodeStateset(osg::Node *nodeParam)
{
    osg::ref_ptr<osg::StateSet> stateset1 = nodeParam->getOrCreateStateSet();
    osg::ref_ptr<osg::Program> program1 = new osg::Program;

    program1->addShader(new osg::Shader(osg::Shader::VERTEX, vertShader));
    program1->addShader(new osg::Shader(osg::Shader::FRAGMENT, fragShader));
    stateset1->setAttributeAndModes(program1, osg::StateAttribute::ON);
}

 

posted @ 2019-07-07 21:13  西北逍遥  阅读(1100)  评论(0编辑  收藏  举报