Understanding OpenGL Blend Function
I really don’t know who and why some one create a so complex thing like alpha blending modes in openGL. When I first saw these GL_ONE, GL_ONE_MINUS_SRC_ALPHA stuff I really did not get it. I did not get on second time, and the same when using it for thousand times. Long story short, here is what you need in the most cases: cross blending, additive blending, multiplied blending.
Cross Blending
Alpha of source will control the blending. If alpha is 1.0 you will only see the source, if its 0.0 you will see the target. Use : glBlendFunc( GL_SRC_ONE_MINUS_ALPHA, GL_SRC_ALPHA );
Rn = Rz * (1.0 - Aq) + Rq * Aq; Gn = Gz * (1.0 - Aq) + Gq * Aq; Bn = Bz * (1.0 - Aq) + Bq * Aq; An = Az * (1.0 - Aq) + Aq * Aq;
Additive Color Blending
You need this to lighten up things. Use: glBlendFunc( GL_ONE, GL_ONE );
Rn = Rz + Rq; Gn = Gz + Gq; Bn = Bz + Bq; An = Az + Aq;
Additive Alpha Blending
Its same like additive color blending, but it uses alpha channel of source to define the blending strength. Use glBlendFunc( GL_ONE, GL_SRC_ALPHA );
Rn = Rz + Rq * Aq; Gn = Gz + Gq * Aq; Bn = Bz + Bq * Aq; An = Az + Aq * Aq;
Multiplied Blending
You just multiply the color values. You could use this to colorize a scene. etc. Use: glBlendFunc( GL_ZERO, GL_SRC_COLOR );
Rn = Rz * Rq; Gn = Gz * Gq; Bn = Bz * Bq; An = Az * Aq;
Hope this is useful for some one.
About this entry
You’re currently reading “ Understanding OpenGL Blend Function ,” an entry on coders
- Author:
- hhamm
- Published:
- 1.22.10 / 7pm
- Category:
- math, openAL, programming
- Feedback:






4 Comments
Jump to comment form | comments rss [?] | trackback uri [?]