drwoof
drwoof

Reputation: 132

Grayscale Color Depth in Android OpenGL ES

In OpenGL ES, colors range from 0-1f. Do these values directly map to 0-255, aka 8-bit? Or does the 0-1f range achieve finer colors at higher than 8-bit?

I'm producing a pattern programmatically where rgb are equal (because it's grayscale) so effectively the image is 8-bit. I'd like to achieve a deeper color depth in grayscale such as 16-bit, is this possible?

Upvotes: 1

Views: 316

Answers (1)

solidpixel
solidpixel

Reputation: 12109

Depends on your input/output texture format; if it is RGB565 then it's going to be less than 8-bit, if it's RGB10_A2 then it's going to be more than 8-bit.

Texture filtering (e.g. bilinear or trilinear) is generally done at higher precision than the original data, so may result in values which are not exactly e.g. a multiple of 1/256 for an 8-bit texture.

I'd like to achieve a deeper color depth in grayscale such as 16-bit, is this possible?

OpenGL ES 3.0 has wide integer formats, OpenGL ES ES 3.2 has fp16 and fp32 formats, so it's definitely possible to store relatively arbitrary data at more than 8 bit per channel.

However, the real question is for what purpose? If you intending to show the value on screen then the odds are you have no device actually capable of displaying 16-bit per channel color. Nearly all consumer-grade monitors and mobile device panels are 8-bit per color channel (in mobile, many are not even that and accept 8-bit data but only display 6 or 7 bits of precision in the panel).

Upvotes: 1

Related Questions