Normal map compression

From Tech Artists Wiki

Jump to: navigation, search

Normal maps can take up a lot of memory. Compression can reduce the size of a map to 1/4 or less of the uncompressed file, which means you can either increase the resolution or you can use more maps.

Usually the compression method is to throw away the Blue channel, because this can be re-computing at minimal cost in the shader code. Then the bitmap only has to store two color channels, instead of four (red, green, blue, and alpha).

Contents

[edit] DXT5nm

DXT5nm is the same file format as DXT5 except before compression the red channel is moved into the alpha channel, the green channel is left as-is, and the red and blue channels are blanked with the same solid color. This re-arranging of the color channels is often called swizzling.

The Green and Alpha channels are used because in the DXT format they are compressed using somewhat higher bit depths than the Red and Blue channels. Red and Blue have to be filled with the same solid color because most DXT compressors use an algorithm that compares differences between the three color channels. If you try to store some kind of texture in Red and/or Blue (specular power, height map, etc.) then the compressor will create more compression artifacts because it has to compare all three channels.

There are some options in the NVIDIA DXT compressor that help reduce the artifacts if you want to add texture to the Red or Blue channels. The artifacts will be greater than if you keep Red and Blue empty, but it might be a trade-off worth making. Some notes in this thread on the NVIDIA Developer Forums.

[edit] DXT1

DXT1 can also be used for tangent-space normal maps, because it is half the size of a DXT5. The downside is it causes many compression artifacts, so much so that most people end up not using it. The upside though is that DXT stays compressed in video memory, meaning you can use more textures or larger textures within the same amount of RAM.

[edit] 3DC

3Dc compression works similar to DXT5nm, with some important differences. It yields the best results of any listed algorithm for tangent space normal map compression, and requires no extra processing time or unique hardware. Details can be found in the 3Dc whitepaper from ATI.


[edit] Uncompressed/2-Channel

The 8.8 DDS formats aren't actually compressed, but just two 8bit grayscale channels. It does save you from having to store all three color channels, so it ends up 2/3 the size of an uncompressed map. Your shader has to recompute the blue channel for it to work.

[edit] Signed/Unsigned

Compressed normal map textures can also be signed, to simplify shader instructions. See DDS Signed/Unsigned for more info.

[edit] Links

Personal tools