Hi, I work on a deferred renderer for my master thesis. Everything is fine and now I want to correctly render transparent objects. I want to use forward rendering for that taks - just render the transparent objects in one pass, blend them together and add it to buffer of rendered opaque objects (by deferred rendering).
The problem is that I don't now how to correctly access opaque/transparent objects in my scene graph to render them separately and combine them in the final stage of deferred renderer. I have found a disscussion http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/2008-July/014769.html where access to render bin #10 (which should always contain transparent geometry ?) is described. So I got and idea that I could create my custom scene graph node (derived from osg::Geode) and redefine its traversal method, where I would "discard" the render bin for transparent/opaque objects after the cull traversal. I modified the code from the discussion a little bit and I mask depth and color buffer for writing when rendering transparent objects (don't know how to acctually remove transparent drawables from particular render bin): Code: void RenderBinMaskNode::traverse(osg::NodeVisitor& nv) { this->osg::Group::traverse( nv ); // Clone render-bin 10 if this is a cull visitor if ( nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR ) { osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>( &nv ); if ( cv ) { // Act if we have a RenderStage pointer if ( osgUtil::RenderStage* renderStage = cv->getRenderStage() ) { // Get the render-bin list osgUtil::RenderBin::RenderBinList& binList = renderStage->getRenderBinList(); osg::notify(osg::ALWAYS) << "RENDER BIN LIST SIZE: " << binList.size() << std::endl; // go to renderbin which stores transparent drawables (always number 10 ?) if( binList.find(10) != binList.end() ) { // for this render bin, do not render its content osg::StateSet* binStateSet = binList[10]->getStateSet(); // mask depth buffer binStateSet->setAttributeAndModes( new osg::Depth(osg::Depth::LESS, 0.0, 1.0, false), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE ); // mask color buffer binStateSet->setAttributeAndModes( new osg::ColorMask(false, false, false, false), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE ); // TO DO: stencil and accum mask } } } } } If I add this custom node as a child of my camera node and the scene itself as a child of my custom node, then no transparent objects are rendered - which is exactly what I want. But the trouble is when I want to render only the transparent objects. When I dump the size of render bin list (see the code), it is 0 if no transparent object should be rendered on the screen (it is outside the view frustum) and 1 if a transparent object should be rendered (but it is not visible since I mask the depth and color buffers). So I have only one render bin containing transparent geometry and no render bin with opaque geometry (and even though the opaque geometry is rendered correctly). I don't underestand why since as far as I know, the cull visitor should fill at least two render bins, one for transparent and one for opaque geometry. Finally, my questions: Is it correct that I have only one render bin containing transparent geometry and no render bin with opaque geometry? How can I render only the transparent geometry of my scene (possibly using the approach from the code)? Thank you in advance for _any_ help. I really need to solve this out. PS.: I apologize for my poor English. Regards, Jirka. ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=10874#10874 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org