Sprite has extruded edges after applying custom shader [Solved]

Hey guys

I made a Sprite lit shader graph that draws an outline around a sprite, but for some reason it creates these extruded edges around the sprite. How do I solve that? The default shader Sprite-Lit-Default doesn’t seem to have the same issue.

This is the Sprite-Lit-Default shader

My custom shader

Any help would be greatly appreciated. Thanks in advance :slight_smile:

7486118--921185--1.PNG
7486118--921188--sprite-lit-default.PNG
7486118--921191--2.PNG

Would be nice to see the shader because otherwise I’m just speculating.

My guess is that you’re not passing the alpha from the _MainTex to output / final color.

What you’re seeing there is the shape of the Sprite’s mesh, which includes areas that are 100% transparent.

Hi, thanks for the reply. I also thought it might be that. I am passing the alpha from the _MainTex though. There are a few ways to achieve the outline. All of the methods I tried have that same jagged mesh effect. Here is a screenshot of the URP

Youre shader should work but youre sprite not.
The alpha more visible looks like this:

7489703--921989--wrongAlpha.PNG

Try this as sprite:

7489703--921986--alphaCutut.png

1 Like

The alpha is a separate node on the Fragment output, which from the pic is locked at value of 1 for all pixels. Use a split node and connect the alpha directly.

It looks like you’re interpreting the semi-alpha pixels to get an outline, which may not be possible unless you were to carefully tune the alpha of those pixels so that they’re not too transparent along the edge of the rgb.

1 Like

@Lo-renzo Oh yes of course. Thank you. That fixed it!

The tutorials I was following were using an older version of shader graph, which didn’t have the alpha node exposed on the Fragment section. It is fixed by connecting the alpha of the sample with the alpha of the fragment. Thanks again :slight_smile:

7492414--922435--OutlineFixed.PNG