I've been working on an addon to compress pixel data with DXT (ofxDXT) to upload already compressed texture data into ofTextures (vs uploading raw RGBA data and making the GPU compress it). This is very useful to be able to preload more textures in GPU memory (think image sequences / sprite sheets), but also to stream them from disk. DXT gives you a 4:1 compression ratio with a quite acceptable quality loss on RGBA texture data, and a 8:1 ratio on RGB data.
This currently works on my branch of OF (close to 0.10.1) in GL2, GL3 and GL4, but it requires some changes to ofTexture.
The changes are quite small (see here, sorry for tab vs space mess), and would only affect anything when a texture glInternalType is DXT. Basically when the internal type is of the GL_COMPRESSED_RGB_S3TC_DXT*_EXT family, instead of calling glTexImage2D() you need to call glCompressedTexImage2D() for both alloc() and load(). After this, the ofTexture just works as normal.
But I wonder if this is a chance to revisit what's up with with the compression options im ofTexture. There's an ofTextureCompression type in ofTextureData that you can seet, but its not being used anywhere in the implementation.
There's two ways you can use texture compression as far as I can tell:
You upload raw RGBA data as usual, but specify you want it store compressed (and the GPU does the compression at upload time)
You upload already compressed data, the GPU just stores what you send and treats it as compressed.
I feel 2 is probably more common, but 1 can also be very useful because of the upload bandwith savings.
I've been working on an addon to compress pixel data with DXT (ofxDXT) to upload already compressed texture data into ofTextures (vs uploading raw RGBA data and making the GPU compress it). This is very useful to be able to preload more textures in GPU memory (think image sequences / sprite sheets), but also to stream them from disk. DXT gives you a 4:1 compression ratio with a quite acceptable quality loss on RGBA texture data, and a 8:1 ratio on RGB data.
This currently works on my branch of OF (close to 0.10.1) in GL2, GL3 and GL4, but it requires some changes to ofTexture.
The changes are quite small (see here, sorry for tab vs space mess), and would only affect anything when a texture glInternalType is DXT. Basically when the internal type is of the
GL_COMPRESSED_RGB_S3TC_DXT*_EXT
family, instead of callingglTexImage2D()
you need to callglCompressedTexImage2D()
for both alloc() and load(). After this, the ofTexture just works as normal.But I wonder if this is a chance to revisit what's up with with the compression options im ofTexture. There's an ofTextureCompression type in ofTextureData that you can seet, but its not being used anywhere in the implementation.
There's two ways you can use texture compression as far as I can tell:
I feel 2 is probably more common, but 1 can also be very useful because of the upload bandwith savings.