Texture Compression Question

Started by
4 comments, last by ET3D 18 years ago
HY! How can I use texture compression in D3D9? Is it really slow? And what is the average compression ratio? Can I use it with mipmapping? Bye!
Advertisement
To use compression you should use DXT1-5 formats. You can save DXT files from PhotoShop for example with a DDS plugin. DDS is the file extension and stands for "direct draw surface" so DDS file can contain compressed and uncompressed textures.

To create a texture from DDS file, there is a function named something like D3DXCreateTextureFromFile(...).

A DDS file may contain mipmaps if desired. The compression ratio is constant 1:4 or 1:6.
The DX docs describe the compression method exactly. It's fixed compression, with 4 bits per pixel for no alpha or 1 bit alpha (DXT1) or 8 bits per pixel for more accurate alpha (the other DXTs). The compression ratio therefore depends on the original representation. The x6 and x4 values are RGB8->DXT1 and RGBA8->DXT2-5.

Texture compression is slow to create, which is why it's normally created offline. As Demus79 said, you can use a Photoshop plugin. You can also use the DX Texture Tool that comes with the SDK to convert images.

In use DXT textures are faster than non-compressed ones because they're less bandwidth intensive.
Just don't do it on Normal maps or anything with non-colour data, the results aren't as pretty as you would hope
Steven ToveySPUify | Twitter
Ok, but how can I create a compressed texture form a jpg file in the vido memory? Wich parameteres shall I use in the D3DXCreteTextureFromFileEx(...) to create compressed texture in memory? I couldn't find any sample in the dxsdk.
Create the texture *outside* your program. Use DDS files instead of JPG ones.

This topic is closed to new replies.

Advertisement