first commit

This commit is contained in:
marwy 2026-11-27 13:16:36 +03:00
commit a408df2a76
218 changed files with 52376 additions and 0 deletions

33
shaders/gl/blur.frag Normal file
View file

@ -0,0 +1,33 @@
#version 330 core
// 2-Pass Dual Kawase Blur Fragment Shader (OpenGL 3.3 Core)
// u_mode == 0: 5-tap downsample; u_mode != 0: 8-tap upsample.
uniform sampler2D u_tex;
uniform vec2 u_texel_size;
uniform float u_offset;
uniform int u_mode;
in vec2 v_uv;
out vec4 o_color;
void main() {
vec2 hp = u_texel_size * 0.5 * u_offset;
if (u_mode == 0) {
vec4 sum = textureLod(u_tex, v_uv, 0.0) * 4.0;
sum += textureLod(u_tex, v_uv - hp, 0.0);
sum += textureLod(u_tex, v_uv + hp, 0.0);
sum += textureLod(u_tex, v_uv + vec2(hp.x, -hp.y), 0.0);
sum += textureLod(u_tex, v_uv - vec2(hp.x, -hp.y), 0.0);
o_color = sum * 0.125;
} else {
vec4 sum = textureLod(u_tex, v_uv + vec2(-hp.x * 2.0, 0.0), 0.0);
sum += textureLod(u_tex, v_uv + vec2(-hp.x, hp.y), 0.0) * 2.0;
sum += textureLod(u_tex, v_uv + vec2(0.0, hp.y * 2.0), 0.0);
sum += textureLod(u_tex, v_uv + vec2(hp.x, hp.y), 0.0) * 2.0;
sum += textureLod(u_tex, v_uv + vec2(hp.x * 2.0, 0.0), 0.0);
sum += textureLod(u_tex, v_uv + vec2(hp.x, -hp.y), 0.0) * 2.0;
sum += textureLod(u_tex, v_uv + vec2(0.0, -hp.y * 2.0), 0.0);
sum += textureLod(u_tex, v_uv + vec2(-hp.x, -hp.y), 0.0) * 2.0;
o_color = sum * (1.0 / 12.0);
}
}

15
shaders/gl/blur.vert Normal file
View file

@ -0,0 +1,15 @@
#version 330 core
// Fullscreen triangle vertex shader for Dual Kawase Blur (OpenGL 3.3 Core)
out vec2 v_uv;
void main() {
vec2 positions[3] = vec2[3](
vec2(-1.0, -1.0),
vec2( 3.0, -1.0),
vec2(-1.0, 3.0)
);
vec2 p = positions[gl_VertexID];
gl_Position = vec4(p, 0.0, 1.0);
v_uv = p * 0.5 + vec2(0.5);
}

251
shaders/gl/ui_sdf.frag Normal file
View file

@ -0,0 +1,251 @@
#version 330 core
// Strict OpenGL 3.3 Core Uber-SDF Fragment Shader — 1-to-1 parity with `shaders/ui_sdf.wgsl`.
uniform vec2 u_screen_size;
uniform float u_scale_factor;
uniform int u_flip_v;
uniform sampler2D u_tex;
in vec2 v_frag_pos;
flat in vec4 v_rect;
flat in vec4 v_radii;
flat in vec4 v_uv_or_params;
flat in vec4 v_clip_rect;
flat in uvec4 v_colors;
flat in vec4 v_metrics;
flat in uvec4 v_meta;
out vec4 o_color;
const uint MODE_SOLID = 0u;
const uint MODE_TEXTURED = 1u;
const uint MODE_GLYPH = 2u;
const uint MODE_BACKDROP_BLUR = 3u;
const uint MODE_PLUS_GRADIENT = 4u;
const uint MODE_SHADOW = 5u;
const uint MODE_LINE = 6u;
const uint FLAG_RING_ONLY = 1u;
vec4 unpack_rgba(uint rgba) {
float r = float(rgba & 255u) * (1.0 / 255.0);
float g = float((rgba >> 8u) & 255u) * (1.0 / 255.0);
float b = float((rgba >> 16u) & 255u) * (1.0 / 255.0);
float a = float((rgba >> 24u) & 255u) * (1.0 / 255.0);
return vec4(r, g, b, a);
}
// Per-corner rounded box SDF (radii = [tl, tr, br, bl], +Y down).
float sd_rounded_box(vec2 p, vec2 half_size, vec4 radii) {
float r_right = (p.y > 0.0) ? radii.z : radii.y;
float r_left = (p.y > 0.0) ? radii.w : radii.x;
float r = (p.x > 0.0) ? r_right : r_left;
float cr = clamp(r, 0.0, min(half_size.x, half_size.y));
vec2 q = abs(p) - half_size + vec2(cr);
return min(max(q.x, q.y), 0.0) + length(max(q, vec2(0.0))) - cr;
}
float sd_segment(vec2 p, vec2 a, vec2 b) {
vec2 pa = p - a;
vec2 ba = b - a;
float h = clamp(dot(pa, ba) / max(dot(ba, ba), 1e-6), 0.0, 1.0);
return length(pa - ba * h);
}
vec2 erf_approx(vec2 x) {
vec2 s = sign(x);
vec2 a = abs(x);
vec2 y = vec2(1.0) + (vec2(0.278393) + (vec2(0.230389) + vec2(0.078108) * (a * a)) * a) * a;
vec2 y2 = y * y;
return s - s / (y2 * y2);
}
vec3 sample_plus_gradient(float t_in) {
float t = clamp(t_in, 0.0, 1.0);
vec3 c0 = vec3(1.0, 0.3607843, 0.3019608); // #ff5c4d @ 0%
vec3 c1 = vec3(0.9215686, 0.2745098, 0.6235294); // #eb469f @ 30%
vec3 c2 = vec3(0.5137255, 0.2549020, 0.9372549); // #8341ef @ 75%
vec3 c3 = vec3(0.2470588, 0.4078431, 0.9764706); // #3f68f9 @ 100%
if (t < 0.30) {
return mix(c0, c1, t * (1.0 / 0.30));
} else if (t < 0.75) {
return mix(c1, c2, (t - 0.30) * (1.0 / 0.45));
} else {
return mix(c2, c3, (t - 0.75) * (1.0 / 0.25));
}
}
vec4 composite_over(vec4 fg, vec4 bg) {
return fg + bg * (1.0 - fg.a);
}
void main() {
uint mode = v_meta.x;
float aa = 0.5 / max(u_scale_factor, 1.0);
// Per-instance analytical rounded-rect clip
float clip_cov = 1.0;
if (v_clip_rect.z > 0.0 && v_clip_rect.w > 0.0) {
vec2 ch = v_clip_rect.zw * 0.5;
vec2 cc = v_clip_rect.xy + ch;
float cr = v_metrics.y;
float cd = sd_rounded_box(v_frag_pos - cc, ch, vec4(cr));
clip_cov = 1.0 - smoothstep(-aa, aa, cd);
if (clip_cov <= 0.0001) {
discard;
}
}
vec4 c_start = unpack_rgba(v_colors.x);
vec4 c_end = unpack_rgba(v_colors.y);
vec4 c_border = unpack_rgba(v_colors.z);
float border_w = v_metrics.x;
// MODE_GLYPH: R8 coverage mask with DirectWrite/Chromium perceptual stem darkening
if (mode == MODE_GLYPH) {
vec2 local = clamp((v_frag_pos - v_rect.xy) / max(v_rect.zw, vec2(1e-5)), vec2(0.0), vec2(1.0));
vec2 uv = mix(v_uv_or_params.xy, v_uv_or_params.zw, local);
float cov_raw = textureLod(u_tex, uv, 0.0).r;
if (cov_raw <= 0.0001) {
discard;
}
float fg_luma = dot(c_start.rgb, vec3(0.299, 0.587, 0.114));
float glyph_gamma = mix(0.92, 0.66, fg_luma);
float cov = pow(clamp(cov_raw, 0.0, 1.0), glyph_gamma);
float a = cov * c_start.a * clip_cov;
if (a <= 0.0001) {
discard;
}
o_color = vec4(c_start.rgb * a, a);
return;
}
// MODE_LINE: Anti-aliased capsule segment
if (mode == MODE_LINE) {
float dist = sd_segment(v_frag_pos, v_rect.xy, v_rect.zw) - border_w * 0.5;
float cov = 1.0 - smoothstep(-aa, aa, dist);
float a = cov * c_start.a * clip_cov;
if (a <= 0.0001) {
discard;
}
o_color = vec4(c_start.rgb * a, a);
return;
}
// MODE_SHADOW: Analytical Gaussian rounded-box drop shadow
if (mode == MODE_SHADOW) {
float ox = v_uv_or_params.x;
float oy = v_uv_or_params.y;
float blur = max(v_uv_or_params.z, 0.5);
float spread = v_uv_or_params.w;
float sigma = max(blur * 0.5, 0.5);
vec2 half_size = max(v_rect.zw * 0.5 + vec2(spread), vec2(0.5));
vec2 center = v_rect.xy + v_rect.zw * 0.5 + vec2(ox, oy);
vec2 p = v_frag_pos - center;
float inv_sig = 1.0 / (sigma * 1.41421356);
vec2 e1 = erf_approx((p + half_size) * inv_sig);
vec2 e2 = erf_approx((p - half_size) * inv_sig);
float box_int = 0.25 * (e1.x - e2.x) * (e1.y - e2.y);
float r_avg = (v_radii.x + v_radii.y + v_radii.z + v_radii.w) * 0.25 + max(spread, 0.0);
float d = sd_rounded_box(p, half_size, vec4(r_avg));
float corner_falloff = 0.5 * (1.0 - erf_approx(vec2(d * inv_sig, 0.0)).x);
float density = clamp(min(box_int, corner_falloff), 0.0, 1.0);
float a = density * c_start.a * clip_cov;
if (a <= 0.0001) {
discard;
}
o_color = vec4(c_start.rgb * a, a);
return;
}
// Box-based modes: MODE_SOLID, MODE_TEXTURED, MODE_BACKDROP_BLUR, MODE_PLUS_GRADIENT
vec2 half_size = v_rect.zw * 0.5;
vec2 center = v_rect.xy + half_size;
vec2 p = v_frag_pos - center;
float max_r = max(max(v_radii.x, v_radii.y), max(v_radii.z, v_radii.w));
float d = -1.0;
float outer_cov = 1.0;
if (max_r > 0.001 || border_w > 0.001) {
d = sd_rounded_box(p, half_size, v_radii);
outer_cov = 1.0 - smoothstep(-aa, aa, d);
if (outer_cov <= 0.0001) {
discard;
}
}
vec4 fill_pm = vec4(0.0);
if (mode == MODE_SOLID) {
vec4 fill_col = c_start;
vec2 grad_dir = v_uv_or_params.xy;
if (dot(grad_dir, grad_dir) > 0.0001) {
vec2 local = (v_frag_pos - v_rect.xy) / max(v_rect.zw, vec2(1e-5)) - vec2(0.5);
float span = abs(grad_dir.x) + abs(grad_dir.y);
float t = clamp(dot(local, grad_dir) / max(span, 1e-5) + 0.5, 0.0, 1.0);
fill_col = mix(c_start, c_end, t);
}
float fa = fill_col.a * outer_cov;
fill_pm = vec4(fill_col.rgb * fa, fa);
} else if (mode == MODE_TEXTURED) {
vec2 local = clamp((v_frag_pos - v_rect.xy) / max(v_rect.zw, vec2(1e-5)), vec2(0.0), vec2(1.0));
vec2 uv = mix(v_uv_or_params.xy, v_uv_or_params.zw, local);
if (u_flip_v != 0) {
uv.y = 1.0 - uv.y;
}
// Isotropic hardware mipmap LOD from texel-to-physical-pixel footprint
vec2 tex_dims = vec2(textureSize(u_tex, 0));
vec2 uv_span = abs(v_uv_or_params.zw - v_uv_or_params.xy);
vec2 rect_px = max(v_rect.zw * max(u_scale_factor, 1.0), vec2(1.0));
vec2 texels_per_px = (tex_dims * uv_span) / rect_px;
float max_ratio = max(texels_per_px.x, texels_per_px.y);
float lod = max(log2(max(max_ratio, 1.0)) - 0.25, 0.0);
vec4 tex = textureLod(u_tex, uv, lod);
float scale = c_start.a * outer_cov;
fill_pm = vec4(tex.rgb * c_start.rgb * scale, tex.a * scale);
} else if (mode == MODE_BACKDROP_BLUR) {
vec2 sz = max(u_screen_size, vec2(1.0));
vec2 screen_uv = clamp(vec2(v_frag_pos.x / sz.x, 1.0 - v_frag_pos.y / sz.y), vec2(0.0), vec2(1.0));
vec4 bg_sample = textureLod(u_tex, screen_uv, 0.0);
vec4 bg_pm = vec4(bg_sample.rgb * outer_cov, outer_cov);
float tint_a = c_start.a * outer_cov;
vec4 tint_pm = vec4(c_start.rgb * tint_a, tint_a);
fill_pm = composite_over(tint_pm, bg_pm);
} else if (mode == MODE_PLUS_GRADIENT) {
vec2 grad_dir = v_uv_or_params.xy;
vec2 local = (v_frag_pos - v_rect.xy) / max(v_rect.zw, vec2(1e-5)) - vec2(0.5);
float span = abs(grad_dir.x) + abs(grad_dir.y);
float t = clamp(dot(local, grad_dir) / max(span, 1e-5) + 0.5, 0.0, 1.0);
vec3 rgb = sample_plus_gradient(t);
if ((v_meta.z & FLAG_RING_ONLY) != 0u) {
float inner_cov = 1.0 - smoothstep(-aa, aa, d + border_w);
float ring_cov = clamp(outer_cov - inner_cov, 0.0, 1.0);
float ra = ring_cov * c_start.a * clip_cov;
if (ra <= 0.0001) {
discard;
}
o_color = vec4(rgb * ra, ra);
return;
}
float fa = c_start.a * outer_cov;
fill_pm = vec4(rgb * fa, fa);
}
vec4 result = fill_pm;
if (border_w > 0.0 && c_border.a > 0.0) {
float inner_cov = 1.0 - smoothstep(-aa, aa, d + border_w);
float border_cov = clamp(outer_cov - inner_cov, 0.0, 1.0);
float ba = border_cov * c_border.a;
vec4 border_pm = vec4(c_border.rgb * ba, ba);
result = composite_over(border_pm, fill_pm);
}
result *= clip_cov;
if (result.a <= 0.0001 && max(result.r, max(result.g, result.b)) <= 0.0001) {
discard;
}
o_color = result;
}

82
shaders/gl/ui_sdf.vert Normal file
View file

@ -0,0 +1,82 @@
#version 330 core
// Strict OpenGL 3.3 Core Uber-SDF Instanced Quad Vertex Shader
// Zero SSBOs, zero OpenGL 4.x features: reads UiInstance via per-instance VBO attributes (divisor = 1).
uniform vec2 u_screen_size;
uniform float u_scale_factor;
layout(location = 0) in vec4 a_rect; // [x, y, w, h] or [x0, y0, x1, y1] for MODE_LINE
layout(location = 1) in vec4 a_radii; // [tl, tr, br, bl]
layout(location = 2) in vec4 a_uv_or_params; // [u0, v0, u1, v1] | shadow [ox, oy, blur, spread] | grad [dx, dy, 0, 0]
layout(location = 3) in vec4 a_clip_rect; // [x, y, w, h] (w <= 0 => no clip)
layout(location = 4) in uvec4 a_colors; // [color_start, color_end, border_color, reserved]
layout(location = 5) in vec4 a_metrics; // [border_width, clip_radius, extra0, extra1]
layout(location = 6) in uvec4 a_meta; // [mode, texture_id, flags, reserved]
const uint MODE_GLYPH = 2u;
const uint MODE_SHADOW = 5u;
const uint MODE_LINE = 6u;
out vec2 v_frag_pos;
flat out vec4 v_rect;
flat out vec4 v_radii;
flat out vec4 v_uv_or_params;
flat out vec4 v_clip_rect;
flat out uvec4 v_colors;
flat out vec4 v_metrics;
flat out uvec4 v_meta;
void main() {
vec2 corners[6] = vec2[6](
vec2(0.0, 0.0),
vec2(1.0, 0.0),
vec2(0.0, 1.0),
vec2(0.0, 1.0),
vec2(1.0, 0.0),
vec2(1.0, 1.0)
);
vec2 corner = corners[gl_VertexID];
float inv_scale = 1.0 / max(u_scale_factor, 1.0);
uint mode = a_meta.x;
vec2 bmin = a_rect.xy;
vec2 bmax = a_rect.xy + a_rect.zw;
if (mode == MODE_SHADOW) {
float ox = a_uv_or_params.x;
float oy = a_uv_or_params.y;
float blur = max(a_uv_or_params.z, 0.5);
float spread = a_uv_or_params.w;
float margin = blur * 3.0 + max(spread, 0.0) + 2.0 * inv_scale;
bmin = a_rect.xy + vec2(ox, oy) - vec2(margin);
bmax = a_rect.xy + a_rect.zw + vec2(ox, oy) + vec2(margin);
} else if (mode == MODE_LINE) {
vec2 a = a_rect.xy;
vec2 b = a_rect.zw;
float pad = a_metrics.x * 0.5 + 1.5 * inv_scale;
bmin = min(a, b) - vec2(pad);
bmax = max(a, b) + vec2(pad);
} else if (mode != MODE_GLYPH) {
float max_r = max(max(a_radii.x, a_radii.y), max(a_radii.z, a_radii.w));
if (max_r > 0.001 || a_metrics.x > 0.001) {
float pad = 1.0 * inv_scale;
bmin -= vec2(pad);
bmax += vec2(pad);
}
}
vec2 p = mix(bmin, bmax, corner);
vec2 sz = max(u_screen_size, vec2(1.0));
float ndc_x = (p.x / sz.x) * 2.0 - 1.0;
float ndc_y = 1.0 - (p.y / sz.y) * 2.0;
gl_Position = vec4(ndc_x, ndc_y, 0.0, 1.0);
v_frag_pos = p;
v_rect = a_rect;
v_radii = a_radii;
v_uv_or_params = a_uv_or_params;
v_clip_rect = a_clip_rect;
v_colors = a_colors;
v_metrics = a_metrics;
v_meta = a_meta;
}

293
shaders/gl/vibe.frag Normal file
View file

@ -0,0 +1,293 @@
#version 330 core
// Verbatim 1-to-1 OpenGL 3.3 Core port of Yandex Music Desktop 5.129.0's official WebGL My Vibe shader
// Matches `shaders/vibe.wgsl` and `original_yandex_music/decompiled/vibe_wheel_foryou_spec.md` verbatim.
uniform vec4 u_uv_scale_time_maxr;
uniform vec4 u_rot01;
uniform vec4 u_rot2_inner01;
uniform vec4 u_inner2_glow012;
uniform vec4 u_audio012_pad;
uniform uvec4 u_colors_a;
uniform uvec4 u_colors_b;
in vec2 v_uv;
out vec4 o_color;
const float EFFECT_PI = 3.1415;
const float MATH_PI = 3.14159265359;
const float TWO_MATH_PI = 6.28318530718;
const float INV_TWO_EFFECT_PI = 0.15915963712;
const float CIRCLE_WIDTH_BASE = 0.8;
const float CIRCLE_WIDTH_STEP = 0.2;
const float SPARK_STRENGTH_BASE = 1.0;
const float SPARK_STRENGTH_STEP = 0.3;
const float CIRCLE_RADIUS_BASE = 0.95;
const float CIRCLE_RADIUS_STEP = 0.15;
const float CIRCLE_OFFSET_BASE = 0.0;
const float CIRCLE_OFFSET_STEP = 1.57;
vec3 unpack_rgb(uint rgb) {
float r = float(rgb & 255u) * (1.0 / 255.0);
float g = float((rgb >> 8u) & 255u) * (1.0 / 255.0);
float b = float((rgb >> 16u) & 255u) * (1.0 / 255.0);
return vec3(r, g, b);
}
vec4 mod289_4(vec4 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
vec3 mod289_3(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
vec4 permute(vec4 x) { return mod289_4(((x * 34.0) + vec4(1.0)) * x); }
vec4 taylorInvSqrt(vec4 r) { return vec4(1.79284291400159) - 0.85373472095314 * r; }
float snoise3(vec3 v) {
const vec2 C = vec2(0.1666667, 0.3333333);
const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
vec3 i0 = floor(v + vec3(dot(v, C.yyy)));
vec3 x0 = v - i0 + vec3(dot(i0, C.xxx));
vec3 g = step(x0.yzx, x0.xyz);
vec3 l = vec3(1.0) - g;
vec3 i1 = min(g.xyz, l.zxy);
vec3 i2 = max(g.xyz, l.zxy);
vec3 x1 = x0 - i1 + C.xxx;
vec3 x2 = x0 - i2 + 2.0 * C.xxx;
vec3 x3 = x0 - vec3(1.0) + 3.0 * C.xxx;
vec3 i = mod289_3(i0);
vec4 p = permute(permute(permute(
vec4(i.z) + vec4(0.0, i1.z, i2.z, 1.0))
+ vec4(i.y) + vec4(0.0, i1.y, i2.y, 1.0))
+ vec4(i.x) + vec4(0.0, i1.x, i2.x, 1.0));
float n_ = 0.142857142857;
vec3 ns = n_ * D.wyz - D.xzx;
vec4 j = p - 49.0 * floor(p * ns.z * ns.z);
vec4 x_ = floor(j * ns.z);
vec4 y_ = floor(j - 7.0 * x_);
vec4 x = x_ * ns.x + ns.yyyy;
vec4 y = y_ * ns.x + ns.yyyy;
vec4 h = vec4(1.0) - abs(x) - abs(y);
vec4 b0 = vec4(x.xy, y.xy);
vec4 b1 = vec4(x.zw, y.zw);
vec4 s0 = floor(b0) * 2.0 + vec4(1.0);
vec4 s1 = floor(b1) * 2.0 + vec4(1.0);
vec4 sh = -step(h, vec4(0.0));
vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;
vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;
vec3 p0 = vec3(a0.xy, h.x);
vec3 p1 = vec3(a0.zw, h.y);
vec3 p2 = vec3(a1.xy, h.z);
vec3 p3 = vec3(a1.zw, h.w);
vec4 norm = taylorInvSqrt(vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));
p0 *= norm.x;
p1 *= norm.y;
p2 *= norm.z;
p3 *= norm.w;
vec4 m = max(vec4(0.6) - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), vec4(0.0));
m = m * m;
return 42.0 * dot(m * m, vec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)));
}
float tri(float x) { return abs(fract(x) - 0.5); }
vec3 tri3(vec3 p) {
float tx = tri(p.x);
return vec3(
tri(p.z + tri(p.y * 20.0)),
tri(p.z + tx),
tri(p.y + tx)
);
}
float triNoise3D(vec3 p_in, float timeShift) {
vec3 p = p_in;
float z = 0.4;
float rz = 0.1;
vec3 bp = p;
vec3 ts = vec3(timeShift);
for (int i = 0; i < 5; i++) {
vec3 dg = tri3(bp * 0.01);
p += dg + ts;
bp *= 4.0;
z *= 0.9;
p *= 1.6;
rz += tri(p.z + tri(0.6 * p.x + 0.1 * tri(p.y))) / z;
}
return smoothstep(0.0, 8.0, rz + sin(rz + sin(z) * 2.8) * 2.2);
}
float shapeSpark(float rawSpark) {
float s2 = rawSpark * rawSpark;
float s4 = s2 * s2;
float s8 = s4 * s4;
float spark = rawSpark * 0.2 + s8 * s2;
float gateInput = clamp(0.3 / max(spark, 0.00001), 0.0, 1.0);
float gate = gateInput * gateInput * (3.0 - 2.0 * gateInput);
return spark * gate;
}
float light(float intensity, float attenuation, float dist) {
return intensity / (1.0 + dist + dist * attenuation);
}
vec4 makeNoiseBlob2(
vec2 localUv,
vec3 color1,
vec3 color2,
float offset,
float innerAdd,
float glowIntensity,
float vTimeHalf
) {
float len = length(localUv);
float n0 = snoise3(vec3(localUv * 1.2 + vec2(offset), vTimeHalf + offset)) * 0.5 + 0.5;
float r0 = clamp(n0, 0.0, 1.0);
float d0 = abs(len - r0);
float v0 = 1.0 - smoothstep(r0, max(r0 + innerAdd, r0 + 0.001), len);
float v1 = light(glowIntensity, 10.0, d0);
vec3 col = clamp(mix(color1, color2, localUv.y * 2.0) + vec3(v1), vec3(0.0), vec3(1.0));
return vec4(col, v0);
}
vec4 makeBlob(
vec2 uv,
float baseLen,
float blob,
vec3 color1,
vec3 color2,
float width,
float baseReaction,
float audioStrength,
float offset,
vec2 noiseOffset,
float innerAdd,
float glowIntensity,
float vTimeHalf
) {
float outerRadius = blob + width * 0.5
+ baseReaction * (1.0 + (audioStrength * 0.6) * 50.0 * baseReaction);
if (baseLen >= outerRadius) {
return vec4(0.0);
}
vec4 noise = makeNoiseBlob2(
uv + noiseOffset,
color1,
color2,
offset,
innerAdd,
glowIntensity,
vTimeHalf
);
float outerMask = 1.0 - smoothstep(0.5, max(outerRadius, 0.501), baseLen);
noise.a *= outerMask;
return noise;
}
void main() {
// OpenGL FBO: v_uv.y = 0 at bottom, 1 at top -> +uv.y points UP, matching WebGL verbatim!
vec2 uv = (v_uv * 2.0 - vec2(1.0)) * u_uv_scale_time_maxr.xy;
float baseLen = length(uv);
if (baseLen >= u_uv_scale_time_maxr.w) {
o_color = vec4(0.0);
return;
}
float vTime = u_uv_scale_time_maxr.z;
float vTimeHalf = vTime * 0.5;
float timeShift = vTime * 0.01;
float angle = atan(uv.y, uv.x);
float angleIndex = angle * INV_TWO_EFFECT_PI;
float shiftedAngle = angle + EFFECT_PI;
if (shiftedAngle > MATH_PI) {
shiftedAngle -= TWO_MATH_PI;
}
float shiftedIndex = shiftedAngle * INV_TWO_EFFECT_PI;
float seamAngle = (shiftedAngle + EFFECT_PI) * 0.5;
float seamWeight = smoothstep(0.9, 1.0, sin(seamAngle));
float rawSpark = triNoise3D(vec3(angleIndex, 0.0, 0.0), timeShift);
if (seamWeight > 0.0) {
float seamSpark = triNoise3D(vec3(shiftedIndex, 0.0, shiftedIndex), timeShift);
rawSpark = mix(rawSpark, seamSpark, seamWeight);
}
float spark = shapeSpark(rawSpark);
vec3 c0_start = unpack_rgb(u_colors_a.x);
vec3 c1_start = unpack_rgb(u_colors_a.y);
vec3 c2_start = unpack_rgb(u_colors_a.z);
vec3 c0_end = unpack_rgb(u_colors_a.w);
vec3 c1_end = unpack_rgb(u_colors_b.x);
vec3 c2_end = unpack_rgb(u_colors_b.y);
vec4 color = vec4(0.0);
float n0 = clamp(snoise3(vec3(uv * 1.2, vTimeHalf)), -1.0, 1.0);
float sharedOffset = 0.3 * n0;
// Layer 0 (bottom)
vec4 b0 = makeBlob(
uv, baseLen,
CIRCLE_RADIUS_BASE + sharedOffset,
c0_start, c0_end,
CIRCLE_WIDTH_BASE,
SPARK_STRENGTH_BASE * spark,
u_audio012_pad.x,
CIRCLE_OFFSET_BASE,
u_rot01.xy,
u_rot2_inner01.z,
u_inner2_glow012.y,
vTimeHalf
);
color = vec4(mix(color.rgb, b0.rgb, b0.a), max(b0.a, color.a));
// Layer 1 (middle)
vec4 b1 = makeBlob(
uv, baseLen,
(CIRCLE_RADIUS_BASE - CIRCLE_RADIUS_STEP) + sharedOffset,
c1_start, c1_end,
CIRCLE_WIDTH_BASE - CIRCLE_WIDTH_STEP,
(SPARK_STRENGTH_BASE - SPARK_STRENGTH_STEP) * spark,
u_audio012_pad.y,
CIRCLE_OFFSET_BASE + CIRCLE_OFFSET_STEP,
u_rot01.zw,
u_rot2_inner01.w,
u_inner2_glow012.z,
vTimeHalf
);
color = vec4(mix(color.rgb, b1.rgb, b1.a), max(b1.a, color.a));
// Layer 2 (top)
vec4 b2 = makeBlob(
uv, baseLen,
(CIRCLE_RADIUS_BASE - CIRCLE_RADIUS_STEP * 2.0) + sharedOffset,
c2_start, c2_end,
CIRCLE_WIDTH_BASE - CIRCLE_WIDTH_STEP * 2.0,
(SPARK_STRENGTH_BASE - SPARK_STRENGTH_STEP * 2.0) * spark,
u_audio012_pad.z,
CIRCLE_OFFSET_BASE + CIRCLE_OFFSET_STEP * 2.0,
u_rot2_inner01.xy,
u_inner2_glow012.x,
u_inner2_glow012.w,
vTimeHalf
);
color = vec4(mix(color.rgb, b2.rgb, b2.a), max(b2.a, color.a));
float out_a = clamp(color.a * 0.80, 0.0, 1.0);
vec3 out_rgb = clamp(color.rgb, vec3(0.0), vec3(1.0)) * 0.80;
o_color = vec4(out_rgb, out_a);
}

15
shaders/gl/vibe.vert Normal file
View file

@ -0,0 +1,15 @@
#version 330 core
// Fullscreen triangle vertex shader for Verbatim 5.129.0 My Vibe Shader (OpenGL 3.3 Core)
out vec2 v_uv;
void main() {
vec2 positions[3] = vec2[3](
vec2(-1.0, -1.0),
vec2( 3.0, -1.0),
vec2(-1.0, 3.0)
);
vec2 p = positions[gl_VertexID];
gl_Position = vec4(p, 0.0, 1.0);
v_uv = p * 0.5 + vec2(0.5);
}