The Depth class is simply a wrapper around OpenGL depth controls, all of which are explained in the OpenGL blue book The bin name controls render order of Drawable within a render bin (as opposed to the bin number, which controls relative processing order of the bins themselves). OSG defines two bin name: "RenderBin", which sorts by state, then front to back, and "DepthSortedBin" which sorts in back to front order. (I might be wrong on the specifics; check the code.) To solve your issue, you simply need to do three things: 1. Disable the depth test (or set it to GL_ALWAYS). 2. Call setRenderBinDetails and pass in a very large bin number. 3. Don't draw anything after it, which means no other Drawables in this bin that might overdraw what you want to show up, no nested post-render cameras, and no fancy bin nesting. Paul Martz Skew Matrix Software LLC http://www.skew-matrix.com <http://www.skew-matrix.com/> +1 303 859 9466
_____ From: [email protected] [mailto:[email protected]] On Behalf Of Vincent Bourdier Sent: Friday, January 09, 2009 2:58 AM To: OpenSceneGraph Users Subject: Re: [osg-users] Depth, CULL, renderBin : what and when ? Hi, Thanks for your explanations. If anyone can explain me the Depth class and the binName string , I would be very grateful. For now, I've tried this : void setNodeAlwaysRendered(osg::Node* n) { if(!n) return; osg::ref_ptr<osg::StateSet> state = n->getOrCreateStateSet(); //no scene graph culling n->setCullingActive(false); //set depht test off state->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF); //last rendered state->setRenderBinDetails(INT_MAX, "RenderBin"); } But nothing changed... I apply it on a PAT, and on a geode ... but the node it still culled by the other one... I use HUDs in the scene, but the scene graph is not attached to them... so I don't think it can explain that. Is there some properties to check on the View ? compositeViewer ? camera ? Can I apply that on every king of node ? is there a mean to force children inherit the state ? is it necessary ? Thanks for you help. Regards, Vincent. 2009/1/9 Serge Lages <[email protected]> Hi Vincent, I'll try to answer to your questions... On Fri, Jan 9, 2009 at 9:55 AM, Vincent Bourdier <[email protected]> wrote: Hi, I need some explanations about the ways OSG allow to modify the render. I am working on a function, to apply to a node, to set it always rendered over the other nodes. In other words, If I apply this on an osgText, I would be able to read the text whatever my camera position can be (of course if text is in the frustum). I make some search and I found a lot of things: * node->setCullingActive() : disable/enable the culling on a node. I am I good, disabling this on a node is not sufficient, after that we need to tell the node when to be rendered, isn't it ? You don't necessarily need to disable the culling to be sure to see your node. The culling is applied depending on the view frustum or the distance (small feature culling). And you're right, it's not sufficient to disable it. * state->setMode(GL_DEPTH_TEST, OFF) : same thing ? what is the difference with the first one ? just OSG/OpenGl distinction ? This one disable depth tests with the other nodes, which means that when you'll render your node, OpenGL will not check if your object is behind another one, it will render your node on top of everything rendered so far. It's a first step to be sure to see your node, so don't forget to set the GL_DEPTH_TEST to off. * state->setRenderbinDetails(binNum, binName) : num < 0 will be first rendered, num >0 will be the last ? what is the binName ? I saw "LastRenderBin" or "RenderBin" ... is there some keyword or it is just a name ? what is this word function ? RenderBins allows you to control the rendering order of your node, I must admit that it's a complex topic I don't still fully understand. But what you need to know is that if you set something like that : state->setRenderbinDetails(INT_MAX, "RenderBin") ; You'll be pretty sure to have your object rendered last. In combination with the GL_DEPTH_TEST, you've got your reciepe to get an object always rendered. But be aware to not have an other osg::Camera rendering after the one where your object is attached. In this case, be sure that you render your object with the last osg::Camera rendered in your scene. Hope this helps ! -- Serge Lages http://www.tharsis-software.com _______________________________________________ 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

