Raised This Month: $51 Target: $400
 12% 

Optimization transparency DXT3 DXT5 by utility 'Color Quantizer'


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
FishDude
Member
Join Date: Jul 2014
Old 12-10-2014 , 17:27   Optimization transparency DXT3 DXT5 by utility 'Color Quantizer'
Reply With Quote #1

(Sorry for my bad English, I use a machine translator.)

This article describes some compensation for the lack of colors in borders of transparency/opacity zones of textures.

Problem: As you already know, in DXT texture compression, the image is divided into 4x4 pixel squares, and each square there are only 2 fixed color + 2 intermediate between fixed colors (total 4 colors). Therefore, in thin multi-colored elements of image some colors gets distorted. Example:

This is 'D-sprite' from this project, zoom x2.



Looking good, but mipmap #2 looks not so good:



Wrong blue colors. Why? let's turn off trasparent mask:



The picture looks typical for Photoshop. The main thing is that there is a white background, which really does not exist in the texture (because it is hidden transparency mask).
White on mipmaps mixed with true blue (while reducing sprite) and gave this wrong white-blue color.

Now I'll show you how you can avoid the wrong colors.

Load the original sprite using a utility 'CQ'. ( http://kherson.myftp.biz/cq/ )
On toolbar press 'image resize'. Dont touching any controls, press 'ok'.
(In fact, resizing does not occur, we use only a side effect of the built-in CQ's algorithm reduction image: the program fills the fields under invisible colors with colors from boundaries, that we just needed.)

You can check result by press Ctrl + mouse click (and hold your click) on picture:



What happened? CQ painted over all transparent areas with color, taken from opaque border area, in this case, black.

This strategy is make easy picture for DXT compression algorithm. Let us save our sprite.
(Achtung!) Do not use .png format: built in CQ png-optimizer will erase "filled transparency" for the sake of improving compression.
(Achtung!) You need ONLY .tga and ONLY in true-color-mode: before saving, select 'TrueColor' in number-of-colors CQ's combo-box.

Then look at the finished VTF:


As you can see, the colors and even the shape of the object is much better preserved.

Probably, I chose not the best example for the sprite. I assure you, I described method is used not only for the salvation of mipmaps, but even for the main picture and very often helps save the color on the edges of the transparent areas.

Just a few another examples. These examples show how "spread out" colors of opaque areas to transparent areas.





Attached Thumbnails
Click image for larger version

Name:	01-d-sprite.png
Views:	1103
Size:	691 Bytes
ID:	140643   Click image for larger version

Name:	02-mipmap2.png
Views:	1028
Size:	585 Bytes
ID:	140644   Click image for larger version

Name:	08-example-forum-v2.png
Views:	1061
Size:	56.1 KB
ID:	140655   Click image for larger version

Name:	d-without-a.png
Views:	827
Size:	975 Bytes
ID:	149445   Click image for larger version

Name:	before-after.png
Views:	1061
Size:	15.9 KB
ID:	149446  

Click image for larger version

Name:	fixedmipmap2v2.png
Views:	869
Size:	1.3 KB
ID:	149448   Click image for larger version

Name:	21-example.png
Views:	1618
Size:	14.6 KB
ID:	149449   Click image for larger version

Name:	24-examples.png
Views:	999
Size:	81.8 KB
ID:	149450  

Last edited by FishDude; 11-03-2015 at 22:38.
FishDude is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:06.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode