Copy link to clipboard
Copied
Hello,
I'm in a process of making assets for Unity3D engine and I'm making transparent png's with alpha channels premultiplied with black. My questions:
I think its some kind of inconsistency, or am I missing something?
Thank You for your time,
Peter
PNG, the format standard, does not support alpha channels, only a single transparency channel.
PNG only allows 4 channels, and that fourth channel is transparency.
Some video software packages misuse PNG and treat it as premultiplied, even though the file spec. says it must be straight color.
You could save yourself a lot of trouble by skipping the alpha channels and just saving your PNG after step 1.
Yes, if you messed with the alpha channel and color values you might have ended up with a file that
...Copy link to clipboard
Copied
PNGs are not premultiplied, and are saved as straight color/alpha from Photoshop.
No, it is not normal or expected to export PNG via video.
PNG does not support alpha channels, only transparency.
TIFF can save alpha channels as well as transparency.
But it sounds like you have alpha channels (of which there can be many) confused with transparency (a single channel with specific meaning and relation to the color channels)..
Copy link to clipboard
Copied
Hello Mr Cox,
Thank You for your reply.
Chris Cox wrote:
PNGs are not premultiplied, and are saved as straight color/alpha from Photoshop.
PNG does not support alpha channels, only transparency.
Do you mean that PNGs dont support alpha channels at all? Or just in Photoshop? These two sentences are confusing.
I understand that transparency and alpha channels are different thing, but I want to make files transparent and with alpha channels.
If PNG is not premultiplied why video export has an option to premultiply PNG alpha with black/other color? Its really confusing!
What I have been doing to this day:
1) I have made a graphic "x" on transparent background.
2) I selected the layer and ran action "Alpha Channel from Visible Layers".
3) Then I have made full black layer under the graphic "x".
4) Then used superPNG plugin to intergrate Alpha 1 channel(made by action) within png file.
Programmer i work with says that the files I gave him worked like premultiplied alpha pngs, he wrote custom scripts and shaders and he says that these were ok. I am really confused now.
So as You see I'm really torn right now! I have red parts of PNG speciffication, everything on wikipedia about PNGs and alpha composing etc. and some other articles around web and I feel just stupidier. Could You recommend me a good read about this topic or elaborate more? It could be a book or anything.
Best regards,
Peter
Copy link to clipboard
Copied
PNG, the format standard, does not support alpha channels, only a single transparency channel.
PNG only allows 4 channels, and that fourth channel is transparency.
Some video software packages misuse PNG and treat it as premultiplied, even though the file spec. says it must be straight color.
You could save yourself a lot of trouble by skipping the alpha channels and just saving your PNG after step 1.
Yes, if you messed with the alpha channel and color values you might have ended up with a file that looks like premultiplied values (since you wrote all zeros into the color channel, but didn't need to).
Copy link to clipboard
Copied
Thank You Mr Cox, I think that some gears In my brain started rotating and somehow I just got it! I had many misconceptions in my brain.
Copy link to clipboard
Copied
If you really require "premultiplied png" images, it is quite easy to DIY those in Photoshop:
1) import/open a png with normal transparency
2) duplicate the original layer
3) create a new fill layer and fill with either white or black, depending whether you need to premultiply with black or white
4) then merge the duplicated layer with the fill layer
5) <ctrl>click the original to load the transparency as a selection
6) select the merged layer, and create a layer mask based on that selection.
Now delete the original, and save as a png. Voila, a premultiplied anti-aliased version.
This type of premultiplication is often done by the programmer during runtime - but depending on the tools (and developer 😉 you may have to do it yourself. Tools like TexturePacker add an option to pre-multiply with black automatically for png export, btw.
Some additional info:
http://blogs.msdn.com/b/shawnhar/archive/2009/11/06/premultiplied-alpha.aspx
Copy link to clipboard
Copied
Actually, that web page gets a lot of things wrong.
For most purposes, straight color is better than premultiplied and will result in a lot less artifacts when making adjustments, color corrections, filtering, etc.
Straight color also allow for more blend modes, with premultiplied you either have to un-multiply or live with just normal blend mode.
Copy link to clipboard
Copied
Ah, good to know. Thanks, Chris. Makes me wonder why developers often ask for premultiplied png images?
Copy link to clipboard
Copied
Some are working with applications (video and film) that want premultiplied images.
Some have to deal with broken titling systems that mess up premultiplication and file format support.
But many just don't know the math and terminology, or have been told by someone that they want it, without knowing why.
Copy link to clipboard
Copied
some windows api's for alpha blending want premultiplied alpha images.
it's a pain to create them, but I'd rather do the pre-processing work than process at runtime.
Copy link to clipboard
Copied
Chris...since better is entirely relative to the users application of the assets... even most 'purposes' will find Pre_mult Alpha is better for web, 3D VFX etc...
When utilizing Pre-multiplied Alpha blending (Source + Destination*{1-SrcAlpha}) you work pre multiplied color + alpha and it is superior to
[More : Premultiplied alpha]
None of the transparency workflow.
No to any color data alteration... it's unusable and unacceptable.
Photoshop has not facilitated the 3D/RTVFX industry over 7 years now; We use SuperPNG to author RGBA with absolute precision and none of the hidden ambiguity between different export/save features.
This is not because the collective 3D/games industry are hacks with a bias.... quite the opposite
Copy link to clipboard
Copied
There is a misunderstanding here and it would be great if someone could clarify the right answer here.
This is what i've found on the internet about PNG having an alpha channel (which is a channel thsat storage transparency.
PNG does support an alpha channel, which is used to control transparency, and it is stored as a separate channel from the RGB (color) channels.
Specifically, PNG can store up to 4 channels in total:
3 color channels (Red, Green, Blue) for the image color data.
1 additional channel for alpha, which is responsible for transparency.
Copy link to clipboard
Copied
There is a misunderstanding here and it would be great if someone could clarify the right answer here.
This is what i've found on the internet about PNG having an alpha channel (which is a channel thsat storage transparency.
PNG does support an alpha channel, which is used to control transparency, and it is stored as a separate channel from the RGB (color) channels.
Specifically, PNG can store up to 4 channels in total:
3 color channels (Red, Green, Blue) for the image color data.
1 additional channel for alpha, which is responsible for transparency.
By @sacha_3801
Photoshop can save a PNG with transparency as RGBA(lpha).
When Photoshop opens a PNG RGBA image, the Alpha channel is applied and the A channel is no longer visible in the channels pannel, and there are only RGB channels. The Alpha channel can be recreated via Select > Load Selection, selecting the transparency channel.
Copy link to clipboard
Copied
The alpha channel of png is just that. Calling it transparency is just syntax. We don't need 25 alpha channel support to be added to PNG, we just need the one to work better in Photoshop. And premultiplied alpha is the norm for internal rendering of Illustrator and most image and vector rendering tools. Blending is perfectly fine in premultiplied space with all blend modes, but the formulas change (see post on Iggy blend modes). To suggest otherwise is disingenuous.
It's currently unclear that Photoshop does correct srgb premultiplied alpha. Png import/export ignores sRGB flags, and the values seem to just be treated as srgbColor * a, until export occurs where the layers are converted back to unumultiplied alpha (since PNG doesn't support both forms). This differs from a more correct form of srgbToLinear( srgbColor ) * alpha, which we get when using the GPU to read these textures. I assume Photoshop must do this to store the values in 8-bit data instead of promoting it to higher bit-depth.
Bilinear or trilinear sampling is only correct from premultiplied textures, so before the GPU can read from them, something had to convert them regardless. Photoshop Tiff export, from what I understand, only exports premultiplied data.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now