<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">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.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"><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/<wbr>20130705/shader-library-<wbr>circle-disc-fake-sphere-in-<wbr>glsl-opengl-glslhacker/</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::<wbr>PrimitiveSet::POLYGON, 0, points));<br><br> return geom;<br>}<br><br></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>