we are using jogl in our project already for a long time.
Recently i tried to switch from a previous Jogl 2.x version (from march) to the latest jogl 2.0-rc9 libs.
Everything works fine, except that the textures seems to be not premultiplied anymore.
Rendering textures with alpha values with blend option gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE_MINUS_SRC_ALPHA) ( which is the correct way to use with pre multiplied textures) does result in white areas where the transparent pixels should be.
Are there some changes in the ways how jogl handles textures and alpha values?
"premultiplied alpha" generally means that a constant color (e.g. the background color) is mixed with the normal RGB values of the pixel beforehand. The amount of mix is determined by the value of the alphachannel.
Its generally regarded as a compatibility fallback method for uses where translucency is not available.
Nowadays I would generally discourage using premultiplied alpha and use "real" direct alpha which (at least from my experience) works flawlessly with jogl.
Maybe you could elaborate a little bit more on your problem as I doubt that the blending modes do not work correctly. Maybe the problem is application specific on your side ?
"To make things easier for developers, the Texture class will automatically convert non-premultiplied image data into premultiplied data when storing it into an OpenGL texture."
Or is this not true anymore?
I have simple png images which alpha channel e.g. to mask round corners.
In the past i always setup blending equation to match premultiplied alpha textures. But in the new version this does not work anymore.
So does jogl changes the way it loads the textures?
I know how to use alpha blending in this way. And it would be no big deal to change my code to use
inGL.glBlendFunc(GL_SRC_ONE, GL_ONE_MINUS_SRC_COLOR); (which i have to use in case of premultiplied alpha).
I only wanted to know if JOGL changes its default behaviour when loading png images as texture.
As written in the javadoc ot should automatically create premultiplied images everytime, and so it does in the past.
I have to change a lot of code to chnage my alpha blending. SO i just wanted to be sure.
On 07/29/2012 11:19 PM, Sebastian Greif [via jogamp] wrote:
> I thought that jogl uses premultiplied alpha for textures as default.
> It always does in the past.
> When i load a texture with alpha values with the TextureIO of jogl it
> transforms the texture to be premultiplied as default in the past.
> Take a look at the javadoc at
> http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/opengl/util/texture/Texture.html >
> "To make things easier for developers, the Texture class will automatically
> convert non-premultiplied image data into premultiplied data when storing it
> into an OpenGL texture."
> Or is this not true anymore?
> I have simple png images which alpha channel e.g. to mask round corners.
> In the past i always setup blending equation to match premultiplied alpha
> textures. But in the new version this does not work anymore.
> So does jogl changes the way it loads the textures?
PNG images are now loaded using PNGJ, which does not depend on AWT anymore.
In case the image contains alpha, the resulting Texture is in RGBA mode,
not per-multiplied, since this would disallow proper GL usage here w/ other
normal RGBA sources.
Even though this might be a regression compared to previous AWT behavior
of loading PNG images _and_ the documentation, this IMHO is the way it should be.
Using OpenGL >= 2.0 and OpenGL ES 2.0, RGBA pixel format is usually the default.
Pls. add a bug report and we will fix the documentation in this regard.
AFAIK (while reading / modding code) other formats like TGA etc will
provide an RGBA Texture as well if the source is RGBA.