Hi
I am trying to use uniform arrays with OSG, but it fails. Here are the snippets
of code that a'm using:
Code:
osg::StateSet *ss = node->getOrCreateStateSet();
// one way of populating uniform array that I tried
for(int i = 0; i < sz; ++i)
{
char buf[30];
sprintf(buf, "colourPoints[%d]", i);
osg::Vec3 colour = osg::Vec3(1.0, 0.0, 1.0);
ss->addUniform(new osg::Uniform(buf, osg::Vec4(colour, 1.0)));
}
// another way
osg::Uniform *colourPoints = new osg::Uniform(osg::Uniform::FLOAT_VEC4,
"colourPoints", 20);
for(int i = 0; i < sz; ++i)
{
osg::Vec3 colour = osg::Vec3(1.0, 0.0, 1.0);
colourPoints->setElement(i, osg::Vec4(colour, 1.0));
}
ss->addUniform(colourPoints);
// and glsl
uniform vec4 colourPoints[5];
void main(void)
{
vec4 col = colourPoints[1];
gl_FragColor = col;
}
I tried to set up uniforms both ways but neither of them worked and all I get
is a black colour. It must be something obvious that I am missing..
Cheers,
Eldar
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=47598#47598
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org