.PNG loader corrupts RGB when alpha==0

If a .png with a valid alpha channel is imported, the resulting texture has incorrect RGB values where alpha==0. Instead of the contents of the source file, pixels with alpha==0 seem to take on the RGB value of the last pixel processed on the current row with a non-zero alpha.

A workaround is to convert the .png to a .tga and import that, in which case the RGB values for pixels with alpha==0 are imported correctly.

See the attached example.png - RGB noise with a circular alpha mask.

138040-example.png

Imported as a .png, and examining RGB in the texture viewer (alpha channel disabled):

Converting the .png to a .tga in a 3rd party app (like Gimp) and importing that provides the correct result:

This sadly is normal png behavior, and isnt as much an ue4 issue as it is a Photoshop & png issue. (afaict)
If you need to use alpha channels alongside RGB its best to use TGA.

Since ue4 compresses any fileformat to its internal dx/dc format it filesize and filetype dont matter that much. (in normal cases at least)

I definitely agree that the input filetype doesn’t much matter to the end result.

However, I can open the same .png that UE4 corrupts inside Gimp and see the correct RGB values where the alpha is masked out. It is absolutely not normal behavior.

Regardless, here’s hoping this bug report gets served up the next time someone is pulling their hair out trying to use AlphaComposite with .png assets

hehe, while I do understand that frustration I barely use alpha channels.
I often combine what I need in RGB, (nothing dictates you cant use other channels during alpha composite)

but yea, thats just me and not a decent solution. especially not for non-vfx.

This is an UE4 Issue, not an .png Issue as GIMP can bring back the rgb values when the black alpha is replaced with a white one!

I noticed that if you export the .png from ue4 and open it in GIMP again, it has only black rgb values even with a white alpha. So UE4 doesn´t just fail at reading the rgb channels for A=0 pixels, it even overwrites the rgb value with 0,0,0!

I only used .png so far for my project and don´t want to change all my stuff up just because no one seems to care that UE4 has a crippleling bug in it´s texture importer!

This Question needs some official feedback on whether or not this is going to be locked at.

it wont be looked at, it wont be changed.
you’ll have to live with it. its a limitation of .png (inside ue4)

as someone who prefers .png over .tga, the only times I use .TGA is when I need an alpha channel.
that said, try to avoid alpha channels as much as possible, as they take up the same amount of filesize as RG and B combined. so its often cheaper/smarter to store three alpha channels in a seperate RGB file anyways.