Hello Guest

Author Topic: Edge bleeding with solid shaders.  (Read 6037 times)

Bigcheese

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 19
    • View Profile
Edge bleeding with solid shaders.
« 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.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Edge bleeding with solid shaders.
« Reply #1 on: October 28, 2013, 04:05:19 pm »
How are you drawing the sprites? Are they pixel perfect?

Bigcheese

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Edge bleeding with solid shaders.
« Reply #2 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.

Bigcheese

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Edge bleeding with solid shaders.
« Reply #3 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.

Bigcheese

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Edge bleeding with solid shaders.
« Reply #4 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

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Edge bleeding with solid shaders.
« Reply #5 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)

Bigcheese

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Edge bleeding with solid shaders.
« Reply #6 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?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Edge bleeding with solid shaders.
« Reply #7 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.