Re: [osg-users] Problem with semi-transparent textures
Hi Martin, On 17 May 2012 11:52, Martin Oswald martin.r.osw...@gmail.com wrote: I hope this description makes the problem a bit more clear. I'm afraid even with this explanation I can't spot a reason of what might be going wrong for you. When stumped on issues like this I tend to pare back my usage of classes/data to a bare minimum and see if I can get something simple working then step back through the process adding the more complex tasks/data to see if something breaks. Sometimes just this process helps spot the problems in terms of forcing a thorough review of the source code, sometimes it's the results that illuminate what is going on. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problem with semi-transparent textures
Hi Ulrich, thanks for this hint. Actually, this is not a typo but missing knowledge from my side. The documentation doesn't say much about the semantics of WRAP_R, WRAP_S and WRAP_T. However, I have seen the use of WRAP_R in several examples in the web that deal with 2D textures. I have copied this part of the code from the osgimagesequence example from osg which also deals with 2D textures. Also, I don't think that this is related to my problem I would be grateful for deeper insights on on that. Cheers, Martin Ulrich Hertlein wrote: On 5/05/12 22:30 , Martin Oswald wrote: texture2D = dynamic_castosg::Texture2D*(attr); ... texture2D-setWrap(osg::Texture::WRAP_R,osg::Texture::REPEAT); Typo? 2D textures only require WRAP_S and WRAP_T. /ulrich -- Post generated by Mail2Forum -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=47751#47751 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problem with semi-transparent textures
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_castosg::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 osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problem with semi-transparent textures
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 martin.r.osw...@gmail.com 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_castosg::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=47566#47566 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problem with semi-transparent textures
On 5/05/12 22:30 , Martin Oswald wrote: texture2D = dynamic_castosg::Texture2D*(attr); ... texture2D-setWrap(osg::Texture::WRAP_R,osg::Texture::REPEAT); Typo? 2D textures only require WRAP_S and WRAP_T. /ulrich ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org