Hi
 
wouldnt it be better to use uniform in this case?
 
Cheers.
 
24.10.2012, 13:28, "Daniel Schmid" <daniel.sch...@swiss-simtec.ch>:

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);

    }

  }

}

[/code]

 

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

,

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to