[osg-users] Problem blending multiple render passes

Sebastian Messerschmidt sebastian.messerschmidt at gmx.de
Sat Sep 9 03:41:23 PDT 2017


Hi Antiro,

Without the complete code it is hard to guess, but some things to check:

1. Are the consecutive cameras set up _not_ to clear the color buffer?
2. Have you disabled depth writes?

> Hi,
> 
> I'm trying to compute the effect of multiple lights in a deferred shading setup. The subgraph of my scenegraph which is supposed to take care of this consists of a root node with a number of RTT cameras as children. All cameras are configured to write the effect of a single light to the exact same output texture.
> On the root node I have (tried to) enable blending so the output texture will contain a combination of all the lighting that is computed, however, when I run the code, it only contains the lighting information of the last child camera (i.e. It is overwriting the output texture instead of blending it)
> 
> I have set up blending at the root node as follows:
> 
> Code:
> auto passState=m_pointLightRoot->getOrCreateStateSet();
> 	passState->setMode(GL_BLEND, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
> 	passState->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
> 	osg::BlendFunc *blendFunc = new osg::BlendFunc(GL_ONE,GL_ONE);
> 	osg::BlendEquation *blendEqn = new osg::BlendEquation(osg::BlendEquation::Equation::FUNC_ADD);
> 	passState->setAttributeAndModes(blendFunc,osg::StateAttribute::ON |osg::StateAttribute::OVERRIDE);
> 	passState->setAttributeAndModes(blendEqn,osg::StateAttribute::ON |osg::StateAttribute::OVERRIDE);
> 
> 
> 
> 
> Is there something wrong with the way I set up blending? Or with my approach of having the different cameras as children of the root?
I would put all lights using the same shader under one group and one 
camera (e.g. one pass).

Cheers
Sebastian
> 
> Thank you!
> 
> Cheers,
> antiro
> 
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=71679#71679
> 
> 
> 
> 
> 
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> 


More information about the osg-users mailing list