My initial implementation with AutoTransform is not fast enough for my application. I have thousands of MatrixTransforms sharing a single AutoTransform with a child Geode, containing a geometry with two lines. I was getting around 17 fps. Removing the AutoTransforms improved the framerate to 20-25 fps (20 is sufficient for my application).
Since I still need the constant size, I am attempting to use an alternate implementation with PointSprites to see if that performs any better. I used the osgpointsprite example as a guide. However, I'm having trouble getting transparency to work. I want a white 'X' to overlay the rest of the scene at each point. What I am getting is a black opaque box at each point, with the white X inside the box. I've set the alpha to 0 in the point color array, and in the texture outside the X. Can someone help me figure out what I'm doing wrong? Here's the code: Code: osg::ref_ptr<osg::Geode> geode = new osg::Geode; osg::ref_ptr<osg::Geometry> geom = new osg::Geometry; osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array; vertices->push_back(osg::Vec3(0.0, 0.0, 10.0)); osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array; colors->push_back(osg::Vec4(0.0, 0.0, 0.0, 0.0)); geom->setVertexArray(vertices); geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POINTS, 0, 1)); geom->setColorArray(colors); geom->setColorBinding(osg::Geometry::BIND_PER_VERTEX); geode->addDrawable(geom); // Give it an initial bound so it doesn't get culled (osg can't calculate a bounding volume for a single point) geode->setInitialBound( osg::BoundingSphere( osg::Vec3(0.0, 0.0, 0.0), 100.0 ) ); const int pixelsX = 50; const int pixelsY = 50; const int bytesPerPixel = 4; unsigned char *buf = new unsigned char[pixelsX * pixelsY * bytesPerPixel]; memset(buf, 0x00, pixelsX*pixelsY*bytesPerPixel); for (int i = 0; i < pixelsX; i++) { for (int j = 0; j < pixelsY; j++) { if (i == j || pixelsX - i - 1 == j) { for (int k = 0; k < bytesPerPixel; k++) { buf[i * pixelsY * bytesPerPixel + j * bytesPerPixel + k] = 0xFF; } } } } osg::ref_ptr<osg::Image> img = new osg::Image; img->setImage(pixelsX, pixelsY, 1, GL_RGBA8, // internal format GL_RGBA, // pixel format GL_UNSIGNED_INT_8_8_8_8_REV, // pixel data type buf, // data buffer osg::Image::USE_NEW_DELETE); // allocation mode osg::ref_ptr<osg::Texture2D> tex = new osg::Texture2D; tex->setImage(img); tex->setBorderColor(osg::Vec4(0.0, 0.0, 0.0, 0.0)); osg::ref_ptr<osg::PointSprite> sprite = new osg::PointSprite; osg::ref_ptr<osg::Point> point = new osg::Point; point->setSize(100.0); osg::ref_ptr<osg::StateSet> ss = geode->getOrCreateStateSet(); ss->setTextureAttributeAndModes(0, sprite, osg::StateAttribute::ON); ss->setTextureAttributeAndModes(0, tex, osg::StateAttribute::ON); ss->setAttribute(point); ss->setMode(GL_LIGHTING, osg::StateAttribute::OFF); osg::ref_ptr<osg::TexEnv> texenv = new osg::TexEnv; texenv->setMode(osg::TexEnv::DECAL); ss->setTextureAttribute(0, texenv); Thanks, Mike ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=48668#48668 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org