Hi Michael, try using a osg::vec2 instead of a float for your "vertex_shader_attribute". Recently I had a similar problem. I received wrong values when associating a vertex attribute array of floats with a vertex array and trying to read the floats in the shader. Using a vec2 instead and just reading the first component (vertex_shader_attribute.x) resolved the issue.
Hope this helps, Daniel Schmidt, Michael M wrote: > Hi, > > I'm getting odd behavior with a vertex shader. The following > pseudo-code snippets do not produce the same results. Can anyone tell > me why? > > Program 1: > > //Outside the shader, set a shader attribute to negative offset. > vertex_shader_attribute = -offset; > ... > //Then in the shader, set temp to the attribute. > temp = vertex_shader_attribute; > > > Program 2: > > //Outside the shader, set a shader attribute to the vertex x minus > an offset > vertex_shader_attribute = vertex.x - offset; > ... > //Then in the shader, set temp to attribute minus gl_Vertex x. > temp = vertex_shader_attribute - gl_Vertex.x; > > > The "temp" should be set to -offset in both cases, but I'm not seeing > the same behavior in my app. The "temp" value is the only thing that > changes between programs. > > Is gl_Vertex equal to the vertex passed into geom->setVertexArray()? > > Thanks, > Mike > ------------------------------------------------------------------------ > > _______________________________________________ > 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

