Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which OpenGL ES 2.0 texture formats are color-, depth- or stencil-renderable?

From OpenGL ES 2.0 specification section 4.4.5:

"Formats not listed in table 4.5, including compressed internal formats. are not color-, depth-, or stencil-renderable, no matter which components they contain."

Table 4.5

Then there are extensions that extend this table such as:

  • OES_depth24
  • OES_depth32
  • OES_rgb8_rgba8
  • ARM_rgba8

If I understood the specification correctly, table 4.5 affects both texture and renderbuffer formats. And in that case, for example, RGB and RGBA textures with 8-bits per component are not color-renderable unless the extension OES_rgb8_rgba8 (or ARM_rgba8 for RGBA) is supported.

On a test device that supports OES_rgb8_rgba8 the following texture formats are valid, i.e., framebuffer complete when attached to FBO as the color attachment:

  • RGB 565
  • RGB 888
  • RGBA 4444
  • RGBA 5551
  • RGBA 8888

And these were not:

  • Alpha 8
  • Luminance 8
  • LuminanceAlpha 88

The results match my assumptions (at least on 1 device) but I would like to know if I understood the specification correctly or is this working by accident?

like image 738
Mika Haarahiltunen Avatar asked Sep 08 '13 19:09

Mika Haarahiltunen


1 Answers

Yes, your assumptions are correct.

The list of renderable formats in the official specification are just what an OpenGL ES 2.0 implementation is required to support. Most support many more than what is listed there.

However, no implementation of OpenGL / OpenGL ES supports alpha or luminance textures as color-renderable. You can replicate the behavior with texture swizzle extensions and/or GLSL vector swizzling. The extension: EXT_texture_rg adds Red and Red/Green image formats that are useable by textures and renderbuffers. These two formats are very useful when you want to draw into a one or two-channel image format using an FBO (since GL_LUMINANCE, GL_ALPHA and GL_LUMINANCE_ALPHA are not color-renderable formats).

Generally speaking, the set of renderbuffer image formats is a subset of texture image formats. You can use compressed image formats (optional in ES 2.0), luminance and alpha image formats for texturing and pixel transfer operations but they are not supported by renderbuffers. This means that while you can draw using these textures, you cannot draw into them by attaching them to an FBO. To draw into a texture, it must have an image format that is both a renderbuffer format and texture format.

On a historical note, there are renderbuffer formats that are/were not usable as textures. Multisample formats are one example, multisample texturing was added after the initial FBO specification was created.

like image 72
Andon M. Coleman Avatar answered Sep 19 '22 14:09

Andon M. Coleman