76 lines
2.3 KiB
Plaintext
76 lines
2.3 KiB
Plaintext
|
[gd_resource type="ShaderMaterial" load_steps=2 format=2]
|
||
|
|
||
|
[sub_resource type="Shader" id=1]
|
||
|
code = "shader_type canvas_item;
|
||
|
|
||
|
uniform vec4 line_color : hint_color = vec4(1);
|
||
|
uniform float line_thickness : hint_range(0, 50) = 1.0;
|
||
|
|
||
|
uniform bool rainbow = false; //Activate the rainbow or select you color
|
||
|
uniform float line_scale : hint_range(0, 20) = 1.2; // thickness of the line
|
||
|
uniform float frequency : hint_range(0.0, 2.0) = 0.5; // frequency of the rainbow
|
||
|
uniform float light_offset : hint_range(0.00001, 1.0) = 0.5; // this offsets all color channels;
|
||
|
uniform float alpha : hint_range(0.0, 1.0) = 1.0;
|
||
|
|
||
|
|
||
|
void fragment() {
|
||
|
vec2 size = TEXTURE_PIXEL_SIZE * line_thickness;
|
||
|
|
||
|
float outline = texture(TEXTURE, UV + vec2(-size.x, 0)).a;
|
||
|
outline += texture(TEXTURE, UV + vec2(0, size.y)).a;
|
||
|
|
||
|
outline += texture(TEXTURE, UV + vec2(size.x, 0)).a;
|
||
|
|
||
|
outline += texture(TEXTURE, UV + vec2(0, -size.y)).a;
|
||
|
|
||
|
|
||
|
outline += texture(TEXTURE, UV + vec2(-size.x, size.y)).a;
|
||
|
|
||
|
outline += texture(TEXTURE, UV + vec2(-size.x, size.y * 0.5)).a;
|
||
|
|
||
|
|
||
|
|
||
|
outline += texture(TEXTURE, UV + vec2(size.x, size.y)).a;
|
||
|
outline += texture(TEXTURE, UV + vec2(size.x, size.y * 0.5)).a;
|
||
|
|
||
|
|
||
|
outline += texture(TEXTURE, UV + vec2(-size.x, -size.y)).a;
|
||
|
outline += texture(TEXTURE, UV + vec2(-size.x, -size.y * 0.5)).a;
|
||
|
|
||
|
|
||
|
|
||
|
outline += texture(TEXTURE, UV + vec2(size.x, -size.y)).a;
|
||
|
outline += texture(TEXTURE, UV + vec2(size.x, -size.y * 0.5)).a;
|
||
|
|
||
|
|
||
|
outline = min(outline, 1.0);
|
||
|
|
||
|
|
||
|
vec4 color = texture(TEXTURE, UV);
|
||
|
|
||
|
vec4 animated_line_color = vec4(light_offset + sin(2.0*3.14*frequency*TIME),
|
||
|
light_offset + sin(2.0*3.14*frequency*TIME + radians(120.0)),
|
||
|
light_offset + sin(2.0*3.14*frequency*TIME + radians(240.0)),
|
||
|
alpha);
|
||
|
|
||
|
|
||
|
if (rainbow == true){//if rainbow is activated
|
||
|
COLOR = mix(color, animated_line_color, outline - color.a);
|
||
|
}
|
||
|
if (rainbow == false){//if rainbow not is activated and you pick a color
|
||
|
COLOR = mix(color, line_color , outline - color.a);
|
||
|
}
|
||
|
|
||
|
// COLOR = mix(color, line_color, outline - color.a);
|
||
|
}"
|
||
|
|
||
|
[resource]
|
||
|
shader = SubResource( 1 )
|
||
|
shader_param/line_color = Color( 1, 1, 1, 1 )
|
||
|
shader_param/line_thickness = 35.0
|
||
|
shader_param/rainbow = true
|
||
|
shader_param/line_scale = 1.2
|
||
|
shader_param/frequency = 0.25
|
||
|
shader_param/light_offset = 0.5
|
||
|
shader_param/alpha = 1.0
|