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_ptr<osg::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_ptr<osg::StateSet> ss = new osg::StateSet;

                osg::ref_ptr<osg::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_ptr<osg::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
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to