141 lines
6.1 KiB
Plaintext
141 lines
6.1 KiB
Plaintext
[gd_resource type="ShaderMaterial" load_steps=2 format=4 uid="uid://s6xe8igevnv2"]
|
||
|
||
[sub_resource type="Shader" id="1"]
|
||
code = "shader_type canvas_item;
|
||
|
||
#include \"tools.gdshaderinc\"
|
||
|
||
#define RADIUS_INNER_0 200.0 /* Радиус внутренний для режима приоритет РТО */
|
||
#define RADIUS_INNER_1 480.0 /* Радиус внутренний для режима приоритет РЛС */
|
||
#define ANTENAS_COUNT 28 /* Количество антенн */
|
||
#define ANT_BAND_READY 0U /* Антенна (модуль ФС) готова или исправна */
|
||
#define ANT_BAND_FAILED 1U /* Антенна (модуль ФС) не исправно */
|
||
|
||
uniform vec2 pc0 = vec2(560, 560); /* Центр сетки антенн */
|
||
uniform float rotation: hint_range(0.0, 360.0) = 0.0; /* */
|
||
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);
|
||
uniform float radius_inner_0 = RADIUS_INNER_0;
|
||
uniform float radius_inner_1 = RADIUS_INNER_1;
|
||
uniform float radius_outter = 550.0; /* Радиус внешний. Должно быть равно ant_band_r1_6 */
|
||
uniform float alpha: hint_range(0.0, 1.0) = 0.5;
|
||
uniform int mode = 0; /* Режим отображения. Приоритет РТО - 0, приоритет РЛС - 1 */
|
||
uniform float ffr: hint_range(0.0, 1.0) = 0.2; /* Индикация неисправности модулей ФС. Заметность штриховки. Индикация неисправности модулей ФС */
|
||
uniform float sfr: hint_range(0.0, 10.0) = 0.0; /* Индикация неисправности модулей ФС. Скорость движения штрховки */
|
||
uniform float afr: hint_range(0.0, 180.0) = 0.0; /* Индикация неисправности модулей ФС. Наклон штрховки */
|
||
|
||
const int ant_band_count_0 = 2;
|
||
const int ant_band_count_1 = 2;
|
||
const int ant_band_count_2 = 2;
|
||
const int ant_band_count_3 = 2;
|
||
const int ant_band_count_4 = 2;
|
||
const int ant_band_count_5 = 2;
|
||
const int ant_band_count_6 = 2;
|
||
|
||
const float ant_band_r0_0[] = {RADIUS_INNER_0, RADIUS_INNER_1};
|
||
const float ant_band_r0_1[] = {250.0, 490.0};
|
||
const float ant_band_r0_2[] = {300.0, 500.0};
|
||
const float ant_band_r0_3[] = {350.0, 510.0};
|
||
const float ant_band_r0_4[] = {400.0, 520.0};
|
||
const float ant_band_r0_5[] = {450.0, 530.0};
|
||
const float ant_band_r0_6[] = {500.0, 540.0};
|
||
|
||
const float ant_band_r1_0[] = {250.0, 490.0};
|
||
const float ant_band_r1_1[] = {300.0, 500.0};
|
||
const float ant_band_r1_2[] = {350.0, 510.0};
|
||
const float ant_band_r1_3[] = {400.0, 520.0};
|
||
const float ant_band_r1_4[] = {450.0, 530.0};
|
||
const float ant_band_r1_5[] = {500.0, 540.0};
|
||
const float ant_band_r1_6[] = {550.0, 550.0};
|
||
|
||
uniform vec4 ant_band_c[ANTENAS_COUNT];
|
||
uniform uint ant_band_m[ANTENAS_COUNT];
|
||
const float d4 = 90.0;
|
||
const float ds = 1.0;
|
||
|
||
|
||
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_px(a0 * sf, theta, ds) - smooth_px(a1 * sf, theta, ds);
|
||
float vr = smooth_px(r0, l, ds) - smooth_px(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, int cnt, float r0, float r1, inout int index)
|
||
{
|
||
float da = 180.0 / float(cnt);
|
||
for (int i = -cnt; i <= cnt; i ++)
|
||
{
|
||
vec4 col;
|
||
int j = index;
|
||
if (i == 2)
|
||
{
|
||
index--;
|
||
j = index - 3;
|
||
}
|
||
col.rgb = ant_band_c[j].rgb;
|
||
index++;
|
||
col.a = alpha + (random_timed(uv) - 0.5f) * ant_band_c[j].a;
|
||
if (ant_band_m[j] == ANT_BAND_FAILED)
|
||
{
|
||
vec2 uvr = uv;
|
||
rotate_vec2(uvr, radians(afr), pc0);
|
||
col.a *= (1.0 - ffr) + tanh(10.0 * sin(TIME * sfr + 2.0 * PI * uvr.x / 10.0)) * ffr;
|
||
}
|
||
float v = float(i & 1);
|
||
vec4 color = v * col + (1.0f - v) * col;
|
||
sector(c, uv, p0, float(i) * da, da, r0, r1, color);
|
||
}
|
||
}
|
||
|
||
|
||
void vertex()
|
||
{
|
||
rotate_vec2(VERTEX, radians(360.0 - rotation), pc0);
|
||
}
|
||
|
||
|
||
void fragment()
|
||
{
|
||
ivec2 isz = textureSize(TEXTURE, 0);
|
||
vec2 uv = UV * vec2(float(isz.x), float(isz.y)); // координаты текущей точки в пикселях
|
||
COLOR = vec4(0, 0, 0, 0);
|
||
int index = 0;
|
||
// Сетка антенн
|
||
antenas(COLOR, uv, pc0, ant_band_count_0, ant_band_r0_0[mode], ant_band_r1_0[mode], index);
|
||
antenas(COLOR, uv, pc0, ant_band_count_1, ant_band_r0_1[mode], ant_band_r1_1[mode], index);
|
||
antenas(COLOR, uv, pc0, ant_band_count_2, ant_band_r0_2[mode], ant_band_r1_2[mode], index);
|
||
antenas(COLOR, uv, pc0, ant_band_count_3, ant_band_r0_3[mode], ant_band_r1_3[mode], index);
|
||
antenas(COLOR, uv, pc0, ant_band_count_4, ant_band_r0_4[mode], ant_band_r1_4[mode], index);
|
||
antenas(COLOR, uv, pc0, ant_band_count_5, ant_band_r0_5[mode], ant_band_r1_5[mode], index);
|
||
antenas(COLOR, uv, pc0, ant_band_count_6, ant_band_r0_6[mode], ant_band_r1_6[mode], index);
|
||
}
|
||
"
|
||
|
||
[resource]
|
||
shader = SubResource("1")
|
||
shader_parameter/pc0 = Vector2(560, 560)
|
||
shader_parameter/rotation = 0.0
|
||
shader_parameter/color0 = Color(0.380392, 0.470588, 0.509804, 0.537255)
|
||
shader_parameter/color1 = Color(0.3315, 0.45645, 0.51, 0.537255)
|
||
shader_parameter/radius_inner_0 = 200.0
|
||
shader_parameter/radius_inner_1 = 480.0
|
||
shader_parameter/radius_outter = 550.0
|
||
shader_parameter/alpha = 0.5
|
||
shader_parameter/mode = 0
|
||
shader_parameter/ffr = 0.2
|
||
shader_parameter/sfr = 0.0
|
||
shader_parameter/afr = 0.0
|
||
shader_parameter/ant_band_c = PackedVector4Array(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, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|