Live data from Hacker News

Beware of Transparent Pixels

adriancourreges.com

71–80 of 97 posts

Re: Beware of Transparent Pixels

#71
This is also relevant for CSS: Some browsers (I think Safari) treat "transparent" as "transparent black" for gradiets, so "linear-gradient(transparent, white)" will result in unexpected grayish parts in the gradient. As a workaround, one needs to use "linear-gradient(rgba(255, 255, 255, 0), white)" instead.

Re: Beware of Transparent Pixels

#73

Earlier quoted context omitted.

That little ditty is also very likely why PNG has zero uptake in visual effects and CGI. Associated (aka premultiplied) alpha is the _sole_ means to embody both occlusion and emission. Unassociated (aka straight or key) alpha cannot represent these facets. Consider a candle flame that exists as mostly emission and low to no occlusion. With associated alpha, you can use zero alpha triplets with non-zero emission RGB t…

> Consider a candle flame that exists as mostly emission and low to no occlusion. I don't think associated alpha helps much here. You can special case pixels that are doing pure emission, but when a pixel is doing both you need the lighting to affect the color of the occlusion but not affect the color of the emission.

It ends up being a pure add emission. It can't be done with unassociated alpha due to the multiplication.

Re: Beware of Transparent Pixels

#74

Earlier quoted context omitted.

A 16bpp linear pre-multiplied format would be awesome. sRGB is a pain to use in practice: - Slow to convert to linear colour space (requires a pow).. except - GPUs use an 8-bit lookup table to convert input sRGB to output linear value. - This doesn't work for more than 8 bits as the table gets excessively large very quickly. It's a pity PNG doesn't have flag to mark the image data as being pre-multiplied.

That little ditty is also very likely why PNG has zero uptake in visual effects and CGI. Associated (aka premultiplied) alpha is the _sole_ means to embody both occlusion and emission. Unassociated (aka straight or key) alpha cannot represent these facets. Consider a candle flame that exists as mostly emission and low to no occlusion. With associated alpha, you can use zero alpha triplets with non-zero emission RGB t…

I've been throwing around the idea of making a new intermediate file format which can contain only pre-multiplied transparency. But, do you know any file format already supports this?

Re: Beware of Transparent Pixels

#75

Earlier quoted context omitted.

That little ditty is also very likely why PNG has zero uptake in visual effects and CGI. Associated (aka premultiplied) alpha is the _sole_ means to embody both occlusion and emission. Unassociated (aka straight or key) alpha cannot represent these facets. Consider a candle flame that exists as mostly emission and low to no occlusion. With associated alpha, you can use zero alpha triplets with non-zero emission RGB t…

I've been throwing around the idea of making a new intermediate file format which can contain only pre-multiplied transparency. But, do you know any file format already supports this?

TIFF can do premultiplied alpha. The problem with TIFF is that it's such a grab bag of options, it makes it difficult to know what you're dealing with.

Re: Beware of Transparent Pixels

#76
post #75

Earlier quoted context omitted.

I've been throwing around the idea of making a new intermediate file format which can contain only pre-multiplied transparency. But, do you know any file format already supports this?

TIFF can do premultiplied alpha. The problem with TIFF is that it's such a grab bag of options, it makes it difficult to know what you're dealing with.

EXR is associated by convention. TIFF mandates it, although with an additional TIFF tag for an "opacity" channel that behaves as unassociated IIRC.

Re: Beware of Transparent Pixels

#77
post #75

Earlier quoted context omitted.

I've been throwing around the idea of making a new intermediate file format which can contain only pre-multiplied transparency. But, do you know any file format already supports this?

TIFF can do premultiplied alpha. The problem with TIFF is that it's such a grab bag of options, it makes it difficult to know what you're dealing with.

Thanks - I didn't know that - anything else apart from TIFF?

Re: Beware of Transparent Pixels

#78
post #36

Premultiplied alpha results in less color depth, though. If my alpha is 10%, then my possible RGB values become 0-25. Even if I multiply by 10, I still lose the maximum possible values 251-255, and only values 0, 10, 20, 30... 250, are possible. The correct solution is to pay close attention to all of the factors... and to be ESPECIALLY aware of pixel scaling. Provide your RGBA textures at the 1:1 pixel scale they wi…

The article suggests why 1:1 won't be adequate, there will still be interpolation when the position isn't on a pixel boundary. In practical applications the reduced color gamut isn't a problem, your ability to discriminate the colors goes down as the transparency goes up. It would only be a problem if you were trying to convert the pixels to something less transparent than they started.

> when the position isn't on a pixel boundary

Yeah, that's not the definition of "1:1" that I use. The definition of 1:1 that I use has texels lining up exactly with pixels.

Re: Beware of Transparent Pixels

#80
post #8

Reminds me of "Is there a reason Hillary Clinton's logo has hidden notches?" https://graphicdesign.stackexchange.com/questions/73601/is-t...

Yeah! I recently built a website that heavily uses Illustrator assets exported as svg. I was happy to have read that explanation before pulling my hair out over weird artifacts.
Post reply on HN