How to create a simple outline around a PNG sprite?

Really nice topic. I wish I had some of this information long ago when I was starting out with shaders. I use essentially the same technique in my game for outline shader, but on meshes. You just first render its silhouette, and then it’s the same.


image

for sprites, i feel it would be better to bake the outline into the sprite, but that would require a lot of additional work and would mess with the sizes of the sprites too. It’s a trade-off.

I think you have to basically shrink the sprite by the outline width. And expand the drawn particle. Shrinking the sprite is simple enough. You need the have the resolution of the sprite inside the shader for that, so you can scale the UV and offset it.