- Home /
Outline set of tiled sprites
Hi, I've been trying to outline the ground in my game, like I used to do before I started using Unity. It's been a few days since I've been looking for a solution, so I thought I'd ask my first question here for some guidance. Basically, I want to draw a two pixels wide (relative to the scale of the ground texture, not game pixels) black outline around my ground, which is composed of a tiled sprite renderer and a Box collider 2D.
Because the ground is composed of severals colliders (to make walls, ground, etc), I'm using a shader so that the tiling occurs using the worldspace and not the actual ground position. This way, when two rectangle overlaps, the tilling is respected no matter their coordinates. This requirements makes using a sprite with a predrawn 2 pixels black top/bottom/sides/corner impossible, since the black outline would then appear on overlapping rectangles, and the sides of the sprites wouldn't go to the side of the object but be drawn tiled with world placement.
I then tried to use shaders to make my outline. There are many tutorials out there on how to make a colored outline for a sprite. The problem is that the sprites in these tutorials are often pixel art with no compression and filter mode set to Point (no filter), which isn't my case, so I could only obtain ugly results, and that was only when the tutorial wasn't simply outdated. Finally I noticed that there was an outline component in Unity, but it seem to be used only to outline text.
I'll take any clue on this issue. Thanks!
Here's how my ground looks like now:
And here's how I want it to look like (edited picture):