РВП. Добавлен макет вида "ПО СТЦ"

This commit is contained in:
sasha80
2023-04-21 14:38:19 +03:00
parent a85375bc25
commit 8b1d07d3d5
12 changed files with 614 additions and 982 deletions

View File

@@ -3,49 +3,46 @@
[sub_resource type="Shader" id="1"]
code = "shader_type canvas_item;
const float M_PI = 3.141592653589793;
/*const vec3 blue1 = vec3(0.42, 0.51, 0.55);
const vec3 blue2 = vec3(0.11, 0.21, 0.25);
const vec3 blue3 = vec3(0.35, 0.76, 0.83);
const vec3 blue4 = vec3(0.953, 0.969, 0.89);
const vec3 red = vec3(1.00, 0.38, 0.227);
uniform vec4 blue1: source_color = vec4(0.4, 0.3, 0.3, 1.0);
uniform vec4 blue2: source_color = vec4(0.6, 0.5, 0.5, 1.0);
uniform vec4 blue3: source_color = vec4(0.8, 0.7, 0.7, 1.0);
uniform vec4 blue4: source_color = vec4(1.0, 0.9, 0.9, 1.0);
uniform vec4 red: source_color = vec4(1.0, 0.5, 0.3, 1.0); */
uniform vec4 blue0: source_color = vec4(0.38, 0.47, 0.51, 1.0);
uniform vec4 blue1: source_color = vec4(0.39, 0.44, 0.50, 1.0);
uniform vec4 blue2: source_color = vec4(0.11, 0.21, 0.25, 1.0);
uniform vec4 blue3: source_color = vec4(0.35, 0.76, 0.83, 1.0);
uniform vec4 blue4: source_color = vec4(0.953, 0.969, 0.89, 1.0);
uniform vec4 red: source_color = vec4(1.00, 0.38, 0.227, 1.0);
uniform float line_width = 2.0;
uniform float sec_forward = 180.0;
uniform float sec_back = 0.0;
uniform float sec_left = 90.0;
uniform float sec_right = 300.0;
uniform float d0 = 520.0;
uniform float d1 = 1120.0;
uniform float d2 = 1160.0;
uniform float d3 = 100.0;
uniform float d4 = 180.0;
uniform float d5 = 650.0;
uniform float d6 = 800.0;
uniform float d7 = 950.0;
uniform vec2 pc0 = vec2(0, 0);
uniform vec2 pc1 = vec2(0, 0);
uniform vec2 pc2 = vec2(0, 0);
uniform float ap_ant_w = 12.0;
uniform vec2 tr0 = vec2(0, 0);
uniform vec2 tr1 = vec2(0, 0);
uniform vec2 tr2 = vec2(0, 0);
uniform vec2 pc0;
uniform vec2 pc1;
uniform vec2 pc2;
uniform vec2 tr0;
uniform vec2 tr1;
uniform vec2 tr2;
uniform float sec_var = 0.0;
uniform float ap_ant_w = 12.0;
#define ANTENNAS_GRID_SIZE 7
const float line_width = 2.0;
const float ant_band_count_0 = 2.0;
const float ant_band_count_1 = 2.0;
const float ant_band_count_2 = 2.0;
const float ant_band_count_3 = 2.0;
const float ant_band_count_4 = 2.0;
const float ant_band_count_5 = 2.0;
const float ant_band_count_6 = 2.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;
uniform int band_ants[3]; // количество антенн, радиус внутренний, радиус внешний, подстройка по углу
float SMOOTH(float r, float R)
{
@@ -80,10 +77,10 @@ vec3 radar_scan_line(vec2 uv, vec2 center, float time, float radius, vec3 color)
if (r < radius)
{
//compute the distance to the line theta=theta0
vec2 p = radius * vec2(cos(theta0 * M_PI / 180.0), - sin(theta0 * M_PI / 180.0));
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));
//compute gradient based on angle difference to theta0
float theta = mod(180.0 * atan(d.y, d.x) / M_PI + theta0, 360.0);
float theta = mod(180.0 * atan(d.y, d.x) / PI + theta0, 360.0);
float gradient = clamp(1.0 - theta / 90.0, 0.0, 1.0);
return color * SMOOTH(l, 1.0) + 0.5 * gradient * color;
}
@@ -112,8 +109,6 @@ void rotate_uv(inout vec2 uv, float a)
uv.x = cos(a) * (uv.x - mid) + sin(a) * (uv.y - mid) + mid;
uv.y = cos(a) * (uv.x - mid) - sin(a) * (uv.x - mid) + mid;
}
void sector2(inout vec3 c, vec2 uv, vec2 center, float a, float da, float r0, float r1, vec3 color)
@@ -155,7 +150,7 @@ float circle3(vec2 uv, vec2 center, float radius, float width)
vec2 d = uv - center;
float r = sqrt(dot(d, d));
d = normalize(d);
float theta = 180.0 * (atan(d.y, d.x) / M_PI);
float theta = 180.0 * (atan(d.y, d.x) / PI);
return smoothstep(2.0, 2.1, abs(mod(theta + 2.0, 45.0) - 2.0))
* mix(0.5, 1.0, step(45.0, abs(mod(theta, 180.0) - 90.0)))
* (SMOOTH(r - width / 2.0, radius) - SMOOTH(r + width / 2.0, radius));
@@ -233,16 +228,16 @@ vec3 circle_h(inout vec3 c, vec2 uv, vec2 c0, float r, vec3 color)
}
void antenas(inout vec3 c, vec2 uv, vec2 p0, int cnt, float r0, float r1, vec3 c0, vec3 c1, float a, float adj)
void antenas(inout vec3 c, vec2 uv, vec2 p0, float cnt, float r0, float r1, vec3 c0, vec3 c1, float a)
{
float da = 180.0f / float(cnt);
c0 *= a;
c1 *= a;
for (int i = -cnt; i <= cnt; i ++)
for (int i = int(-cnt); i <= int(cnt); i ++)
{
float v = float(i & 1);
vec3 col = v * c0 + (1.0f - v) * c1;
sector(c, uv, p0, float(i) * da + adj, da, r0, r1, col);
sector(c, uv, p0, float(i) * da, da, r0, r1, col);
}
}
@@ -260,7 +255,6 @@ void line(inout vec3 color, vec2 uv, vec2 p0, vec2 p1, vec3 c, float a)
{
vec2 d = uv - p0;
float radius = distance(p0, p1);
float r = sqrt(dot(d, d));
float theta0 = acos(dot(normalize(p0), normalize(p1)));
vec2 p = radius * vec2(cos(theta0), -sin(theta0));
float l = length(d - p * clamp(dot(d, p) / dot(p, p), 0.0, 1.0));
@@ -271,64 +265,47 @@ void line(inout vec3 color, vec2 uv, vec2 p0, vec2 p1, vec3 c, float a)
void line_r(inout vec3 color, vec2 uv, vec2 center, float theta0, float radius, vec3 c, float a)
{
vec2 d = uv - center;
float r = sqrt(dot(d, d));
vec2 p = radius * vec2(cos(theta0 * M_PI / 180.0), - sin(theta0 * M_PI / 180.0));
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 += c * SMOOTH(l, 1.0);
}
/* Возвращает угол атаки в диапазоне 0...180
для правого борта и -0...-180 для левого борта.
aoa - Угол в диапазоне 0...360 */
float get_ang_atack(float aoa)
{
if ((0.0 <= aoa) && (aoa < 180.0))
return aoa;
else
return aoa - 360.0;
}
void fragment()
{
ivec2 isz = textureSize(TEXTURE, 0);
vec2 uv = UV * vec2(float(isz.x), float(isz.y));
vec3 rs = vec3(d2, d1, d0) / 2.0f;
COLOR = texture(TEXTURE, UV);
vec2 uv = UV * vec2(float(isz.x), float(isz.y)); // координаты текущей точки в пикселях
COLOR = vec4(0, 0, 0, 1.0); //texture(TEXTURE, UV); // Цвет текущей точки
// РТО
//circle_thin(COLOR.rgb, uv, pc0, d0 / 2.0, line_width, blue1.rgb, 1.0);
//circle_thin(COLOR.rgb, uv, pc0, d1 / 2.0, line_width, blue1.rgb, 1.0);
//circle_thin(COLOR.rgb, uv, pc0, d2 / 2.0, line_width, blue1.rgb, 1.0);
//circle_thin(COLOR.rgb, uv, pc0, d5 / 2.0, line_width, blue1.rgb, 0.5);
//circle_thin(COLOR.rgb, uv, pc0, d6 / 2.0, line_width, blue1.rgb, 0.5);
//circle_thin(COLOR.rgb, uv, pc0, d7 / 2.0, line_width, blue1.rgb, 0.5);
//line_r(COLOR.rgb, uv, pc0, 45, 580, blue1.rgb, 1.0);
//line_r(COLOR.rgb, uv, pc0, 135, 580, blue1.rgb, 1.0);
//line_r(COLOR.rgb, uv, pc0, 225, 580, blue1.rgb, 1.0);
//line_r(COLOR.rgb, uv, pc0, 315, 580, blue1.rgb, 1.0);
sector2(COLOR.rgb, uv, pc0, sec_var, ap_ant_w, 280, 580, red.rgb);
//sector(COLOR.rgb, uv, pc0, sec_back, ap_ant_w, 280, 580, red.rgb);
//sector(COLOR.rgb, uv, pc0, sec_left, ap_ant_w, 280, 580, red.rgb);
//sector(COLOR.rgb, uv, pc0, sec_right, ap_ant_w, 280, 580, red.rgb);
//antenas(COLOR.rgb, uv, pc0, ants_count, d6 / 2.0, d7 / 2.0, blue0.rgb, blue1.rgb, 0.3, 7.5);
antenas(COLOR.rgb, uv, pc0, 2, 220, 280, blue1.rgb, blue0.rgb, 0.4, 0);
antenas(COLOR.rgb, uv, pc0, 2, 280, 340, blue0.rgb, blue1.rgb, 0.4, 0);
antenas(COLOR.rgb, uv, pc0, 2, 340, 400, blue1.rgb, blue0.rgb, 0.4, 0);
antenas(COLOR.rgb, uv, pc0, 2, 400, 460, blue0.rgb, blue1.rgb, 0.4, 0);
antenas(COLOR.rgb, uv, pc0, 2, 460, 520, blue1.rgb, blue0.rgb, 0.4, 0);
antenas(COLOR.rgb, uv, pc0, 2, 520, 580, blue0.rgb, blue1.rgb, 0.4, 0);
// Сектор направления
sector(COLOR.rgb, uv, pc0, get_ang_atack(450.0 - sec_var), ap_ant_w, float(ant_band_r0_0), float(ant_band_r1_6), red.rgb);
//antenas(COLOR.rgb, uv, pc0, band_ants[0], 100, 120, blue0.rgb, blue1.rgb, 0.4, 0);
//antenas(COLOR.rgb, uv, pc0, band_ants[1], 125, 150, blue0.rgb, blue1.rgb, 0.4, 0);
//antenas(COLOR.rgb, uv, pc0, band_ants[2], 155, 180, blue0.rgb, blue1.rgb, 0.4, 0);
// Сетка антенн
antenas(COLOR.rgb, uv, pc0, ant_band_count_0, ant_band_r0_0, ant_band_r1_0, blue1.rgb, blue0.rgb, 0.4);
antenas(COLOR.rgb, uv, pc0, ant_band_count_1, ant_band_r0_1, ant_band_r1_1, blue0.rgb, blue1.rgb, 0.4);
antenas(COLOR.rgb, uv, pc0, ant_band_count_2, ant_band_r0_2, ant_band_r1_2, blue1.rgb, blue0.rgb, 0.4);
antenas(COLOR.rgb, uv, pc0, ant_band_count_3, ant_band_r0_3, ant_band_r1_3, blue0.rgb, blue1.rgb, 0.4);
antenas(COLOR.rgb, uv, pc0, ant_band_count_4, ant_band_r0_4, ant_band_r1_4, blue1.rgb, blue0.rgb, 0.4);
antenas(COLOR.rgb, uv, pc0, ant_band_count_5, ant_band_r0_5, ant_band_r1_5, blue0.rgb, blue1.rgb, 0.4);
antenas(COLOR.rgb, uv, pc0, ant_band_count_6, ant_band_r0_6, ant_band_r1_6, blue1.rgb, blue0.rgb, 0.4);
// Цели
bip1(COLOR.rgb, uv, tr0, 13.0, blue1.rgb, 1.0);
bip1(COLOR.rgb, uv, tr1, 13.0, blue1.rgb, 1.0);
bip1(COLOR.rgb, uv, tr2, 13.0, blue1.rgb, 1.0);
// Массивы не работают
//for (int i = 0; i < 3; i ++)
//{
// int cnt = int(band_ants[i].x);
// float r0 = band_ants[i].y;
// float r1 = band_ants[i].z;
// float adj = band_ants[i].w;
// antenas(COLOR.rgb, uv, pc0, cnt, r0, r1, blue0.rgb, blue1.rgb, 0.3, adj);
//}
// Качка
circle_thin(COLOR.rgb, uv, pc1, d4 / 2.0, line_width, blue1.rgb, 1.0);
line_r(COLOR.rgb, uv, pc1, 0, d4 / 2.0, blue1.rgb, 1.0);
@@ -343,29 +320,13 @@ void fragment()
shader = SubResource("1")
shader_parameter/blue0 = Color(0.38, 0.47, 0.51, 1)
shader_parameter/blue1 = Color(0.39, 0.44, 0.5, 1)
shader_parameter/blue2 = Color(0.11, 0.21, 0.25, 1)
shader_parameter/blue3 = Color(0.35, 0.76, 0.83, 1)
shader_parameter/blue4 = Color(0.953, 0.969, 0.89, 1)
shader_parameter/red = Color(1, 0.38, 0.227, 1)
shader_parameter/line_width = 2.0
shader_parameter/sec_forward = 180.0
shader_parameter/sec_back = 0.0
shader_parameter/sec_left = 90.0
shader_parameter/sec_right = 300.0
shader_parameter/d0 = 520.0
shader_parameter/d1 = 1120.0
shader_parameter/d2 = 1160.0
shader_parameter/d3 = 100.0
shader_parameter/d4 = 180.0
shader_parameter/d5 = 650.0
shader_parameter/d6 = 800.0
shader_parameter/d7 = 950.0
shader_parameter/pc0 = Vector2(590, 600)
shader_parameter/pc0 = Vector2(610, 600)
shader_parameter/pc1 = Vector2(110, 1070)
shader_parameter/pc2 = Vector2(100, 1060)
shader_parameter/ap_ant_w = 12.0
shader_parameter/pc2 = Vector2(100, 1065)
shader_parameter/tr0 = Vector2(600, 1000)
shader_parameter/tr1 = Vector2(1000, 600)
shader_parameter/tr2 = Vector2(300, 400)
shader_parameter/sec_var = 0.0
shader_parameter/band_ants = PackedInt32Array(8, 8, 12)
shader_parameter/ap_ant_w = 12.0