Работа в процессе. Рефактор
This commit is contained in:
@@ -3,9 +3,11 @@ shader_type canvas_item;
|
||||
/* Закрашенный сектор окружности ограниченный угловым сектором и радиусами */
|
||||
|
||||
uniform vec4 color: source_color = vec4(1, 1, 1, 1);
|
||||
uniform vec4 clip_color: source_color = vec4(1.0, 0.5, 0.5, 1.0);
|
||||
uniform float width: hint_range(0.0, 360.0, 0.1) = 45.0;
|
||||
uniform float band: hint_range(0.0, 0.125) = 0.04;
|
||||
uniform float radius: hint_range(0.0, 0.125) = 0.06;
|
||||
uniform float band: hint_range(0.0, 0.125) = 0.02;
|
||||
uniform float radius: hint_range(0.0, 0.125) = 0.08;
|
||||
uniform float dir: hint_range(0.0, 360.0) = 0.0;
|
||||
uniform float inner_clip: hint_range(0.0, 0.125) = 0.045;
|
||||
|
||||
|
||||
@@ -41,7 +43,7 @@ vec4 sector(vec4 c, vec2 uv_pos, float r0, float r1, float w)
|
||||
float va = smooth_px(-w, theta, dsa) - smooth_px(w, theta, dsa);
|
||||
if (rc)
|
||||
{
|
||||
c *= vec4(1.0, 0.5, 0.5, 1.0);
|
||||
c *= clip_color;
|
||||
}
|
||||
return c * sqrt(va * vr);
|
||||
}
|
||||
@@ -55,6 +57,12 @@ void rotate_vec2(inout vec2 vert, float a)
|
||||
}
|
||||
|
||||
|
||||
void vertex()
|
||||
{
|
||||
rotate_vec2(VERTEX, radians(90.0 - dir));
|
||||
}
|
||||
|
||||
|
||||
void fragment()
|
||||
{
|
||||
float dr = band / 2.0;
|
||||
|
||||
@@ -3,19 +3,11 @@
|
||||
[sub_resource type="Shader" id="1"]
|
||||
code = "shader_type canvas_item;
|
||||
|
||||
uniform vec2 pc0;
|
||||
uniform vec2 pc1;
|
||||
uniform vec2 pc2;
|
||||
uniform vec2 tr0;
|
||||
uniform vec2 tr1;
|
||||
uniform vec2 tr2;
|
||||
uniform float strob_dir = 0.0;
|
||||
uniform float strob_dir_width = 12.0;
|
||||
uniform vec4 strob_color;
|
||||
uniform vec2 pc0; /* Центр сетки антенн */
|
||||
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);
|
||||
|
||||
const float ANTENNAS_GRID_SIZE = 7.0;
|
||||
|
||||
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;
|
||||
@@ -40,14 +32,12 @@ 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 vec4 blue0 = vec4(0.38, 0.47, 0.51, 0.4);
|
||||
const vec4 blue1 = vec4(0.39, 0.44, 0.50, 0.4);
|
||||
const float ds = 1.0;
|
||||
|
||||
|
||||
float SMOOTH(float r, float R)
|
||||
float SMOOTH(float r, float R, float d)
|
||||
{
|
||||
return 1.0 - smoothstep(R - 1.0, R + 1.0, r);
|
||||
return 1.0 - smoothstep(R - d, R + d, r);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,9 +50,11 @@ void sector(inout vec4 c, vec2 uv, vec2 center, float a, float da, float r0, flo
|
||||
da /= 2.0;
|
||||
float a0 = radians(a - da);
|
||||
float a1 = radians(a + da);
|
||||
float va = SMOOTH(a0 * sf, theta) - SMOOTH(a1 * sf, theta);
|
||||
float vr = SMOOTH(r0, l) - SMOOTH(r1, l);
|
||||
c.rgb += color.rgb * sqrt(va * vr) * color.a;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,19 +84,23 @@ void line_r(inout vec4 color, vec2 uv, vec2 center, float theta0, float radius,
|
||||
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) * c.a;
|
||||
color.rgb += c.rgb * SMOOTH(l, 1.0, ds) * c.a;
|
||||
}
|
||||
|
||||
|
||||
/* Возвращает угол атаки в диапазоне 0...180
|
||||
для правого борта и -0...-180 для левого борта.
|
||||
aoa - Угол в диапазоне 0...360 */
|
||||
float get_ang_atack(float aoa)
|
||||
void rotate_vec2(inout vec2 vert, float a)
|
||||
{
|
||||
if ((0.0 <= aoa) && (aoa < 180.0))
|
||||
return aoa;
|
||||
else
|
||||
return aoa - 360.0;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -112,27 +108,22 @@ void fragment()
|
||||
{
|
||||
ivec2 isz = textureSize(TEXTURE, 0);
|
||||
vec2 uv = UV * vec2(float(isz.x), float(isz.y)); // координаты текущей точки в пикселях
|
||||
COLOR = vec4(0, 0, 0, 1.0); //texture(TEXTURE, UV); // Цвет текущей точки
|
||||
COLOR = vec4(0, 0, 0, 0.0); //texture(TEXTURE, UV); // Цвет текущей точки
|
||||
|
||||
// Сетка антенн
|
||||
antenas(COLOR, uv, pc0, ant_band_count_0, ant_band_r0_0, ant_band_r1_0, blue1, blue0);
|
||||
antenas(COLOR, uv, pc0, ant_band_count_1, ant_band_r0_1, ant_band_r1_1, blue0, blue1);
|
||||
antenas(COLOR, uv, pc0, ant_band_count_2, ant_band_r0_2, ant_band_r1_2, blue1, blue0);
|
||||
antenas(COLOR, uv, pc0, ant_band_count_3, ant_band_r0_3, ant_band_r1_3, blue0, blue1);
|
||||
antenas(COLOR, uv, pc0, ant_band_count_4, ant_band_r0_4, ant_band_r1_4, blue1, blue0);
|
||||
antenas(COLOR, uv, pc0, ant_band_count_5, ant_band_r0_5, ant_band_r1_5, blue0, blue1);
|
||||
antenas(COLOR, uv, pc0, ant_band_count_6, ant_band_r0_6, ant_band_r1_6, blue1, blue0);
|
||||
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);
|
||||
antenas(COLOR, uv, pc0, ant_band_count_6, ant_band_r0_6, ant_band_r1_6, color1, color0);
|
||||
}
|
||||
"
|
||||
|
||||
[resource]
|
||||
shader = SubResource("1")
|
||||
shader_parameter/pc0 = Vector2(610, 600)
|
||||
shader_parameter/pc1 = Vector2(110, 1070)
|
||||
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/strob_dir = 0.0
|
||||
shader_parameter/strob_dir_width = 12.0
|
||||
shader_parameter/strob_color = null
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user