Reputation: 1015
I want to implement a fragment/blending operation using OpenGL ES 3.1 that fulfills the following requirements:
Can this be done via the usual blending functions, alpha tricks etc.?
Upvotes: 2
Views: 262
Reputation: 6766
I think you could just use standard premultiplied alpha blending:
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
If you want to replace, then you output an alpha value of 1 from your fragment shader. If you want to do additive then you output an alpha value of 0 from your fragment shader.
That assumes you're only really interested in the RGB values that end up in your framebuffer.
Upvotes: 2
Reputation: 12159
If you know this at vertex shading time I presume that whole triangles are either one blend or another. This is an ideal thing for stencil testing provided that you don't have too much geometry.
How much this costs depends on your geometry, as you need to pass it in to rendering multiple times, but the stencil testing part of this is normally close to "free".
Upvotes: 2