OpenGL: Blending Formula

Taken from the Red Book:

Let the source and destination blending factors be (Sr, Sg, Sb, Sa) and (Dr, Dg, Db, Da), respectively, and the RGBA values of the source and destination be indicated with a subscript of s or d. Then the final, blended RGBA values are given by

(RsSr+RdDr, GsSg+GdDg, BsSb+BdDb, AsSa+AdDa)


Expanded:

red = Red(src)*Red(srcBlendFactor) +
Red(dest)*Red(destBlendFactor)
green = Green(src)*Green(srcBlendFactor) +
Green(dest)*Green(destBlendFactor)
blue = Blue(src)*Blue(srcBlendFactor) +
Blue(dest)*Blue(destBlendFactor)
alpha = Alpha(src)*Alpha(srcBlendFactor) +
Alpha(dest)*Alpha(destBlendFactor)

No comments: