mardi 27 janvier 2015

Gimp 2.6.12: modify alpha channel while preserving color


This is for a video game in which a specularity mask is in the alpha channel of the normalmap. I need to create an image where the alpha value for some pixels are 0 (to indicate no specularity,) but where the color values for those pixels are preserved (keeping the normal data.)


I found a way to do this manually using imagemagick, placing my desired alpha channel in a separate image and then merging them. Here's how:


convert ground_0045_nm.tga alpha.tga -alpha off -compose copy_opacity -composite result.tga


This results in an image with the color channels from ground_0045_nm.tga and the the alpha channel from alpha.tga. (wasn't able to embed examples, sorry.)


What I'm looking for is a way to do this in GIMP.


The obvious approach would be to paste the desired alpha channel into a layer mask and then apply it. Unfortunately GIMP seems to throw away color data for transparent pixels if I do this. Meaning that if I disable the alpha channel I see a mostly blank white texture.


I can also open my correct image, produced with imagemagick, and GIMP seems to throw away the color data at load time.


However, I can verify that my image is correct by loading it into the game engine and hacking the GLSL shaders to display the normalmap directly.


Is there any way around this behavior of GIMP? I suspect this may be a GIMP bug.





Aucun commentaire:

Enregistrer un commentaire