Reputation: 9423
Is it possible in opengl to setup blending to achieve additive color overlays?
Red + green = yellow, cyan + magenta = white, etc.. (see diagram)
Upvotes: 14
Views: 26480
Reputation: 49739
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.
Upvotes: 21
Reputation: 2311
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.
Upvotes: 8