Brett wrote:
Hi,
Im new to osg.I want to use an attribute float vertextemp; in my vertex shader.How to
give that array to vertex shader.
Assuming you have an osg::Geometry object called "geometry", and an
osg::Program called "program", the following code should work:
osg::FloatArray * attrib = new osg::FloatArray();
// (Fill attrib with per-vertex attributes)
int attrNum = 1;
geometry->setVertexAttribArray(attrNum, attrib);
geometry->setVertexAttribBinding(attrNum, osg::Geometry::BIND_PER_VERTEX);
program->addBindAttribLocation("vertextemp", attrNum);
You can set attrNum to any vertex attribute location that's not
currently in use. I'd avoid 0, 2, 3, or 8, because certain video
drivers may still alias the generic vertex attributes with the
traditional ones (vertex coordinates are at 0, normals at 2, colors at
3, texture coordinates at 8).
--"J"
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org