<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Hi Laurens,</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">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.</p>
<p style="margin-top:0;margin-bottom:0">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.<br>
As an illustration, I believe the OSG Beginner's guide has an example similar to this.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">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.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">My apologies for not being as descriptive as I should have been.</p>
<p style="margin-top:0;margin-bottom:0">Just for the sake of completeness, I'm running my program on Ubuntu 14.04 with Intel i5-4690 CPU's integrated graphics.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Again, thanks for helping. Now that I've found the culprit, it should be a bit easier to get this working now.</p>
<p style="margin-top:0;margin-bottom:0">José.<br>
</p>
<br>
<div style="color: rgb(0, 0, 0);">
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> osg-users <osg-users-bounces@lists.openscenegraph.org> on behalf of L. Voerman <l.voerman@rug.nl><br>
<b>Sent:</b> Wednesday, July 4, 2018 1:52 PM<br>
<b>To:</b> OpenSceneGraph Users<br>
<b>Subject:</b> Re: [osg-users] Drawing a partially transparent image in a quad</font>
<div> </div>
</div>
<meta content="text/html; charset=utf-8">
<div>
<div dir="ltr">Hi  <span style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif; font-size:16px; float:none; display:inline">
José,</span>
<div><span style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif; font-size:16px; float:none; display:inline">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.</span></div>
<div><span style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif; font-size:16px; float:none; display:inline">osg also has a few examples, some of those actually do render transparent textures.</span></div>
<div><span style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif; font-size:16px; float:none; display:inline">Another blind guess:</span></div>
<div><font face="Calibri, Helvetica, sans-serif" color="#000000"><span style="font-size:16px">could you have a shader active (shaderGen?). </span></font></div>
<div><font face="Calibri, Helvetica, sans-serif" color="#000000"><span style="font-size:16px">Laurens.</span></font></div>
</div>
<br>
<div class="x_gmail_quote">
<div dir="ltr">On Wed, Jul 4, 2018 at 10:38 AM Jose Pedro Canilho <<a href="mailto:jpc_ace@hotmail.com" id="LPlnk407544" class="OWAAutoLink" previewremoved="true">jpc_ace@hotmail.com</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">
<div id="x_m_-7697574961732764683divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top:0; margin-bottom:0"></p>
<div>
<p style="margin-top:0; margin-bottom:0">Hi Laurens.</p>
<p style="margin-top:0; margin-bottom:0">Thank you for your patience regarding my issue.</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">I was not familiar with the "writing out .osg files and view them with osgviewer" method, but it is indeed a helpful hint!<br>
I was able to view my quads/images in the osgviewer, and, to my surprise, they didn't seem to have any transparency issues!<br>
So I must be doing something wrong within my program itself.</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">I'll try and keep digging for my issue, and report any interesting findings. And I'll keep your suggestions in mind.</p>
Thank you for all the help!</div>
<p></p>
<br>
<div style="color:rgb(0,0,0)">
<hr style="display:inline-block; width:98%">
<div id="x_m_-7697574961732764683divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> osg-users <<a href="mailto:osg-users-bounces@lists.openscenegraph.org" target="_blank" id="LPlnk26766" class="OWAAutoLink" previewremoved="true">osg-users-bounces@lists.openscenegraph.org</a>>
 on behalf of L. Voerman <<a href="mailto:l.voerman@rug.nl" target="_blank" id="LPlnk448749" class="OWAAutoLink" previewremoved="true">l.voerman@rug.nl</a>><br>
<b>Sent:</b> Tuesday, July 3, 2018 9:04 AM<br>
<b>To:</b> OpenSceneGraph Users<br>
<b>Subject:</b> Re: [osg-users] Drawing a partially transparent image in a quad</font>
<div> </div>
</div>
<div>
<div dir="ltr">Hi ,
<div>I can't see what you are doing wrong, other guesses:</div>
<div>- you moved all quads into the transparent bin, and render them all at the same depth</div>
<div>- you compress the images to textures without transparency</div>
<div>- you are looking at a mipmap where the alpha values are interpolated as well.</div>
<div><br>
</div>
<div>for testing you could add</div>
<div>
<div><span style="white-space:pre-wrap"></span>osg::AlphaFunc *alphaTest = new osg::AlphaFunc(osg::AlphaFunc::GREATER, 0.5f);</div>
<div><span style="white-space:pre-wrap"></span>qss.setAttributeAndModes(alphaTest);</div>
</div>
<div>to discard (not blend) the fragments with an alpha value below 0.5</div>
<div><br>
</div>
<div>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.</div>
<div>Laurens.</div>
</div>
<br>
<div class="x_m_-7697574961732764683x_gmail_quote">
<div dir="ltr">On Mon, Jul 2, 2018 at 6:25 PM Jose Pedro Canilho <<a href="mailto:jpc_ace@hotmail.com" id="LPlnk653069" class="x_m_-7697574961732764683OWAAutoLink OWAAutoLink" target="_blank" previewremoved="true">jpc_ace@hotmail.com</a>> wrote:<br>
</div>
<blockquote class="x_m_-7697574961732764683x_gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">
<div id="x_m_-7697574961732764683x_m_-7795004925793149185divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top:0; margin-bottom:0">Hi Laurens.<br>
Thank you for your reply!<br>
<br>
I've actually already had a black background color set in my camera ("setClearColor( 0,0,0,1 )").</p>
<p style="margin-top:0; margin-bottom:0">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?<br>
<br>
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:</p>
<p style="margin-top:0; margin-bottom:0"><br>
<span style="color:#d4d4d4"></span></p>
<div style="color:#d4d4d4; background-color:#1e1e1e; font-family:'Droid Sans Mono','monospace',monospace,'Droid Sans Fallback'; font-weight:normal; font-size:14px; line-height:19px; white-space:pre-wrap">
<div><span style="color:#d4d4d4">
<div style="color:#d4d4d4; background-color:#1e1e1e; font-family:'Droid Sans Mono','monospace',monospace,'Droid Sans Fallback'; font-weight:normal; font-size:14px; line-height:19px; white-space:pre-wrap">
<div><span style="color:#d4d4d4">osg::ref_ptr</span><span style="color:#d4d4d4"><</span><span style="color:#d4d4d4">osg::Image</span><span style="color:#d4d4d4">></span><span style="color:#d4d4d4"> img
</span><span style="color:#d4d4d4">=</span><span style="color:#d4d4d4"> </span><span style="color:#c586c0">new</span><span style="color:#d4d4d4">
</span><span style="color:#dcdcaa">osg::Image</span><span style="color:#d4d4d4">();</span></div>
</div>
</span></div>
<div><span style="color:#d4d4d4">img-></span><span style="color:#dcdcaa">setImage</span><span style="color:#d4d4d4">(width,height,</span><span style="color:#b5cea8">1</span><span style="color:#d4d4d4">,GL_RGBA8,GL_RGBA,GL_UNSIGNED_BYTE,dataPtr,osg::Image::NO_DELETE);</span></div>
</div>
<p></p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">I believe these format options are correct, since I'm able to create other RGBA images correctly.<br>
</p>
<br>
<p style="margin-top:0; margin-bottom:0">Thanks once again.</p>
<p style="margin-top:0; margin-bottom:0">José<br>
</p>
<div style="color:rgb(0,0,0)">
<hr style="display:inline-block; width:98%">
<div id="x_m_-7697574961732764683x_m_-7795004925793149185divRplyFwdMsg" dir="ltr">
<font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> osg-users <<a href="mailto:osg-users-bounces@lists.openscenegraph.org" id="LPlnk965290" class="x_m_-7697574961732764683OWAAutoLink OWAAutoLink" target="_blank" previewremoved="true">osg-users-bounces@lists.openscenegraph.org</a>>
 on behalf of L. Voerman <<a href="mailto:l.voerman@rug.nl" id="LPlnk689044" class="x_m_-7697574961732764683OWAAutoLink OWAAutoLink" target="_blank" previewremoved="true">l.voerman@rug.nl</a>><br>
<b>Sent:</b> Monday, July 2, 2018 3:13 PM<br>
<b>To:</b> OpenSceneGraph Users<br>
<b>Subject:</b> Re: [osg-users] Drawing a partially transparent image in a quad</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div><br>
</div>
<div>Hi Jose,</div>
<div>You may have a black background, with the blending actually (partly) working, change </div>
<div>getCamera()->setClearColor( osg::Vec4(r,g,b,a) );<br>
</div>
<div>to see if that's the case.</div>
<div>the stuff that needs blending needs to be rendered after the background, normally done with:</div>
stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
<div><br>
</div>
<div>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.</div>
<div>Regards, Laurens.</div>
<div><br>
</div>
<div><br>
<div><br>
</div>
</div>
</div>
<br>
<div class="x_m_-7697574961732764683x_m_-7795004925793149185x_gmail_quote">
<div dir="ltr">On Mon, Jul 2, 2018 at 11:28 AM Jose Pedro Canilho <<a href="mailto:jpc_ace@hotmail.com" id="LPlnk804750" class="x_m_-7697574961732764683x_m_-7795004925793149185OWAAutoLink x_m_-7697574961732764683OWAAutoLink OWAAutoLink" target="_blank" previewremoved="true">jpc_ace@hotmail.com</a>>
 wrote:<br>
</div>
<blockquote class="x_m_-7697574961732764683x_m_-7795004925793149185x_gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">
<div id="x_m_-7697574961732764683x_m_-7795004925793149185x_m_3733428938383503358divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top:0; margin-bottom:0">Hi everyone!<br>
<br>
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.<br>
<br>
</p>
<p style="margin-top:0; margin-bottom:0">In my program, I draw several quads, each containing a RGBA squared image.
<br>
</p>
<p style="margin-top:0; margin-bottom:0">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.<br>
<br>
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:<br>
</p>
<div style="color:#d4d4d4; background-color:#1e1e1e; font-family:'Droid Sans Mono','monospace',monospace,'Droid Sans Fallback'; font-weight:normal; font-size:14px; line-height:19px; white-space:pre-wrap">
<div><span style="color:#569cd6">auto</span><span style="color:#d4d4d4"> qss </span>
<span style="color:#d4d4d4">=</span><span style="color:#d4d4d4"> </span><span style="color:#9cdcfe">quad</span><span style="color:#d4d4d4">-></span><span style="color:#dcdcaa">getOrCreateStateSet</span><span style="color:#d4d4d4">();</span></div>
<div><span style="color:#d4d4d4">qss-></span><span style="color:#dcdcaa">setMode</span><span style="color:#d4d4d4">(GL_BLEND, osg::StateAttribute::ON)</span></div>
</div>
<p></p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">but to no avail.</p>
<p style="margin-top:0; margin-bottom:0">I also tried to attach a blend function to the quad, like such:</p>
<p style="margin-top:0; margin-bottom:0"></p>
<div style="color:#d4d4d4; background-color:#1e1e1e; font-family:'Droid Sans Mono','monospace',monospace,'Droid Sans Fallback'; font-weight:normal; font-size:14px; line-height:19px; white-space:pre-wrap">
<div><span style="color:#d4d4d4">osg::BlendFunc</span><span style="color:#d4d4d4">*</span><span style="color:#d4d4d4"> blendFunc
</span><span style="color:#d4d4d4">=</span><span style="color:#d4d4d4"> </span><span style="color:#c586c0">new</span><span style="color:#d4d4d4">
</span><span style="color:#dcdcaa">osg::BlendFunc</span><span style="color:#d4d4d4">(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE_MINUS_SRC_ALPHA );</span></div>
<div><span style="color:#d4d4d4">qss-></span><span style="color:#dcdcaa">setAttributeAndModes</span><span style="color:#d4d4d4">(blendFunc);</span></div>
</div>
<br>
<p></p>
<p style="margin-top:0; margin-bottom:0">but that didn't work either.</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">Are there any other issues that I might be overlooking here?</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">Thanks in advance.<br>
</p>
</div>
</div>
_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org" id="LPlnk612004" class="x_m_-7697574961732764683x_m_-7795004925793149185OWAAutoLink x_m_-7697574961732764683OWAAutoLink OWAAutoLink" target="_blank" previewremoved="true">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" id="LPlnk936014" class="x_m_-7697574961732764683x_m_-7795004925793149185OWAAutoLink x_m_-7697574961732764683OWAAutoLink OWAAutoLink" target="_blank" previewremoved="true">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</blockquote>
</div>
</div>
</div>
</div>
</div>
_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org" id="LPlnk815901" class="x_m_-7697574961732764683OWAAutoLink OWAAutoLink" target="_blank" previewremoved="true">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" id="LPlnk87904" class="x_m_-7697574961732764683OWAAutoLink OWAAutoLink" target="_blank" previewremoved="true">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</blockquote>
</div>
</div>
</div>
</div>
</div>
_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org" target="_blank" id="LPlnk373433" class="OWAAutoLink" previewremoved="true">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank" id="LPlnk980732" class="OWAAutoLink" previewremoved="true">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</blockquote>
</div>
</div>
</div>
</div>
</body>
</html>