It is the sampling from the texture that will get a bad color, isn't it? So a position between a white non transparent pixel and a black transparent pixel would become gray 50% transparent? If so, using pre multiplied alpha won't help as long as the colors are wrong?
Yes, so if we've got two pixels A=(1,1,1,1) and B=(0,0,0,0), then sampling exactly between them gives S=A*0.5+B*0.5, or S=(0.5, 0.5, 0.5, 0.5).
For example, let's say the background is light green: G=(0.5, 1, 0.5).
With regular alpha blending (
src=srcAlpha, dst=1-srcAlpha), we get:
S*0.5 + G*0.5
=(0.25, 0.25, 0.25) + (0.25, 0.5, 0.25)
=(0.5, 0.75, 0.5) <- darker than the original background, hence the black outline around the sprite.
With premultiplied alpha blending (
src=1, dst=1-srcAlpha), we get:
S + G*0.5
=(0.5, 0.5, 0.5) + (0.25, 0.5, 0.25)
=(0.75, 1, 0.75) <- brighter than the original background, no black outline any more.
(I am using pre multiple alpha already)
What does the code for setting your blend mode look like?
Edited by Hodgman, 09 September 2012 - 02:10 AM.