2D Toolkit Forum

2D Toolkit => Support => Topic started by: Bigcheese on October 28, 2013, 03:56:37 pm

Title: Edge bleeding with solid shaders.
Post by: Bigcheese on October 28, 2013, 03:56:37 pm
I have an issue with edge bleeding, the case is that I use a solid shader for the full color sprites, and blend for the tiles that have some alpha.
When I put all sprites on the blend shader I close to no bleeding. but with the solid I get lots of bleeding, if I try adding "Padding" from the settings, the bleedings turns to "black" lines.

What can be the issue behind this?
any recommendations would appreciated.
 
Thanks.
Title: Re: Edge bleeding with solid shaders.
Post by: unikronsoftware on October 28, 2013, 04:05:19 pm
How are you drawing the sprites? Are they pixel perfect?
Title: Re: Edge bleeding with solid shaders.
Post by: Bigcheese on October 29, 2013, 07:46:28 am
Sorry, should've explained that.

It's a retro style game, so the filter mode is set to point "Point", using a tk2dCamera with autoscale set to "Closest Multiple Of Two".
In scale all my tiles are set to pixel perfect, except some lower tiles (1 solid color) are stretched in the Y Axis. I'm guessing the bleeding might be happening because of that?
I can't tell why though.

thanks for help.
Title: Re: Edge bleeding with solid shaders.
Post by: Bigcheese on October 29, 2013, 09:38:55 am
Things that I've tried since then with no luck,
-Set all the tiles to pixel perfect.
-Changed the camera auto scale from "Closest Multiple Of Two" to "Pixel Perfect".
-Changed the camera type from "Orthographic Size" to "Pixels Per Meter". and laid the pixel perfect tiles perfectly next to each other. (with 20 Pixel per meters, I laid the 60X60 tiles to be +3 meters away from each other in both X and Y direction)

And I still get the flickering lines between the tiles while the camera is moving, when the shader is set to Solid, If I change it to Blend, the lines mostly disappear.
If I add padding the lines turn to black.

Thanks.
Title: Re: Edge bleeding with solid shaders.
Post by: Bigcheese on October 29, 2013, 10:07:10 am
Also one the thing to note, those flickering lines on the edges of the tile, only appear when running the game on a device, it does not show in the editor
Title: Re: Edge bleeding with solid shaders.
Post by: unikronsoftware on October 29, 2013, 10:44:00 am
One cheeky way to fix / sidestep  the issue is to pad, then set pad type to extend. The other is to make sure the sprites are always on pixel boundaries, and the camera is always snapped to a pixel. See if that helps?

Also what device are you running on? Is this affecting you? (http://2dtoolkit.com/forum/index.php/topic,612.0.html)
Title: Re: Edge bleeding with solid shaders.
Post by: Bigcheese on October 30, 2013, 10:57:56 am
Yeah the extend thing fixed the issue, though I'm not entirely happy with the results, I'm thinking of trying the tilemaps feature, would that solve the rounding issue, if I snap the tile pieces to pixels?
Title: Re: Edge bleeding with solid shaders.
Post by: unikronsoftware on October 30, 2013, 07:45:59 pm
The tile map would ensure the tiles are all laid out on the grid, but you still will need to make sure your camera is snapped to a pixel and isn't downscaling. Its a filtering error thats causing it to happen - I suppose its possible to try to avoid by offsetting the UVs in slightly, but that will just have a nasty side effect of making the pixels not perfectly square under all circumstances.