Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/ianguth/ianguthridge.com/wp-settings.php on line 18

Strict Standards: Declaration of Walker_Comment::start_lvl() should be compatible with Walker::start_lvl(&$output) in /home/ianguth/ianguthridge.com/wp-includes/comment-template.php on line 0

Strict Standards: Declaration of Walker_Comment::end_lvl() should be compatible with Walker::end_lvl(&$output) in /home/ianguth/ianguthridge.com/wp-includes/comment-template.php on line 0

Strict Standards: Declaration of Walker_Comment::start_el() should be compatible with Walker::start_el(&$output) in /home/ianguth/ianguthridge.com/wp-includes/comment-template.php on line 0

Strict Standards: Declaration of Walker_Comment::end_el() should be compatible with Walker::end_el(&$output) in /home/ianguth/ianguthridge.com/wp-includes/comment-template.php on line 0

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method GoogleSitemapGeneratorLoader::Enable() should not be called statically in /home/ianguth/ianguthridge.com/wp-includes/plugin.php on line 339Programming | Ian Guthridge.com

Tag: programming

Ok, “A Sticky Situation” was written fast; the bulk of the coding was completed in 10 weeks. So logically its code base has a “few” flaws. The one that brought me here to write this post is located in its runtime texture generation: all the textures created where uncompressed.

Uncompressed textures aren’t necessarily a bad thing, but ASS was pushing a fair number of large unique textures to the screen, eating up all the texture fetch bandwith on older and/or laptop cards. Many of these textures were generated at runtime (most commonly a texture was blurred). So I decided to look into compressing the textures.

Since the whole point is that I am trying to get back some texture fetch bandwith, I need to use a compression technique that is understood by the GPU. This leaves me with one choice: DXT. Specifically DXT5.

Ok I’m going to give you a quick explanation of DXT right quick. It is a type of lossy compression that nearly all GPUs “in the wild” can decode. It works by:

Then for each of the 16 pixels in the block it stores a 2-bit value that describes how far it is from each of the colors.

Now DXT compression comes in quite a few different flavors DXT1 and DXT5 are the most commonly used (as far as I can tell). The only real difference between the two is in how they encode alpha. DXT1 only supports “cutout” alpha (basically a 1 bit alpha, either it is opaque or it is transparent) while DXT5 supports a gradient alpha. I am not going to get into exactly how each encodes alpha for length reasons, but let me know if you would like to know more.