Skip to content

Instantly share code, notes, and snippets.

@cenullum
Created October 18, 2020 16:30
Show Gist options
  • Save cenullum/b16f87cded4ea3cf15871712c9f6b11a to your computer and use it in GitHub Desktop.
Save cenullum/b16f87cded4ea3cf15871712c9f6b11a to your computer and use it in GitHub Desktop.
Godot Engine Circle with Outline Color Shader
shader_type canvas_item;
uniform vec4 outline_color:hint_color = vec4(1.0,1.0,0.0,1.0);
uniform float inner_circle=0.45;
uniform float outer_circle=0.5;
const vec4 alpha_color= vec4(0,0,0,0);
uniform float smoothness=0.01;
void fragment(){
vec2 origin = UV-vec2(0.5,0.5);
float dist =length(origin); //sqrt(dot(origin,origin));
vec4 _color= mix (texture(TEXTURE,UV),outline_color,smoothstep(inner_circle-smoothness,inner_circle+smoothness,dist));
COLOR= mix (_color,alpha_color,smoothstep(outer_circle-smoothness,outer_circle+smoothness,dist));
}
@cenullum
Copy link
Author

cenullum commented Oct 18, 2020

image
image
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment