wdr at January 18th, 2014 16:52 — #1
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.
vilem_otte at January 18th, 2014 20:55 — #2
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.
wdr at January 19th, 2014 02:14 — #3
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.
thenut at January 19th, 2014 16:18 — #4
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.
stainless at January 20th, 2014 04:19 — #5
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.
wdr at January 21st, 2014 10:14 — #6
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.
reedbeta at January 21st, 2014 15:55 — #7
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.