Files
uarep-ctl/shaders/strips.gdshader
2024-06-14 14:57:29 +03:00

47 lines
1.4 KiB
Plaintext

shader_type canvas_item;
#include "res://shaders/tools.gdshaderinc"
const vec2 center = vec2(0.125, 0.125);
const float sharpness = 300.0;
uniform float rotation = 0.0;
uniform vec4 color = vec4(1.0, 1.0, 1.0, 1.0);
uniform float width = 1.0;
uniform float speed = 1.0;
uniform bool disabled = false;
uniform vec2 scale = vec2(1.0, 1.0);
void vertex()
{
rotate_vec2(UV, rotation, center);
}
void fragment()
{
COLOR = color;
if (disabled)
{
float ds = 1.0 / sharpness;
float tx = float(int(TIME * 1000.0 * speed) % 10000) / 1000.0 * center.x + center.x;
COLOR.a = 0.0;
vec2 uv = UV;
rotate_vec2(uv, -rotation, center);
float v3 = smoothstep(0.0, 1.0, (uv.x - center.x / 2.0 / scale.x) * sharpness);
float v4 = smoothstep(0.0, 1.0, (uv.y - center.y / 2.0 / scale.y) * sharpness);
float v5 = smoothstep(0.0, 1.0, (center.x * 2.0 - center.x / 2.0 / scale.x - uv.x) * sharpness);
float v6 = smoothstep(0.0, 1.0, (center.y * 2.0 - center.y / 2.0 / scale.y - uv.y) * sharpness);
for (float x = -2.0; x < 2.0; x += 0.03)
{
float v0 = smoothstep(0.0, 1.0, (tx - UV.x + x) * sharpness + width);
float v1 = smoothstep(0.0, 1.0, (UV.x - tx - x) * sharpness + width);
float v2 = smooth_px(length(UV.x - center.x), center.x * 2.0 - ds, ds);
COLOR.a += v0 * v1 * v2 * v3 * v4 * v5 * v6;
}
COLOR.a *= color.a;
}
}