Skip to content

Instantly share code, notes, and snippets.

@kzerot
Created May 8, 2020 12:55
Show Gist options
  • Save kzerot/07a4251031efcb683eb0a8d3158e6d3b to your computer and use it in GitHub Desktop.
Save kzerot/07a4251031efcb683eb0a8d3158e6d3b to your computer and use it in GitHub Desktop.
Simple godot shader
shader_type canvas_item;
uniform vec4 col : hint_color;
uniform float eff_str = 0.8;
float rand(float x){
return fract(cos(x) * 2345.6789);
}
float triangle(float x){
return abs(1.0 - mod(abs(x), 2.0)) * 2.0 - 1.0;
}
void fragment()
{
float time = floor( TIME * 12.0) / 4.0;
vec2 uv = SCREEN_UV;
vec2 p = uv;
p += vec2(triangle(p.y * rand(time) * 4.0) * rand(time * 1.9) * 0.013,
triangle(p.x * rand(time * 3.2) * 4.0) * rand(time * 2.1) * 0.013) * eff_str;
p += vec2(rand(p.x * 3.2 + p.y * 7.9) * 0.01,
rand(p.x * 1.1 + p.y * 6.7) * 0.01) *eff_str;
vec4 baseColor = vec4(texture(SCREEN_TEXTURE, uv).rgb,1.);
vec4 edges = 1.0 - (baseColor / vec4(texture(SCREEN_TEXTURE,p).rgb, 1.));
float l = clamp(length(edges), 0., 1.5);
COLOR.rgb = vec3(col.rgb * l);
COLOR.a = l * 0.6 * col.a;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment