Hi all I want to pass a custom vertex attribute (lets say a material code) to my vertex shader. For the moment I use BIND_PER_VERTEX:
Code: int l_SMC = 1027; // some material code for (unsigned int i=0; i<a_geode.getNumDrawables(); ++i) { osg::Geometry* l_Geom = a_geode.getDrawable(i)->asGeometry(); if (l_Geom) { osg::Array* l_VertexArray = l_Geom->getVertexArray(); if (l_VertexArray) { unsigned int vertex_count = l_VertexArray->getNumElements(); osg::IntArray* l_Array = new osg::IntArray; for (int v=0; v<vertex_count; v++) { l_Array->push_back(l_SMC); } l_Geom->setVertexAttribArray(6, l_Array); l_Geom->setVertexAttribNormalize(6, false); l_Geom->setVertexAttribBinding(6, osg::Geometry::BIND_PER_VERTEX); } } } Since the material code is unique within geometries, so actually I would need to transfer it only once per Geometry. If I change to BIND_OVERALL, the data is no longer transferred, or at least my shader cannot detect it anymore. I thought i should maybe reduce the VertexAttribArray (l_Array) to one single entry, but this doesn't work either. What is the correct way of passing general or common data, on a per geometry (and not vertex) basis? Regards Daniel ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=50745#50745 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org