The simplest outline shader (canvas_item)
Simple outline shader. Does not work with pixel art and requires partly transparent pixels around the character.
https://www.youtube.com/watch?v=EU022XHDOHw&t=56s
# Learn how to create 2D shaders like these
Want to master 2D shaders? Learn how to create stunning effects like these and more by gaining a deep understanding of the GDShader language in Godot:
# Credits sprite
Credits to the creator of this cool necromancer sprite!
https://creativekind.itch.io
Shader code
shader_type canvas_item;
uniform vec3 outline_c: source_color;
uniform float progress: hint_range(0.0, 1.0);
void fragment() {
COLOR = mix(COLOR, vec4(outline_c, COLOR.a), progress - COLOR.a * progress);
}
Why does this code achieve an outline effect? It doesn’t seem to set up an outline explicitly. Could you explain?
Added the video in the description. It uses partly transparent pixels if there are any around a character. It’s not designed to work with pixel art or sprites that do not have partly transparent pixels around the character.
Understood, thank you very much for your response.
You’re a genius who makes use of the translucency of the edges, but it’s also very restrictive
haha thanks! Yeah it’s restrictive, never the less it might help someone somewhere