Hi Nick, 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?
Or maybe if you have quick snippets it could spare me some valuable time. 2017-01-02 20:56 GMT+00:00 Trajce Nikolov NICK < [email protected]>: > Hi Bruno, > > 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. > > 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 > > Cheers, > Nick > > On Mon, Jan 2, 2017 at 8:21 PM, Bruno Oliveira < > [email protected]> wrote: > >> Hello, >> >> >> 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. >> >> 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). >> >> >> Now I know this can be done with Shaders. I can draw the circle directly >> in the fragment shader with this example (http://www.geeks3d.com/201307 >> 05/shader-library-circle-disc-fake-sphere-in-glsl-opengl-glslhacker/). >> >> 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? >> >> Here is teh code for drawing the circle, I use this for each vertex: >> >> osg::Vec3Array* getArray(const float radius, const int points, const >> osg::Vec3& center) { >> auto array = new osg::Vec3Array(); >> const float ratio = (float(2.0*osg::PI) / float(points)); >> for (int i = 0; i < points; i++) { >> const float angle = float(i) * ratio; >> array->push_back(osg::Vec3( >> center.x() + radius*cosf( angle ), >> center.y() + radius*sinf( angle ), >> center.z()) >> ); >> } >> return array; >> } >> >> osg::Geometry* getGeometry(const float radius, const int points, const >> osg::Vec3& center) { >> osg::Geometry* geom = new osg::Geometry(); >> >> geom->setVertexArray(getArray(radius, points, center)); >> geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POLYGON, >> 0, points)); >> >> return geom; >> } >> >> >> _______________________________________________ >> osg-users mailing list >> [email protected] >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >> >> > > > -- > trajce nikolov nick > > _______________________________________________ > 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

