OpenGL Texture Compression

Adfa6cf87d3749a0e1acd928285b3f23
1
WDR 106 Jan 18, 2014 at 21:52 opengl textures compression

Hi… I searched the internet and also DevMaster, but could only find little related to OpenGL Texture Compression. From what I read from the little information, I could understand that OpenGL can be used to compress textures into mipmaps and use these mipmaps to display the compressed texture on the screen. What I don’t understand, however, is how the compression of texture is done. Are we supposed to write a code using the provided functions in OpenGL to perform the compression process or is there a predefined function provided in OpenGL that will compress the textures? I couldn’t find any information regarding this. Please, someone tell me how this is done. Thank you.

6 Replies

Please log in or register to post a reply.

B20d81438814b6ba7da7ff8eb502d039
3
Vilem_Otte 117 Jan 19, 2014 at 01:55

Huh, you’re mixing two things together…

Texture filtering - the main purpose of this is to reduce aliasing of applied texture on image. For the purpose of this we use texture magnification filtering (aka when 1 pixel in texture covers more pixels on screen), and texture minification filtering (aka when several pixels in image covers 1 pixel on screen).

The minification filtering is often done using MIP maps (multum in parvo) - I guess you know the principle, just put it into wiki and read how it works.

Texture compression is something else, this relates to texture storage. You can store textures are RGB8 (8-bits per channel), RGB32F (32-bit float per channel), R5G6B5 (5 bits red and blue, 6 bits red), S3TC DXT1 aka BC1 (this one is compressed using S3 texture compression algorithm - this is compressed texture format).

OpenGL supports hardware decompressing of several formats (F.e. named S3TC), and it can also compress these textures. The quality of compressed textures by hardware is low, so it is recommended to compress using other tools (I use my own), but F.e. The Compressonator from AMD works perfectly.

Adfa6cf87d3749a0e1acd928285b3f23
0
WDR 106 Jan 19, 2014 at 07:14

Ok… So, if I wanted good quality textures, I should use an external tool to compress the textures and then load the compressed texture file into the program using the methods provided, right? I think I got it. Thanks, Vilem. I’ll ask if I have any further questions.

Adfa6cf87d3749a0e1acd928285b3f23
0
WDR 106 Jan 21, 2014 at 15:14

Since we are on the topic… Does the Compressonator for ATi GPUs work for nVidia GPUs? I know there is one for nVidia i.e. the nVidia Texture Tools but overall reception on the internet about that tool is mostly kind of negative.

A8433b04cb41dd57113740b779f61acb
1
Reedbeta 167 Jan 21, 2014 at 20:55

Compression formats are all standardized, so it doesn’t matter which vendor’s tool you use.

NVTT contains a library that you can link into your own projects, as well as a set of command-line tools, and Compressonator is a graphical tool (it may also have a command-line interface; I’m not sure). Also, NVTT is open-source while Compressonator isn’t. So it all depends on what you’re looking for.

6837d514b487de395be51432d9cdd078
1
TheNut 179 Jan 19, 2014 at 21:18

Reedbeta posted on article discussing the technicalities of texture compression if you’re interested. The article is available here.

As Vilem pointed out, drivers can do both decompression and compression, although for quality purposes you should use an offline tool for that. For high quality, compression can actually take quite a bit of time. Keep in mind the output is just raw image data. You need to wrap this in your own header format to store important details about the texture (resolution, mipmaps, compression type, etc.) and deal with that when you’re uploading the data to the video card.

When working with texture compression, you should also poll for the supported formats on various platforms. S3 compressions are well supported on desktop hardware, but Android uses Ericcson texture compression. In the old days, one had to even decompress manually if the hardware didn’t support it (ghastly!). Just something to keep in mind.

B5262118b588a5a420230bfbef4a2cdf
0
Stainless 151 Jan 20, 2014 at 09:19

in the old days!

I STILL have to decode manually on some platforms. :<

A lot of set top boxes and TV’s have really good GPU’s, but since texture compression is not a requirement for OpenGL ES, just an optional extra, many devices don’t support it.