Re: [osg-users] multipass transparency
Hi For such complex transparent models you need some proper order-independent transparency algorithm Cheers. 09.10.2012, 23:22, Tina Guo guoyiting1...@gmail.com: Hi, Thanks for reply. Now the code is like virtual void define_passes() { osg::ref_ptrosg::StateSet ss = new osg::StateSet; ss-setAttributeAndModes( new osg::ColorMask(true, true, true, true) ); osg::Depth* depth = new osg::Depth; depth-setWriteMask( false ); ss-setAttributeAndModes( depth, osg::StateAttribute::ON ); addPass( ss.get() ); ss = new osg::StateSet; ss-setAttributeAndModes( new osg::ColorMask(false, false, false, false) ); depth-setWriteMask( true ); ss-setAttributeAndModes( depth, osg::StateAttribute::ON ); addPass( ss.get() ); } However, it could not handle sel-intersection(the picture in the attached doc) Using: transparency-setRenderingHint(osg::StateSet::TRANSPARENT_BIN); transparency-setAttributeAndModes(new osg::BlendFunc(GL_SRC_ALPHA ,GL_ONE_MINUS_SRC_ALPHA), osg::StateAttribute:ShockedN); osg::Depth* depth = new osg::Depth; depth-setWriteMask( false ); transparency-setAttributeAndModes( depth, osg::StateAttribute::ON ); _geom_solid-setStateSet(transparency); instead of transparency-setRenderingHint(osg::StateSet::TRANSPARENT_BIN); transparency-setAttributeAndModes(new osg::BlendFunc(GL_SRC_ALPHA ,GL_ONE_MINUS_SRC_ALPHA), osg::StateAttribute:ShockedN); _geom_solid-setStateSet(transparency); self-intersection is correct. However, some transparent parts will disappear, like the wheels of the car in the picture in the doc, the color seems to be blended after the inner parts. ... Thank you! Cheers, Tina[/img] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=50533#50533 Attachments: http://forum.openscenegraph.org//files/test_152.pdf ___ 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] multipass transparency
Hi If you need to blend all visible layers - try to change order of passes, and set colormask to all false's (so first will be only color, second only depth). If you dont need depth from transparent geometry - you can get by with only first pass. If you need only closest single layer - you draw first pass depth only (with colormask set to false's), second pass with depth test set to lequal. Cheers. 09.10.2012, 09:33, Tina Guo guoyiting1...@gmail.com: Hi, In open inventor, there is a transparency mode called: delayed blend Transparent objects are rendered using multiplicative alpha blending, in a second rendering pass with depth buffer updates disabled. And I want to get the same effect. here's what I am trying to do transparency-setRenderingHint(osg::StateSet::TRANSPARENT_BIN); transparency-setAttributeAndModes(new osg::BlendFunc(GL_SRC_ALPHA ,GL_ONE_MINUS_SRC_ALPHA), osg::StateAttribute::ON); _geom_solid-setStateSet(transparency); class TransparencyTechnique : public osgFX::Technique { public: TransparencyTechnique() : osgFX::Technique() {} virtual bool validate( osg::State ss ) const { return true; } protected: virtual void define_passes() { osg::ref_ptrosg::StateSet ss = new osg::StateSet; ss-setAttributeAndModes( new osg::ColorMask(true, true, true, true) ); addPass( ss.get() ); ss = new osg::StateSet; osg::Depth* depth = new osg::Depth; depth-setWriteMask( false ); ss-setAttributeAndModes( depth, osg::StateAttribute::ON ); addPass( ss.get() ); } }; The result is not right. how should define_passes() be defined? ... Thank you! Cheers, Tina -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=50484#50484 ___ 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] multipass transparency
Hi, Thanks for reply. Now the code is like virtual void define_passes() { osg::ref_ptrosg::StateSet ss = new osg::StateSet; ss-setAttributeAndModes( new osg::ColorMask(true, true, true, true) ); osg::Depth* depth = new osg::Depth; depth-setWriteMask( false ); ss-setAttributeAndModes( depth, osg::StateAttribute::ON ); addPass( ss.get() ); ss = new osg::StateSet; ss-setAttributeAndModes( new osg::ColorMask(false, false, false, false) ); depth-setWriteMask( true ); ss-setAttributeAndModes( depth, osg::StateAttribute::ON ); addPass( ss.get() ); } However, it could not handle sel-intersection(the picture in the attached doc) Using: transparency-setRenderingHint(osg::StateSet::TRANSPARENT_BIN); transparency-setAttributeAndModes(new osg::BlendFunc(GL_SRC_ALPHA ,GL_ONE_MINUS_SRC_ALPHA), osg::StateAttribute:ShockedN); osg::Depth* depth = new osg::Depth; depth-setWriteMask( false ); transparency-setAttributeAndModes( depth, osg::StateAttribute::ON ); _geom_solid-setStateSet(transparency); instead of transparency-setRenderingHint(osg::StateSet::TRANSPARENT_BIN); transparency-setAttributeAndModes(new osg::BlendFunc(GL_SRC_ALPHA ,GL_ONE_MINUS_SRC_ALPHA), osg::StateAttribute:ShockedN); _geom_solid-setStateSet(transparency); self-intersection is correct. However, some transparent parts will disappear, like the wheels of the car in the picture in the doc, the color seems to be blended after the inner parts. ... Thank you! Cheers, Tina[/img] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=50533#50533 Attachments: http://forum.openscenegraph.org//files/test_152.pdf ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] multipass transparency
Hi, In open inventor, there is a transparency mode called: delayed blend Transparent objects are rendered using multiplicative alpha blending, in a second rendering pass with depth buffer updates disabled. And I want to get the same effect. here's what I am trying to do transparency-setRenderingHint(osg::StateSet::TRANSPARENT_BIN); transparency-setAttributeAndModes(new osg::BlendFunc(GL_SRC_ALPHA ,GL_ONE_MINUS_SRC_ALPHA), osg::StateAttribute::ON); _geom_solid-setStateSet(transparency); class TransparencyTechnique : public osgFX::Technique { public: TransparencyTechnique() : osgFX::Technique() {} virtual bool validate( osg::State ss ) const { return true; } protected: virtual void define_passes() { osg::ref_ptrosg::StateSet ss = new osg::StateSet; ss-setAttributeAndModes( new osg::ColorMask(true, true, true, true) ); addPass( ss.get() ); ss = new osg::StateSet; osg::Depth* depth = new osg::Depth; depth-setWriteMask( false ); ss-setAttributeAndModes( depth, osg::StateAttribute::ON ); addPass( ss.get() ); } }; The result is not right. how should define_passes() be defined? ... Thank you! Cheers, Tina -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=50484#50484 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org