Discussion:
How do I fill the framebuffer with an alpha channel?
Preet
2012-04-17 06:35:18 UTC
Permalink
Hey,

I have some geometry which has a single primitive set that's a
tri-strip. Some of the triangles in the primitive overlap, so when I
add a material to the geometry with an alpha value I see the overlap
as shown here:

Loading Image...

I don't want the object's opacity to be affected by self
interferences. I read that "one way to solve this in generic OpenGL is
to fill the framebuffer with your desired alpha channel, switch the
blending mode to glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA) and
draw the geometry". I can use osg::BlendFunc properly, but...

* I don't know how to preemptively "fill the framebuffer with your
desired alpha channel" with osg. Can anyone provide any pointers as to
how that can be done?


Regards,

Preet
Robert Osfield
2012-04-19 07:52:33 UTC
Permalink
Hi Preet,

One trick you can use to avoid these double overlay blending issues is
to render the geometry twice, first with depth write on but colour
writes off so that you populate the depth buffer with the nearest
fragments to the camera, then a second pass where your turn on the
colour writes, with this second pass only the fragments that are
nearest the camera will effect the frame buffer. For this technique
you should have depth test set to accept fragments at or nearer than
the fragment in the framebuffer - the setting is for osg::Depth will
be Depth::LEQUAL.

Robert.
Post by Preet
Hey,
I have some geometry which has a single primitive set that's a
tri-strip. Some of the triangles in the primitive overlap, so when I
add a material to the geometry with an alpha value I see the overlap
http://i.stack.imgur.com/s5yqV.png
I don't want the object's opacity to be affected by self
interferences. I read that "one way to solve this in generic OpenGL is
to fill the framebuffer with your desired alpha channel, switch the
blending mode to glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA) and
draw the geometry". I can use osg::BlendFunc properly, but...
* I don't know how to preemptively "fill the framebuffer with your
desired alpha channel" with osg. Can anyone provide any pointers as to
how that can be done?
Regards,
Preet
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Loading...