When I made that change, I got an alpha channel. I don’t know anything about photoshop but the alpha was clearly visible in the Unity editor. What version of Unity are you using? Whatever the answer, your solution might just be upgrading to 2017.2…
Keep in mind that when you open a PNG with an alpha channel in photoshop it does NOT appear transparent anywhere.
You have to look over in the alpha channel (channels tab) to see it, but the window remains fully opaque. It’s apparently by design but I find it maddening when I’m using Photoshop.
Try opening the alpha PNG with the Gimp image program and you will see the alpha “holes.”
EDIT: correction! Apparently the latest Photoshop does show transparencies properly. I know that older version do not. Not sure how much older…
bump…
Every PNG i save is messed up
made a flowmap painter to paint on rivers inside unity and if i open it in unity i get the same result as my above post, desperately need a solution…
What I don’t get is that your exact code, with that one line fixed, generates a .PNG with transparency. So either you aren’t running the fixed version of the code, you aren’t measuring the transparency correctly, or there is something different about your environment than everyone else’s.
Which of those possibilities would you like help further investigating?
To me it looks fine, what do you expect to get exactly? Photoshop displays PNGs only the way you see above, it does not support seperated alpha channels for pngs. If you need the alpha chanel seperated then you have to open the map in a different programm or save something else as png.
You could store the RGB map and the Alpha in two different JPGs with Quality setting of 100. Then import to Photoshop, put the mask in a seperate channel and then save as a TGA.
Unity should add a EncodeToTGA(), that would be neat.
EDIT: Oh look, maybe try this?
yes i changed to the jpg method, didn’t know PS doesn’t support alpha channel in png
and i vote YES on the EncodeToTGA()
EDIT: Oh wow thanks for the link!!!
I think the thing you’re missing is that alpha is used as transparency in Photoshop. That’s what it’s supposed to look like. Anywhere the alpha channel is black is transparent, and anywhere it’s white is opaque. That’s how transparency usually works. If you want to ignore the alpha channel in Photoshop I think there’s a command somewhere to just turn it off but at the moment I don’t remember where.
I tested the script now and it works fine. But I thought the Alpha handling isn’t good so I added a boolean “storeAlpha” to the Method and replaced “_texture2D.format == TextureFormat.ARGB32” with that boolean.
Whatever people say, TGA is still the best format for textures.
BTW: If you save PNGs in Photoshop and transparency is 0 then color information is lost. So only use PNGs if alpha is transparency. For UI sprites it is the preferrred format, but not for textures.
Yes there is. That image you posted is showing transparency. See those grey and white squares in the background? Those are not actually part of the image, that is Photoshop’s “transparent background”. It’s trying to show you that most of the image is transparent and the only parts that aren’t transparent are where you see colors. If you copy and paste that image on top of a different image in Photoshop, it only pastes the non-transparent parts. You won’t see the grey and white squares anymore. Transparency and alpha channel are the same thing in Photoshop. You said you’re making a Flow Map and they use alpha channels for something else, but that’s a very edge case. MOST of the time, with images, alpha means transparency.