Re: [osg-users] constant size overlay
Hi Michael, Using that many separate transform nodes will not be efficient. Is there a reason why you are using so many transforms in each subgraph? I think it would be best to explain at a high level what you are trying to achieve as there a number of different approaches one can take to tackle dynamic objects, but choosing which of them to pursue would depend on what you are trying to achieve. Robert. On 9 July 2012 23:00, Michael Schanne michael.scha...@gmail.com wrote: It turns out that using point sprites is not an option for me as I now have a requirement that the objects must rotate with the world. I could use AutoTransform with setAutoScaleToScreen(true) and setAutoRotateMode(NO_ROTATION), but it's still not quite fast enough for my application. I am holding at around 19 fps, but I'd like to get it to at least 25 fps. My scene graph contains several thousand MatrixTransforms arranged like this: Root | ... MT ( x 2000) / \ MT MT / \ / \ MT MT MT MT \ | | / AutoTransform | Geode At my default zoom level, only about 32 objects are visible at a time. Is there anything else I try to improve performance while maintaining the constant screen size and rotate-with-world properties? ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=48779#48779 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] constant size overlay
It turns out that using point sprites is not an option for me as I now have a requirement that the objects must rotate with the world. I could use AutoTransform with setAutoScaleToScreen(true) and setAutoRotateMode(NO_ROTATION), but it's still not quite fast enough for my application. I am holding at around 19 fps, but I'd like to get it to at least 25 fps. My scene graph contains several thousand MatrixTransforms arranged like this: Root | ... MT ( x 2000) / \ MT MT / \ / \ MT MT MT MT \ | | / AutoTransform | Geode At my default zoom level, only about 32 objects are visible at a time. Is there anything else I try to improve performance while maintaining the constant screen size and rotate-with-world properties? ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=48779#48779 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] constant size overlay
Hi, Michael Alpha to coverage have any effect only when drawing to csaa or msaa multisampled render target or fb. Cheers, Sergey. 06.07.2012, 03:00, Michael Schanne michael.scha...@gmail.com: Alpha to coverage didn't have any visible effect, but using alpha testing instead seems to work: Code: osg::AlphaFunc *af = new osg::AlphaFunc(); af-setFunction(osg::AlphaFunc::GEQUAL, 0.75f); ss-setAttributeAndModes(af, osg::StateAttribute::ON); Cheers, Michael[/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=48719#48719 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] constant size overlay
Alpha to coverage didn't have any visible effect, but using alpha testing instead seems to work: Code: osg::AlphaFunc *af = new osg::AlphaFunc(); af-setFunction(osg::AlphaFunc::GEQUAL, 0.75f); ss-setAttributeAndModes(af, osg::StateAttribute::ON); Cheers, Michael[/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=48719#48719 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] constant size overlay
Thanks! My other mistake was using DECAL instead of REPLACE in my TexEnv. I didn't realize DECAL was keeping the point's original alpha, which made the entire point sprite transparent, not just the X. I still don't quite have the visual effect I want yet. When the X's are close enough to overlap, the topmost ones appear to be cutting a gap or casting a shadow on the X's beneath, even though alpha is 0 for every black texel (see attachment ps.jpg). I'd like to just have the white overlap (as in attachment at.jpg, from my AutoTransform implementation). Is there anything I can do to fix it? ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=48694#48694 Attachments: http://forum.openscenegraph.org//files/at_303.jpg http://forum.openscenegraph.org//files/ps_140.jpg ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] constant size overlay
maybe you can use alpha to coverage? It's another state attribute you can set, maybe you can google that It only works if you have antialiasing enabled. Cheers, Martin -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=48695#48695 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] constant size overlay
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_ptrosg::Geode geode = new osg::Geode; osg::ref_ptrosg::Geometry geom = new osg::Geometry; osg::ref_ptrosg::Vec3Array vertices = new osg::Vec3Array; vertices-push_back(osg::Vec3(0.0, 0.0, 10.0)); osg::ref_ptrosg::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_ptrosg::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_ptrosg::Texture2D tex = new osg::Texture2D; tex-setImage(img); tex-setBorderColor(osg::Vec4(0.0, 0.0, 0.0, 0.0)); osg::ref_ptrosg::PointSprite sprite = new osg::PointSprite; osg::ref_ptrosg::Point point = new osg::Point; point-setSize(100.0); osg::ref_ptrosg::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_ptrosg::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
Re: [osg-users] constant size overlay
You have to enable blending. Try this: [code] ss-setRenderingHint(osg::StateSet::TRANSPARENT_BIN); ss-setMode(GL_BLEND,osg::StateAttribute::OVERRIDE | osg::StateAttribute::PROTECTED | osg::StateAttribute::ON); [/code] Thank you! Cheers, Martin -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=48670#48670 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] constant size overlay
AutoTransform was exactly what I needed; thanks :) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46638#46638 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] constant size overlay
If you don't need the overlays to be clickable then you can also attach point sprites to your scene elements. That should be a little more performant than the autotransform thing. Turn off depth test to make the icons shine through. Cheers, Martin -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46640#46640 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] constant size overlay
On 03/26/2012 09:03 AM, Michael Schanne wrote: Hi, I want to use OSG to create an overlay where I have different symbols marking certain points in my scene. I want these symbols to remain a constant size in screen coordinates until crossing certain thresholds (for example, they are size A when at a distance X from the camera, then change to size B once distance X). It’s a little different than a HUD because I want the symbols to move as I pan the camera, so that they stay at the same world coordinates. I am using an orthographic projection where the camera is directly overhead in the Z direction, and it will only pan in the X-Y plane. I took a look at the OverlayNode class, but the description didn’t sound like what I wanted. The LOD class sounded more like what I need, so I could switch between multiple sized children based on the camera distance, but I’m still not quite sure how to make each child have a constant size within its camera distance range. Does anyone have any suggestions for me? Hi, Michael, There's not an existing OSG construct that will do exactly what you want, but you might take a look at AutoTransform to see if you can build what you want based on that. --J ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org