[osg-users] Drawing a partially transparent image in a quad

L. Voerman l.voerman at rug.nl
Mon Jul 2 07:13:35 PDT 2018


Hi Jose,
You may have a black background, with the blending actually (partly)
working, change
getCamera()->setClearColor( osg::Vec4(r,g,b,a) );
to see if that's the case.
the stuff that needs blending needs to be rendered after the background,
normally done with:
stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);

If it's not blending at all I would recommend you to check if your image
did not end up as an RGB image instead of RGBA.
Regards, Laurens.




On Mon, Jul 2, 2018 at 11:28 AM Jose Pedro Canilho <jpc_ace at hotmail.com>
wrote:

> Hi everyone!
>
> I've been battling with this issue for a couple of days and could really
> use some assistance. I'm fairly new to OSG (and 3D rendering in general) so
> I might be doing some rookie mistake.
>
> In my program, I draw several quads, each containing a RGBA squared image.
>
> At one point, I'm required to draw a new image on top of the existent
> images. This new image is also squared, but it is partially transparent
> (i.e., several pixels have the RGBA value of 0,0,0,0). At the moment, these
> pixels are being rendered black instead of transparent, and thus are
> mistakenly covering some regions of the background images/quads.
>
> After quite a few searches online, I was pointed in the direction of the
> GL_BLEND macro and blend functions. I tried to enable blending for the new
> image/quad:
> auto qss = quad->getOrCreateStateSet();
> qss->setMode(GL_BLEND, osg::StateAttribute::ON)
>
>
> but to no avail.
>
> I also tried to attach a blend function to the quad, like such:
>
> osg::BlendFunc* blendFunc = new osg::BlendFunc(osg::BlendFunc::SRC_ALPHA,
> osg::BlendFunc::ONE_MINUS_SRC_ALPHA );
> qss->setAttributeAndModes(blendFunc);
>
> but that didn't work either.
>
>
> Are there any other issues that I might be overlooking here?
>
>
> Thanks in advance.
> _______________________________________________
> 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/20180702/87fd71dd/attachment.html>


More information about the osg-users mailing list