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

This commit is contained in:
sasha80
2025-04-01 09:27:26 +03:00
parent 32b288db9d
commit edaf6cc78d
6 changed files with 21 additions and 29 deletions

View File

@@ -197,7 +197,7 @@ quality/driver/fallback_to_gles2=true
[shader_globals] [shader_globals]
ticks_msec={ tick_curent={
"type": "int", "type": "int",
"value": 0 "value": 0
} }

View File

@@ -10,15 +10,8 @@ func set_track_visible(value: bool): $track.visible = value
func set_ecm_visible(value: bool): $ecm_done.visible = value func set_ecm_visible(value: bool): $ecm_done.visible = value
func update(_tick_ms: int = 0): pass func update(tick_rx: int):
$bip.set_instance_shader_parameter('tick_update', tick_rx)
## Задаёт цвет
func set_color(color: Color): $bip.self_modulate = color
## Возвращает цвет
func get_color(): return $bip.self_modulate
## Функция присваивает заданое значение видимости селектору. ## Функция присваивает заданое значение видимости селектору.

View File

@@ -6,8 +6,8 @@
[sub_resource type="ShaderMaterial" id="ShaderMaterial_qq6yq"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_qq6yq"]
shader = ExtResource("2_ybnsn") shader = ExtResource("2_ybnsn")
shader_parameter/tick_update = 0 shader_parameter/tick_delta = 200
shader_parameter/time_delta = 200 shader_parameter/radius = 0.06
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_xbpqf"] [sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_xbpqf"]
@@ -231,19 +231,21 @@ scale = Vector2(20, 20)
texture = SubResource("PlaceholderTexture2D_xbpqf") texture = SubResource("PlaceholderTexture2D_xbpqf")
[node name="selector" type="Sprite2D" parent="."] [node name="selector" type="Sprite2D" parent="."]
visible = false
material = SubResource("ShaderMaterial_fkqwb") material = SubResource("ShaderMaterial_fkqwb")
scale = Vector2(20, 20) scale = Vector2(20, 20)
texture = SubResource("PlaceholderTexture2D_hqs6j") texture = SubResource("PlaceholderTexture2D_hqs6j")
centered = false centered = false
[node name="recomendation" type="Sprite2D" parent="."] [node name="recomendation" type="Sprite2D" parent="."]
visible = false
material = SubResource("ShaderMaterial_lpmq6") material = SubResource("ShaderMaterial_lpmq6")
scale = Vector2(20, 20) scale = Vector2(20, 20)
texture = SubResource("PlaceholderTexture2D_hqs6j") texture = SubResource("PlaceholderTexture2D_hqs6j")
centered = false centered = false
metadata/_edit_lock_ = true
[node name="ecm_done" type="Sprite2D" parent="."] [node name="ecm_done" type="Sprite2D" parent="."]
visible = false
material = SubResource("ShaderMaterial_h3oo7") material = SubResource("ShaderMaterial_h3oo7")
position = Vector2(-5, -5) position = Vector2(-5, -5)
scale = Vector2(30, 30) scale = Vector2(30, 30)
@@ -251,6 +253,7 @@ texture = SubResource("PlaceholderTexture2D_hqs6j")
centered = false centered = false
[node name="track" type="Sprite2D" parent="."] [node name="track" type="Sprite2D" parent="."]
visible = false
material = SubResource("ShaderMaterial_lkrha") material = SubResource("ShaderMaterial_lkrha")
position = Vector2(10, 10) position = Vector2(10, 10)
scale = Vector2(26, 26) scale = Vector2(26, 26)

View File

@@ -162,7 +162,7 @@ func map_threat_to_bip(th: threats.Threat, bip: Control):
## Обработчик сигнала обновления цели. ## Обработчик сигнала обновления цели.
func on_threat_update(th): func on_threat_update(th):
var bip = get_node('%d' % th.id) var bip = get_node('%d' % th.id)
bip.update() bip.update(th.tick_rx)
map_threat_to_bip(th, bip) map_threat_to_bip(th, bip)

View File

@@ -250,7 +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) RenderingServer.global_shader_parameter_set('tick_curent', 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

@@ -2,23 +2,19 @@ shader_type canvas_item;
#include "res://shaders/tools.gdshaderinc" #include "res://shaders/tools.gdshaderinc"
global uniform int tick_curent;
/* Закрашенная окружность */ /* Закрашенная окружность */
uniform int tick_update = 0; /* Время последнего обновления, мс */ instance uniform int tick_update = 1000; /* Время последнего обновления, мс */
uniform int time_delta = 200; /* Время вспышки при обновлении, мc */ uniform int tick_delta = 200; /* Время вспышки при обновлении, мc */
const float ds = 0.01; /* Относительное расстояние на котором выполняется сглаживание краёв */ uniform float radius = 0.060; /* Радиус */
const float ds = 0.010; /* Относительное расстояние на котором выполняется сглаживание краёв */
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 alpha_offset = 0.5; /* Изменние скорости альфа канала */
const float alpha_main = 1.0;
global uniform int ticks_msec;
void fragment() void fragment()
{ {
float alpha = alpha_offset; COLOR = vec4(1, 1, 1, 1);
if ((ticks_msec - tick_update) < time_delta) COLOR.a = 1.5 - smoothstep(float(tick_update), float(tick_update + tick_delta), float(tick_curent));
{ COLOR.a *= smooth_px(length(UV - center), radius + (COLOR.a - 0.5) / 20.0, ds);
alpha = alpha_main;
}
COLOR = texture(TEXTURE, UV);
COLOR.a = (alpha_main - alpha) * smooth_px(length(UV - center), radius, ds);
} }