Sign in to follow this  

Texture Compression Question

This topic is 4305 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Just don't do it on Normal maps or anything with non-colour data, the results aren't as pretty as you would hope

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Create the texture *outside* your program. Use DDS files instead of JPG ones.

Share this post


Link to post
Share on other sites
Sign in to follow this