Weird filtering issue

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Calin Leafshade
Prole
Posts: 6
Joined: Fri Jul 12, 2013 2:43 pm

Weird filtering issue

Post 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
qbIn0Us.png (26.43 KiB) Viewed 147 times
It goes away if I use nearest neighbour filtering but then I get weird stepping as the camera moves.

Any ideas?
Calin Leafshade
Prole
Posts: 6
Joined: Fri Jul 12, 2013 2:43 pm

Re: Weird filtering issue

Post 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?
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

Re: Weird filtering issue

Post 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.
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Weird filtering issue

Post 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.
Shallow indentations.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], BrotSagtMist, slime and 202 guests