# Is there any way to compress \`rbga\` channel to single channel

**URL:** <https://forums.imgtec.com/t/is-there-any-way-to-compress-rbga-channel-to-single-channel/2840>\
**Category:** PowerVR Insider\
**Tags:** pvrtextool\
**Created:** [October 30, 2018, 3:32am UTC](https://forums.imgtec.com/t/is-there-any-way-to-compress-rbga-channel-to-single-channel/2840 "2018-10-30T03:32:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bin381](https://avatars.discourse-cdn.com/v4/letter/b/b5ac83/32.png) [@bin381](https://forums.imgtec.com/u/bin381)\
**Post date:** [October 30, 2018, 3:32am UTC](https://forums.imgtec.com/t/is-there-any-way-to-compress-rbga-channel-to-single-channel/2840/1 "2018-10-30T03:32:13Z")

</div>

For example,the texture is in rgba mode but what I need just alpha channel.  
So I want to remove the data in rbg channels and just store the alpha data.  
And then I can save the texture size to 1/3.

Is there any way to achieve this goal？  
Thanks!

---

<div class="post-metadata">

**Author:** ![CarlosSarria](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/carlossarria/32/263_2.png) [@CarlosSarria](https://forums.imgtec.com/u/CarlosSarria)\
**Post date:** [October 31, 2018, 10:29am UTC](https://forums.imgtec.com/t/is-there-any-way-to-compress-rbga-channel-to-single-channel/2840/2 "2018-10-31T10:29:45Z")

</div>

Hi,

Yes, it is possible. If you are using PVRTexTool just re-compress the texture with an alpha-only format (Name: **A 8** ). Alternatively you can do it programmatically, removing the three channels from the original data (converting from 32bit to 8bit). Load it to OpenGL ES with the GL\_ALPHA flag.

Regards.

Carlos.

---

<div class="post-metadata">

**Author:** ![bin381](https://avatars.discourse-cdn.com/v4/letter/b/b5ac83/32.png) [@bin381](https://forums.imgtec.com/u/bin381)\
**Post date:** [November 8, 2018, 11:12am UTC](https://forums.imgtec.com/t/is-there-any-way-to-compress-rbga-channel-to-single-channel/2840/3 "2018-11-08T11:12:22Z")

</div>

> [@CarlosSarria](#):
>
> Regards

Am I right?  
./PVRTexToolCLI -f a8 -i example.png -o output.pvr

---

<div class="post-metadata">

**Author:** ![CarlosSarria](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/carlossarria/32/263_2.png) [@CarlosSarria](https://forums.imgtec.com/u/CarlosSarria)\
**Post date:** [November 8, 2018, 4:36pm UTC](https://forums.imgtec.com/t/is-there-any-way-to-compress-rbga-channel-to-single-channel/2840/4 "2018-11-08T16:36:33Z")

</div>

Yes, that is correct.The format a8 will carry only the alpha channel in your png.

Regards.

Carlos.

---

<div class="post-metadata">

**Author:** ![SimonFenney](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/simonfenney/32/257_2.png) [@SimonFenney](https://forums.imgtec.com/u/SimonFenney)\
**Post date:** [November 9, 2018, 9:18am UTC](https://forums.imgtec.com/t/is-there-any-way-to-compress-rbga-channel-to-single-channel/2840/5 "2018-11-09T09:18:23Z")

</div>

If you can modify your shaders, you can achieve even higher space savings if you

1. Create an RGBA texture where each pixel is defined as [RGBA]=[A’, 0, 0, 255], where A’ is the original per-pixel alpha value
2. Compress the texture as PVRTC with 4bpp (or even 2bpp if the quality ends up being good enough)
3. Getting the fragment shader to transfer the R channel of the sampled result to the alpha channel.

Notes:

- Actually, it doesn’t matter if you use [A’, 0, 0, 255], [A’, A’, 0, 255] or [0, A’, 0, 255], as long as it’s consistent . It’s just that the R and G channels in PVRTC have slightly more accuracy than B.
- It is essential that the A be set to 255 as “opaque” data will compress slightly better (as it gives more precision to the RG&B channels)
- It is important to keep B constant (and one of a small set of particular constants) - here I’ve chosen 0, but 255 would also do equally well.
