0
votes

Is there a blending equation that can be made using the OpenGL glBlendFunc that would allow for a transparent color (RGBA) to be rendered behind an additive overlay.

Rendering Ontop:

Transparent square overlay on additive layer.

This effect can be achieved using glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

Rendering Underneath:

Transparent square underneath additive layer.

Is there an equation for this blending effect?

1
The usual approach would be to change your draw order (i.e. sort objects based on depth first). Any reason you cannot do that? - Paul-Jan

1 Answers

0
votes

There are no glBlendFunc options for directly drawing overlay. Info can be found here:

http://benmcdowell.com/implementing-photoshop-blend-modes-in-opengl/

However, your effect doesn't seem to be overlay, seems to be either screen

glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);

or additive

glBlendFunc(GL_SRC_ALPHA, GL_ONE);

I'd suggest you try all combinations, there aren't that many possible. If you need crazier effects however, you'll need to code shaders.

P.S. I lied. You don't HAVE to code shaders to do crazy effects like overlay, but you have to draw so many times it becomes unusable in real time. I should have said it's better to use shaders.