Hi there

I found out, that it makes a difference if the texture file is loaded in the OSG file it self or in the application. If I load it in the application the transparency works.

Now it only needs the following settings:

   // sets the state set of the OSG node for the sky and sets the states
   ref_ptr<StateSet> stateSky = geoSky->getOrCreateStateSet();
   stateSky->setTextureAttributeAndModes(0, texSky, StateAttribute::ON);
   stateSky->setMode(GL_LIGHTING, StateAttribute::OFF);
   stateSky->setMode(GL_BLEND, osg::StateAttribute::OFF);
   stateSky->setRenderingHint(StateSet::TRANSPARENT_BIN);

Thanks all for the help.

Regards
Dominic

Dominic Stalder schrieb:
Hi Chris

now I have the following settings:

ref_ptr<BlendFunc> blfSky = new BlendFunc(BlendFunc::SRC_ALPHA, BlendFunc::ONE_MINUS_SRC_ALPHA); // sets the state set of the OSG node for the sky and sets the states
   ref_ptr<StateSet> stateSky = geoSky->getOrCreateStateSet();
   stateSky->setAttributeAndModes(blfSky);
stateSky->setMode(GL_BLEND, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
   stateSky->setRenderingHint(StateSet::TRANSPARENT_BIN);

but there is no transparency. Even with the setRenderBinDetails(1, "DepthSortedBin"); enabled it doesn't work.

I added a material like this:

   // creates a new material for the sky
   ref_ptr<Material> material = new Material;
   material->setAlpha(Material::FRONT_AND_BACK, 0.5);
stateSky->setAttributeAndModes(material, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);

Now there is some transparency, but now also the clouds are half transparent, this is not whati want. Any idea?

Regards
Dominic

Chris 'Xenon' Hanson schrieb:
On 12/11/2009 10:15 AM, Dominic Stalder wrote:
How can I set the state to include transparency?

  Here's an example:
http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/2009-June/029244.html

You might be able to skip the rendering hint, and the backface cull will probably be
beneficial to you.


_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to