Using shader graphs to add an outline to a sprite of a tank. Despite following tutorials, the outline distorts the sprite

Viewed 430

I'm trying to add a black outline surrounding a sprite I have for a tank.

I've tried following every tutorial I could find on 2d outlines for sprites, however almost all of them were done using a previous unity version (I'm using 2021.1.3f1) and don't seem to have any of the problems I've been having.

After using Alpha subtraction on an offset copy of the sample texture (and multiplying by a color) I then try to add it back to the original sample texture. That's when things go wrong, no matter what I've tried it keeps either chopping off the right side of the sprite (I was trying to add the left outline first), or making the right side of the sprite the opposite color of what I'm putting on the left.

enter image description here

What I mean by "cutting off the right", those treads should be the same thickness on the right as on the left, it's like adding the outline to one side trimmed the other.

If it matters, the sprite is a PNG I got from Kenney and then modified in Krita. For whatever reason, changing the color of the outline seems to also change how much is getting trimmed.

I've been banging my head against this for four hours now, any ideas or suggestions are greatly appreciated.

Update: After following One Full Time Equivalent's suggestion below I do get an outline surrounding the entire sprite, but now it's distorting the colors at the edges of the sprite as seen here: enter image description here

After replacing Add with Blend enter image description here

1 Answers

After your subtraction node, put in an Absolute node, otherwise you will subtract the right edge in the alpha channel (this is exactly what you observe right now). Always be aware that you can only see half the color space and negative channels can be tricky to deal with.

Related