简体   繁体   中英

OpenGL - Rendering Transparency Under Additive Layer

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:

透明正方形叠加层在附加层上。

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

Rendering Underneath:

添加剂层下面的透明正方形。

Is there an equation for this blending effect?

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.

PS 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM