Game Development Reference
In-Depth Information
take the two pixels and average them together, resulting in an alpha value of 0.5, this is the
alpha value that the conventional alpha blend will use.
Consider the following example:
Thesourcepixelcolorisred p s = {1,0,0,1} anditsneighborisaborderpixelp b ={0,0,0,0}.
In this situation if a filter is applied, the filtered color will be
Now,thiswillbethesourcepixelusedbythecolorblendoperation,considerthatweblend
this pixel onto a green pixel on the render target p rt ={0,1,0,1} .
Using conventional alpha blending:
The red component of the final color is actually darker than we expected. Given an alpha
value of 0.5, we expected the resulting color after the blend to be {0.5, 0.5, 0, 0.5}.
Premultiplied alpha uses the blend factors:
ONE, INVSRCALPHA
This yields the formula:
Continuing the previous example, we can see that with premultiplied alpha we do not have
the same problem:
Which is the result we expected.
Premultiplied alpha also has a performance advantage as we avoid performing the multi-
plications during the blend. In extreme cases, such as in conjunction with some compres-
sion algorithms premultiplication may produce a significant loss of quality.
Search WWH ::




Custom Search