Skip to content

Commit 1e008b0

Browse files
authored
Void particles outline (#2171)
As delivered by PixelFrog, and composed the 3 of them in a row with GIMP. And change the amount of rows to 3, the new amount of particle variations. ## Void enemy: Add outline to all particles To do it, because the GPUParticle2D needs a CanvasItemMaterial for the 3 variations, add a CanvasGroup and apply the outline shader to it. Also, change the particles to: - Animate the scale animation now starting at zero and ending at zero too. - Do not animate the alpha of particles anymore. - Emit from the sphere surface (not from sphere). Resolve #1857
1 parent 2a72538 commit 1e008b0

6 files changed

Lines changed: 51 additions & 14 deletions

File tree

Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Particles CanvasGroup outline effect.
3+
*
4+
* SPDX-FileCopyrightText: The Threadbare Authors
5+
* SPDX-License-Identifier: MPL-2.0
6+
*/
7+
shader_type canvas_item;
8+
render_mode unshaded;
9+
10+
uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest;
11+
12+
uniform vec4 outline_color : source_color = vec4(1.0);
13+
uniform float thickness : hint_range(0.0, 10.0) = 2.0;
14+
15+
16+
void fragment() {
17+
vec4 color = textureLod(screen_texture, SCREEN_UV, 0.0);
18+
19+
vec4 outline = texture(screen_texture, SCREEN_UV - vec2(thickness, 0.0) * SCREEN_PIXEL_SIZE);
20+
outline += texture(screen_texture, SCREEN_UV + vec2(thickness, 0.0) * SCREEN_PIXEL_SIZE);
21+
outline += texture(screen_texture, SCREEN_UV - vec2(0.0, thickness) * SCREEN_PIXEL_SIZE);
22+
outline += texture(screen_texture, SCREEN_UV + vec2(0.0, thickness) * SCREEN_PIXEL_SIZE);
23+
24+
outline.rgb = outline_color.rgb;
25+
outline.a *= outline_color.a;
26+
27+
if (color.a > 0.0001) {
28+
color.rgb /= color.a;
29+
}
30+
31+
COLOR *= mix(outline, color, color.a);
32+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://dvyec12fgsuta

scenes/quests/lore_quests/quest_002/1_void_runner/components/void_particles.tscn

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,21 @@
44

55
[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_31awk"]
66
particles_animation = true
7-
particles_anim_h_frames = 5
7+
particles_anim_h_frames = 3
88
particles_anim_v_frames = 1
99
particles_anim_loop = false
1010

11-
[sub_resource type="Curve" id="Curve_8l6e1"]
12-
_data = [Vector2(0, 0.733414), 0.0, 0.0, 0, 0, Vector2(0.315152, 0.717732), 0.0, 0.0, 0, 0, Vector2(0.9, 0), 0.0, 0.0, 0, 0, Vector2(0.99697, 0), 0.0, 0.0, 0, 0]
13-
point_count = 4
14-
15-
[sub_resource type="CurveTexture" id="CurveTexture_rrhr1"]
16-
curve = SubResource("Curve_8l6e1")
17-
1811
[sub_resource type="Curve" id="Curve_304le"]
19-
_data = [Vector2(0, 1), 0.0, 1.4, 0, 0, Vector2(1, 0.407895), 0.0, 0.0, 0, 0]
12+
_data = [Vector2(0, 0.033189893), 0.0, 6.926748, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
2013
point_count = 2
14+
metadata/_snap_count = 2
2115

2216
[sub_resource type="CurveTexture" id="CurveTexture_45we0"]
2317
curve = SubResource("Curve_304le")
2418

2519
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_rrhr1"]
2620
particle_flag_disable_z = true
27-
emission_shape = 1
21+
emission_shape = 2
2822
emission_sphere_radius = 120.0
2923
angular_velocity_min = -10.0
3024
angular_velocity_max = 9.99998
@@ -34,7 +28,6 @@ gravity = Vector3(0, 0, 0)
3428
scale_min = 1.8
3529
scale_max = 2.0
3630
scale_curve = SubResource("CurveTexture_45we0")
37-
alpha_curve = SubResource("CurveTexture_rrhr1")
3831
anim_offset_max = 1.0
3932

4033
[node name="GPUParticles2D" type="GPUParticles2D" unique_id=1339463382]

scenes/quests/lore_quests/quest_002/1_void_runner/components/void_spreading_enemy.gd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ var _live_particles: int = 0
4747
@onready var path_walk_behavior: PathWalkBehavior = %PathWalkBehavior
4848
@onready var follow_walk_behavior: NavigationFollowWalkBehavior = %NavigationFollowWalkBehavior
4949
@onready var alert_animation: AnimationPlayer = %AlertAnimation
50+
@onready var particles_canvas_group: CanvasGroup = %ParticlesCanvasGroup
5051

5152

5253
func _set_idle_patrol_path(new_path: Path2D) -> void:
@@ -123,7 +124,7 @@ func _emit_particles() -> void:
123124

124125
var particles: GPUParticles2D = VOID_PARTICLES.instantiate()
125126
particles.emitting = true
126-
add_child(particles)
127+
particles_canvas_group.add_child(particles)
127128
_live_particles += 1
128129

129130
await particles.finished

scenes/quests/lore_quests/quest_002/1_void_runner/components/void_spreading_enemy.tscn

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
[ext_resource type="Script" uid="uid://csev4hv57utxv" path="res://scenes/game_logic/walk_behaviors/character_speeds.gd" id="3_45we0"]
77
[ext_resource type="AudioStream" uid="uid://dgpeb1dtmfqud" path="res://assets/third_party/sounds/characters/enemies/guard/AlertSound.ogg" id="5_2dnul"]
88
[ext_resource type="Texture2D" uid="uid://c75ofhy3swhj3" path="res://scenes/game_elements/characters/enemies/guard/components/exclamation_mark.png" id="6_pumxu"]
9+
[ext_resource type="Shader" uid="uid://dvyec12fgsuta" path="res://scenes/quests/lore_quests/quest_002/1_void_runner/components/particles_canvasgroup_outline.gdshader" id="7_o4sxw"]
910

1011
[sub_resource type="RectangleShape2D" id="RectangleShape2D_8g3pn"]
1112
size = Vector2(68, 20)
@@ -99,6 +100,11 @@ _data = {
99100
&"alert": SubResource("Animation_pumxu")
100101
}
101102

103+
[sub_resource type="ShaderMaterial" id="ShaderMaterial_gwqur"]
104+
shader = ExtResource("7_o4sxw")
105+
shader_parameter/outline_color = Color(1, 1, 1, 1)
106+
shader_parameter/thickness = 2.0
107+
102108
[node name="VoidSpreadingEnemy" type="CharacterBody2D" unique_id=1007896559]
103109
collision_layer = 0
104110
collision_mask = 0
@@ -159,4 +165,8 @@ texture = ExtResource("6_pumxu")
159165
unique_name_in_owner = true
160166
libraries/ = SubResource("AnimationLibrary_gwqur")
161167

168+
[node name="ParticlesCanvasGroup" type="CanvasGroup" parent="." unique_id=574273484]
169+
unique_name_in_owner = true
170+
material = SubResource("ShaderMaterial_gwqur")
171+
162172
[connection signal="body_entered" from="PlayerCaptureArea" to="." method="_on_player_capture_area_body_entered"]

0 commit comments

Comments
 (0)