a ColorBlending .ox OpenGL Color Blending Methods for producing color-mixing effects (only performed in RGB or RGBAmode) e blending effects are generated with the blending factors for destination object(the current object in the frame buffer)and source object(the incoming object) The new blended color is calculated as (factor)Source"(R,G, B, A)source +(factor)De. *(R, G, B, A)Des SrkRs+ Dr*Rd Sa* Gs Do**Gd Sb*Bs Db*Bd Sa*As+ Da*Ad_(5-1) (Rs, GS, Bs, As)-Source Color (Rd, Gd, Bd, Ad)-Destination Color (Sr, Sg, Sb, Sa)-Source blending factors r, Dg, Db, Da)-Destination blending factors 16
Methods for producing color-mixing effects (only performed in RGB or RGBAmode) Blending effects are generated with the blending factors for destination object (the current object in the frame buffer) and source object (the incoming object). The new blended color is calculated as (factor)Source * (R,G, B,A)Source+ (factor)Des.* (R,G,B,A)Des. (Sr*Rs + Dr*Rd, Sg*Gs + Dg*Gd, Sb*Bs + Db*Bd, Sa*As + Da*Ad) (5-1) (Rs, Gs, Bs,As) – Source Color (Rd, Gd, Bd, Ad) – Destination Color (Sr, Sg, Sb, Sa) – Source blending factors (Dr, Dg, Db, Da) – Destination blending factors OpenGL Color Blending 16
OpenGL Color Blending e How to set up color blending in opengl Firstly to activate this feature glEnable GL BLEND glDisable(GL BleND) Then use the function glBlendFuncfActor, d Factor) Factor(default: GL_oNE) [default: replacing d Factor(default: GL_ ZERO) GL_ZER-(0.0,0.0,0.0,0.0, GL ONE--(1.0,1.0,1.0,1.0
How to set up color blending in OpenGL Firstly, to activate this feature glEnable (GL_BLEND); glDisable (GL_BLEND); Then, use the function glBlendFunc (sFactor,dFactor); sFactor (default:GL_ONE) [default:“replacing”] dFactor (default: GL_ZERO): GL_ZERO -- (0.0, 0.0, 0.0,0.0), GL_ONE -- (1.0, 1.0, 1.0,1.0) OpenGL Color Blending 17
OpenGL Color Blending Constant RGB alpha Blend Factor Blend Factor GL ZERO (0.0,0) 0 GL ONE (1,1,1) GL SRC COLOR (R, G, By GL ONE MINUS SRC COLOR (1,1,1)=( R, G By1-A GL DST COLOR (Ra, Gd, Ba) A GL ONE MINUS DST COLOR (1,1,1)(GdBa GL SRC ALPHA (A, A, Ay A GL ONE MINUS SRC ALPHA (1.1,1)(AAA1-A GL DST ALPHA (Ad, Ad, Ad) GL ONE MINUS DST ALPHA (1,1,1)(A4A1-A GL CONSTANT COLOR (Re, Go be A GL_ONE_ MINUS_CONSTANT_ COLOR (1, 1, 1-(Rc, Gc, Be) 1-Ac GL CONSTANT ALPHA Ac, AJ) GL_ONE_ MINUS_ CONSTANT_ ALPHA (1, 1, I)(Ac A. Ac 1-Ac GL SRC ALPHA SATURATE (, f): fmin(A,1-Ad)I Table 6-1 Source and Destination Blending Factors (From: OpenGL programming guide, h Ed
OpenGL Color Blending 18 (From:OpenGL programmingguide,7 th Ed.)
OpenGL Color Blending Example: the drawn order effects the blending result ● Alpha:0.75 e Source and destination blending tors GL SRC ALPHA and GL ONE MINUS SRC aLpha 0. 75*(source color)+(1.0-0.75) *(des color) yellow one cyan one cyan one ow one (From: OpenGL programming guide, h Ed
OpenGL Color Blending Example: the drawn order effects the blending result Alpha:0.75; Source and destination blending factors: GL_SRC_ ALPHA andGL_ONE_MINUS_SRC_ALPHA 0.75*(source color) + (1.0-0.75)*(des.color) yellowone; cyan one. 19 (From:OpenGL programmingguide,7 th Ed.) cyan one; yellowone