From 2e1d15a0a0d10dca3fd992bf345898fb975f507a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=A8=E8=90=BD=E5=9F=BA=E5=9B=B4=E8=99=BE?= <3161880837@qq.com> Date: Wed, 27 Aug 2025 14:59:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E6=BF=80=E5=85=89?= =?UTF-8?q?=E6=9D=90=E8=B4=A8=E5=92=8C=E7=9D=80=E8=89=B2=E5=99=A8=E5=8F=82?= =?UTF-8?q?=E6=95=B0=EF=BC=8C=E4=BC=98=E5=8C=96=E6=BF=80=E5=85=89=E6=95=88?= =?UTF-8?q?=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Bullets/Laser.tscn | 6 ++++-- shaders/Laser.gdshader | 10 +++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/components/Bullets/Laser.tscn b/components/Bullets/Laser.tscn index 64b5380..2e1f801 100644 --- a/components/Bullets/Laser.tscn +++ b/components/Bullets/Laser.tscn @@ -8,6 +8,9 @@ [sub_resource type="ShaderMaterial" id="ShaderMaterial_5n8cv"] shader = ExtResource("2_h6cxi") +shader_parameter/color = Color(0.654902, 1, 1, 1) +shader_parameter/laser_width = 0.01 +shader_parameter/soft_edge = 0.5 [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_y85id"] height = 300.0 @@ -29,10 +32,9 @@ sprite_frames = SubResource("SpriteFrames_yip5k") material = SubResource("ShaderMaterial_5n8cv") offset_left = -10.0 offset_top = -300.0 -offset_right = 19.0 +offset_right = 10.0 [node name="hitbox" parent="." index="1"] -visible = false position = Vector2(150, 0) rotation = 1.5708 shape = SubResource("CapsuleShape2D_y85id") diff --git a/shaders/Laser.gdshader b/shaders/Laser.gdshader index a629778..4154724 100644 --- a/shaders/Laser.gdshader +++ b/shaders/Laser.gdshader @@ -3,14 +3,10 @@ uniform vec4 color: source_color; uniform float laser_width: hint_range(0.01, 1.0) = 0; uniform float soft_edge: hint_range(0.0, 0.5) = 0.5; void fragment() { - float textureWidth=float(textureSize(TEXTURE,0).x); - float textureHeight=float(textureSize(TEXTURE,0).y); - float radius=textureHeight/2.0; - float radiusU=radius*TEXTURE_PIXEL_SIZE; - float dist = distance(vec2(0.5,clamp(UV.y,radiusU,1.0-radiusU)),UV); + float dist = abs(UV.x - 0.5); float core = 1.0 - smoothstep(0.0, laser_width, dist); - float edge=1.0 - smoothstep(laser_width, laser_width + soft_edge, dist); - float alpha = max(core, edge); + float edge = 1.0 - smoothstep(laser_width, laser_width + soft_edge, dist); + float alpha = max(core, edge); COLOR = color; COLOR.a = alpha; } \ No newline at end of file