Доработка. Мигание при обновлении отметок целей

This commit is contained in:
sasha80
2025-03-31 11:54:24 +03:00
parent e5e8a6f937
commit 32b288db9d
4 changed files with 28 additions and 22 deletions

View File

@@ -194,3 +194,10 @@ renderer/rendering_method.mobile="gl_compatibility"
shader_compiler/shader_cache/strip_debug=true shader_compiler/shader_cache/strip_debug=true
anti_aliasing/quality/msaa_2d=1 anti_aliasing/quality/msaa_2d=1
quality/driver/fallback_to_gles2=true quality/driver/fallback_to_gles2=true
[shader_globals]
ticks_msec={
"type": "int",
"value": 0
}

View File

@@ -1,9 +1,16 @@
[gd_scene load_steps=12 format=3 uid="uid://nl1vklubr5kr"] [gd_scene load_steps=14 format=3 uid="uid://nl1vklubr5kr"]
[ext_resource type="Script" uid="uid://y4l1v8eqayr0" path="res://scenes/bip/bip.gd" id="1_h7l70"] [ext_resource type="Script" uid="uid://y4l1v8eqayr0" path="res://scenes/bip/bip.gd" id="1_h7l70"]
[ext_resource type="Texture2D" uid="uid://cp4bv6lh8w83k" path="res://data/bip.png" id="2_yjvg0"] [ext_resource type="Shader" uid="uid://n6xe6w76iw3v" path="res://shaders/bip.gdshader" id="2_ybnsn"]
[ext_resource type="Shader" uid="uid://da53rd1r7al8l" path="res://shaders/tracked.gdshader" id="3_2a1qb"] [ext_resource type="Shader" uid="uid://da53rd1r7al8l" path="res://shaders/tracked.gdshader" id="3_2a1qb"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_qq6yq"]
shader = ExtResource("2_ybnsn")
shader_parameter/tick_update = 0
shader_parameter/time_delta = 200
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_xbpqf"]
[sub_resource type="Shader" id="Shader_60ho7"] [sub_resource type="Shader" id="Shader_60ho7"]
code = "shader_type canvas_item; code = "shader_type canvas_item;
@@ -217,19 +224,11 @@ layout_mode = 3
anchors_preset = 0 anchors_preset = 0
script = ExtResource("1_h7l70") script = ExtResource("1_h7l70")
[node name="bip" type="TextureButton" parent="."] [node name="bip" type="Sprite2D" parent="."]
layout_direction = 1 material = SubResource("ShaderMaterial_qq6yq")
layout_mode = 0 position = Vector2(10, 10)
offset_left = 10.0 scale = Vector2(20, 20)
offset_top = 10.0 texture = SubResource("PlaceholderTexture2D_xbpqf")
offset_right = 10.0
offset_bottom = 10.0
scale = Vector2(0.4, 0.4)
action_mode = 0
button_mask = 3
texture_normal = ExtResource("2_yjvg0")
ignore_texture_size = true
stretch_mode = 3
[node name="selector" type="Sprite2D" parent="."] [node name="selector" type="Sprite2D" parent="."]
material = SubResource("ShaderMaterial_fkqwb") material = SubResource("ShaderMaterial_fkqwb")
@@ -256,5 +255,3 @@ material = SubResource("ShaderMaterial_lkrha")
position = Vector2(10, 10) position = Vector2(10, 10)
scale = Vector2(26, 26) scale = Vector2(26, 26)
texture = SubResource("PlaceholderTexture2D_svd33") texture = SubResource("PlaceholderTexture2D_svd33")
[connection signal="gui_input" from="bip" to="." method="_on_bip_gui_input"]

View File

@@ -250,6 +250,7 @@ func get_tcp_data(sock: SocketTCP, peer, len_rx):
func _process(_delta: float) -> void: func _process(_delta: float) -> void:
tick = Time.get_ticks_msec() tick = Time.get_ticks_msec()
RenderingServer.global_shader_parameter_set('ticks_msec', tick)
for addr in units_udp: for addr in units_udp:
var unit = units[addr] var unit = units[addr]
match unit.process(tick): match unit.process(tick):

View File

@@ -3,20 +3,21 @@ shader_type canvas_item;
#include "res://shaders/tools.gdshaderinc" #include "res://shaders/tools.gdshaderinc"
/* Закрашенная окружность */ /* Закрашенная окружность */
uniform float tick_update = 0.0; /* Время последнего обновления, мс */ uniform int tick_update = 0; /* Время последнего обновления, мс */
const float time_delta = 0.5; /* Время вспышки при обновлении, c */ uniform int time_delta = 200; /* Время вспышки при обновлении, мc */
const float ds = 0.01; /* Относительное расстояние на котором выполняется сглаживание краёв */ const float ds = 0.01; /* Относительное расстояние на котором выполняется сглаживание краёв */
const vec2 center = vec2(0.125, 0.125); /* Центр должен быть в (0.5, 0.5), но это не так */ const vec2 center = vec2(0.125, 0.125); /* Центр должен быть в (0.5, 0.5), но это не так */
const float radius = 0.075 - ds * 2.0; /* Радиус должен быть 0.5, но это не так */ const float radius = 0.075 - ds * 2.0; /* Радиус должен быть 0.5, но это не так */
const float alpha_offset = 0.5; /* Изменние скорости альфа канала */ const float alpha_offset = 0.5; /* Изменние скорости альфа канала */
const float alpha_main = 1.0; const float alpha_main = 1.0;
global uniform int ticks_msec;
void fragment() void fragment()
{ {
float alpha = 0.0; float alpha = alpha_offset;
if ((TIME - tick_update) < time_delta) if ((ticks_msec - tick_update) < time_delta)
{ {
alpha = time_delta - (TIME - tick_update) * alpha_offset; alpha = alpha_main;
} }
COLOR = texture(TEXTURE, UV); COLOR = texture(TEXTURE, UV);
COLOR.a = (alpha_main - alpha) * smooth_px(length(UV - center), radius, ds); COLOR.a = (alpha_main - alpha) * smooth_px(length(UV - center), radius, ds);