Hi Robert,
thanks a lot for your help!
To answer your questions:
Yes, all images have RGBA channels - the one that gets replaced by the image
sequence and all of the images of the image sequence.
Also, blending is enabled - although I did not set the state attribute myself.
I guess this is done when I'm loading the scene from a collada file.
I'm only parsing the scene tree to the texture2D element I want to replace and
finally replace it via
Code:
texture2D->setImage(imageSequence.get());
However, I have also tried explicitly setting the state attribute via
Code:
stateset->setMode(GL_BLEND, osg::StateAttribute::ON);
but without any noticeable change.
I guess the problem is related to some missing update related to the alpha
channels. Because I see the transparency of both the image that got replaced
and the the one of the image sequence.
For instance, if the texture image that is loaded from the file has all
transparency values set to 255 (everything visible) then I see the transparency
effects of image sequence correctly.
On the other hand, if the texture image loaded from the file is also semi
transparent then - after replacing it by the image sequence - I see an
'overlay' of both transparency channels (the one from the original image AND
the one from the image sequence).
As a result, I don't see the image sequence correctly because pixels that were
transparent in the original image might not be transparent in the new image
sequence anymore.
The weird thing is that this behavior only applies to the alpha channel. All
RGB values are shown correctly.
I hope this description makes the problem a bit more clear.
I'm an osg newbie and I still have no clue where to start to look at.
Thanks for any hints.
Cheers,
Martin
robertosfield wrote:
> Hi Martin,
>
> Do all the images have an alpha channel? i.e. RGBA?
>
> Is blending enabled, i.e, do you have a GL_BLEND enabled? Such as via:
>
> stateset->setMode(GL_BLEND, osg::StateAttribute::ON);
>
> Robert.
>
> On 5 May 2012 13:30, Martin Oswald <> wrote:
>
> > Hi,
> >
> > I encounter the following issue with semi-transparent texture images:
> > After loading a textured model from a file, I want to change the texture
> > image into an image sequence.
> > My code looks similar to the one of the 'osgimagesequence' example program.
> > The texture replacement works fine and the image sequence shows up as
> > expected, except of the following issue:
> > The original image loaded from the file has different transparency values
> > for every pixel.
> > The image sequence replacing the single image also has different
> > transparency values for every pixel and every frame.
> > While the image content (rgb-values) is showing up correctly the
> > transparency values are not updated and stay constant for the whole image
> > sequence.
> > In particular, the transparency values shown for the image sequence are
> > still the same as the ones from the original image.
> > In short, replacing the texture image seems to update the rgb-values but
> > not the transparency values.
> >
> > Here is a code snipped :
> >
> >
> > Code:
> >
> > osg::StateAttribute* attr =
> > stateSet->getTextureAttribute(textureNum,osg::StateAttribute::TEXTURE);
> > if (attr)
> > {
> > texture2D = dynamic_cast<osg::Texture2D*>(attr);
> >
> > if (texture2D)
> > {
> > texture2D->setDataVariance(osg::Object::DYNAMIC);
> > texture2D->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
> > texture2D->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
> > texture2D->setWrap(osg::Texture::WRAP_R,osg::Texture::REPEAT);
> > texture2D->setResizeNonPowerOfTwoHint(false);
> > texture2D->setImage(imageSequence.get());
> > }
> > }
> >
> >
> >
> >
> >
> > I have tried changing/updating the osg::Material node and/or adding
> > osg::BlendFunc to change the transparency properties but without the
> > desired result.
> > I would highly appreciate if someone could give me a hint on how to fix
> > this issue.
> >
> > Thanks a lot.
> >
> > Cheers,
> > Martin
> >
> >
> >
>
>
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=47752#47752
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org