LWJGL Forum

Programming => OpenGL => Topic started by: Setlock on December 10, 2018, 22:06:33

Title: Strange Texture Bug When Drawing Opaque Images
Post by: Setlock on December 10, 2018, 22:06:33
Hello everyone, recently Ive been having an issue that youll see below. Yes I have GL_BLEND enabled, GL_ALPHA_TEST enabled, GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA),          GL11.glAlphaFunc(GL11.GL_GREATER, 0),    GL11.glEnable(GL11.GL_DEPTH_TEST);

(https://i.stack.imgur.com/F20HN.png)

As you can see the white appears where opaque pixels should be. Thanks in advanced for your help with this


Title: Re: Strange Texture Bug When Drawing Opaque Images
Post by: spasi on December 10, 2018, 23:00:50
Premultiplied alpha (https://tomforsyth1000.github.io/blog.wiki.html#%5B%5BPremultiplied%20alpha%5D%5D). "Use it, love it, pass it on."
Title: Re: Strange Texture Bug When Drawing Opaque Images
Post by: Setlock on December 11, 2018, 00:01:51
Premultiplied alpha (https://tomforsyth1000.github.io/blog.wiki.html#%5B%5BPremultiplied%20alpha%5D%5D). "Use it, love it, pass it on."

But how would this be implemented in OpenGL?
Title: Re: Strange Texture Bug When Drawing Opaque Images
Post by: spasi on December 11, 2018, 11:25:19
You multiply the RGB channels of all your RGBA textures by the ALPHA channel, then use:

glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA);

instead of

glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);