Re: [osg-users] Unwanted effect with two effect nodes in the line of sight (see-through)
Ok, I think I solved it. There is quite a catch to the following OSG FX method: Code: void Technique::addPass(osg::StateSet* ss) { if (ss) { _passes.push_back(ss); ss-setRenderBinDetails(static_castint(_passes.size()), RenderBin); } } Then again, this is was setRenderingHints does (yes, that's source code comment is in there, it's the 3.2.0 source): Code: void StateSet::setRenderingHint(int hint) { _renderingHint = hint; // temporary hack to get new render bins working. switch(_renderingHint) { case(TRANSPARENT_BIN): { _binMode = USE_RENDERBIN_DETAILS; _binNum = 10; _binName = DepthSortedBin; break; } case(OPAQUE_BIN): { _binMode = USE_RENDERBIN_DETAILS; _binNum = 0; _binName = RenderBin; break; } default: // DEFAULT_BIN { setRenderBinToInherit(); break; } } } So what I did before (in Technique::add_passes) did NOT work: Code: stateSet-setRenderingHint(osg::StateSet::TRANSPARENT_BIN); addPass(stateSet.get()); But reversing the order DOES work: Code: addPass(stateSet.get()); stateSet-setRenderingHint(osg::StateSet::TRANSPARENT_BIN); The order makes the difference since both have functionality similar to setRenderBinDetails - but with different settings. Good to know how addPass() and setRenderingHint() work. Is my interpretation correct? Cheers, Florian -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56587#56587 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Unwanted effect with two effect nodes in the line of sight (see-through)
Hi David and all, thank you for taking your time to answer this. To make things clear, I am using self-written subclasses of the Effect class (from the osgFX namespace). Simply adding the second pass to the transparent bin did not help. Though I have to admit I do not have the expertise (yet) to understand the interaction between multi-pass and multi-bin. I suspect that I need a transparency effect in two passes, not in one pass. This would explain why the single pass transparency occludes my second pass of the other effect node, right? I would like to understand this a bit more, before I start trying things out, so my question are: 1. how do multi-pass and multiple bins play together? 2. if have nodes using two-pass rendering, does my transparency effect node also need two-pass (AND transparent bin) in order to take effect OVER the other effect nodes? As another hint: I am also using the built-in osgFX::Scribe node which suffers from the effect, that the scribed nodes gets completely occluded by the transparent wall (left, in the attached screenshot scribe-gets-occluded.png). Thank you! Cheers, Florian Links I found (relevant?): http://forum.openscenegraph.org/viewtopic.php?t=11180 http://forum.openscenegraph.org/viewtopic.php?t=12791 -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56559#56559 Attachments: http://forum.openscenegraph.org//files/scribe_gets_occluded_175.png ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Unwanted effect with two effect nodes in the line of sight (see-through)
Hi, 1. for transparent walls we use our own node (derived from Effect) - see code below 2. for tinting objects, we also use an effect node derived from Effect - see code below Used by themselves, everything works fine. But if we have a tinted object behind a transparent object, the tinting effect is gone (see screenshot). Code for transparency effect: Code: void define_passes() { // implement pass #1 { // s.a. http://www.mail-archive.com//msg13796.html osg::ref_ptrosg::StateSet stateSet = new osg::StateSet; // mat osg::Material* mat = new osg::Material; mat-setAlpha(osg::Material::FRONT_AND_BACK, alpha); stateSet-setAttributeAndModes(mat, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); // backface culling, führt dazu dass innere Rückseiten nicht angezeigt werden osg::CullFace* cull = new osg::CullFace(); cull-setMode(osg::CullFace::BACK); stateSet-setAttributeAndModes(cull, osg::StateAttribute::ON); // turn on blending osg::BlendFunc* bf = new osg::BlendFunc(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE_MINUS_SRC_ALPHA ); stateSet-setMode(GL_BLEND, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); stateSet-setAttributeAndModes(bf); // rendering hints stateSet-setRenderingHint(osg::StateSet::TRANSPARENT_BIN); // lighting stateSet-setMode(GL_LIGHTING, osg::StateAttribute::OFF); addPass(stateSet.get()); } } Code for coloring effect: Code: void define_passes() { // implement pass #1 - draw original with a little offset { osg::ref_ptrosg::StateSet ss = new osg::StateSet; osg::ref_ptrosg::PolygonOffset polyoffset = new osg::PolygonOffset; polyoffset-setFactor(1.0f); polyoffset-setUnits(1.0f); ss-setAttributeAndModes(polyoffset.get(), osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON); addPass(ss.get()); } // implement pass #2 - draw tinted { osg::ref_ptrosg::StateSet ss = new osg::StateSet; // Material überschreiben ss-setAttributeAndModes(_wf_mat.get(), osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON); // notwendig, damit alpha greift ss-setMode(GL_BLEND,osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE); addPass(ss.get()); } } See attached image: The fire extinguisher should be all yellow, but behind the transparent wall - it is as if it was rendered without the effect. I hope someone can sched some light on this issue? Thank you! Florian PS sorry if the code snippets come out weird, leading space for indentation somehow goes wrong...[/img][/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56477#56477 Attachments: http://forum.openscenegraph.org//files/transparency_bug_132.png ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Unwanted effect with two effect nodes in the line of sight (see-through)
Hi Florian We can't really help you without know how work your multi pass system. My guess is that osg draw your first pass #1 - draw original with a little offset, then transparency pass, then pass #2 - draw tinted. You can use osg::StateSet::RenderingHint(osg::StateSet::TRANSPARENT_BIN) in your transparency stateSet this will tell to osg that your geometry is transparency and have to be draw after other drawable and from front to back order Take a look to osg::StateSet::setRenderBinDetails and osgUtil::RenderBin and how all of this work. HTH David 2013/9/25 Florian Kolbe florian.ko...@in-gmbh.de Hi, 1. for transparent walls we use our own node (derived from Effect) - see code below 2. for tinting objects, we also use an effect node derived from Effect - see code below Used by themselves, everything works fine. But if we have a tinted object behind a transparent object, the tinting effect is gone (see screenshot). Code for transparency effect: Code: void define_passes() { // implement pass #1 { // s.a. http://www.mail-archive.com//msg13796.html osg::ref_ptrosg::StateSet stateSet = new osg::StateSet; // mat osg::Material* mat = new osg::Material; mat-setAlpha(osg::Material::FRONT_AND_BACK, alpha); stateSet-setAttributeAndModes(mat, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); // backface culling, führt dazu dass innere Rückseiten nicht angezeigt werden osg::CullFace* cull = new osg::CullFace(); cull-setMode(osg::CullFace::BACK); stateSet-setAttributeAndModes(cull, osg::StateAttribute::ON); // turn on blending osg::BlendFunc* bf = new osg::BlendFunc(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE_MINUS_SRC_ALPHA ); stateSet-setMode(GL_BLEND, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); stateSet-setAttributeAndModes(bf); // rendering hints stateSet-setRenderingHint(osg::StateSet::TRANSPARENT_BIN); // lighting stateSet-setMode(GL_LIGHTING, osg::StateAttribute::OFF); addPass(stateSet.get()); } } Code for coloring effect: Code: void define_passes() { // implement pass #1 - draw original with a little offset { osg::ref_ptrosg::StateSet ss = new osg::StateSet; osg::ref_ptrosg::PolygonOffset polyoffset = new osg::PolygonOffset; polyoffset-setFactor(1.0f); polyoffset-setUnits(1.0f); ss-setAttributeAndModes(polyoffset.get(), osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON); addPass(ss.get()); } // implement pass #2 - draw tinted { osg::ref_ptrosg::StateSet ss = new osg::StateSet; // Material überschreiben ss-setAttributeAndModes(_wf_mat.get(), osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON); // notwendig, damit alpha greift ss-setMode(GL_BLEND,osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE); addPass(ss.get()); } } See attached image: The fire extinguisher should be all yellow, but behind the transparent wall - it is as if it was rendered without the effect. I hope someone can sched some light on this issue? Thank you! Florian PS sorry if the code snippets come out weird, leading space for indentation somehow goes wrong...[/img][/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56477#56477 Attachments: http://forum.openscenegraph.org//files/transparency_bug_132.png ___ 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