Добавление шейдеров
This commit is contained in:
84
Shaders/ray.gdshader
Normal file
84
Shaders/ray.gdshader
Normal file
@@ -0,0 +1,84 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
uniform vec4 color_signal: source_color;
|
||||
uniform float turn = 0.785;
|
||||
|
||||
const float outer_radius = 0.309;
|
||||
const float inner_radius = 0.72;
|
||||
const float zoom = 100.0;
|
||||
const float speed = 2.1;
|
||||
const float size = 6.0;
|
||||
const float blur = 0.000001;
|
||||
const float fill_ratio = 0.03;
|
||||
|
||||
|
||||
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 ;
|
||||
}
|
||||
|
||||
|
||||
vec2 rotate_uv(vec2 uv, vec2 pivot, float rotation) {
|
||||
float cosa = cos(rotation);
|
||||
float sina = sin(rotation);
|
||||
uv -= pivot;
|
||||
return vec2(
|
||||
cosa * uv.x - sina * uv.y,
|
||||
cosa * uv.y + sina * uv.x
|
||||
) + pivot;
|
||||
}
|
||||
|
||||
|
||||
float circle(vec2 uv, float value)
|
||||
{
|
||||
float d = length(uv);
|
||||
float t = smoothstep(
|
||||
inner_radius + blur,
|
||||
inner_radius - blur,
|
||||
d
|
||||
) - smoothstep(
|
||||
outer_radius + blur,
|
||||
outer_radius - blur,
|
||||
d
|
||||
);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
void fragment(){
|
||||
float d = length((UV-0.5)*2.0);
|
||||
float t = pow(smoothstep(0.9,0.2,d),0.35);
|
||||
vec2 uv = (UV * 2.0) - 1.0;
|
||||
|
||||
vec3 rainbow = 0.5*cos(TIME+UV.xyx+vec3(0,2,4));
|
||||
vec4 color = vec4(rainbow.rgb,1.0);
|
||||
vec2 origin = vec2(0.0, 0.0);
|
||||
color = vec4(color_signal.rgb,1.0);
|
||||
uv = rotate_uv(uv, origin, turn * TAU);
|
||||
float c = circle(uv, 0.5);
|
||||
float mask = mask(uv, fill_ratio);
|
||||
d = sin(zoom*d - speed*TIME);
|
||||
//d = abs(d);
|
||||
d = size/d;
|
||||
color *= d*t;
|
||||
|
||||
COLOR = vec4(color * mask * c);
|
||||
}
|
||||
159
Shaders/shader_edu.tres
Normal file
159
Shaders/shader_edu.tres
Normal file
@@ -0,0 +1,159 @@
|
||||
[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);
|
||||
|
||||
|
||||
}
|
||||
"
|
||||
|
||||
[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)
|
||||
Reference in New Issue
Block a user