Alpha equation
by William Finlayson · in Technical Issues · 12/08/2001 (3:06 pm) · 2 replies
I am in need of a fast equation for Alpha blending. I thought of just taking a proportion of each colour, and adding them, but I'm not sure if it'll work, does anyone know what formula is usually used to perform alpha blending?
The way I was thinking of doing it was this:
taking the alpha coefficient to be a number between 1.0 and 0.0
fc = final colour value
dc = colour thats already there
sc = colour value being drawn
fc = (sc*alpha)+(dc*(1-alpha))
(apply individually to red, green and blue channels)
does that sound about right? Any links to do with alpha blending would also be appreciated.
The way I was thinking of doing it was this:
taking the alpha coefficient to be a number between 1.0 and 0.0
fc = final colour value
dc = colour thats already there
sc = colour value being drawn
fc = (sc*alpha)+(dc*(1-alpha))
(apply individually to red, green and blue channels)
does that sound about right? Any links to do with alpha blending would also be appreciated.
About the author
#2
12/10/2001 (12:36 am)
Yeah, this is something new I'm doing, and it needs done in SW. I was thinking exactly the same thing for pre-calcing :) But the faster the equation is, the better, as long as it produces acceptable looking results.
Torque Owner SR
But if for some reason you must do the alpha yourself, one trick you can do is pre-multiply the source colours by the alpha channel (that is, if you're alpha values aren't changing at all). For any image you're blitting, simple pre-multiply the colour by the alpha, and store the result back into the colour channel. Then when you have to blit, you only have to perform the alpha multiplication on the destination colour.