[osg-users] HUD camera and post render camera

Romain Roch jumaroch.belpecajo at gmail.com
Tue Sep 15 07:44:05 PDT 2015


Hi,

To handle the rendering of selected objects in my scene, I added a post render camera in the scene graph just underneath the root node.
I placed the scene objects both under the root and the post render camera so that I have the following scene graph
<pre>          root
          /  \ 
         /   selection_camera
        /   /
       scene          
       /  \      
    obj1  obj2</pre>
    
The selection_camera is configured with special render attributes and is defined so that it renders only objects with a specific node mask.
Everything works well, except when I'm adding a HUD text in the scene.
<pre>          root
          /  \ 
         /   selection_camera
        /   /
       scene          
       /  \      
    obj1  HUD_cam
            \
            Text</pre>
In this case, the text is not displayed through the view's camera. If I configure the HUD node mask so that it is not culled by the selection camera,
I can see the text, but though selection camera only. If I disable the selection camera (setNodeMaks(0)), the text is visible.

Here is the setup of the selection camera:


Code:
osg::Camera *selectionCamera = new osg::Camera;
selectionCamera->setCullMask(VISU::NodeSelected); // only render selected objects
selectionCamera->setRenderOrder( osg::Camera::POST_RENDER);
selectionCamera->setClearMask(GL_DEPTH_BUFFER_BIT);
// Enable transparency
selectionCamera->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
selectionCamera->getStateSet()->setMode(GL_CULL_FACE, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); // cull back faces
selectionCamera->getStateSet()->setAttribute(new osg::BlendFunc(GL_SRC_ALPHA, GL_ONE)); // Modify blending


   
The Text camera is a standard HUD (cf osghud example).

I would like to know why my text is not displayed.         

Thank you!

Romain

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65137#65137








More information about the osg-users mailing list