<div dir="ltr">Hi Bruno,<div><br></div><div>As I am recalling how this is to be done is something like this:</div><div><br></div><div>Let say you want to pass colors as vertex attributes:</div><div><br></div><div>const size_t vertexAttribLocation = 5;</div><div><br></div><div>osg::Vec4Array* colors = new ...</div><div>osg::Geometry* geometry = new ...</div><div><br></div><div>geometry->setVertexAttribArray(vertexAttribLocation ,colors,osg::Array::BIND_PER_VERTEX);</div><div><br></div><div>osg::Program* program = new ...</div><div>program->addBindAttribLocation("colors", vertexAttribLocation );</div><div><br></div><div>and then in your GLSL you just call it by the name "colors"</div><div><br></div><div>#version 120<br></div><div>attribute vec4 colors;<br></div><div>void main(void) ....</div><div><br></div><div>you do the same for the radius and you may do it for the vertices itself although based on your GLSL version you can use gl_Vertex too</div><div><br></div><div>Hope this helps</div><div>Nick</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 2, 2017 at 11:10 PM, Bruno Oliveira <span dir="ltr"><<a href="mailto:bruno.manata.oliveira@gmail.com" target="_blank">bruno.manata.oliveira@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Nick, <div>thanks for your answer. I read the osgvertexattributes.cpp example and did not quite get it at first. Do you know if there are any further documentation or snippets I could read?</div><div><br></div><div>Or maybe if you have quick snippets it could spare me some valuable time. </div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2017-01-02 20:56 GMT+00:00 Trajce Nikolov NICK <span dir="ltr"><<a href="mailto:trajce.nikolov.nick@gmail.com" target="_blank">trajce.nikolov.nick@gmail.com</a><wbr>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Bruno,<div><br></div><div>yes, you can pass VertexAttributes to the program and look them up in the shader. You can pass the centers as Vec3Array, Vec4Array for colors and probably encode the radius into float array or the vertex.w() from the vertex array.</div><div><br></div><div>Do a search through the examples for how to set up your program with VertexAttributes ... Ping me if you if troubles, I might be able to give some snippets </div><div><br></div><div>Cheers,</div><div>Nick</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_-6149091093651843910h5">On Mon, Jan 2, 2017 at 8:21 PM, Bruno Oliveira <span dir="ltr"><<a href="mailto:bruno.manata.oliveira@gmail.com" target="_blank">bruno.manata.oliveira@gmail.c<wbr>om</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_-6149091093651843910h5"><div dir="ltr"><div><div>Hello,<br><br><br></div>I have an array of 3d points that I want to render in a scene. I want to render them as circles, centered on each point coordinates, with a given radius and a color that is given by a color array I have in memory.<br><br>For now, I am creating a node for each point, that consists of a PrimitiveSet (polygon) that I iterate around the point center. (Check code below).<br><br><br></div>Now I know this can be done with Shaders. I can draw the circle directly in the fragment shader with this example (<a href="http://www.geeks3d.com/20130705/shader-library-circle-disc-fake-sphere-in-glsl-opengl-glslhacker/" target="_blank">http://www.geeks3d.com/201307<wbr>05/shader-library-circle-disc-<wbr>fake-sphere-in-glsl-opengl-gls<wbr>lhacker/</a>). <br><br>But I need to pass the vertex centers and respective colors. Is it possible to pass a osg::Vec3Array* with vertex centers and a osg::Vec4Array* of colors directly to a Shader, so that I can , in a single compiled Shader program, handle all point positions and colors?<br><div><br>Here is teh code for drawing the circle, I use this for each vertex:<br><br>osg::Vec3Array* getArray(const float radius, const int points, const osg::Vec3& center) {<br> auto array = new osg::Vec3Array();<br> const float ratio = (float(2.0*osg::PI) / float(points));<br> for (int i = 0; i < points; i++) {<br> const float angle = float(i) * ratio;<br> array->push_back(osg::Vec3(<br> center.x() + radius*cosf( angle ),<br> center.y() + radius*sinf( angle ),<br> center.z())<br> );<br> }<br> return array;<br>}<br><br>osg::Geometry* getGeometry(const float radius, const int points, const osg::Vec3& center) { <br> osg::Geometry* geom = new osg::Geometry();<br><br> geom->setVertexArray(getArray(<wbr>radius, points, center));<br> geom->addPrimitiveSet(new osg::DrawArrays(osg::Primitive<wbr>Set::POLYGON, 0, points));<br><br> return geom;<br>}<br><br></div></div>
<br></div></div>______________________________<wbr>_________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org" target="_blank">osg-users@lists.openscenegraph<wbr>.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.or<wbr>g/listinfo.cgi/osg-users-opens<wbr>cenegraph.org</a><br>
<br></blockquote></div><span class="m_-6149091093651843910HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="m_-6149091093651843910m_1467725020597466289gmail_signature" data-smartmail="gmail_signature">trajce nikolov nick<br></div>
</font></span></div>
<br>______________________________<wbr>_________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org" target="_blank">osg-users@lists.openscenegraph<wbr>.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.or<wbr>g/listinfo.cgi/osg-users-opens<wbr>cenegraph.org</a><br>
<br></blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.<wbr>openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.<wbr>org/listinfo.cgi/osg-users-<wbr>openscenegraph.org</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">trajce nikolov nick<br></div>
</div>