<p>A normal argb image has 8 bits per channel and therefor 32 bits per pixel, the size of an integer. That's why it's stored in an integer a lot of the times.</p>

<p>Floats are also 32 bits.</p>

<p>Something that you can do, is to have a separate image that has only 1 channel, for the transparency. If you make that a float type (or for 16 bit, another type that uses 16 bits instead of 32 bits), then it will take about the same room as an extra normal image.</p>

<p>After a quick google, I found out that most programs are limited to 8 bit per channel, but there should be programs that have 16 bit per channel.
This gives you at least more precision.</p>

<p>When loading in the normal 16 bit image (your texture, if you use 16 bits per channel), you could convert the normal rgb part to 8 bits, and load that in and then create a new image that has 1 channel that is 16 or 32 bits, and then store the alpha value in there.</p>

<p>This way it should be similar to having an extra image, and you do, but instead of 2 textures, you have the transparency in another image.</p>

<p>What would then also be possible to do, is to store the transparency in a normal rgba image (inside your program as a texture), as you were talking about, and then in the shader, you manipulate the rgba values to restore the transparency value. This way you wouldn't need a floating point image.</p>

<p>This is just a quick idea. As far as I know, this should work. (This is my first answer here! whoop! whoop!)</p>

<p>Hope it helps and good luck!</p>

<p><a href="https://developer.mbed.org/handbook/C-Data-Types" rel="nofollow">https://developer.mbed.org/handbook/C-Data-Types</a></p>

<p>(^for the data sizes)</p>

CC BY-SA 3.0
2016-08-13T14:26:14.233Z
2016-08-13T14:26:14.233Z
bram0101
<p>I am making an engine with 2D volumetric transparent objects and need advice how to store transparency data. There are 3 requirements:<br>
- The transparency textures need to be easily editable with common tools (e.g paint.NET, so .png preferred)<br>
- Since a pixel value will determine the light transmittance 8 bits are not enough - in this case lights could travel maximum 256 pixels in non fully transparent textures.<br>
- It should be clear what each pixel means when looking at the texture.    </p>

<p>I've tried using the HEX values from RGB pixels. For example heres a strip with HEX values from 0 to 0xFFFFFF:</p>

<p><a href="https://i.sstatic.net/aXgNJ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/aXgNJ.png" alt="RGB strip"></a></p>

<p>While this gives enough values (256*256*256), looking at the image its not clear what each pixel means (=if I'd pick a random pixel from this image you could not tell approximately the alpha value).</p>

<p>Does anyone know a good method how to represent >256 values in an RGB texture, where its clear what each pixel means?</p>

CC BY-SA 3.0
2016-08-13T08:19:17.027Z
You could use a 16 bit image format, but then paint dot net wont cut it. Though quite many other editors would work fine.
joojaa
CC BY-SA 3.0
2016-08-13T09:25:06.283Z
@joojaa and how well do GPUs cope with 16 bit textures? This game needs to run on mobile too.
sydd
CC BY-SA 3.0
2016-08-14T01:11:24.507Z
What are you trying to accomplish with a 16-bit or 32-bit alpha channel? The human eye can barely distinguish 64 levels of any given color, so it's unlikely that more bits for your alpha channel will be noticeable.
user1118321
CC BY-SA 3.0
2016-08-14T01:12:08.880Z
To answer your question above, modern desktop and laptop GPUs should have no problem using 16-bit half float textures. Mobile will be another story. Some may support it but most probably won't at this point in time.
user1118321
<texture><transparency>
How to store > 256 transparency values in textures?
sydd
# How to store > 256 transparency values in textures?

(Asked by: username_0 on 2016-08-12)

I am making an engine with 2D volumetric transparent objects and need advice how to store transparency data. There are 3 requirements:  
- The transparency textures need to be easily editable with common tools (e.g paint.NET, so .png preferred)  
- Since a pixel value will determine the light transmittance 8 bits are not enough - in this case lights could travel maximum 256 pixels in non fully transparent textures.  
- It should be clear what each pixel means when looking at the texture.

I've tried using the HEX values from RGB pixels. For example heres a strip with HEX values from 0 to 0xFFFFFF:

[![RGB strip](https://i.sstatic.net/aXgNJ.png)](https://i.sstatic.net/aXgNJ.png)

While this gives enough values (256\*256\*256), looking at the image its not clear what each pixel means (=if I'd pick a random pixel from this image you could not tell approximately the alpha value).

Does anyone know a good method how to represent >256 values in an RGB texture, where its clear what each pixel means?

**Tags:** texture, transparency

> **Comments:**
> **username_1**: You could use a 16 bit image format, but then paint dot net wont cut it. Though quite many other editors would work fine.  
> **username_0**: @username_1 and how well do GPUs cope with 16 bit textures? This game needs to run on mobile too.  
> **username_2**: What are you trying to accomplish with a 16-bit or 32-bit alpha channel? The human eye can barely distinguish 64 levels of any given color, so it's unlikely that more bits for your alpha channel will be noticeable.  
> **username_2**: To answer your question above, modern desktop and laptop GPUs should have no problem using 16-bit half float textures. Mobile will be another story. Some may support it but most probably won't at this point in time.  

---

## 1 answers

### Answer by username_3 on 2016-08-13. Score: 1 | Accepted answer

A normal argb image has 8 bits per channel and therefor 32 bits per pixel, the size of an integer. That's why it's stored in an integer a lot of the times.

Floats are also 32 bits.

Something that you can do, is to have a separate image that has only 1 channel, for the transparency. If you make that a float type (or for 16 bit, another type that uses 16 bits instead of 32 bits), then it will take about the same room as an extra normal image.

After a quick google, I found out that most programs are limited to 8 bit per channel, but there should be programs that have 16 bit per channel.
This gives you at least more precision.

When loading in the normal 16 bit image (your texture, if you use 16 bits per channel), you could convert the normal rgb part to 8 bits, and load that in and then create a new image that has 1 channel that is 16 or 32 bits, and then store the alpha value in there.

This way it should be similar to having an extra image, and you do, but instead of 2 textures, you have the transparency in another image.

What would then also be possible to do, is to store the transparency in a normal rgba image (inside your program as a texture), as you were talking about, and then in the shader, you manipulate the rgba values to restore the transparency value. This way you wouldn't need a floating point image.

This is just a quick idea. As far as I know, this should work. (This is my first answer here! whoop! whoop!)

Hope it helps and good luck!

<https://developer.mbed.org/handbook/C-Data-Types>

(^for the data sizes)


---

