Files
hms-mediaengine/plugins/builtin/generators/com.hms.generator.shapes/shaders/gl/shapes.frag
T
HMS MediaEngine Agent 75ca88ddbe Phase 3: Alle 24 Pflicht-Plugins (10 Generatoren + 14 Filter, §15.1/§15.2)
- 10 Generatoren mit Manifest + HLSL + GLSL + GLES je Plugin:
  solid, gradient, checker_grid, stripes_chaser, noise_clouds
  (AQ Octaves 2/3/5), plasma, wave_bars, shapes, drops_ripples,
  starfield (AQ 32/128/512 Partikel)
- 14 Filter mit Manifest + Shader je Backend:
  transform2d (keine AQ-Geometriereduktion), color_adjust,
  gradient_map, blur_sharpen (separabel 2-Pass, AQ 5/9/17 Samples),
  pixelate_quantize, mirror_tile, kaleidoscope, wave_displace
  (Noise adaptiv, Amount unverändert), rgb_split, glow_bloom
  (Kaskade 2/4/8), edge_emboss, vignette, strobe_pulse (Safety
  clamp 2 Hz, nie durch DMX allein freischaltbar), feedback_trails
  (Double-Buffer, Clear-Trigger, §15.3)
- Uniform-Vertrag §14.4 in allen 75 Shadern; Generatoren sampeln nie
  u_input_texture; alle Filter mit mix-0-Bypass (§15.3)
- 195 parametrisierte Plugin-Tests: Manifest/Backends/DMX-Slots<=8/
  AQ>=3 Varianten/Uniform-Satz/Vollstaendigkeit exakt 10+14
- Nachtraegliche Manifest-Fixes: AQ-Bloecke fuer 4 1-Pass-Filter,
  mix-Parameter fuer feedback_trails (Slot-Overlap vermieden)
- Gesamtsuite 506 gruen, Ruff gruen
2026-09-11 01:53:48 +02:00

94 lines
3.5 KiB
GLSL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Shapes Generator
// HMS MediaEngine Generator (GLSL, Linux x64). Semantik identisch zu HLSL/GLES (§12.6, §15.1).
#version 330 core
uniform vec2 u_resolution;
uniform float u_time_seconds;
uniform float u_delta_seconds;
uniform float u_frame_index;
uniform float u_layer_opacity;
uniform float u_audio_rms;
uniform float u_audio_peak;
uniform float u_audio_bass;
uniform float u_audio_mid;
uniform float u_audio_treble;
uniform float u_audio_beat;
uniform float4 param_color_a;
uniform float4 param_color_b;
uniform float param_form;
uniform float param_count;
uniform float param_size;
uniform float param_rotation;
uniform float param_distribution;
uniform float param_fill_stroke;
uniform float param_seed;
uniform float u_quality_samples;
in vec2 v_uv;
out vec4 fragColor;
float hash21(vec2 p)
{
p = fract(p * vec2(123.34, 456.21));
p += dot(p, p + 45.32);
return fract(p.x * p.y);
}
float sdCircle(vec2 p, float r) { return length(p) - r; }
float sdBox(vec2 p, vec2 b) { vec2 d = abs(p) - b; return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0); }
float sdTri(vec2 p, float s) { p = abs(p); return max(p.x * 0.8660254 + p.y * 0.5, -p.y) - s * 0.5; }
float sdLine(vec2 p, vec2 a, vec2 b) { vec2 pa = p - a; vec2 ba = b - a; float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0); return length(pa - ba * h); }
float sdPoly(vec2 p, float r, int n) { float an = 6.2831853 / float(n); float a = atan(p.x, p.y) + 0.5; float b = an * floor(a / an); vec2 q = vec2(cos(b), sin(b)) * dot(vec2(cos(a), sin(a)), vec2(cos(b), sin(b))); return length(p - q * r); }
void main()
{
vec2 p = v_uv - 0.5;
float t = u_time_seconds;
float maxN = clamp(u_quality_samples, 1.0, 64.0);
float form = floor(param_form + 0.5);
float distr = floor(param_distribution + 0.5);
float fill = floor(param_fill_stroke + 0.5);
float acc = 0.0;
float colAcc = 0.0;
for (int i = 0; i < 64; i++)
{
if (float(i) >= maxN) { break; }
vec2 pos;
if (distr < 0.5)
{
float g = ceil(sqrt(maxN));
float gx = float(i % int(g));
float gy = floor(float(i) / g);
pos = (vec2(gx, gy) + 0.5) / g - 0.5;
}
else if (distr < 1.5)
{
float ang = 6.2831853 * float(i) / maxN;
pos = 0.35 * vec2(cos(ang), sin(ang));
}
else
{
pos = vec2(hash21(vec2(float(i) + param_seed, 1.0)), hash21(vec2(float(i) + param_seed, 2.0))) - 0.5;
}
vec2 lp = p - pos;
float cr = cos(param_rotation);
float sr = sin(param_rotation);
lp = vec2(cr * lp.x - sr * lp.y, sr * lp.x + cr * lp.y);
float d;
if (form < 0.5) { d = sdCircle(lp, param_size); }
else if (form < 1.5) { d = sdBox(lp, vec2(param_size, param_size)); }
else if (form < 2.5) { d = sdTri(lp, param_size); }
else if (form < 3.5) { d = sdLine(lp, vec2(-param_size, 0.0), vec2(param_size, 0.0)); }
else { d = sdPoly(lp, param_size, 6); }
float v;
if (fill < 0.5) { v = 1.0 - smoothstep(0.0, 0.01, d); }
else { v = 1.0 - smoothstep(0.0, 0.01, abs(d) - 0.01); }
acc += v;
colAcc += v * (float(i) / max(maxN - 1.0, 1.0));
}
acc = clamp(acc, 0.0, 1.0);
float mixT = maxN > 1.0 ? colAcc / max(acc, 1e-5) : 0.0;
vec3 col = mix(param_color_a.rgb, param_color_b.rgb, mixT);
fragColor = vec4(col * acc * u_layer_opacity, acc * u_layer_opacity);
}