# Alpha blending with textures alpha channel

**URL:** <https://forums.imgtec.com/t/alpha-blending-with-textures-alpha-channel/371>\
**Category:** PowerVR Insider\
**Created:** [June 8, 2009, 2:46pm UTC](https://forums.imgtec.com/t/alpha-blending-with-textures-alpha-channel/371 "2009-06-08T14:46:01Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![lichtens](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@lichtens](https://forums.imgtec.com/u/lichtens)\
**Post date:** [June 8, 2009, 2:46pm UTC](https://forums.imgtec.com/t/alpha-blending-with-textures-alpha-channel/371/1 "2009-06-08T14:46:01Z")

</div>

Hi,

i have a real problem with alpha blending of objects using the alpha channel of an pvrtc texture. in fact the alpha values of the textures are ok when i regard them in the pvrtc tex tool. i store the bytearray to file, before uploading the texture to gl.

after this the textures alpha values seems to be broken or sth like this.

i use

glBlendFunc(GL\_SRC\_ALPHA, GL\_ONE\_MINUS\_SRC\_ALPHA);

as blendfunction. glColor is set to 1.0, 1.0, 1.0, 1.0. object is shown completely white after blending. For testing i set down alpha value of glColor to 0.5 then this white object is blended somehow, but on complete different areas then the texture has alpha set.

This effect brought me to the point, that there must be something wrong in the way i send pvrtc texture to the gl pipeline.Â

Someone has a hint, what can be done wrong here?

With best regards!

---

<div class="post-metadata">

**Author:** ![xmas](https://avatars.discourse-cdn.com/v4/letter/x/958977/32.png) [@xmas](https://forums.imgtec.com/u/xmas)\
**Post date:** [June 8, 2009, 2:52pm UTC](https://forums.imgtec.com/t/alpha-blending-with-textures-alpha-channel/371/2 "2009-06-08T14:52:35Z")

</div>

If a textured object shows up white it may be a sign that the texture is incomplete. If mipmapping is enabled for the texture (GL\_TEXTURE\_MIN\_FILTER is one that contains _MIPMAP_) you need an entire mipmap chain from base level to 1x1. Could you post your code to load the texture?

---

<div class="post-metadata">

**Author:** ![lichtens](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@lichtens](https://forums.imgtec.com/u/lichtens)\
**Post date:** [June 8, 2009, 7:30pm UTC](https://forums.imgtec.com/t/alpha-blending-with-textures-alpha-channel/371/3 "2009-06-08T19:30:29Z")

</div>

Of course i will do:

glGenTextures(1, &id);

glBindTexture(GL\_TEXTURE\_2D, id);

for(nMIPMapLevel = 0; nMIPMapLevel \<= nTextureLevelsNeeded; nSizeX = PVRT\_MAX(nSizeX/2, (unsigned int)1), nSizeY = PVRT\_MAX(nSizeY/2, (unsigned int)1), nMIPMapLevel++)  
Â {  
Â if (format == GL\_COMPRESSED\_RGBA\_PVRTC\_2BPPV1\_IMG || format == GL\_COMPRESSED\_RGB\_PVRTC\_2BPPV1\_IMG)  
Â {  
Â CompressedImageSize = ( PVRT\_MAX(nSizeX, PVRTC2\_MIN\_TEXWIDTH) \* PVRT\_MAX(nSizeY, PVRTC2\_MIN\_TEXHEIGHT) \* bitcount + 7) / 8;  
Â }  
Â else  
Â {// PVRTC4 case  
Â CompressedImageSize = ( PVRT\_MAX(nSizeX, PVRTC4\_MIN\_TEXWIDTH) \* PVRT\_MAX(nSizeY, PVRTC4\_MIN\_TEXHEIGHT) \* bitcount + 7) / 8;  
Â }  
Â Â   
Â glTexEnvf( GL\_TEXTURE\_ENV, GL\_TEXTURE\_ENV\_MODE, GL\_MODULATE );  
Â glTexParameterf( GL\_TEXTURE\_2D, GL\_TEXTURE\_MIN\_FILTER, GL\_NEAREST );  
Â glTexParameterf( GL\_TEXTURE\_2D, GL\_TEXTURE\_MAG\_FILTER, GL\_LINEAR );Â   
Â   
Â glTexParameterf( GL\_TEXTURE\_2D, GL\_TEXTURE\_WRAP\_S,  
Â GL\_REPEAT );  
Â glTexParameterf( GL\_TEXTURE\_2D, GL\_TEXTURE\_WRAP\_T,  
Â GL\_REPEAT );  
Â glCompressedTexImage2D(GL\_TEXTURE\_2D, nMIPMapLevel, format, nSizeX, nSizeY, 0,  
Â CompressedImageSize, data);  
}

[/CODE]

Best Regards

EDIT: All other textures are shown well with this code. Problems only occur with thouse which should be blended over textures alpha channel

Lichtens2009-06-09 07:44:09[CODE]

glGenTextures(1, &id);

glBindTexture(GL\_TEXTURE\_2D, id);

for(nMIPMapLevel = 0; nMIPMapLevel \<= nTextureLevelsNeeded; nSizeX = PVRT\_MAX(nSizeX/2, (unsigned int)1), nSizeY = PVRT\_MAX(nSizeY/2, (unsigned int)1), nMIPMapLevel++)  
Â {  
Â if (format == GL\_COMPRESSED\_RGBA\_PVRTC\_2BPPV1\_IMG || format == GL\_COMPRESSED\_RGB\_PVRTC\_2BPPV1\_IMG)  
Â {  
Â CompressedImageSize = ( PVRT\_MAX(nSizeX, PVRTC2\_MIN\_TEXWIDTH) \* PVRT\_MAX(nSizeY, PVRTC2\_MIN\_TEXHEIGHT) \* bitcount + 7) / 8;  
Â }  
Â else  
Â {// PVRTC4 case  
Â CompressedImageSize = ( PVRT\_MAX(nSizeX, PVRTC4\_MIN\_TEXWIDTH) \* PVRT\_MAX(nSizeY, PVRTC4\_MIN\_TEXHEIGHT) \* bitcount + 7) / 8;  
Â }  
Â Â   
Â glTexEnvf( GL\_TEXTURE\_ENV, GL\_TEXTURE\_ENV\_MODE, GL\_MODULATE );  
Â glTexParameterf( GL\_TEXTURE\_2D, GL\_TEXTURE\_MIN\_FILTER, GL\_NEAREST );  
Â glTexParameterf( GL\_TEXTURE\_2D, GL\_TEXTURE\_MAG\_FILTER, GL\_LINEAR );Â   
Â   
Â glTexParameterf( GL\_TEXTURE\_2D, GL\_TEXTURE\_WRAP\_S,  
Â GL\_REPEAT );  
Â glTexParameterf( GL\_TEXTURE\_2D, GL\_TEXTURE\_WRAP\_T,  
Â GL\_REPEAT );  
Â glCompressedTexImage2D(GL\_TEXTURE\_2D, nMIPMapLevel, format, nSizeX, nSizeY, 0,  
Â CompressedImageSize, data);  
}

[/CODE]

Best Regards

EDIT: All other textures are shown well with this code. Problems only occur with thouse which should be blended over textures alpha channel

  
Lichtens2009-06-09 07:44:09

---

<div class="post-metadata">

**Author:** ![lichtens](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@lichtens](https://forums.imgtec.com/u/lichtens)\
**Post date:** [June 10, 2009, 10:34am UTC](https://forums.imgtec.com/t/alpha-blending-with-textures-alpha-channel/371/4 "2009-06-10T10:34:42Z")

</div>

Nothing wrong with this code?Â

No new ideas?

I am still looking urgently for hints, pointing me to the solution of this problem!

---

<div class="post-metadata">

**Author:** ![xmas](https://avatars.discourse-cdn.com/v4/letter/x/958977/32.png) [@xmas](https://forums.imgtec.com/u/xmas)\
**Post date:** [June 17, 2009, 9:10am UTC](https://forums.imgtec.com/t/alpha-blending-with-textures-alpha-channel/371/5 "2009-06-17T09:10:44Z")

</div>

What code do you use for rendering? Can you make texturing work at all, or is this only related to alpha textures?

---

<div class="post-metadata">

**Author:** ![lichtens](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@lichtens](https://forums.imgtec.com/u/lichtens)\
**Post date:** [June 17, 2009, 9:28am UTC](https://forums.imgtec.com/t/alpha-blending-with-textures-alpha-channel/371/6 "2009-06-17T09:28:05Z")

</div>

As written before, it is only related to the alpha textures! All other textures, loaded with the same code above are rendered like excpected!

It is depthtest enabled without writing...Â

blending enabled, alphatest enabled, blendfunction is GL\_SRC\_ALPHA, GL\_ONE\_MINUS\_SRC\_ALPHA

Alpha function is GL\_GREATER, 0.01

Then rendered with an draw elements call!

Best regards,

Andi

---

<div class="post-metadata">

**Author:** ![xmas](https://avatars.discourse-cdn.com/v4/letter/x/958977/32.png) [@xmas](https://forums.imgtec.com/u/xmas)\
**Post date:** [June 17, 2009, 9:30am UTC](https://forums.imgtec.com/t/alpha-blending-with-textures-alpha-channel/371/7 "2009-06-17T09:30:42Z")

</div>

Can you send us a minimal example application that shows this behaviour?

---

<div class="post-metadata">

**Author:** ![lichtens](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@lichtens](https://forums.imgtec.com/u/lichtens)\
**Post date:** [June 17, 2009, 9:38am UTC](https://forums.imgtec.com/t/alpha-blending-with-textures-alpha-channel/371/8 "2009-06-17T09:38:17Z")

</div>

Wow.... i dont think this is possible that easy.... it is embedded in a really big project!Â

Textures are generated live, coming from internet. Same belongs to the geometry!

---

<div class="post-metadata">

**Author:** ![lichtens](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@lichtens](https://forums.imgtec.com/u/lichtens)\
**Post date:** [June 18, 2009, 9:06am UTC](https://forums.imgtec.com/t/alpha-blending-with-textures-alpha-channel/371/9 "2009-06-18T09:06:04Z")

</div>

I had some interesting findings to this problem today:

These objects are only white as long as we stand directly in front of it.... going away from them makes them shown as the picture which should be on them but with blackbackround on the parts of the texture which should be blended.... so also no blending...

Is this pointing to a problem with midmap generation?

Any new ideas with this information?

---

<div class="post-metadata">

**Author:** ![lichtens](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@lichtens](https://forums.imgtec.com/u/lichtens)\
**Post date:** [June 19, 2009, 11:25am UTC](https://forums.imgtec.com/t/alpha-blending-with-textures-alpha-channel/371/10 "2009-06-19T11:25:35Z")

</div>

Here is a debug logger output for the texture loading:

14:15:05 Message Handler: Texture UUID: bde22c20-5d1c-0914-975d-169f0284e9da  
14:15:05 Message Handler: Texture Hash : 37349316  
14:15:05 Message Handler: Texture Data Length : 5620  
14:15:05 Message Handler: Total Texture Data Length = 5620  
14:15:05 OpenGL Texture upload!  
14:15:05 Loading PVRTC Texture!  
14:15:05 Copied texture header... decoding!  
14:15:05 ===\> PVRTC Texture Header Size = 52  
14:15:05 ===\> PVRTC Texture Height = 128  
14:15:05 ===\> PVRTC Texture Width = 128  
14:15:05 ===\> PVRTC Texture MipMap Count = 7  
14:15:05 ===\> PVRTC Texture Pixel Format Flags = 0x0000830c  
14:15:05 ===\> PVRTC Texture Data Size = 5568  
14:15:05 ===\> PVRTC Texture Bit Count = 2  
14:15:05 ===\> PVRTC Texture Red Bit Mask = 0  
14:15:05 ===\> PVRTC Texture Green Bit Mask = 0  
14:15:05 ===\> PVRTC Texture Blue Bit Mask = 0  
14:15:05 ===\> PVRTC Texture Alpha Bit Mask = 1  
14:15:05 PVRTC Header decompressed!  
14:15:05 PVRTC Format Computed!  
14:15:05 GL\_COMPRESSED\_RGBA\_PVRTC\_2BPPV1\_IMG  
14:15:05 Texture Data Memory allocated!  
14:15:05 PVRTC Texture Data copied!  
14:15:05 Texture generated!  
14:15:05 GL Error Code Hex = 0x00000000  
14:15:05 Texture bound!  
14:15:05 GL Error Code Hex = 0x00000000  
14:15:05 ===\> TextureID = 5  
14:15:05 ===\> PVRTC OpenGL Texture upload MipMap Level = 0  
14:15:05 GL Error Code Hex = 0x00000000  
14:15:05 ===\> PVRTC OpenGL Texture upload MipMap Level = 1  
14:15:05 GL Error Code Hex = 0x00000000  
14:15:05 ===\> PVRTC OpenGL Texture upload MipMap Level = 2  
14:15:05 GL Error Code Hex = 0x00000000  
14:15:05 ===\> PVRTC OpenGL Texture upload MipMap Level = 3  
14:15:05 GL Error Code Hex = 0x00000000  
14:15:05 ===\> PVRTC OpenGL Texture upload MipMap Level = 4  
14:15:05 GL Error Code Hex = 0x00000000  
14:15:05 ===\> PVRTC OpenGL Texture upload MipMap Level = 5  
14:15:05 GL Error Code Hex = 0x00000000  
14:15:05 ===\> PVRTC OpenGL Texture upload MipMap Level = 6  
14:15:05 GL Error Code Hex = 0x00000000  
14:15:05 ===\> PVRTC OpenGL Texture upload MipMap Level = 7  
14:15:05 GL Error Code Hex = 0x00000000  
14:15:05 generated  
14:15:05 iTextureLists-\>textureUploadReady  
  
[/CODE]

Everything looks quite normal for me. maybe anyone here can see a mistake in there.Â

Can anyone tell me more about the header values:

PVRTC Texture Pixel Format Flags

PVRTC Texture Red Bit Mask  
PVRTC Texture Green Bit Mask   
PVRTC Texture Blue Bit Mask  
PVRTC Texture Alpha Bit Mask

Is it correct, that R,G,B Bit Mask is set to 0 ?

What kind of information can i see in the format flags?

[CODE]

14:15:05 Message Handler: Texture UUID: bde22c20-5d1c-0914-975d-169f0284e9da  
14:15:05 Message Handler: Texture Hash : 37349316  
14:15:05 Message Handler: Texture Data Length : 5620  
14:15:05 Message Handler: Total Texture Data Length = 5620  
14:15:05 OpenGL Texture upload!  
14:15:05 Loading PVRTC Texture!  
14:15:05 Copied texture header... decoding!  
14:15:05 ===\> PVRTC Texture Header Size = 52  
14:15:05 ===\> PVRTC Texture Height = 128  
14:15:05 ===\> PVRTC Texture Width = 128  
14:15:05 ===\> PVRTC Texture MipMap Count = 7  
14:15:05 ===\> PVRTC Texture Pixel Format Flags = 0x0000830c  
14:15:05 ===\> PVRTC Texture Data Size = 5568  
14:15:05 ===\> PVRTC Texture Bit Count = 2  
14:15:05 ===\> PVRTC Texture Red Bit Mask = 0  
14:15:05 ===\> PVRTC Texture Green Bit Mask = 0  
14:15:05 ===\> PVRTC Texture Blue Bit Mask = 0  
14:15:05 ===\> PVRTC Texture Alpha Bit Mask = 1  
14:15:05 PVRTC Header decompressed!  
14:15:05 PVRTC Format Computed!  
14:15:05 GL\_COMPRESSED\_RGBA\_PVRTC\_2BPPV1\_IMG  
14:15:05 Texture Data Memory allocated!  
14:15:05 PVRTC Texture Data copied!  
14:15:05 Texture generated!  
14:15:05 GL Error Code Hex = 0x00000000  
14:15:05 Texture bound!  
14:15:05 GL Error Code Hex = 0x00000000  
14:15:05 ===\> TextureID = 5  
14:15:05 ===\> PVRTC OpenGL Texture upload MipMap Level = 0  
14:15:05 GL Error Code Hex = 0x00000000  
14:15:05 ===\> PVRTC OpenGL Texture upload MipMap Level = 1  
14:15:05 GL Error Code Hex = 0x00000000  
14:15:05 ===\> PVRTC OpenGL Texture upload MipMap Level = 2  
14:15:05 GL Error Code Hex = 0x00000000  
14:15:05 ===\> PVRTC OpenGL Texture upload MipMap Level = 3  
14:15:05 GL Error Code Hex = 0x00000000  
14:15:05 ===\> PVRTC OpenGL Texture upload MipMap Level = 4  
14:15:05 GL Error Code Hex = 0x00000000  
14:15:05 ===\> PVRTC OpenGL Texture upload MipMap Level = 5  
14:15:05 GL Error Code Hex = 0x00000000  
14:15:05 ===\> PVRTC OpenGL Texture upload MipMap Level = 6  
14:15:05 GL Error Code Hex = 0x00000000  
14:15:05 ===\> PVRTC OpenGL Texture upload MipMap Level = 7  
14:15:05 GL Error Code Hex = 0x00000000  
14:15:05 generated  
14:15:05 iTextureLists-\>textureUploadReady  
  
[/CODE]

Everything looks quite normal for me. maybe anyone here can see a mistake in there.Â

Can anyone tell me more about the header values:

PVRTC Texture Pixel Format Flags

PVRTC Texture Red Bit Mask  
PVRTC Texture Green Bit Mask   
PVRTC Texture Blue Bit Mask  
PVRTC Texture Alpha Bit Mask

Is it correct, that R,G,B Bit Mask is set to 0 ?

What kind of information can i see in the format flags?

---

<div class="post-metadata">

**Author:** ![GordonMaclachlan](https://avatars.discourse-cdn.com/v4/letter/g/c68b51/32.png) [@GordonMaclachlan](https://forums.imgtec.com/u/GordonMaclachlan)\
**Post date:** [July 3, 2009, 1:59pm UTC](https://forums.imgtec.com/t/alpha-blending-with-textures-alpha-channel/371/11 "2009-07-03T13:59:21Z")

</div>

For PVRTC, the bit mask flags don’t make a great deal of sense which is why they are left blank (I think they’re only really in the format because of an attempt to keep it like DDS which I’ve never really understood). It’s safe to ignore them entirely.  
  
  
  
  
  
The alpha mask will be set to 0 if there is no alpha in the PVRTC file so that you can know whether to use GL\_COMPRESSED\_RGBA\_PVRTC\_2BPPV1\_IMG vs GL\_COMPRESSED\_RGB\_PVRTC\_2BPPV1\_IMG or GL\_COMPRESSED\_RGBA\_PVRTC\_4BPPV1\_IMG vs GL\_COMPRESSED\_RGB\_PVRTC\_4BPPV1\_IMG. You can also use the alpha bit of the dwpfFlags field for this purpose (this is how our own texture loading code does it).  
  
  
  
  
  
It sounds like you are having trouble with MIP-maps. If you disable MIP-maps for these textures does your rendering improve?  
  
  
  
  
  
PVRTC is tricky to load MIP-map chains for because of the minimum size requirement for MIP-levels and since OpenGL ES requires full MIP chains it’s very easy to have problems. I’d suggest you examine the loading code from our own SDK in PVRTools/OGLES/PVRTTextureAPI.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