grendizerufo / nvidia-texture-tools

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

Request: Support for dithering on RGBA formats #51

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It would really be nice if it was not necessary to restrict dithering to
just DXT-compressed formats.  For example, I may want to convert from a
B8G8R8A8 TGA to a A4R4G4B4 texture, which could definitely make a case for
using colour dithering with.

As of NVidia Texture Tools 2.0.3, it seems that this is not currently
supported, as the enableColorDithering flag only takes effect for DXT1,
DXT1a, DXT3, and DXT5 compressed formats.  ( In
Compressor::Private::quantizeMipmap -- nvtt/Compressor.cpp line 616 )

Original issue reported on code.google.com by jon...@gmail.com on 11 Jun 2008 at 9:05

GoogleCodeExporter commented 9 years ago
As a temporary workaround, I've made the following change locally to mimic the
behavior of the current code (see attached file).  This allows for arbitrary 
colour
quantization given the bitsize of each colour.  It also has the nice (and not so
coincidental) side-effect that it solves Issue 50 as well since it preserves 
alpha.

Original comment by jon...@gmail.com on 11 Jun 2008 at 10:00

Attachments:

GoogleCodeExporter commented 9 years ago
Sorry, I just realized that
r = r << ( 8 - rsize ) | r >> rsize;
should really read
r = r << ( 8 - rsize ) | r >> ( 2 * rsize - 8 );

Likewise for g and b.  Sorry for any inconvenience.

Original comment by jon...@gmail.com on 11 Jun 2008 at 10:30

GoogleCodeExporter commented 9 years ago
I think that in PixelFormat.h there's a function that should do what you want:

r = PixelFormat::convert(r, 8, rsize);
r = PixelFormat::convert(r, rsize, 8);

and that will also work in the case that rsize < 4.

Original comment by cast...@gmail.com on 11 Jun 2008 at 10:44

GoogleCodeExporter commented 9 years ago
I'll modify and integrate your patch into the 2.0 branch. I think it should be
possible to replace the specialized quantizers with this one.

Original comment by cast...@gmail.com on 11 Jun 2008 at 10:45

GoogleCodeExporter commented 9 years ago
I've integrated the patch in the 2.0 branch. Thanks!

Original comment by cast...@gmail.com on 12 Jun 2008 at 1:20