<div dir="ltr"><div><div><div><div><div><div><div><div><div>Hello,<br><br></div>I have a point cloud and I need to pass some float attribute. I need one flag per vertex, so I am using vertex attribute array.<br><br></div>Here's how I do it:<br><br></div><b>osg::Geometry* geom = (...);<br><br>osg::ref_ptr<osg::FloatArray> vvv(new osg::FloatArray());<br></b></div><b>for (int i = 0; i < nPoints; i++) vvv->push_back(0.);<br><br></b></div><b>geom->setVertexAttribArray(20, vvv);<br>geom->setVertexAttribBinding(20, osg::Geometry::BIND_PER_VERTEX);</b><br><br><br></div>Then I create a osg::Program and bind the attribute as follows:<br><br><b>m_program->addBindAttribLocation("classif", 20); <br></b><br><br><br></div>And here's my vertex shader that paints the vertices as <b>white</b> if the attribute "classif" is > 0.1 and <b>red</b> otherwise:<br><br><b>            // Vertex Shader<br>            "varying   vec4 vcolor;\n"<br>            "attribute float classif;\n"<br>            "\n"<br>            "void main()\n"<br>            "{\n"<br>            "  vcolor      = ((classif > 0.1) ? vec4(1., 1., 1., 1.) : vec4(1., 0., 0. ,1.));\n"<br>            "  gl_Position = ftransform();\n"<br>            "}\n",<br><br><br>            // Fragment Shader<br>            "varying vec4 vcolor;\n"<br>            "void main() {\n"<br>            "  gl_FragColor = vcolor;\n"<br>            "}"</b><br><br><br><br></div>Now, what happens is that, despite I set all attributes to 0., all the points appear as white (i.e. the shader is interpreting the attribute as > 0.1). And no matter what values I put on the attributes, the vertices are always rendered as white.<br><br></div>Any hints on why this is happening?<br><div><div><br><br><br></div></div></div>