Skip to content

Instantly share code, notes, and snippets.

@MauriceButler
Forked from CIOSAI/EdgeTracingShader
Created March 15, 2023 00:31
Show Gist options
  • Save MauriceButler/078fb46e2e0f12dcd1c0618c3ed8a20f to your computer and use it in GitHub Desktop.
Save MauriceButler/078fb46e2e0f12dcd1c0618c3ed8a20f to your computer and use it in GitHub Desktop.
Edge Tracing Shader in Godot
shader_type canvas_item;
uniform sampler2D tex;
uniform float intensity;
uniform vec4 color : hint_color;
uniform float speed;
float sample(in vec2 st){
return texture(tex, st).a;
}
void fragment(){
float t = TIME*speed;
vec2 px = vec2(1.)/vec2(textureSize(tex, 0));
float neighbor =
sample(UV+px*vec2( 1., 0.))+
sample(UV+px*vec2( 0., 1.))+
sample(UV+px*vec2(-1., 0.))+
sample(UV+px*vec2( 0., -1.));
float center = sample(UV)*4.;
float edge = clamp(neighbor-center, 0., 1.);
float lit = dot(UV-vec2(.5), vec2(cos(t), sin(t)))-t;
lit = mod(lit, 1.);
lit = pow(lit, 12.);
COLOR = vec4(color.rgb*vec3(intensity), edge*lit);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment