2

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?

2
  • Ideally, you already want the input textures to have the pre-multiplied alpha, otherwise you will get artifacts when the texture filter interpolates between neighboring texels with differing alpha values. Commented Jul 25, 2021 at 16:45
  • Sure, that's what I'm aiming for, but resolving the multisampled texture will not premultiply alpha at antialiasing pixels that multisampling created. Commented Jul 25, 2021 at 19:19

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

That's what I was suspecting. The additional problem though is that I need to draw two types of things into the multisampled texture: 1) blended transparent sprites that already have premultiplied alpha, and 2) fully opaque triangles whose only alpha is created by antialiasing itself (and it's not multiplied). So I end up with multiplied and straight values in the multisampled texture. Not sure what'd be the best way to organize the whole thing so the final result is all multiplied values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.