• Advertisement
Sign in to follow this  

which texture format should I use (.TIF .JPG .BMP etc) ???

This topic is 4906 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

please help me with D3DXCreateTextureFromFile(...) or D3DXCreateTextureFromFileEX(...) which texture format should i use for these functions and which is faster. i have seen in many games that they use TIFF format but its too big in size why they use this format. thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
I love pngs because they can have an alpha channel, they're compressed but they don't use lossy compression.

- bmp: are very large and have no alpha channel but are easy to read
- tga: have alpha and can be compressed but most arn't resulting in them basically being bmp's with alpha
- gif: are palleted which reduces the number of usable colurs (you can have true colour gifs but really i'd stay away)
- jpeg: use lossy compression so loose image quality but they're very small

take your pic - I think I covered most of the major points. Pngs can be harder to read the other formats but google for libpng for a free and relativly easy to use lib for reading png's.

Share this post


Link to post
Share on other sites
DDS files load fastest and also have the advantage that they support all the funky D3D formats (including DXT compression) directly so you can do all your processing offline and store the textures on disk in the optimum format for runtime use. The only disadvantage is that they are quite large compared to some of the other compressed formats and so may not be ideal if you want to stream data over the Internet or offer your game as a very small download.

Share this post


Link to post
Share on other sites
Speaking of which, does anyone have a link to a clip of C++ code to transfer GIF images into memory? I personally use GIF for any webbaised image, I think it's the best, however from it's docs it seems to go way over my head.

Share this post


Link to post
Share on other sites
All of the D3DXCreateTextureFromFile*() functions support loading DDS files. DDS files load the fastest because they are basically an exact copy of a Direct3D surface.

Share this post


Link to post
Share on other sites
Quote:
Original post by ehsan_the_tiamat
please help me with D3DXCreateTextureFromFile(...) or D3DXCreateTextureFromFileEX(...)
which texture format should i use for these functions and which is faster. i have seen in many games that they use TIFF format but its too big in size why they use this format.
thanks in advance.


The DDS file format is a good one because there is no processing on load. This is especially helpful when you are using DXT compressed textures (which you should), since compressing them is somewhat slow. I DO not recommend using JPEG due to the compression artifacts.

Additionally, it is one of the few formats that supports MIP levels, which is handy if your mip levels cannot be computed via load, or it is expensive.

Since few appliciations save in DDS format, an easy way to manage it is to create a file cache. You check to see if the .dds file exists, if it does, you load it, if not, you load a .tiff or .png, process it, then save out the .dds version (using D3DX). This way you only get slow load times when you change your textures (but you must blow away the cache when they change).

Share this post


Link to post
Share on other sites
Make sure your DDS contains MIPs because if it doesn't loading takes even longer than usual as D3DX decompresses the DXT, computes mips and recompresses all the mip levels. We shaved several seconds off our load times by using DDS files with precomputed MIPs (using nVidia's Photoshop DDS saver plugin).

Also, if you make a DDS in a format that your card doesn't like, for example R8G8B8 24 bit format, beware. I can't remember if it was the PCs or the XBoxes, but one of them just crashed if you tried to render using these. D3DX *should* have converted it to a valid format, but I guess it doesn't always.

Also, since it hasn't been mentioned, while PNG may be smaller on disk than a DDS, a DDS using DXT will always take less video memory than a similar bit-depth PNG. This saves video memory, which saves GPU memory bandwidth (a critcal resource), and improves the usage of the texture cache. If the quality loss of a DDS DXT format is acceptable, use it. Some textures however, look better without compression. Also, note Doom3's sneaky use of DXT5 (or is it 3) with explict alpha for normal maps. They put R and B in the color channels, which get compressed better as you don't have 3 changing components, then put the G in the alpha channel. The result was higher quality compressed normal maps.

Share this post


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

  • Advertisement