[osg-users] Transparency on a drawable

Vincent Bourdier vincent.bourdier at gmail.com
Mon Jul 14 23:04:23 PDT 2008


Hi Ulrich

thanks for help.

I use/try this code for the moment :

osg::StateSet* state = g->getOrCreateStateSet();

state->setMode(GL_BLEND,osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
    osg::Material* mat =
(osg::Material*)state->getAttribute(osg::StateAttribute::MATERIAL);
    if(!mat) {
        mat = new osg::Material;
    }
    mat->setAlpha(osg::Material::FRONT_AND_BACK, alpha);
    state->setAttributeAndModes(mat,osg::StateAttribute::ON);
    state->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
    state->setMode(GL_LIGHTING, osg::StateAttribute::OFF);

But nothing appear transparent...

Regards,
   Vincent

2008/7/12 Ulrich Hertlein <u.hertlein at sandbox.de>:

> Vincent Bourdier wrote:
>
>> I do exactly the same things, on Nodes...
>>
>>> stateset->setMode(GL_BLEND,   osg::StateAttribute::OVERRIDE |
>>> osg::StateAttribute::ON );
>>> stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
>>>
>>
> Are you sure you're doing this last line?  It's not in the code snippet you
> posted initially...
>
> Cheers,
> /ulrich
>
>     double opacity = 0.1;
>>
>>       osg::StateSet* state = mygometry->getOrCreateStateSet();
>>       state->setMode(GL_BLEND,osg::StateAttribute::ON|
>>       osg::StateAttribute::OVERRIDE);
>>       osg::Material* mat = (osg::Material*)state->getAttribute
>>       (osg::StateAttribute::MATERIAL);
>>       if(!mat) {
>>           mat = new osg::Material;
>>           mat->setAlpha(osg::Material::FRONT_AND_BACK, opacity);
>>           state->setAttributeAndModes(mat,osg::StateAttribute::ON);
>>       }
>>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080715/ad63e5da/attachment-0003.htm>


More information about the osg-users mailing list