From 700f75f43bea225044ec0591e27a919014feb355 Mon Sep 17 00:00:00 2001 From: klemek Date: Sun, 9 Nov 2025 17:58:06 +0100 Subject: [PATCH] feat: src12 scales --- DEVELOPMENT.md | 2 +- README.md | 10 +++---- default/inc_functions.glsl | 12 +++++++++ default/inc_fx.glsl | 8 +++--- default/inc_src.glsl | 53 ++++++++++++++++++++++++++++---------- 5 files changed, 62 insertions(+), 23 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 71bf374..76726a3 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -88,7 +88,7 @@ make -f Makefile.dev release-arch - [x] split with includes - [x] src 9 : sentences repeat h - [x] src 10 : isometric grid - - [ ] src 12 : pattern in my kitchen + - [x] src 12 : pattern in my kitchen - [ ] src 13 : cursor with select - [ ] src 14 : ? - [ ] src 15 : ? diff --git a/README.md b/README.md index 9a98030..f13314c 100644 --- a/README.md +++ b/README.md @@ -150,12 +150,12 @@ options: | | **6** | CP437 | _Zoom_ | _Charset_ | _Char. Delta_ | TV | _Lens_ | _Horz. Noise_ | _Dezoom_ | | | **7** | Sentences | _Zoom_ | _Sentence_ | _Vertical repeat_ | Kaleidoscope | _Axes_ | _Rotation_ | _Horz. Scroll_ | | | **8** | Sentences repeat | _X Shift_ | _Sentence_ | _Vertical repeat_ | CP437 | _Zoom_ | _Charset_ | _Char. Delta_ | -| | **9** | Isometric grid | _Zoom_ | _Scroll_ | _Elevation_ | Lens | _Lens limit_ | _Lens power_ | _Pre Zoom_ | +| | **9** | Isometric grid | _Zoom_ | _Scroll_ | _Elevation_ | Lens | _Lens limit_ | _Lens power_ | _Pre Zoom_ | | **3** | **A** | Video In 2 + Thru | _Hue_ | _Saturation_ | _Light_ | Spill | _Bottom limit_ | _Top Limit_ | _Rotation_ | -| | **B** | | | | | Game Of Life | _Pixel Size_ | _Ruleset/Threshold_ | _Feedback_ | -| | **C** | | | | | | | | | -| | **D** | | | | | | | | | -| | **E** | | | | | | | | | +| | **B** | Scales | _Zoom_ | _Shape_ | _Ripples_ | Game Of Life | _Pixel Size_ | _Ruleset/Threshold_ | _Feedback_ | +| | **C** | (same as 1) | | | | | (same as 1) | | | +| | **D** | (same as 2) | | | | | (same as 2) | | | +| | **E** | (same as 3) | | | | | (same as 3) | | | TODO update diff --git a/default/inc_functions.glsl b/default/inc_functions.glsl index 30db4c4..00cc9fb 100644 --- a/default/inc_functions.glsl +++ b/default/inc_functions.glsl @@ -9,6 +9,18 @@ // BASICS +float istep(float x, float y) { + return 1 - step(x, y); +} + +float estep(float x, float y) { + return smoothstep(x - 0.0001, x + 0.0001, y); +} + +float iestep(float x, float y) { + return 1 - estep(x, y); +} + float ease(float x) { return 0.5 - cos(max(min(x, 1.0), 0.0)*PI) * 0.5; } diff --git a/default/inc_fx.glsl b/default/inc_fx.glsl index ac6388c..07414ea 100644 --- a/default/inc_fx.glsl +++ b/default/inc_fx.glsl @@ -344,7 +344,7 @@ subroutine(fx_stage_sub) vec4 fx_11(vec2 vUV, sampler2D previous, sampler2D feed return fx_master(c0, c, seed, m0); } -// TODO FX 12 +// FX 12 : Game Of Life subroutine(fx_stage_sub) vec4 fx_12(vec2 vUV, sampler2D previous, sampler2D feedback, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec3 m0) { // start @@ -461,7 +461,7 @@ subroutine(fx_stage_sub) vec4 fx_12(vec2 vUV, sampler2D previous, sampler2D feed // TODO FX 13 subroutine(fx_stage_sub) vec4 fx_13(vec2 vUV, sampler2D previous, sampler2D feedback, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec3 m0) { - return fx_3(vUV, previous, feedback, seed, b1, f1, b2, f2, b3, f3, m0); + return fx_2(vUV, previous, feedback, seed, b1, f1, b2, f2, b3, f3, m0); // start vec2 uv0 = vUV.st; @@ -481,7 +481,7 @@ subroutine(fx_stage_sub) vec4 fx_13(vec2 vUV, sampler2D previous, sampler2D feed // TODO FX 14 subroutine(fx_stage_sub) vec4 fx_14(vec2 vUV, sampler2D previous, sampler2D feedback, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec3 m0) { - return fx_4(vUV, previous, feedback, seed, b1, f1, b2, f2, b3, f3, m0); + return fx_3(vUV, previous, feedback, seed, b1, f1, b2, f2, b3, f3, m0); // start vec2 uv0 = vUV.st; @@ -501,7 +501,7 @@ subroutine(fx_stage_sub) vec4 fx_14(vec2 vUV, sampler2D previous, sampler2D feed // TODO FX 15 subroutine(fx_stage_sub) vec4 fx_15(vec2 vUV, sampler2D previous, sampler2D feedback, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec3 m0) { - return fx_5(vUV, previous, feedback, seed, b1, f1, b2, f2, b3, f3, m0); + return fx_4(vUV, previous, feedback, seed, b1, f1, b2, f2, b3, f3, m0); // start vec2 uv0 = vUV.st; diff --git a/default/inc_src.glsl b/default/inc_src.glsl index 84e0bff..f3c12b0 100644 --- a/default/inc_src.glsl +++ b/default/inc_src.glsl @@ -65,7 +65,7 @@ subroutine(src_stage_sub) vec4 src_2(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 uv2 *= rot(rotation + iBeats / 16); float k = thickness * 2; uv2.y = cmod(uv2.y, k * 2 + 0.1); - float f = step(uv2.y, k * 0.125 + 0.05) * step(-uv2.y, k * 0.125 + 0.01); + float f = istep(k * 0.125 + 0.05, uv2.y) * istep(k * 0.125 + 0.01, -uv2.y); return vec4(f); } @@ -94,7 +94,7 @@ subroutine(src_stage_sub) vec4 src_3(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 uv2 *= rot(rotation + iBeats / 16); float k = zoom * 0.1 + 0.05; uv2 = cmod(uv2, k * 2); - float f = step(length(uv2), k / (1 + length(uv1) * 2)); + float f = istep(k / (1 + length(uv1) * 2), length(uv2)); return vec4(f); } @@ -137,7 +137,7 @@ subroutine(src_stage_sub) vec4 src_4(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 s *= 0.1; float cut = 0.025 + thickness * 0.475; float y2 = min(1.0, -(uv2.y)); - float f = (0.1 + 0.9 * (cos((y2 + 1.0) * PI) * 0.5 + 0.5)) * step(uv2.y, 0.) * step(fract(y + (s - 1) * (1 - cut) * 0.5), cut);//step(uv2.y, 0.) * mod(-uv2.y * 1.0, 1.0); + float f = (0.1 + 0.9 * (cos((y2 + 1.0) * PI) * 0.5 + 0.5)) * istep(0, uv2.y) * istep(cut, fract(y + (s - 1) * (1 - cut) * 0.5)); return vec4(f); } @@ -338,10 +338,9 @@ subroutine(src_stage_sub) vec4 src_11(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 return src_thru(vUV, iTex4, seed, b1, f1, b2, f2, b3, f3); } -// TODO SRC 12 +// SRC 12 : Scales subroutine(src_stage_sub) vec4 src_12(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3) { - return src_4(vUV, seed, b1, f1, b2, f2, b3, f3); // start vec2 uv0 = vUV.st; @@ -350,15 +349,42 @@ subroutine(src_stage_sub) vec4 src_12(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 // controls + float zoom = 5 + magic(f1, b1, seed + 10) * 15; + float shape = magic(f2, b2, seed + 20); + float repeat = 1 + magic(f3, b3, seed + 30) * 10; + // logic - - return texture(iTex0, vUV); + + float f = 0; + + vec2 uv2 = uv1; + + uv2 *= zoom; + + uv2 = mod(uv2, 4); + + vec2 uv3 = uv2; + + uv3.y = mix(uv3.y, -uv3.y, step(2, uv2.x) * step(2, uv2.y)); + uv3.y = mix(uv3.y, -uv3.y, istep(2, uv2.x) * istep(2, uv2.y)); + + uv3.y = -uv3.y; + + uv3.x = mix(-uv3.x, uv3.x, istep(3, uv2.x) * step(1, uv2.x)); + uv3.x = mix(-uv3.x, uv3.x, istep(3, uv2.y) * step(1, uv2.y)); + + f = istep(0.5, saw((length(mod(uv3, 1)) + shape + 0.5) * repeat)); + + f = mix(1 - f, f, istep(1, abs(uv2.y - 2)) * istep(2, uv2.x)); + f = mix(1 - f, f, step(1, abs(uv2.y - 2)) * step(2, uv2.x)); + + return vec4(f); } // TODO SRC 13 subroutine(src_stage_sub) vec4 src_13(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3) { - return src_5(vUV, seed, b1, f1, b2, f2, b3, f3); + return src_2(vUV, seed, b1, f1, b2, f2, b3, f3); // start vec2 uv0 = vUV.st; @@ -375,7 +401,7 @@ subroutine(src_stage_sub) vec4 src_13(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 // TODO SRC 14 subroutine(src_stage_sub) vec4 src_14(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3) { - return src_7(vUV, seed, b1, f1, b2, f2, b3, f3); + return src_3(vUV, seed, b1, f1, b2, f2, b3, f3); // start vec2 uv0 = vUV.st; @@ -389,9 +415,10 @@ subroutine(src_stage_sub) vec4 src_14(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 return texture(iTex0, vUV); } -// SRC 15 : Calibration +// TODO SRC 15 subroutine(src_stage_sub) vec4 src_15(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3) { + return src_4(vUV, seed, b1, f1, b2, f2, b3, f3); // start vec2 uv0 = vUV.st; @@ -409,7 +436,7 @@ subroutine(src_stage_sub) vec4 src_15(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 float f = 0; - f += step(length(uv1), circle * 0.5); + f += istep(circle * 0.5, length(uv1)); float txt = 0; float txt_rect = rect(uv1 * 10, vec2(0), vec2(2, 1)); @@ -420,11 +447,11 @@ subroutine(src_stage_sub) vec4 src_15(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 float grid = 0; - grid = step(mod(uv1.x + grid_size * 0.05, grid_size), grid_size * 0.1) + step(mod(uv1.y + grid_size * 0.05, grid_size), grid_size * 0.1); + grid = istep(grid_size * 0.1, mod(uv1.x + grid_size * 0.05, grid_size)) + istep(grid_size * 0.1, mod(uv1.y + grid_size * 0.05, grid_size)); grid = mix(grid, 0, show_grid ? min(1, f + txt_rect) : 1); - vec3 c = vec3(step(mod(uv0.x + x_shift, 0.5), 0.25), step(mod(uv0.x + 0.125 + x_shift, 0.5), 0.25), step(mod(uv0.x + x_shift, 1.0), 0.5)); + vec3 c = vec3(istep(0.25, mod(uv0.x + x_shift, 0.5)), istep(0.25, mod(uv0.x + 0.125 + x_shift, 0.5)), istep(0.5, mod(uv0.x + x_shift, 1.0))); c = mix(c, 1 - c, f);