Re: [osg-users] constant size overlay
HI Michael, I can't say much specifically about your scene graph usage/results as there isn't quite enough info to understand it fully. The only thing I'd add as general clarification is that all the transforms above a Geode will be accumulated into a single 4x4 Matrix and this Matrix will then be applied with the Geometry that are associated with each of these Geode's. This will be that in effect all the internal transforms in the scene graph will be flattened by the cull traversal so that draw traversal won't need to handle all the internal matrices. This levels the field for the draw traversals between using a flatter scene graph with less transforms and deeper one with more internal transforms. At this stage I would ask yourself is the performance sufficient with these mods or not, if not then you'll need to do further work. I'll not suggest any further ideas until you provide some feedback on the absolute perfomance you are now getting, the frame rate, cull and draw times are the scene stats all values that would be useful to know. Robert. On 16 July 2012 14:50, Michael Schanne wrote: > Thanks Robert! > > I tested two alternate implementations, one with a flat graph where I > premultiplied the transforms together and used the result in > AutoTransform::setPosition (so the graph had many AutoTransforms and 1 > Geode), and another where I kept the original graph but used a separate > instance of AutoTransform for each point (instead of sharing a single > AutoTransform node, to take advantage of the cached transform). I was > surprised to discover that when I zoomed out so that every object would be > visible, the second implementation was slightly faster by about 2-3 fps. > According to the statistics, the first graph had a shorter cull time (which > makes sense to me, since there were fewer nodes to traverse) but the second > graph more than made up for it in the draw traversal. I can't explain why > this would happen. I would think the second graph would have a slower draw > time, since there are more matrix multiplications to do. What might cause > this? I am using the DrawThreadPerContext thr ea > d model on a dual-core CPU. > > In any case, I am planning to add level of detail nodes so these objects are > not visible when zoomed way out, so I don't need to improve things more just > yet. The performance at my initial zoom level is acceptable for now. > > ... > > Thank you! > > Cheers, > Michael > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=48869#48869 > > > > > > ___ > 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
Thanks Robert! I tested two alternate implementations, one with a flat graph where I premultiplied the transforms together and used the result in AutoTransform::setPosition (so the graph had many AutoTransforms and 1 Geode), and another where I kept the original graph but used a separate instance of AutoTransform for each point (instead of sharing a single AutoTransform node, to take advantage of the cached transform). I was surprised to discover that when I zoomed out so that every object would be visible, the second implementation was slightly faster by about 2-3 fps. According to the statistics, the first graph had a shorter cull time (which makes sense to me, since there were fewer nodes to traverse) but the second graph more than made up for it in the draw traversal. I can't explain why this would happen. I would think the second graph would have a slower draw time, since there are more matrix multiplications to do. What might cause this? I am using the DrawThreadPerContext threa d model on a dual-core CPU. In any case, I am planning to add level of detail nodes so these objects are not visible when zoomed way out, so I don't need to improve things more just yet. The performance at my initial zoom level is acceptable for now. ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=48869#48869 ___ 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 Micahel, For static transforms there will be no need to retain the whole transform hierarchy, instead I'd recommend accumulating all these transforms to provide a position that you need to place your markers. As a first step you could keep your AutoTransform above your final geometry, but just remove the transforms above the AutoTransform, this won't provide you with maximum performance possible but it'll certainly be a step in the right direction, and if you get the performance you need job done. If this isn't sufficient then you'll need to look at other techniques such as vertex shaders for computing the the scaling. Robert. On 12 July 2012 14:28, Michael Schanne wrote: > Our application is a CAD-type app. Our domain objects already store their > locations relative to other objects, so we thought it made sense to mirror > that in our scene graph. Most of these transforms will not change from one > frame to the next, only when the user adds/removes/moves an object, or at > certain other times. > > We also have a live video image provided by a real camera that we are > projecting into the scene through projective texture mapping. It's important > to maintain 20 fps for the video, not so much for the rest of the scene. > Some of our domain objects are represented by 3D surfaces that we want the > video projected onto. Others are overlay type objects that will not have the > video texture applied to them. For each type of object, we have a single > Geode that we then share between all the leaf MatrixTransforms corresponding > to each object's location. > > For the sample graph in my earlier post, each of the 2000 subgraphs are > initially identical. However at certain points in time one or more matrices > in the subgraphs might change, so they would no longer be identical. We also > need to be able to easily add or remove objects at any level at any time. > > ... > > Thank you! > > Cheers, > Michael > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=48815#48815 > > > > > > ___ > 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
Our application is a CAD-type app. Our domain objects already store their locations relative to other objects, so we thought it made sense to mirror that in our scene graph. Most of these transforms will not change from one frame to the next, only when the user adds/removes/moves an object, or at certain other times. We also have a live video image provided by a real camera that we are projecting into the scene through projective texture mapping. It's important to maintain 20 fps for the video, not so much for the rest of the scene. Some of our domain objects are represented by 3D surfaces that we want the video projected onto. Others are overlay type objects that will not have the video texture applied to them. For each type of object, we have a single Geode that we then share between all the leaf MatrixTransforms corresponding to each object's location. For the sample graph in my earlier post, each of the 2000 subgraphs are initially identical. However at certain points in time one or more matrices in the subgraphs might change, so they would no longer be identical. We also need to be able to easily add or remove objects at any level at any time. ... Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=48815#48815 ___ 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, 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 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" : > 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
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
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
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
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 geode = new osg::Geode; osg::ref_ptr geom = new osg::Geometry; osg::ref_ptr vertices = new osg::Vec3Array; vertices->push_back(osg::Vec3(0.0, 0.0, 10.0)); osg::ref_ptr 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 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 tex = new osg::Texture2D; tex->setImage(img); tex->setBorderColor(osg::Vec4(0.0, 0.0, 0.0, 0.0)); osg::ref_ptr sprite = new osg::PointSprite; osg::ref_ptr point = new osg::Point; point->setSize(100.0); osg::ref_ptr 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 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
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
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
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
[osg-users] constant size overlay
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? Thank you! Cheers, Michael -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46587#46587 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org