diff --git a/DungeonShooting_Godot/prefab/bullet/Bullet0001.tscn b/DungeonShooting_Godot/prefab/bullet/Bullet0001.tscn index 0a44b2f..858cd81 100644 --- a/DungeonShooting_Godot/prefab/bullet/Bullet0001.tscn +++ b/DungeonShooting_Godot/prefab/bullet/Bullet0001.tscn @@ -13,6 +13,7 @@ shader_parameter/show_outline = false shader_parameter/outline_color = Color(0, 0, 0, 1) shader_parameter/outline_rainbow = false +shader_parameter/outline_use_blend = true [sub_resource type="ShaderMaterial" id="ShaderMaterial_qhkgc"] resource_local_to_scene = true @@ -23,6 +24,7 @@ shader_parameter/show_outline = false shader_parameter/outline_color = Color(0, 0, 0, 1) shader_parameter/outline_rainbow = false +shader_parameter/outline_use_blend = true [sub_resource type="SpriteFrames" id="SpriteFrames_5wvmf"] animations = [{ @@ -51,7 +53,6 @@ material = SubResource("ShaderMaterial_w5w0i") [node name="AnimatedSprite" type="AnimatedSprite2D" parent="."] -modulate = Color(1.6, 1.6, 1.6, 1) material = SubResource("ShaderMaterial_qhkgc") sprite_frames = SubResource("SpriteFrames_5wvmf") diff --git a/DungeonShooting_Godot/prefab/bullet/Bullet0002.tscn b/DungeonShooting_Godot/prefab/bullet/Bullet0002.tscn index 1cb086c..7ff1c64 100644 --- a/DungeonShooting_Godot/prefab/bullet/Bullet0002.tscn +++ b/DungeonShooting_Godot/prefab/bullet/Bullet0002.tscn @@ -13,6 +13,7 @@ shader_parameter/show_outline = false shader_parameter/outline_color = Color(0, 0, 0, 1) shader_parameter/outline_rainbow = false +shader_parameter/outline_use_blend = true [sub_resource type="ShaderMaterial" id="ShaderMaterial_p0wfd"] resource_local_to_scene = true @@ -23,6 +24,7 @@ shader_parameter/show_outline = false shader_parameter/outline_color = Color(0, 0, 0, 1) shader_parameter/outline_rainbow = false +shader_parameter/outline_use_blend = true [sub_resource type="CircleShape2D" id="CircleShape2D_0vxfv"] radius = 3.0 diff --git a/DungeonShooting_Godot/prefab/role/Enemy0001.tscn b/DungeonShooting_Godot/prefab/role/Enemy0001.tscn index 46e01b2..866f829 100644 --- a/DungeonShooting_Godot/prefab/role/Enemy0001.tscn +++ b/DungeonShooting_Godot/prefab/role/Enemy0001.tscn @@ -14,6 +14,7 @@ shader_parameter/show_outline = true shader_parameter/outline_color = Color(0, 0, 0, 1) shader_parameter/outline_rainbow = false +shader_parameter/outline_use_blend = true [sub_resource type="ShaderMaterial" id="ShaderMaterial_k8mt5"] resource_local_to_scene = true @@ -24,6 +25,7 @@ shader_parameter/show_outline = true shader_parameter/outline_color = Color(0, 0, 0, 1) shader_parameter/outline_rainbow = false +shader_parameter/outline_use_blend = true [node name="Enemy0001" node_paths=PackedStringArray("HurtArea", "HurtCollision", "MountPoint", "BackMountPoint", "InteractiveArea", "InteractiveCollision", "MeleeAttackArea", "MeleeAttackCollision", "ShadowSprite", "AnimatedSprite", "Collision") instance=ExtResource("1_5po38")] collision_layer = 16 diff --git a/DungeonShooting_Godot/resource/material/Blend.gdshader b/DungeonShooting_Godot/resource/material/Blend.gdshader index f83601b..f952fc5 100644 --- a/DungeonShooting_Godot/resource/material/Blend.gdshader +++ b/DungeonShooting_Godot/resource/material/Blend.gdshader @@ -4,8 +4,7 @@ uniform vec4 blend : source_color = vec4(1.0, 1.0, 1.0, 1.0); //混合度 uniform float schedule : hint_range(0.0, 1.0) = 0.0; -//透明度 -//uniform float alpha : hint_range(0.0, 1.0) = 1.0; +// uniform vec4 modulate : source_color = vec4(1.0, 1.0, 1.0, 1.0); //------------------ 轮廓相关 -------------- @@ -13,15 +12,18 @@ //轮廓颜色 uniform vec4 outline_color : source_color = vec4(0.0, 0.0, 0.0, 1.0); //是否是彩虹轮廓 -uniform bool outline_rainbow = false; +uniform bool outline_rainbow = false; +//轮廓是否使用 blend +uniform bool outline_use_blend = true; + //彩虹轮廓变化周期 const float frequency = 0.25; const float light_offset = 0.5; void fragment() { + float a = COLOR.a; //显示轮廓 - if (show_outline) { - vec4 color = texture(TEXTURE, UV); + if (show_outline && a == 0.0) { vec2 size = TEXTURE_PIXEL_SIZE; float outline; outline = texture(TEXTURE, UV + vec2(-size.x, 0)).a; @@ -29,25 +31,28 @@ outline += texture(TEXTURE, UV + vec2(size.x, 0)).a; outline += texture(TEXTURE, UV + vec2(0, -size.y)).a; outline = min(outline, 1.0); - - if (color.a == 0.0 && outline > 0.0) { - 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)), - 1.0 - ); - + if (outline > 0.0) { if (outline_rainbow){ - COLOR = mix(color, animated_line_color, 1); + 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)), + 1.0 + ); + COLOR = mix(COLOR, animated_line_color, 1); + a = animated_line_color.a; } else { - COLOR = mix(color, outline_color , 1); + COLOR = mix(COLOR, outline_color , 1); + a = outline_color.a; } } + if (outline_use_blend) { + COLOR = mix(COLOR, blend, schedule); + } + } else { //非轮廓 + COLOR = mix(COLOR, blend, schedule); } - vec4 col = mix(COLOR, blend, schedule); - col = mix(vec4(0.0, 0.0, 0.0, 0.0), col, COLOR.a); - col *= modulate; - COLOR = col; + COLOR.a *= a; + COLOR *= modulate; }