texture question

Started by
1 comment, last by streamer 17 years, 10 months ago
Hi all. I'm mostly using png files because of transparency and good compression. But I don't really understand in which manner are stored textures in memory. Does DirectX use some intern method of texture data storing? Like does jpg images are uncompressed in memory and copied as uncompressed data in memory? And if this is not true, what kind of texture is best to use? Do compressed textures reduce speed of rendering (because of uncompressing)? Thanks in advance
Advertisement
Most methods for storing images (BMP, TGA, JPG, PNG, GIF, etc), are not used directly in textures. Before, it was all straight pixels (it was stored per pixel, per color, in a big buffer). Any time you copied an image to a texture, you had to decode it to the target format (color format, 16bpp, 24bpp, 32bpp, etc), on a per pixel basis (if the texture was 32x32, then you actually had 32x32 pixels to work with, unlike compressed formats where you have less pixels then the size of the image).

Modern video cards do support different compression schemes, but these are all hardware accelerated. I don't know the internals of compression/decompression, but they are methods that are optimized as to not take much extra time over using a straight uncompressed texture (unlike formats like JPG which can take a moment to decompress). The simplest solution for uploading is to use a 3rd party library (like D3DX for Direct3D), load your image, convert to 32bpp uncompressed, then let the library convert it to your target texture format.

When it comes to input image data, it depends on what quality you want, and your size restraints. Some compressed formats are lossy (like JPG), so using them will result in reduced image quality when rendering, regardless of what format your textures are in. Many newer games are using TGA (or DDS) as it's not compressed (or allows lossless compression), while still being able to store the alpha channel (which many games are using now). This means that it's possible to preserve the full quality of the image when rendering, or scale down to fit the system requirements, as needed.
Thank you for your reply.
I understand fully what you wrote, but one thing I think that I'm not understand clearly. Fore example I want to use R8G8B8 texture format but because of low-end machine on which is a game installed, I convert texture to R5G6B5 format (less memory). But that texture will look somehow different, ain't it? Or I need to create texture for few texture formats, like one for high-end machines, low-end machines, and then load appropriate texture?

This topic is closed to new replies.

Advertisement