In OpenGL, I am using
GL_SRGB8_ALPHA8 for the OpenGL internal texture format for my textures and render targets. This eliminated some banding I was seeing in dark opaque areas. However, in the following screenshot, you can see there is still some banding in the nearly-opaque black pixels on the left side. The render target is transparent in the areas where you see the checkerboard pattern.
Semitransparent pixels in SRGB formatted textures and render target textures appear too transparent when rendered to the screen, and pixels that are very nearly opaque (254, 253, 252 alpha) show noticeable banding as you can see in the sample image.
I've seen the issue with both SRGB formatted render target textures and ordinary textures with SRGB format.
The banding appears to go away if I don't call
I'm using premultiplied alpha, but I'm pretty sure I've eliminated that as a cause of the issue. I'm not doing anything to the sampled color in the pixel shader.
My blend functions:
// Non-premultipled alpha textures glBlendFuncSeparate( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); // Premultiplied alpha textures glBlendFuncSeparate( GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
I tried exporting my render target to a PNG, and the true alpha values stored in the render target are increasing by 1 at each band. The texture appears much more opaque in image editors than it does in my app.
Any advice as to what could cause this kind of alpha banding?