Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 2.69 KB

README.md

File metadata and controls

29 lines (22 loc) · 2.69 KB

Cinder-DDS

Cinder-DDS is a CinderBlock to compress images with the lossy DXT1, DXT5 and YCoCg-DXT5 formats and wrap them in a DDS file container.

S3 Texture Compression (S3TC or sometimes referred to as DirectX Texture Compression, DXTC) is a fixed-rate lossy image compression format supported by many GPUs through the GL_EXT_texture_compression_s3tc OpenGL extension - this allows the compressed image to be transferred directly to the GPU and then decompressed in hardware rather than a more costly decompression on the CPU followed by a higher bandwidth transfer from CPU to GPU.

The YCoCg-DXT5 compression format DXT5 compresses image data in the YCoCg color space, which generally yields higher quality than RGB - the format was proposed by J.M.P. van Waveren and Ignacio Castaño in the paper Real-Time YCoCg-DXT Compression. It is worth noting that the compressed artifact remains in the YCoCg color space, so a fragment shader might be necessary to bring it back into RGB.

DirectDraw Surface (DDS) is an image file container often used for DXT compressed images. It was created by Microsoft, is well supported on Windows in both creation and loading though importantly Cinder can create a texture from a DDS file on non-Windows platforms.

NOTE - Cinder-DDS is to be used with the upcoming 0.9.0 Cinder release.

USAGE

Convert PNG to DXT5 compressed DDS file and create texture from it

auto surface = Surface::create(loadImage(loadAsset("pulsar.png")));
auto buffer = DDSConvert(surface, CompressionFormat::DXT5);
auto texture = gl::Texture2d::createFromDds(DataSourceBuffer::create(buffer));

LIBRARIES

There are quite a few third-party libraries that offer DXT compression:

Some support numerous format variations and even perform additional encoding and compression to further reduce the in-memory size - the GDC 2012 talk DXT is NOT ENOUGH! Advanced texture compression for games goes into more detail for those interested. Cinder-DDS uses SOIL2.