grivescorbett
grivescorbett

Reputation: 1625

Alpha channel with DXT5 compressed texture

I've written a test program using OpenGL on OS X that loads a PNG, compresses it in memory to DXT5 using libsquish (http://code.google.com/p/libsquish/), and textures a plane.

When I upload an image that contains an alpha channel, but no pixels have alpha values other than fully opaque, it displays correctly: https://i.sstatic.net/WlRcD.png

Given the same image but the black part is replaced with transparency, this is the output I get: https://i.sstatic.net/wOPqA.png

The code is not pretty, it is a thrown together proof of concept:

  1. The C++ source: http://pastebin.com/m0RqpgUS
  2. The vertex shader: http://pastebin.com/QyaWCaTk
  3. The fragment shader: http://pastebin.com/KEuFJ83C
  4. The test images: http://dl.dropbox.com/u/4597377/images.zip

Any thoughts?

Upvotes: 0

Views: 802

Answers (1)

grivescorbett
grivescorbett

Reputation: 1625

Turns out I forgot this:

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

Upvotes: 0

Related Questions