简体   繁体   中英

How to setup blending for additive color overlays?

Is it possible in opengl to setup blending to achieve additive color overlays?

Red + green = yellow, cyan + magenta = white, etc.. (see diagram )

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);

should do it.

Have a look at the full description of glBlendFunc

EDIT: Old tutorial link seems to be dead (403 Forbidden). Wayback'd .

Simple additive blending is achieved with glBlendFunc (GL_ONE, GL_ONE). You need to be aware of the fact that OpenGL's color value range is limited to [0,1], and values greater than 1 will be clamped to 1, so adding bright colors may not produce physically correctly blended colors. If you want to achieve that, you will have to add and scale the colors in your own software rather than having OpenGL handle it, or write a shader program that does that while rendering.

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