static const char *microshaderFragSource = {
"varying vec4 color;
"
"uniform bool test1=true;
"
"uniform float test2=15.0;
"
"uniform float gauss_num[10];
"
"void main(void)
"
"{
"
" if(test1)
"
" gl_FragColor = clamp( color, 0.0, 1.0 );
"
" else
"
" gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
"
"}
"
};
// 数组类型的uniform,数组大小必须与.glsl中的数组大小保持一致
osg::FloatArray* g_GaussNum = new osg::FloatArray(10);
osg::Uniform* gauss_num = new osg::Uniform(osg::Uniform::FLOAT, "gauss_num", g_GaussNum->size());
gauss_num->setArray(g_GaussNum);
//如果是vec2类型的数组,使用FLOAT_VEC2,setElement循环设置每一个元素
// 给uniform添加一个回调
osg::Uniform* OffsetUniform = new osg::Uniform("Offset", osg::Vec3(0.0f, 0.0f, 0.0f));
OffsetUniform->setUpdateCallback(new AnimateCallback());
ss->addUniform(OffsetUniform);