Issues with alpha premultiplication and TGA loading.

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Issues with alpha premultiplication and TGA loading.

alpha channel blues
Hi,

I am using TextureIO.newTextureData to create some OpenGL textures, which is convenient for me.  Some of these textures contain normal and height data, for the purpose of bump mapping and parallax occlusion mapping.  The RGB channels store the normal, and the A channel stores the height.  There are two problems with this:

1) When I am loading a PNG, the RGB channels get modified due to the "convenient" alpha premultiplication.  Of course premultiplication with normal/height data is nonsense, so I'd like to disable it.  Surely there is a simple way to do this?  I don't care about the "mathematically correct" way to do blending (to quote the Javadoc) since that's not my use case.

2) TGA files apparently don't get alpha-premultiplied, which is good for me (despite being weirdly inconsistent), so I am using TGA.  Now the problem is that they load upside-down relative to how JPG and PNG are loaded.  I tried switching the "vertical flip" flag in the header as specified in the TGA file format, but this seems to be ignored by the TGA loader.

It would be super useful if I could fix either or both of these issues.  As of now I can't load any RGBA texture without it either being alpha-premultiplied or flipped upside-down.

Thanks!

P.S. I am using jogl-2.0-b45-20111219-linux-amd64
Reply | Threaded
Open this post in threaded view
|

Re: Issues with alpha premultiplication and TGA loading.

gouessej
Administrator
Hi

alpha channel blues wrote
P.S. I am using jogl-2.0-b45-20111219-linux-amd64
Please use the very latest release candidate (RC12) instead of this obsolete version. Tons of fixes have been added since December 2011. Do you realize that you use something completely outdated?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Issues with alpha premultiplication and TGA loading.

alpha channel blues
Hi,

I upgraded to RC12 and everything works perfectly.  Ok, I should have tried that before posting :)  But in my defense, I assumed the behavior was intentional and wasn't subject to change, and I was just missing a simple option somewhere.  In any case, now I have right-side-up TGAs and non-premultiplied PNGs.

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Issues with alpha premultiplication and TGA loading.

gouessej
Administrator
You're welcome. You indicated the version you used, that was important. Best regards.
Julien Gouesse | Personal blog | Website