add shader

This commit is contained in:
2024-12-13 06:45:07 +03:00
parent 604e8dc875
commit 7bc5aa8e3d
12 changed files with 150 additions and 268 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,159 +1,8 @@
[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://s6xe8igevnv2"]
[sub_resource type="Shader" id="1"]
code = "shader_type canvas_item;
uniform vec4 colore: source_color;
uniform vec2 pc0; /* Центр сетки антенн */
uniform vec4 color0: source_color = vec4(0.38, 0.47, 0.51, 0.4);
uniform vec4 color1: source_color = vec4(0.39, 0.44, 0.50, 0.4);
const float mask_grad = 0.75;
const float rotation = 135.0;
const float radius_inner = 200.0; /* Радиус внутренний. Должно быть равно ant_band_r0_0 */
const float radius_outter = 550.0; /* Радиус внешний. Должно быть равно ant_band_r1_6 */
const float ant_band_count_0 = 6.0;
const float ant_band_count_1 = 6.0;
const float ant_band_count_2 = 6.0;
const float ant_band_count_3 = 6.0;
const float ant_band_count_4 = 6.0;
const float ant_band_count_5 = 6.0;
const float ant_band_count_6 = 6.0;
const float ant_band_r0_0 = 200.0;
const float ant_band_r0_1 = 250.0;
const float ant_band_r0_2 = 300.0;
const float ant_band_r0_3 = 350.0;
const float ant_band_r0_4 = 400.0;
const float ant_band_r0_5 = 450.0;
const float ant_band_r0_6 = 500.0;
const float ant_band_r1_0 = 250.0;
const float ant_band_r1_1 = 300.0;
const float ant_band_r1_2 = 350.0;
const float ant_band_r1_3 = 400.0;
const float ant_band_r1_4 = 450.0;
const float ant_band_r1_5 = 500.0;
const float ant_band_r1_6 = 550.0;
const float d4 = 90.0;
const float ds = 1.0;
float SMOOTH(float r, float R, float d)
{
return 1.0 - smoothstep(R - d, R + d, r);
}
float remap(float i_min, float i_max, float o_min, float o_max, float val) {
float t = (val - i_min) / (i_max - i_min);
return o_min + (o_max - o_min) * t;
}
float mask(vec2 uv, float value)
{
float r = atan(uv.x, uv.y);
r = remap(-PI, PI, 0.0, 1.0, r);
r = step(r, value * 0.5);
uv.x = uv.x + 1.0;
uv.x = uv.x * -1.0;
uv.x += 1.0;
float l = atan(uv.x, uv.y);
l = remap(-PI, PI, 0.0, 1.0, l);
l = step(l, value * 0.5);
return r + l ;
}
void sector(inout vec4 c, vec2 uv, vec2 center, float a, float da, float r0, float r1, vec4 color)
{
float l = distance(center, uv);
vec2 d = uv - center;
float sf = 500.0;
float theta = atan(d.x, d.y) * sf;
da /= 2.0;
float a0 = radians(a - da);
float a1 = radians(a + da);
float va = SMOOTH(a0 * sf, theta, ds) - SMOOTH(a1 * sf, theta, ds);
float vr = SMOOTH(r0, l, ds) - SMOOTH(r1, l, ds);
float rgb = sqrt(va * vr);
c.rgb += color.rgb * rgb * color.a;
c.a += rgb * color.a;
}
void antenas(inout vec4 c, vec2 uv, vec2 p0, float cnt, float r0, float r1, vec4 c0, vec4 c1)
{
float da = 180.0f / float(cnt);
for (int i = int(-cnt); i <= int(cnt); i ++)
{
float v = float(i & 1);
vec4 col = v * c0 + (1.0f - v) * c1;
sector(c, uv, p0, float(i) * da, da, r0, r1, col);
}
}
void circle_thin(inout vec3 color, vec2 uv, vec2 p, float r, float w, vec3 c, float a)
{
float d = distance(uv, p);
float v0 = r - w;
float v1 = r + w;
color += a * sqrt(smoothstep(v1, v0, d) * smoothstep(v0, v1, d) * c);
}
void line_r(inout vec4 color, vec2 uv, vec2 center, float theta0, float radius, vec4 c)
{
vec2 d = uv - center;
vec2 p = radius * vec2(cos(theta0 * PI / 180.0), - sin(theta0 * PI / 180.0));
float l = length(d - p * clamp(dot(d, p) / dot(p, p), 0.0, 1.0));
color.rgb += c.rgb * SMOOTH(l, 1.0, ds) * c.a;
}
void rotate_vec2(inout vec2 vert, float a)
{
float sin_a = sin(a);
float cos_a = cos(a);
vert *= mat2(vec2(cos_a, sin_a), vec2(-sin_a, cos_a));
}
void vertex()
{
VERTEX -= pc0;
rotate_vec2(VERTEX, radians(rotation));
VERTEX += pc0;
}
void fragment()
{
ivec2 isz = textureSize(TEXTURE, 0);
vec2 uv = UV * vec2(float(isz.x), float(isz.y)); // координаты текущей точки в пикселях
float mask = mask(uv, mask_grad);
COLOR = vec4(0.0, 0.0, 0.0, 0.0) - mask; //texture(TEXTURE, UV); // Цвет текущей точки
// Сетка антенн
antenas(COLOR, uv, pc0, ant_band_count_0, ant_band_r0_0, ant_band_r1_0, color1, color0);
antenas(COLOR, uv, pc0, ant_band_count_1, ant_band_r0_1, ant_band_r1_1, color0, color1);
antenas(COLOR, uv, pc0, ant_band_count_2, ant_band_r0_2, ant_band_r1_2, color1, color0);
antenas(COLOR, uv, pc0, ant_band_count_3, ant_band_r0_3, ant_band_r1_3, color0, color1);
antenas(COLOR, uv, pc0, ant_band_count_4, ant_band_r0_4, ant_band_r1_4, color1, color0);
antenas(COLOR, uv, pc0, ant_band_count_5, ant_band_r0_5, ant_band_r1_5, color0, color1);
}
"
[ext_resource type="Shader" path="res://Shaders/ray.gdshader" id="1_mtift"]
[resource]
shader = SubResource("1")
shader_parameter/colore = Color(0, 0, 0, 1)
shader_parameter/pc0 = Vector2(560.03, 560)
shader_parameter/color0 = Color(0.203922, 0.203922, 0.203922, 0.478431)
shader_parameter/color1 = Color(0.945098, 0.964706, 0.972549, 0.117647)
shader = ExtResource("1_mtift")
shader_parameter/color_signal = null
shader_parameter/turn = 0.785

39
ems_g.gd Normal file
View File

@@ -0,0 +1,39 @@
extends Panel
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
var node_select1 = $scroll1/table1
var EMS_G_TABLE: Array
for i_row in Constants.INPUT_EMS_G.size()+1:
var column: Array
for out_colum in Constants.OUT_EMS_G.size()+1:
if out_colum > 0 and i_row > 0:
column.append(Constants.Switch)
else:
column.append(Constants.TableNode)
EMS_G_TABLE.append(column)
draw_tabl(node_select1, EMS_G_TABLE, EMS_G_TABLE.size())
node_select1.get_node2(0, 0).text = 'XЭ ТРИ'
for i in Constants.INPUT_EMS_G.size():
node_select1.get_node2(0, i+1).text = Constants.INPUT_EMS_G[i]
for i in Constants.OUT_EMS_G.size():
node_select1.get_node2(i+1, 0).text = Constants.OUT_EMS_G[i]
var columns_min_size: Array
for i in EMS_G_TABLE.size():
columns_min_size.append(70)
node_select1.set_columns_min_size(columns_min_size)
func draw_tabl(tbl, row: Array, count_row: int):
for i_row in count_row:
tbl.add_row(row[i_row])
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass

View File

@@ -47,8 +47,6 @@ func _ready() -> void:
node_control_device.get_node2(0, i).text = Constants.CONTROL_DEVICE[i]
node_control_device.set_columns_min_size([300])
$TabContainer/PRD/Zapret.connect('toggled', Callable(self, '_on_zapret').bind($TabContainer/PRD/Zapret))
$TabContainer/PRD/Zapret2.connect('toggled', Callable(self, '_on_zapret').bind($TabContainer/PRD/Zapret2))
Network.connect('_yau_status_line', Callable(self, '_on_yau_status'))

View File

@@ -10,6 +10,7 @@ const MINIMUM_CODE_AD: int = 2660
const TEMP: float = 115.0 / (MAXIMUM_CODE_ADC - MINIMUM_CODE_AD)
const TableNode = preload("res://table/node.tscn")
const TableList = preload("res://table/node_list.tscn")
const Switch = preload("res://table/switch.tscn")
const SELECT_DEVICE: Array = [[TableNode, TableList]]
const CONTROL_DEVICE: Array = ['ЯЧЕЙКА ЯУ-07Б', 'ФС', 'ЯЧЕЙКА ЭМС-Г', 'ЯЧЕЙКА УГ', 'ЯЧЕЙКА УКП №1', 'ЯЧЕЙКА УКП №2', 'ИП МАА №1', 'ИП МАА №2', 'ИП9-50 №1', 'ИП9-50 №2', 'ИП12-50 №1', '-', '-','ИП5-25', 'Х3:2(СЗИ2 от УФ)', 'Х3:19(СИ2 от ФС)', 'Х3:11(СИ2 в УФ)', 'Х3:14(Модуляция)', 'Х3:27(ФГОЗ)']
const ROWS_REGS_DATA: Array = [
@@ -59,12 +60,46 @@ var CONTROL_POWER_SUPPLY: Array = [
['ИП9-50 №3', 'ОШИБКА. КОНТРОЛЬ ИП9-50 №3'],
['ИП12-50 №2', 'ОШИБКА. КОНТРОЛЬ ИП12-50 №2'],
['ИП5-25', 'ОШИБКА. КОНТРОЛЬ ИП5-25']]
const EMS_G = [
const EMS_G: Array = [
['Нет Х3:2(СЗИ2 от УФ)', 'Есть Х3:2(СЗИ2 от УФ)'],
['Нет Х3:19(СИ2 от ФС)', 'Есть Х3:19(СИ2 от ФС)'],
['Нет Х3:11(СИ2 в УФ)', 'Есть Х3:11(СИ2 в УФ)'],
['Нет Х3:14(Модуляция)', 'Есть Х3:14(Модуляция)'],
['Нет Х3:27(ФГОЗ)', 'Есть Х3:27(ФГОЗ)']]
const INPUT_EMS_G: Array = [
'01/:34',
'02/:35',
'03/:36',
'04/:37',
'05/:38',
'06/:39',
'07/:40',
'08/:41',
'18/:42',
'19/:43',
'20/:44',
'21/:45',
'22/:46',
'23/:47',
'24/:48',
'25/:49',]
const OUT_EMS_G: Array = [
'10/:34',
'11/:35',
'12/:36',
'13/:37',
'14/:38',
'15/:39',
'16/:40',
'17/:41',
'26/:42',
'27/:43',
'28/:44',
'29/:45',
'30/:46',
'31/:47',
'32/:48',
'33/:49',]
enum MODE {
PRD_K,
PRD_B,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 B

View File

@@ -1,34 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bw3yv3smvaxqn"
path="res://.godot/imported/nine-patch.png-798f7950fb3126b4e1ed0c39d9e4beba.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://table/nine-patch.png"
dest_files=["res://.godot/imported/nine-patch.png-798f7950fb3126b4e1ed0c39d9e4beba.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -31,21 +31,3 @@ alignment = 1
editable = false
caret_blink = true
caret_blink_interval = 0.5
[node name="Label" type="Label" parent="."]
visible = false
layout_mode = 0
offset_right = 40.0
offset_bottom = 23.0
[node name="Label" type="Label" parent="Label"]
visible = false
layout_mode = 0
offset_right = 40.0
offset_bottom = 23.0
[node name="CheckButton" type="CheckButton" parent="Label"]
visible = false
layout_mode = 0
offset_right = 44.0
offset_bottom = 24.0

View File

@@ -1,15 +0,0 @@
[gd_scene load_steps=2 format=3 uid="uid://pd3fcx55duj2"]
[ext_resource type="Texture2D" uid="uid://bw3yv3smvaxqn" path="res://table/nine-patch.png" id="1_jtmfn"]
[node name="NinePatchRect" type="NinePatchRect"]
offset_right = 17.0
offset_bottom = 16.0
texture = ExtResource("1_jtmfn")
draw_center = false
patch_margin_left = 8
patch_margin_top = 8
patch_margin_right = 8
patch_margin_bottom = 8
axis_stretch_horizontal = 1
axis_stretch_vertical = 1

7
table/switch.gdshader Normal file
View File

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

27
table/switch.tscn Normal file
View File

@@ -0,0 +1,27 @@
[gd_scene load_steps=6 format=3 uid="uid://dhg1syshfaem2"]
[ext_resource type="Material" uid="uid://s6xe8igevnv2" path="res://Shaders/shader_edu.tres" id="1_nb5jm"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_kwqxa"]
bg_color = Color(0, 0, 0, 1)
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_7vs72"]
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_houwj"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_o2hja"]
bg_color = Color(0.6, 0.6, 0.6, 0)
[node name="PanelContainer" type="PanelContainer"]
offset_right = 186.0
offset_bottom = 40.0
theme_override_styles/panel = SubResource("StyleBoxFlat_kwqxa")
[node name="CheckButton" type="CheckButton" parent="."]
material = ExtResource("1_nb5jm")
layout_mode = 2
size_flags_horizontal = 4
mouse_default_cursor_shape = 2
theme_override_styles/disabled_mirrored = SubResource("StyleBoxTexture_7vs72")
theme_override_styles/hover = SubResource("StyleBoxTexture_houwj")
theme_override_styles/normal = SubResource("StyleBoxFlat_o2hja")

View File

@@ -7,7 +7,7 @@ class_name GDTable extends GridContainer
@export var selector_key_down: Key = KEY_DOWN ## Клавиша увеличения индекса выбранного ряда
@export var selector_key_up: Key = KEY_UP ## Клавиша уменьшения индекса выбранного ряда
@export_file var node_type_file: = 'res://table/node.tscn': get = get_node_scene, set = load_node_scene ## Сцена ячейки устанавливаемая по умолчанию
@export_file var selector_type_file: = 'res://table/selector.tscn': set = load_selector_scene ## Сцена селектора для выбранного ряда
@export_file var switch_type_file: = 'res://table/switch.tscn': set = load_switch_scene ## Сцена селектора для выбранного ряда
const HEAD_PREFIX = 'HEAD_' ## Префикс ключа заголовка таблицы
const INDEX_FORMAT = '%02d_%02d' ## Формат индекса ключа
@@ -28,6 +28,7 @@ var nodes: = {} ## Все ячейки таблицы и до
var columns_min_size = [] ## Ширина каждой колонки
var ScnNode: PackedScene ## Прототип ячейки таблицы
var ScnSelector: PackedScene ## Прототип индикатора выбранного ряда
var ScnSwitch: PackedScene
var selector_color_proc: Callable ## Ссылка на процедуру генератора цвета индикатора выбранного ряда
var selector_size_proc: Callable ## Ссылка на процедуру генератора размера индикатора выбранного ряда
@@ -121,11 +122,9 @@ func set_columns_alignments(alignments: Array):
set_node_alligment(i_col, i_row, alignments[i_col])
##
func load_selector_scene(file_name: String):
selector_type_file = file_name
ScnSelector = load(file_name)
func load_switch_scene(file_name: String):
switch_type_file = file_name
ScnSwitch = load(file_name)
##
func load_node_scene(file_name: String):
@@ -135,10 +134,10 @@ func load_node_scene(file_name: String):
##
func _ready():
ScnSelector = load(selector_type_file)
ScnSwitch = load(switch_type_file)
ScnNode = load(node_type_file)
assert(ScnSelector is PackedScene)
assert(ScnNode is PackedScene)
assert(ScnSwitch is PackedScene)
## Выравнивает по нижнему левому углу. Используется для выравнивания по заголовку.