Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup blending for additive color overlays?

Tags:

opengl

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

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

like image 259
Steph Thirion Avatar asked Dec 26 '08 13:12

Steph Thirion


2 Answers

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.

like image 195
schnaader Avatar answered Nov 09 '22 06:11

schnaader


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.

like image 21
Razzupaltuff Avatar answered Nov 09 '22 04:11

Razzupaltuff