Рефактор.

This commit is contained in:
sasha80
2025-12-22 16:35:10 +03:00
parent 5b69f0f53f
commit a48d45d0b5
10 changed files with 65 additions and 74 deletions

View File

@@ -39,7 +39,7 @@ func get_strob_radius() -> float: return $строб.get_instance_shader_param
func get_strob_color() -> float: return $строб.get_instance_shader_parameter('color') func get_strob_color() -> float: return $строб.get_instance_shader_parameter('color')
func get_canvas_rotation() -> float: return material.get('shader_parameter/rotation') func get_canvas_rotation() -> float: return material.get('shader_parameter/rotation')
func get_radius_outter() -> float: return 280.0 # material.get('shader_parameter/radius_outter') func get_radius_outter() -> float: return size.x / scale.x
func get_band_colors(_val: Array): return material.get('shader_parameter/ant_band_c') func get_band_colors(_val: Array): return material.get('shader_parameter/ant_band_c')
func get_band_failures(_val: Array): return material.get('shader_parameter/ant_band_m') func get_band_failures(_val: Array): return material.get('shader_parameter/ant_band_m')
@@ -116,10 +116,8 @@ func _on_settings_changed():
## Закрашивание по умолчанию блоков ФС цветами из настроек. ## Закрашивание по умолчанию блоков ФС цветами из настроек.
func set_def_colors(): func set_def_colors():
var col_arr: PackedColorArray = [color0, color1] var col_arr: PackedColorArray = [color0, color1]
var col = false
for i in NUM_OF_RANGE: for i in NUM_OF_RANGE:
for j in NUM_OF_DIRECTIONS: for j in NUM_OF_DIRECTIONS:
fs_default_colors.append(col_arr[int(col)]) fs_default_colors.append(col_arr[i & 1])
col = not col i += 1
col = not col
set_band_colors(fs_default_colors) set_band_colors(fs_default_colors)

View File

@@ -1,20 +1,34 @@
[gd_scene load_steps=6 format=3 uid="uid://b5kjdyxuwsot5"] [gd_scene load_steps=7 format=3 uid="uid://b5kjdyxuwsot5"]
[ext_resource type="Material" uid="uid://s6xe8igevnv2" path="res://shaders/antenas.tres" id="1_newdt"] [ext_resource type="Shader" uid="uid://dhipoo0ju5ebg" path="res://shaders/antenas.gdshader" id="1_8cjpq"]
[ext_resource type="Script" uid="uid://b85scuflwlqom" path="res://scenes/diagram/diagram.gd" id="2_8xjuy"] [ext_resource type="Script" uid="uid://b85scuflwlqom" path="res://scenes/diagram/diagram.gd" id="2_8xjuy"]
[ext_resource type="PackedScene" uid="uid://c73ahpv8uiuc7" path="res://scenes/diagram/sector.tscn" id="3_tgnog"] [ext_resource type="PackedScene" uid="uid://c73ahpv8uiuc7" path="res://scenes/diagram/sector.tscn" id="3_tgnog"]
[ext_resource type="Shader" uid="uid://k36g8tww5yo" path="res://shaders/sector.gdshader" id="4_obn6s"] [ext_resource type="Shader" uid="uid://k36g8tww5yo" path="res://shaders/sector.gdshader" id="4_obn6s"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_oqtdt"]
shader = ExtResource("1_8cjpq")
shader_parameter/grid_cells_angle = 4
shader_parameter/grid_layers_radius = 7
shader_parameter/alpha = 0.5
shader_parameter/inner_radius = 0.36
shader_parameter/outer_radius = 1.0
shader_parameter/grid_line_width = 0.0025
shader_parameter/rotation = 0.0
shader_parameter/ffr = 0.2
shader_parameter/sfr = 0.0
shader_parameter/pfr = 0.05
shader_parameter/ant_band_c = PackedColorArray(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
shader_parameter/ant_band_m = PackedInt32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
[sub_resource type="ShaderMaterial" id="ShaderMaterial_lniyv"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_lniyv"]
resource_local_to_scene = true resource_local_to_scene = true
shader = ExtResource("4_obn6s") shader = ExtResource("4_obn6s")
[node name="canvas" type="ColorRect"] [node name="canvas" type="ColorRect"]
texture_filter = 1 texture_filter = 1
material = ExtResource("1_newdt") material = SubResource("ShaderMaterial_oqtdt")
offset_top = -3.0
offset_right = 560.0 offset_right = 560.0
offset_bottom = 557.0 offset_bottom = 560.0
scale = Vector2(2, 2) scale = Vector2(2, 2)
script = ExtResource("2_8xjuy") script = ExtResource("2_8xjuy")
SecZap = ExtResource("3_tgnog") SecZap = ExtResource("3_tgnog")

View File

@@ -1,24 +1,20 @@
[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://s6xe8igevnv2"] shader_type canvas_item;
[sub_resource type="Shader" id="1"] #include "tools.gdshaderinc"
code = "shader_type canvas_item;
#include \"tools.gdshaderinc\"
#define ANT_BAND_READY 1U /* Антенна (модуль ФС) готова или исправна */ #define ANT_BAND_READY 1U /* Антенна (модуль ФС) готова или исправна */
#define ANT_BAND_FAILED 0U /* Антенна (модуль ФС) не исправно */ #define ANT_BAND_FAILED 0U /* Антенна (модуль ФС) не исправно */
// Конфигурация сетки // Конфигурация сетки
uniform int grid_cells_angle = 4; // Количество секторов (90° каждый) uniform int grid_cells_angle = 4; /* Количество секторов (90° каждый) */
uniform int grid_layers_radius = 7; // Количество слоёв по радиусу uniform int grid_layers_radius = 7; /* Количество слоёв по радиусу */
uniform float alpha: hint_range(0.0, 1.0) = 0.5; uniform float alpha: hint_range(0.0, 1.0) = 0.5;
uniform float inner_radius = 0.36; // Внутренняя незакрашенная окружность uniform float inner_radius = 0.36; /* Внутренняя незакрашенная окружность. Относительное значение */
uniform float outer_radius = 1.0; // Внешний радиус uniform float outer_radius = 1.0; /* Внешний радиус. Относительное значение */
uniform float grid_line_width = 0.0025; // Сетка, ширина линий. Относительное значение uniform float grid_line_width = 0.0025; /* Сетка, ширина линий. Относительное значение */
uniform float rotation: hint_range(0, 360) = 0.0; uniform float rotation: hint_range(0, 360) = 0.0;
uniform float ffr: hint_range(0.0, 1.0) = 0.2; /* Индикация неисправности модулей ФС. Заметность штриховки. Индикация неисправности модулей ФС */ uniform float ffr: hint_range(0.0, 1.0) = 0.2; /* Индикация неисправности модулей ФС. Заметность штриховки. Индикация неисправности модулей ФС */
uniform float sfr: hint_range(0.0, 10.0) = 0.0; /* Индикация неисправности модулей ФС. Скорость движения штрховки */ uniform float sfr: hint_range(0.0, 10.0) = 0.0; /* Индикация неисправности модулей ФС. Скорость движения штрховки */
uniform float afr: hint_range(0.0, 180.0) = 0.0; /* Индикация неисправности модулей ФС. Наклон штрховки */
uniform float pfr: hint_range(0.01, 1.0) = 0.05; /* Индикация неисправности модулей ФС. Частота штриховки */ uniform float pfr: hint_range(0.01, 1.0) = 0.05; /* Индикация неисправности модулей ФС. Частота штриховки */
@@ -97,30 +93,14 @@ void fragment()
layer_height - radius_in_layer < grid_line_width) { layer_height - radius_in_layer < grid_line_width) {
cell_color.rgb *= 0.7; // Затемняем границы cell_color.rgb *= 0.7; // Затемняем границы
} }
// Подмешивание шума для включённых // Подмешивание шума для включённых
cell_color.a = alpha + random_timed(centered_uv); cell_color.a = alpha + random_timed(centered_uv);
// Индикация не исправности
if (ant_band_m[cell_index] == ANT_BAND_FAILED) if (ant_band_m[cell_index] == ANT_BAND_FAILED)
{ {
vec2 uvr = (UV - 0.5) * 2.0; cell_color.a *= (1.0 - ffr) + tanh(10.0 * sin(TIME * sfr + 2.0 * PI * centered_uv.x / pfr)) * ffr;
cell_color.a *= (1.0 - ffr) + tanh(10.0 * sin(TIME * sfr + 2.0 * PI * uvr.x / pfr)) * ffr;
} }
COLOR = cell_color; COLOR = cell_color;
} }
"
[resource]
shader = SubResource("1")
shader_parameter/grid_cells_angle = 4
shader_parameter/grid_layers_radius = 7
shader_parameter/alpha = 0.5
shader_parameter/inner_radius = 0.36
shader_parameter/outer_radius = 1.0
shader_parameter/grid_line_width = 0.0025
shader_parameter/rotation = 0.0
shader_parameter/ffr = 0.2
shader_parameter/sfr = 0.0
shader_parameter/afr = 0.0
shader_parameter/pfr = 0.024
shader_parameter/ant_band_c = PackedColorArray(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
shader_parameter/ant_band_m = PackedInt32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

View File

@@ -0,0 +1 @@
uid://dhipoo0ju5ebg

View File

@@ -2,5 +2,5 @@ shader_type canvas_item;
void fragment() void fragment()
{ {
COLOR.rgb = vec3(1.0, 1.0, 1.0) - log(COLOR.rgb); COLOR.rgb = vec3(1.0, 1.0, 1.0) - log(COLOR.rgb);
} }

View File

@@ -16,42 +16,40 @@ uniform float ant_band_r1_0 = 0.4;
float smooth_px(float r, float R, float dss) float smooth_px(float r, float R, float dss)
{ {
return 1.0 - smoothstep(R - dss, R + dss, r); return 1.0 - smoothstep(R - dss, R + dss, r);
} }
void sector(inout vec4 c, vec2 uv, vec2 cnt, float a, float da, float r0, float r1, vec4 col) void sector(inout vec4 c, vec2 uv, vec2 cnt, float a, float da, float r0, float r1, vec4 col)
{ {
float l = distance(cnt, uv); float l = distance(cnt, uv);
vec2 d = uv - cnt; vec2 d = uv - cnt;
float sf = 500.0; float sf = 500.0;
float theta = atan(d.x, d.y) * sf; float theta = atan(d.x, d.y) * sf;
da /= 2.0; da /= 2.0;
float a0 = radians(a - da); float a0 = radians(a - da);
float a1 = radians(a + da); float a1 = radians(a + da);
float va = smooth_px(a0 * sf, theta, dsr) - smooth_px(a1 * sf, theta, dsr); float va = smooth_px(a0 * sf, theta, dsr) - smooth_px(a1 * sf, theta, dsr);
float vr = smooth_px(r0, l, ds) - smooth_px(r1, l, ds); float vr = smooth_px(r0, l, ds) - smooth_px(r1, l, ds);
float rgb = sqrt(va * vr); float rgb = sqrt(va * vr);
c.rgb += col.rgb * rgb * col.a; c.rgb += col.rgb * rgb * col.a;
c.a += rgb * col.a; c.a += rgb * col.a;
} }
void antenas(inout vec4 c, vec2 uv, vec2 p0, int cnt, float r0, float r1, vec4 c0, vec4 c1) void antenas(inout vec4 c, vec2 uv, vec2 p0, int cnt, float r0, float r1, vec4 c0, vec4 c1)
{ {
float da = 180.0f / float(cnt); float da = 180.0f / float(cnt);
for (int i = -cnt; i <= cnt; i ++) for (int i = -cnt; i <= cnt; i ++)
{ {
float v = float(i & 1); float v = float(i & 1);
vec4 col = v * c0 + (1.0f - v) * c1; vec4 col = v * c0 + (1.0f - v) * c1;
sector(c, uv, p0, float(i) * da, da, r0, r1, col); sector(c, uv, p0, float(i) * da, da, r0, r1, col);
} }
} }
vec2 rotateUVmatrinx(vec2 uv, vec2 pivot, float rotation) vec2 rotateUVmatrinx(vec2 uv, vec2 pivot, float rotation)
{ {
mat2 rotation_matrix=mat2( vec2(sin(rotation),-cos(rotation)), mat2 rotation_matrix=mat2(vec2(sin(rotation), -cos(rotation)), vec2(cos(rotation),sin(rotation)));
vec2(cos(rotation),sin(rotation))
);
uv -= pivot; uv -= pivot;
uv *= rotation_matrix; uv *= rotation_matrix;
uv += pivot; uv += pivot;

View File

@@ -21,7 +21,7 @@ void vertex()
void fragment() void fragment()
{ {
COLOR = color; COLOR = color;
if (disabled) if (disabled)
{ {
float ds = 1.0 / sharpness; float ds = 1.0 / sharpness;

View File

@@ -8,16 +8,16 @@ float random_timed(vec2 uv)
float smooth_px(float r, float R, float ds) float smooth_px(float r, float R, float ds)
{ {
return smoothstep(R + ds, R - ds, r); return smoothstep(R + ds, R - ds, r);
} }
void circle_thin(inout vec3 color, vec2 uv, vec2 p, float r, float w, vec3 c, float a) void circle_thin(inout vec3 color, vec2 uv, vec2 p, float r, float w, vec3 c, float a)
{ {
float d = distance(uv, p); float d = distance(uv, p);
float v0 = r - w; float v0 = r - w;
float v1 = r + w; float v1 = r + w;
color += a * sqrt(smoothstep(v1, v0, d) * smoothstep(v0, v1, d) * c); color += a * sqrt(smoothstep(v1, v0, d) * smoothstep(v0, v1, d) * c);
} }

View File

@@ -19,9 +19,9 @@ uniform float speed: hint_range(0.0, 1024.0) = 0.0;
float line(vec2 p1, vec2 p2, float width, vec2 uv) float line(vec2 p1, vec2 p2, float width, vec2 uv)
{ {
float dist = distance(p1, p2); // Дистанция между точками float dist = distance(p1, p2); // Дистанция между точками
float dist_uv = distance(p1, uv); // Дистанция между точкой и текущим пикселем float dist_uv = distance(p1, uv); // Дистанция между точкой и текущим пикселем
return 1.0 - floor(1.0 - (0.001 * width) + distance (mix(p1, p2, clamp(dist_uv / dist, 0.0, 1.0)), uv)); return 1.0 - floor(1.0 - (0.001 * width) + distance (mix(p1, p2, clamp(dist_uv / dist, 0.0, 1.0)), uv));
} }
@@ -65,12 +65,12 @@ void fragment()
float px1 = 0.0; float px1 = 0.0;
float py0 = 0.0; float py0 = 0.0;
float py1 = 0.0; float py1 = 0.0;
COLOR = vec4(1.0, 0.0, 0.0, 0.0); //texture(TEXTURE, UV); // Цвет текущей точки COLOR = vec4(1.0, 0.0, 0.0, 0.0); // Цвет текущей точки
get_line_points(px0, px1, py0, py1, 330.0); get_line_points(px0, px1, py0, py1, 330.0);
COLOR.a += line(vec2(px0, py0), vec2(px1, py1), 15.0, UV); COLOR.a += line(vec2(px0, py0), vec2(px1, py1), 15.0, UV);
get_line_points(px0, px1, py0, py1, 90.0); get_line_points(px0, px1, py0, py1, 90.0);
COLOR.a += line(vec2(px0, py0), vec2(px1, py1), 15.0, UV); COLOR.a += line(vec2(px0, py0), vec2(px1, py1), 15.0, UV);
get_line_points(px0, px1, py0, py1, 210.0); get_line_points(px0, px1, py0, py1, 210.0);
COLOR.a += line(vec2(px0, py0), vec2(px1, py1), 15.0, UV); COLOR.a += line(vec2(px0, py0), vec2(px1, py1), 15.0, UV);
COLOR *= smooth_px(length(UV-center), radius, DSS); COLOR *= smooth_px(length(UV - center), radius, DSS);
} }

View File

@@ -13,5 +13,5 @@ vec3 bw_to_2color(vec3 c, vec3 dark, vec3 light)
void fragment() void fragment()
{ {
COLOR.rgb = bw_to_2color(texture(TEXTURE, UV).rgb, white, black); COLOR.rgb = bw_to_2color(texture(TEXTURE, UV).rgb, white, black);
} }