Hi,
I want to use vertex attributes and I'm having trouble getting it to work. I
think the problem should lie within this code here:
Code:
program->addBindAttribLocation("a_col", 0);
osg::Vec4Array* colors = new osg::Vec4Array;
for(int i=0;i<model->verticesNum;i++) {
float r = model->cols[i*4];
float g = model->cols[i*4+1];
float b = model->cols[i*4+2];
float a = model->cols[i*4+3];
colors->push_back(osg::Vec4(r,g,b,a));
}
//for this commented out code, when used with gl_Color in the vertex shader, it
works, displaying the mesh and colours properly.
//pyramidGeometry->setColorArray(colors);
//pyramidGeometry->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
//but using this code with the a_col atttribute instead of the gl_Color
//doesn't work, it shows the mesh to be white, and slightly deformed. e.g.
vertices being out of place
pyramidGeometry->setVertexAttribArray(0, colors);
pyramidGeometry->setVertexAttribBinding(0, osg::Geometry::BIND_PER_VERTEX);
Am I missing something here?
I'll post the whole code below, incase the above code isn't enough.
..omitted, forums says something about urls and 2 posts, don't know why..
Also my shader programs are:
vertex shader
Code:
attribute vec4 a_col;
varying vec4 col;
void main() {
col = a_col;//gl_Color;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
fragment shader
Code:
varying vec4 col;
void main() {
gl_FragColor =col;
}
Thanks!
andrew
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=22452#22452
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org