cirnogodot/Shaders/minimal_laser.gdshader
2026-01-02 16:06:26 +01:00

23 lines
813 B
Text

shader_type spatial;
render_mode unshaded, blend_add, cull_disabled, depth_draw_opaque;
uniform vec3 beam_color : source_color = vec3(1.0, 0.2, 0.2);
uniform float glow_radius = 0.2; // fraction of cylinder radius
uniform float noise_speed = 1.0;
uniform float flicker_strength = 0.2;
void fragment() {
// Compute distance from center axis
// Cylinder UV: Y goes along height, X around circumference
float d = length(UV - vec2(0.5, 0.0)); // UV.x = around circumference, UV.y along height
// Glow: smooth edge
float alpha = smoothstep(0.5, 0.5 - glow_radius, d);
// Optional flicker along the beam (animated by Y)
float flicker = sin(UV.y * 20.0 + TIME * noise_speed) * flicker_strength;
alpha = clamp(alpha + flicker, 0.0, 1.0);
ALBEDO = beam_color;
ALPHA = alpha;
}