hwixlab / nvidia-texture-tools

Automatically exported from code.google.com/p/nvidia-texture-tools
0 stars 0 forks source link

Support different alpha modes #30

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The alpha channel of the image can be interpreted in different ways. Some
images use it as an independent channel, others use it for transparency,
while others assume that colors are premultiplied by the alpha channel.

The compressor should behave in different ways according to that. Currently
fast compressors behave as if the alpha was independent, but the others
behave as if it was used for transparency.

There's an API available to specify the alpha mode:

/// Alpha mode.
enum AlphaMode
{
    AlphaMode_None,
    AlphaMode_Transparency,
    AlphaMode_Premultiplied,
};

void InputOptions::setAlphaMode(AlphaMode alphaMode);

but it's not being used yet.

Original issue reported on code.google.com by cast...@gmail.com on 4 Feb 2008 at 11:23

GoogleCodeExporter commented 9 years ago
Charles Nicholson points out this article from Tom Forsyth about pre-multiplied 
alpha:

http://home.comcast.net/~tom_forsyth/blog.wiki.html#%5B%5BPremultiplied%20alpha%
5D%5D

Original comment by cast...@gmail.com on 4 Mar 2008 at 10:59

GoogleCodeExporter commented 9 years ago
Ignacio-

Here's a patch against 2.0.1 with the following features:

InputOptions has "void setPremultiplyAlpha(bool b)", backed by 
InputOptions::Private
"bool premultiplyAlpha".

Compressor has the private method "premultiplyAlphaMipmap(Mipmap&, const
InputOptions::Private&)", that converts the mipmap to a FloatImage, multiplies 
the
RGB channels by A into a new FloatImage, and overwrites the old one with the 
new one.
 This happens after mipmap initialization, but before quantization/compression.

nvcompress.exe has the command-line flag "-premula" to invoke this 
functionality.

The code in Compressor is a little sloppy in that it doesn't confirm the correct
number of channels, or error if conflicting options exist.  I'm pretty sure you 
can
do it to a normal map, which you probably don't want.  I adhered to the coding
standard in as much as i could glean without a doc.

Best,
charles

Original comment by charles....@gmail.com on 5 Mar 2008 at 9:49

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks, I checked that in with some changes. I think alpha premultiplication 
should
be applied in the destination gamma space. If you apply it in linear space, 
then when
you transform the color to gamma space you will also transform the 
premultiplied alpha.

Original comment by cast...@gmail.com on 7 Mar 2008 at 1:49

GoogleCodeExporter commented 9 years ago
The cuda compressors now have support for alpha modes.

Original comment by cast...@gmail.com on 6 May 2008 at 8:04

GoogleCodeExporter commented 9 years ago

Original comment by cast...@gmail.com on 11 Oct 2008 at 7:30

GoogleCodeExporter commented 9 years ago

Original comment by cast...@gmail.com on 24 Nov 2008 at 10:36