Page 1 of 1
Weird filtering issue
Posted: Thu Nov 21, 2013 2:21 am
by Calin Leafshade
For some overlays in my game I keep getting weird fringing when the image is being drawn at sub pixel accuracies.
looks like this:

- qbIn0Us.png (26.43 KiB) Viewed 313 times
It goes away if I use nearest neighbour filtering but then I get weird stepping as the camera moves.
Any ideas?
Re: Weird filtering issue
Posted: Thu Nov 21, 2013 3:04 am
by Calin Leafshade
Ok, It seems that the problem is that the surrounding pixels are set to 255,255,255,0 so the white is affecting the pixels as they filter.
Shouldnt the filtering ignore the colouring of those pixels because the alpha is zero? Is there a mistake in the blend function somewhere?
Re: Weird filtering issue
Posted: Thu Nov 21, 2013 7:40 am
by Plu
Apparently that's how it's supposed to work. The fix is to change those surrounding pixels to 0,0,0,0 and it should go away.
Re: Weird filtering issue
Posted: Thu Nov 21, 2013 1:08 pm
by Boolsheet
It actually has to do with the blend mode, but it's not a mistake. It's just how the alpha blend mode works. To get the expected blending you would have to prepare your image for premultiplied blending. That means multiplying the red, green, and blue channel with the alpha channel and then drawing the image with the premultiplied blend mode.
viewtopic.php?f=4&t=75222&p=155021#p155021
The alpha blend mode will be changed in 0.9.0 slightly so this operation is not needed anymore.