Ah yes. Vertex attributes. My mistake, that's what I get for speed reading.

Paul Martz
Skew Matrix Software LLC
http://www.skew-matrix.com
+1 303 859 9466

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Jason Daly
Sent: Wednesday, April 29, 2009 7:21 PM
To: [email protected]
Subject: Re: [osg-users] how to specify GLSL attribute??

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

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to