openglblendingmultisamplingpremultiplied-alpha

Premultiplied alpha and multisampling in OpenGL


I'm rendering some triangles into multisampled texture. Then blit this texture into normal texture and draw a textured quad onto screen.

I need the final texture to have premultiplied alpha. Is there a way to tell OpenGL to automatically premultiply semi-transparent pixels in multisampled texture (or when blitting)?

Or the only way is using an extra shader pass to perform multiplication manually?


Solution

  • A multisample resolve blit can't perform pre-multiplication. You will have to pre-multiply the texture's pixels in the process that reads from the texture.