Missing alpha channel in DXT5 texture when drawing on device

Hello!

I’m porting mobile game to Android and want to use compressed textures in OpenGL the same way I did on iOS with pvr textures.

I’ve managed to convert my textures from png to dxt and run the game on Galaxy Tab 10.1 with Nvidia Tegra 2 chipset.
However there were no smooth alpha in my DXT5 formatted textures. They looked like DXT1-textures with 1-bit alpha.

Please, help me with this problem. I’m really stuck.

Detailes:

  1. I’ve used nvcompress tool version 2.1.0 with flags “-nomips -bc3 -alpha” (and of cause a lot of variations but with no success).

  2. I’m using OpenGL ES1 library.

  3. My openGL code:

     GLuint texture = 0;
     glGenTextures(1, &texture);
     glBindTexture(GL_TEXTURE_2D, texture);
    
     glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
     glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    
    
     int blockSize;
     GLuint format;
     switch (info.format) {
         case S3TC_DXT1:
             format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
             blockSize = 8;
             break;
         case S3TC_DXT3:
             format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
             blockSize = 16;
             break;
         case S3TC_DXT5:
             format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
             blockSize = 16;
             break;
         case ATC:
             format = GL_ATC_RGBA_EXPLICIT_ALPHA_AMD;
             blockSize = 16;
             break;
         default:
             break;
     }
     RCatEngine::utils::logMsg("try to load DDS texture");
     int offset = 0;
     for(int i = 0; i < info.numMipMaps; i++)
     {
     	int size = ((width + 3) / 4) * ((height + 3) / 4) * blockSize;
     	glCompressedTexImage2D(GL_TEXTURE_2D, i, format, width, height, 0, size, textureData + offset);
     	offset += size;
    
     	//Scale next level.
     	width  /= 2;
     	height /= 2;
     }
    

could you provide the assets/resources that you’re using?

Thanks for reply, of cause.

I have experimented a lot with this texture:
[url]Облако Mail.ru - Бесплатное облачное хранилище для передачи и хранения данных онлайн

DDS viewer showd me alpha channel. But I couldn’t get it working on device.

unfortunately, nvidia IT blocks access to that file. feel free to PM me directly to send the file.

likely our gl state is bad - any chance you can provide an apk?

Sent you a message with the same link. Couldn’t find a way to attach file directly. Providing apk is not a problem. I wiil try to make it tomorrow or the day after.

Finally found out the problem. OpenGL state of my game was configured to work with premultiplied alpha-channel.
I’ve added special ‘premultiply’ step to my build system and got proper result. Thanks for help!