https://blog.csdn.net/zsq306650083/article/details/50533480

//osg的写法
osg::ref_ptr<osg::StateSet> ss = box->getOrCreateStateSet();
//参考构造函数 Uniform (Type type, const std::string &name, int numElements=1);
osg::ref_ptr<osg::Uniform> unf = new osg::Uniform(osg::Uniform::FLOAT_VEC4,"path",2);
 //给数组赋值
 unf->setElement(0, osg::Vec4f(1, 0, 1, 1));
 unf->setElement(1, osg::Vec4f(1, 0, 1, 1));
 ss->addUniform(unf);

//在片元着色器的写法
uniform vec4 path[2];
void main()
{
    gl_FragColor = path[0];
}

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄