OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Drawing a partially transparent image in a quad


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
Jose Pedro Canilho
Guest





PostPosted: Mon Jul 02, 2018 9:28 am    Post subject:
Drawing a partially transparent image in a quad
Reply with quote

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:ShockedN)





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.

------------------
Post generated by Mail2Forum
Back to top
L. Voerman
Guest





PostPosted: Mon Jul 02, 2018 2:14 pm    Post subject:
Drawing a partially transparent image in a quad
Reply with quote

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 < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:

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:ShockedN)





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
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum
Back to top
Jose Pedro Canilho
Guest





PostPosted: Mon Jul 02, 2018 4:25 pm    Post subject:
Drawing a partially transparent image in a quad
Reply with quote

Hi Laurens.
Thank you for your reply!

I've actually already had a black background color set in my camera ("setClearColor( 0,0,0,1 )").
I've tried your rendering hint solution, but unfortunately it didn't solve my problem. Do I need to call any state set updating function after setting the rendering hint?

I've also double checked for the correct format in pretty much any place I can think of. I've checked that my raw images are indeed 8bit RGBA. When I construct my osg::image, I use the following:

osg::ref_ptr<osg::Image> img = new osg::Image();


img->setImage(width,height,1,GL_RGBA8,GL_RGBA,GL_UNSIGNED_BYTE,dataPtr,osg::Image::NO_DELETE);





I believe these format options are correct, since I'm able to create other RGBA images correctly.


Thanks once again.
José
From: osg-users <> on behalf of L. Voerman <>
Sent: Monday, July 2, 2018 3:13 PM
To: OpenSceneGraph Users
Subject: Re: Drawing a partially transparent image in a quad



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 < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:

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:ShockedN)





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
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum
Back to top
L. Voerman
Guest





PostPosted: Tue Jul 03, 2018 8:05 am    Post subject:
Drawing a partially transparent image in a quad
Reply with quote

Hi ,I can't see what you are doing wrong, other guesses:
- you moved all quads into the transparent bin, and render them all at the same depth
- you compress the images to textures without transparency
- you are looking at a mipmap where the alpha values are interpolated as well.


for testing you could add
osg::AlphaFunc *alphaTest = new osg::AlphaFunc(osg::AlphaFunc::GREATER, 0.5f);
qss.setAttributeAndModes(alphaTest);

to discard (not blend) the fragments with an alpha value below 0.5


as you seem to have problems in your data, I would strongly recommend to write out the data to file (.osgt will do) and look at it in the osgviewer.
Laurens.


On Mon, Jul 2, 2018 at 6:25 PM Jose Pedro Canilho < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:

Hi Laurens.
Thank you for your reply!

I've actually already had a black background color set in my camera ("setClearColor( 0,0,0,1 )").
I've tried your rendering hint solution, but unfortunately it didn't solve my problem. Do I need to call any state set updating function after setting the rendering hint?

I've also double checked for the correct format in pretty much any place I can think of. I've checked that my raw images are indeed 8bit RGBA. When I construct my osg::image, I use the following:

osg::ref_ptr<osg::Image> img = new osg::Image();


img->setImage(width,height,1,GL_RGBA8,GL_RGBA,GL_UNSIGNED_BYTE,dataPtr,osg::Image::NO_DELETE);





I believe these format options are correct, since I'm able to create other RGBA images correctly.


Thanks once again.
José
From: osg-users < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> on behalf of L. Voerman < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
Sent: Monday, July 2, 2018 3:13 PM
To: OpenSceneGraph Users
Subject: Re: Drawing a partially transparent image in a quad  



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 < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:

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:ShockedN)





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
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum
Back to top
Jose Pedro Canilho
Guest





PostPosted: Wed Jul 04, 2018 8:38 am    Post subject:
Drawing a partially transparent image in a quad
Reply with quote

Hi Laurens.
Thank you for your patience regarding my issue.


I was not familiar with the "writing out .osg files and view them with osgviewer" method, but it is indeed a helpful hint!
I was able to view my quads/images in the osgviewer, and, to my surprise, they didn't seem to have any transparency issues!
So I must be doing something wrong within my program itself.


I'll try and keep digging for my issue, and report any interesting findings. And I'll keep your suggestions in mind. Thank you for all the help!


From: osg-users <> on behalf of L. Voerman <>
Sent: Tuesday, July 3, 2018 9:04 AM
To: OpenSceneGraph Users
Subject: Re: Drawing a partially transparent image in a quad

Hi , I can't see what you are doing wrong, other guesses:
- you moved all quads into the transparent bin, and render them all at the same depth
- you compress the images to textures without transparency
- you are looking at a mipmap where the alpha values are interpolated as well.


for testing you could add
osg::AlphaFunc *alphaTest = new osg::AlphaFunc(osg::AlphaFunc::GREATER, 0.5f);
qss.setAttributeAndModes(alphaTest);

to discard (not blend) the fragments with an alpha value below 0.5


as you seem to have problems in your data, I would strongly recommend to write out the data to file (.osgt will do) and look at it in the osgviewer.
Laurens.


On Mon, Jul 2, 2018 at 6:25 PM Jose Pedro Canilho < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:

Hi Laurens.
Thank you for your reply!

I've actually already had a black background color set in my camera ("setClearColor( 0,0,0,1 )").
I've tried your rendering hint solution, but unfortunately it didn't solve my problem. Do I need to call any state set updating function after setting the rendering hint?

I've also double checked for the correct format in pretty much any place I can think of. I've checked that my raw images are indeed 8bit RGBA. When I construct my osg::image, I use the following:

osg::ref_ptr<osg::Image> img = new osg::Image();


img->setImage(width,height,1,GL_RGBA8,GL_RGBA,GL_UNSIGNED_BYTE,dataPtr,osg::Image::NO_DELETE);





I believe these format options are correct, since I'm able to create other RGBA images correctly.


Thanks once again.
José
From: osg-users < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> on behalf of L. Voerman < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
Sent: Monday, July 2, 2018 3:13 PM
To: OpenSceneGraph Users
Subject: Re: Drawing a partially transparent image in a quad



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 < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:

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:ShockedN)





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
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum
Back to top
L. Voerman
Guest





PostPosted: Wed Jul 04, 2018 12:52 pm    Post subject:
Drawing a partially transparent image in a quad
Reply with quote

Hi  José,Please keep in mind that you did not provide any info at all what your program is , (or OS os graphics hardware), nor what you are trying to do.
osg also has a few examples, some of those actually do render transparent textures.
Another blind guess:
could you have a shader active (shaderGen?). 
Laurens.


On Wed, Jul 4, 2018 at 10:38 AM Jose Pedro Canilho < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:


Hi Laurens.
Thank you for your patience regarding my issue.


I was not familiar with the "writing out .osg files and view them with osgviewer" method, but it is indeed a helpful hint!
I was able to view my quads/images in the osgviewer, and, to my surprise, they didn't seem to have any transparency issues!
So I must be doing something wrong within my program itself.


I'll try and keep digging for my issue, and report any interesting findings. And I'll keep your suggestions in mind. Thank you for all the help!


From: osg-users < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> on behalf of L. Voerman < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
Sent: Tuesday, July 3, 2018 9:04 AM
To: OpenSceneGraph Users
Subject: Re: Drawing a partially transparent image in a quad  

Hi , I can't see what you are doing wrong, other guesses:
- you moved all quads into the transparent bin, and render them all at the same depth
- you compress the images to textures without transparency
- you are looking at a mipmap where the alpha values are interpolated as well.


for testing you could add
osg::AlphaFunc *alphaTest = new osg::AlphaFunc(osg::AlphaFunc::GREATER, 0.5f);
qss.setAttributeAndModes(alphaTest);

to discard (not blend) the fragments with an alpha value below 0.5


as you seem to have problems in your data, I would strongly recommend to write out the data to file (.osgt will do) and look at it in the osgviewer.
Laurens.


On Mon, Jul 2, 2018 at 6:25 PM Jose Pedro Canilho < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:

Hi Laurens.
Thank you for your reply!

I've actually already had a black background color set in my camera ("setClearColor( 0,0,0,1 )").
I've tried your rendering hint solution, but unfortunately it didn't solve my problem. Do I need to call any state set updating function after setting the rendering hint?

I've also double checked for the correct format in pretty much any place I can think of. I've checked that my raw images are indeed 8bit RGBA. When I construct my osg::image, I use the following:

osg::ref_ptr<osg::Image> img = new osg::Image();


img->setImage(width,height,1,GL_RGBA8,GL_RGBA,GL_UNSIGNED_BYTE,dataPtr,osg::Image::NO_DELETE);





I believe these format options are correct, since I'm able to create other RGBA images correctly.


Thanks once again.
José
From: osg-users < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> on behalf of L. Voerman < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
Sent: Monday, July 2, 2018 3:13 PM
To: OpenSceneGraph Users
Subject: Re: Drawing a partially transparent image in a quad  



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 < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:

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:ShockedN)





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
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum
Back to top
Jose Pedro Canilho
Guest





PostPosted: Wed Jul 04, 2018 1:09 pm    Post subject:
Drawing a partially transparent image in a quad
Reply with quote

Hi Laurens,


Indeed, I was hoping I could spare the details of what my program is doing in general, since it is quite a large application at the moment.
But, to keep it short, I'm basically trying to render a quadtree pagedLOD structure, in order to render several large high-resolution images, with each level of the tree corresponding to image tiles of a certain zoom level (according to the current camera's view). In this scenario, my geometry always consists of 2D textures.
As an illustration, I believe the OSG Beginner's guide has an example similar to this.


Either way, I believe I may have found the issue (or one of the issues)! If I'm correct, there was indeed nothing wrong with the images' transparency. I found out I was mistakenly assigning the top-level node's geometry, in my pagedLOD quadtree.


My apologies for not being as descriptive as I should have been.
Just for the sake of completeness, I'm running my program on Ubuntu 14.04 with Intel i5-4690 CPU's integrated graphics.


Again, thanks for helping. Now that I've found the culprit, it should be a bit easier to get this working now.
José.

From: osg-users <> on behalf of L. Voerman <>
Sent: Wednesday, July 4, 2018 1:52 PM
To: OpenSceneGraph Users
Subject: Re: Drawing a partially transparent image in a quad

Hi José, Please keep in mind that you did not provide any info at all what your program is , (or OS os graphics hardware), nor what you are trying to do.
osg also has a few examples, some of those actually do render transparent textures.
Another blind guess:
could you have a shader active (shaderGen?).
Laurens.


On Wed, Jul 4, 2018 at 10:38 AM Jose Pedro Canilho < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:


Hi Laurens.
Thank you for your patience regarding my issue.


I was not familiar with the "writing out .osg files and view them with osgviewer" method, but it is indeed a helpful hint!
I was able to view my quads/images in the osgviewer, and, to my surprise, they didn't seem to have any transparency issues!
So I must be doing something wrong within my program itself.


I'll try and keep digging for my issue, and report any interesting findings. And I'll keep your suggestions in mind. Thank you for all the help!


From: osg-users < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> on behalf of L. Voerman < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
Sent: Tuesday, July 3, 2018 9:04 AM
To: OpenSceneGraph Users
Subject: Re: Drawing a partially transparent image in a quad

Hi , I can't see what you are doing wrong, other guesses:
- you moved all quads into the transparent bin, and render them all at the same depth
- you compress the images to textures without transparency
- you are looking at a mipmap where the alpha values are interpolated as well.


for testing you could add
osg::AlphaFunc *alphaTest = new osg::AlphaFunc(osg::AlphaFunc::GREATER, 0.5f);
qss.setAttributeAndModes(alphaTest);

to discard (not blend) the fragments with an alpha value below 0.5


as you seem to have problems in your data, I would strongly recommend to write out the data to file (.osgt will do) and look at it in the osgviewer.
Laurens.


On Mon, Jul 2, 2018 at 6:25 PM Jose Pedro Canilho < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:

Hi Laurens.
Thank you for your reply!

I've actually already had a black background color set in my camera ("setClearColor( 0,0,0,1 )").
I've tried your rendering hint solution, but unfortunately it didn't solve my problem. Do I need to call any state set updating function after setting the rendering hint?

I've also double checked for the correct format in pretty much any place I can think of. I've checked that my raw images are indeed 8bit RGBA. When I construct my osg::image, I use the following:

osg::ref_ptr<osg::Image> img = new osg::Image();


img->setImage(width,height,1,GL_RGBA8,GL_RGBA,GL_UNSIGNED_BYTE,dataPtr,osg::Image::NO_DELETE);





I believe these format options are correct, since I'm able to create other RGBA images correctly.


Thanks once again.
José
From: osg-users < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> on behalf of L. Voerman < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
Sent: Monday, July 2, 2018 3:13 PM
To: OpenSceneGraph Users
Subject: Re: Drawing a partially transparent image in a quad



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 < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:

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:ShockedN)





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
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum
Back to top
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Missing 'png' image reader sdef General [3rdparty] 2 Mon Nov 12, 2018 5:51 am View latest post
No new posts Read Image from RTT romulogcerqueira General 6 Thu Sep 27, 2018 7:06 pm View latest post
No new posts Image containing floats ivar General 2 Thu Sep 20, 2018 9:18 am View latest post
No new posts minor change: move assumeSizedInterna... mp3butcher General 9 Wed Aug 15, 2018 10:07 pm View latest post
No new posts Culling and instanced drawing wernerM General 7 Fri Jul 13, 2018 4:45 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP