PDA

View Full Version : Transparent PNGs



Philbert
07-05-2015, 02:25 AM
This is probably something I learned years ago but never used. I have some PNG textures that have transparency in them. Can I use that somehow or do I need to make a black/white transparency map from it? I looked at the Enable Alpha Channel option in the Image editor but it;s greyed out. Thanks.

Ztreem
07-05-2015, 03:05 AM
Png's alpha channel in Lw doesn't work that good, I think.
What I do is that I clone the texture in the image editor and set it to alpha only and use that texture to drive the transparency or clipmap.

raw-m
07-05-2015, 07:05 AM
It should be simple, it isn't. See here:
http://forums.newtek.com/showthread.php?146693-Clip-Map-problem-with-PNG-files/page2

JoePoe
07-05-2015, 08:57 AM
mmm. If the Enable option is greyed out then I suspect there is something wrong with the png not LW (care to post it?)
If it's not showing up in the first place, making a clone>alpha-only won't work either.

The only times I've had issues with a PNG alpha have been using it as a clip map on a severely contrasty background (see the thread Raw-M posted).
Usually in transparency channel, it's been pretty good.

Philbert
07-05-2015, 03:19 PM
Yeah, I can post it. These are just textures that export from Make Human. All of the PNGs it exports seem to have this problem. This one is hair.

Hmm... For some reason the forum is giving me errors when I try to upload. Maybe it's too big (3.3MB). Here it is on Dropbox.
https://dl.dropboxusercontent.com/u/3083393/short02_diffuse.png

I'm making a video on Make Human so I'd like this to be as straight forward as possible.

JoePoe
07-05-2015, 04:26 PM
Pretty weird. Confirmed, Enable Alpha greyed out. I opened in an image editor and the transparency is there.... :stumped:. Still thinking....

I just resaved it as png and it was fine. But you shouldn't have to do that.... what a pain!

Maybe something to ask on Make Human forum??

Philbert
07-05-2015, 04:44 PM
Yeah p, I'll mention it there. This is the nightly build so basically beta, but I think the official release might also have this problem.

Sensei
07-05-2015, 08:11 PM
I have the same issue (disabled Alpha Channel) in LW v11.6.1.
In Image Editor we can see Depth: 24 bits.

After loading to Photoshop,
saving as PSD,
loading it again,
saving as PNG,
it's fine in LW, with alpha.

MSherak
07-06-2015, 08:36 AM
FYI, PNG file format does not have an alpha channel. It's transparency. Easy way to see this is when one loads a PNG in Photoshop. The layer will have transparency and no alpha. So unless one uses something like the SuperPNG loader http://www.fnordware.com/superpng/ for Photoshop the alpha has to be setup manually. Alpha channels have to be multiplied to "cut out" the areas you don't want to see. Transparency do not since the pixel knows to mix the background into itself. So really Lightwave is treating the PNG the way the format is stored.

-m

JoePoe
07-06-2015, 09:30 AM
Interesting.

Loads into Affinity photo with an Alpha.
Loads into Gimp with an Alpha.
(maybe these two are just smarter than Pshop ;), which needs a patch for it's shortcoming....not PNGs fault in this case? :))
From SuperPNG website: "It has more comprehensive support for the format than Photoshop's included plug-in..."

Loads into Photoline without an Alpha.

MSherak
07-06-2015, 10:28 AM
Interesting.

Loads into Affinity photo with an Alpha.
Loads into Gimp with an Alpha.
(maybe these two are just smarter than Pshop ;), which needs a patch for it's shortcoming....not PNGs fault in this case? :))
From SuperPNG website: "It has more comprehensive support for the format than Photoshop's included plug-in..."

Loads into Photoline without an Alpha.

PNG's should load into paint packages without an alpha channel since the format does not have one. If packages are loading a PNG with alpha channel then it is converting the transparency to alpha during load, which is fine. Might come down to those packages can't handle transparency.

-m

JoePoe
07-06-2015, 10:43 AM
:stumped: Every source I can find says PNG does support alpha.
The fact that Pshop isn't loading it doesn't define it's capabilities.
Where are you finding this definition?

And certainly, the other programs support transparency :).

Philbert
07-06-2015, 11:50 AM
Well, I loaded the file into Photoshop and did see the transparency. So I saved it out as a new PNF file and loaded that in LW instead. Now I see the Alpha option.. So it seems like it has to do with however the Make Human people saved the original png.

MSherak
07-06-2015, 11:55 AM
Every source I can find says PNG does support alpha.
The fact that Pshop isn't loading it doesn't define it's capabilities.
Where are you finding this definition?

And certainly, the other programs support transparency :).

Terminology of what an alpha is might be confusing and really an "alpha channel" should be called a mask. But yes PNG has an alpha (bit-plane), but not an alpha channel.

----------------------------------------------------------------------------------------
http://www.w3.org/TR/PNG/

3.1.1 alpha
a value representing a pixel's degree of opacity. The more opaque a pixel, the more it hides the background against which the image is presented. Zero alpha represents a completely transparent pixel, maximum alpha represents a completely opaque pixel.
----------------------------------------------------------------------------------------

Now an alpha channel, mask, specifies how the pixel's colors should be merged with another pixel color. Totally different from transparency (from above). This is why if one wants to mask or clip out a polygon with an PNG image a mask needs to be created by being pre-multiplied, usually to a solid black color, and then tied to the transparency texture channel.

Food for thought, an alpha channel in PS can be 8 or 16-bit only but a layer's opacity, transparency, can go all the way to 32-bit.

-m

raw-m
07-08-2015, 12:10 AM
Was the original png index-coloured? I've found in the past that LW ignores transparency if the png has been indexed. Could be that.

Philbert
07-08-2015, 12:27 AM
I couldn't say, I didn't create it.

raw-m
07-08-2015, 12:44 AM
In Photoshop/Image/Mode, it'll tell you there. Indexed pngs are extremely useful for keeping memory usage down.

Sensei
07-08-2015, 12:47 AM
C'mon.
File has been given in #5 post..
It's 32 bit RGBA.
But LW says it's Depth: 24 bit..

raw-m
07-08-2015, 12:51 AM
Sorry, missed the link. The alpha option not showing up threw me as I've encountered it in the past. Move along.....

raymondtrace
07-08-2015, 10:36 AM
Terminology of what an alpha is might be confusing and really an "alpha channel" should be called a mask. But yes PNG has an alpha (bit-plane), but not an alpha channel.

Are you further confusing terminology? A bit plane is a subset of data in a multi-bit channel. PNG most certainly supports an alpha channel for transparency only. It is heavily covered in the PNG spec site (http://www.libpng.org/pub/png/pngintro.html#alpha).

There's no need to separate the concept of alpha channels from opacity/transparency. Alpha channels were created (http://www.alvyray.com/awards/AwardsAcademy96.htm) to handle transparency. You are correct that alpha channels in other image formats can do more than just handle transparency, but even an alpha channel that only supports transparency (like in the PNG spec) is still called an alpha channel. PNG is RGBA.

A lot of the confusion over PNG alpha channels comes from Photoshop. Just because Photoshop does not display an alpha channel in the Channels panel does not mean the PNG file does not have an alpha channel. Photoshop knows that the PNG alpha channel is only used for transparency so that is why it loads the image with transparency (without adding a Photoshop version of alpha channel). Photoshop cannot be fully trusted for analyzing the properties of an image...try saving an image for the web without any resolution data (ppi) and reload it to see Photoshop automatically assigns 72 ppi.

MSherak
07-08-2015, 01:21 PM
Are you further confusing terminology? A bit plane is a subset of data in a multi-bit channel. PNG most certainly supports an alpha channel for transparency only. It is heavily covered in the PNG spec site (http://www.libpng.org/pub/png/pngintro.html#alpha).

There's no need to separate the concept of alpha channels from opacity/transparency. Alpha channels were created (http://www.alvyray.com/awards/AwardsAcademy96.htm) to handle transparency. You are correct that alpha channels in other image formats can do more than just handle transparency, but even an alpha channel that only supports transparency (like in the PNG spec) is still called an alpha channel. PNG is RGBA.

A lot of the confusion over PNG alpha channels comes from Photoshop. Just because Photoshop does not display an alpha channel in the Channels panel does not mean the PNG file does not have an alpha channel. Photoshop knows that the PNG alpha channel is only used for transparency so that is why it loads the image with transparency (without adding a Photoshop version of alpha channel). Photoshop cannot be fully trusted for analyzing the properties of an image...try saving an image for the web without any resolution data (ppi) and reload it to see Photoshop automatically assigns 72 ppi.

Well yes and no. Problem is an mask and opacity/transparency, the two levels of alpha, have been sold as the same thing. So unless one knows how the alpha is stored in a format, most assume it's a mask, one can end up with different results. This is where the incorrect terminology lies.

Alpha stored as a
Mask: Premultipied value (C) where two pixels (A and B) are mixed using this value
Opacity/Transparency: Non-premultiplied pixel value (A) blended into a background pixel (B)

This is why one gets the tint effect with opacity/transparency and one does not with mask. Course one can get a halo with a mask if created incorrectly. So does PNG have an alpha, yes. The alpha in a PNG is not a mask though which most think it is cause it says 32-bit. Only when the alpha in a PNG is pre-multiplied does it become a mask. Look at the TGA format, in reality it has RGB and a Mask. No transparency. So LW and PS are loading PNG correctly and if you want a mask you have to create it.

Dealing with graphics for games everyday I personally call RGBA what they are, bit planes. 0-xxxxxxxx levels of grayscale. I don't hear the term to store an image with 24 or 32 channels. Channels is something paint packages have sold us. As far as PS not placing the right header data in an image format, I would agree with you. Also it's hard to know when there is no place to edit this information anyway in PS, so they just add what they think you need.

Greenlaw
07-08-2015, 01:27 PM
I think it depends on the PNG imagesaver of a given program or plugin.

For example, Photoshop's native PNG saver saves transparency but the third party SuperPNG saver for Photoshop can save a separate Alpha channel just like in a TGA or EXR. At least this is how it worked a few years ago when we routinely used SuperPNG in The Box at R&H.

I haven't used SuperPNG for some time and don't have installed right now to confirm this is still the case, but I think this difference may be true for other software that can save PNG.

G.

MSherak
07-08-2015, 04:09 PM
I think it depends on the PNG imagesaver of a given program or plugin.

For example, Photoshop's native PNG saver saves transparency but the third party SuperPNG saver for Photoshop can save a separate Alpha channel just like in a TGA or EXR. At least this is how it worked a few years ago when we routinely used SuperPNG in The Box at R&H.

I haven't used SuperPNG for some time and don't have installed right now to confirm this still the case, but I think this difference may be true for other software that can save PNG.

G.

Yup on native PS PNG saver, Nope on SuperPNG loader/saver. PNG has an alpha but not an mask. Here is images of the SuperPNG loader/saver and a PNG loaded. Loaded as a Mask (Left) then cut out the layer. Loaded as transparency (Right) no cut needed.. Notice the edges.. Masks are pre-multiplied.

128871128872

Now getting back to the main topic of the thread, the easy way in LW to get a PNG to have an alpha mask is to load the image then use clone in the upper right corner of the image editor. On the clone set Alpha Channel to Alpha Only. Now you have a 32-bit transparency and an 8-bit Alpha Mask.

128873128874

If you notice the PNG is loaded correct with a white background since you have to get the full value off the color from the transparency. Then when you tell the clone to be alpha only it takes this full range of color and pre-multiplies to black and you get your alpha. This is the correct way of doing it. If you were to reproduce this in PS it would be Load the image. Select the layer and then go to Layer-> Layer Mask -> From Transparency. The A (alpha) is extracted into a greyscale mask and your layer is now opaque (RGB). Disable the mask and you will see the full color range.

Greenlaw
07-08-2015, 05:05 PM
I'm having trouble viewing the attachments for some reason but thanks for checking what I wrote.

I should have added that I haven't used SuperPNG in years because I just do exactly as you described in the Lightwave Image Editor with a native Photoshop PNG file and it works fine. :p

G.

raymondtrace
07-08-2015, 05:23 PM
So LW and PS are loading PNG correctly and if you want a mask you have to create it.

The PNG developers think Photoshop is doing it wrong (http://www.libpng.org/pub/png/pngstatus.html#apps-quality).

All that we're looking at here is the different implementations of PNG interpreters. The native capabilities of PNG's alpha channels support masking, transparency or whatever term we want to use. Straight vs premultiplied can be addressed by how we open and process the file. The cloning technique in LW shows this.

The SuperPNG plugin asks what you want to store as the alpha channel (Photoshop's layer transparency or the top alpha channel, if it exists).

You have a similar choice when opening PNG files with the SuperPNG plugin. You can either load the alpha channel as a transparency in a layer or as a separate channel (with the additional option to multiply RGB by alpha).

These are all software options, not a limitation of PNG for transparency masks.

raymondtrace
07-08-2015, 05:31 PM
I should have added that I haven't used SuperPNG in years

I just realized that I missed a nifty SuperPNG update (http://fnordware.blogspot.com/2014/06/superpng-25.html) last year that gives Photoshop a feature that Fireworks users have always had (https://blogs.adobe.com/jnack/2010/08/do-you-care-about-png-8-with-transparency.html).

Greenlaw
07-08-2015, 06:08 PM
Hmm...thanks for the tip! Will have to check that out. :)

G.