[Shader] 2D Pixel Outline Shaders, Unlit + Diffuse
I noticed developer Miguelita (https://twitter.com/wtfmig) created an outline shader for his game, and I found there weren't that many around and available to choose from so I decided to make my own as well and offer it for free.

I based my initial Surface shader off some of the combined work here:


http://answers.unity3d.com/questions/680443/shader-edit-help-2d-outline-coloring.html


However, the shader required the user to adjust settings to get a near-perfect outline. Also being a surface shader meant that it was more difficult to create an unlit version with the technique.


So I modified the original shader so it takes into consideration the size of the the sprite so that when the offset of the pixel outline is 1, it gives an exact outline instead having you do guesswork. This shader also still reacts to light, so point lights will work on it like a standard diffuse.


I then rewrote the shader as a fragment shader so that it could be unlit and replace the standard default sprite shader, while keeping things like pixel-snapping.


Additionally, I added the ability to tint the inside (sprite) apart from the outline, as well as have an "overall" tint. Furthermore, transparency is supported on both the inner sprite and the outline. However, "0" transparency won't work on the inner sprite, due to how the shader is calculated, for that reason it goes quite low and can still be basically invisible if you need just an outline.


The shader is only really useful for a 1px outline, but I added in an offset for those that want to alter that still, possibly for a nifty select animation.


Attached is a UnityPackage containing both shaders. Let me know if you have problems.

Tier Benefits
Recent Posts