Skip to content
shader graph outline for sprites, how do you stop the edges getting cut off?
question1 min read63 viewsSep 13, 2026

shader graph outline for sprites, how do you stop the edges getting cut off?

Jake Morrison@jakemakesgames

September 13, 2026 · 1 min read

#1 in Pixels and Polygons

63 views5 comments

trying to do a simple 1px outline on sprites when you hover them, to show you can interact. shader graph in URP 2D. my approach: sample the main texture alpha 4 times with the UV offset by one texel up, down, left and right, add them up, subtract the original alpha, use that as the outline mask

it works... except the outline is cut off at the edges of the sprite. like the top of the characters head has no outline at all, and neither do the sides of the fence posts

texel size comes from the _MainTex_TexelSize property so that part seems right. what am i missing?

Top answer

Jake Morrison#1 in Pixels and Polygons2 likes

solved, posting for future me: 1. sprite import settings, Mesh Type: Full Rect instead of Tight. tight hugs the visible pixels so there are no fragments outside the art to draw the outline on 2. the sprite needs at least 1px of transparent padding in the texture. mine were cropped exactly to the art 3. if you use a sprite atlas, set padding to 2 or more or the neighbour sprite bleeds into your outline thanks tunde, rubber duck of the day

View in the thread

Written by

Jake Morrison

indie game dev in melbourne, making a cosy farming game in unity that is definitely shipping this year (3rd year saying this). shaders, pixel art, coffee

Get the best of #pixels-and-polygons weekly

One email each Monday with the most useful posts. No spam; unsubscribe in one click.

Comments

5

Sign in to join the conversation.

Sign in to comment
Tunde Adebayo@tunde_ade#2 in Pixels and Polygons
not a unity guy but when i had this in flutter shaders it was because the geometry ended exactly where the visible pixels ended, so there was nowhere to draw the outline. does unity crop the sprite mesh?
1 net votes
Jake Morrison@jakemakesgames#1 in Pixels and Polygons
ooh. it does by default i think (tight mesh). checking
0 net votes
Jake Morrison@jakemakesgames#1 in Pixels and Polygons
solved, posting for future me: 1. sprite import settings, Mesh Type: Full Rect instead of Tight. tight hugs the visible pixels so there are no fragments outside the art to draw the outline on 2. the sprite needs at least 1px of transparent padding in the texture. mine were cropped exactly to the art 3. if you use a sprite atlas, set padding to 2 or more or the neighbour sprite bleeds into your outline thanks tunde, rubber duck of the day
2 net votes
Mariana Costa@mari_costa#2 in Pixels and Polygons
Nice detail for the hover state. Maybe also add a small prompt icon or label, a 1px outline is hard to see for some players.
1 net votes
Jake Morrison@jakemakesgames#1 in Pixels and Polygons
good shout, adding a little prompt above the object too. accessibility in a cosy game should be a no brainer
0 net votes