feat: better src 4

This commit is contained in:
2026-05-16 00:32:41 +02:00
parent 96f97d81df
commit fe3316f730
5 changed files with 207 additions and 170 deletions
+10 -7
View File
@@ -7,7 +7,7 @@ SHELL := /bin/bash
clean:
@rm -rf build
build:
build/$(TARGET):
@mkdir -p build
gcc \
src/*.h src/*.c \
@@ -25,6 +25,9 @@ build:
-o build/$(TARGET) \
-g -Og
.PHONY: build
build: build/$(TARGET)
.PHONY: build-no-video
build-no-video:
@mkdir -p build
@@ -48,15 +51,15 @@ format:
clang-format -i src/*
.PHONY: run
run: build
run: build/$(TARGET)
./build/$(TARGET) $(RUN_ARGS)
.PHONY: sample
sample: build
./build/$(TARGET) --project=sample
sample: build/$(TARGET)
./build/$(TARGET) --project=sample $(RUN_ARGS)
.PHONY: valgrind
valgrind: build
valgrind: build/$(TARGET)
valgrind \
--show-realloc-size-zero=no \
--undef-value-errors=no \
@@ -68,7 +71,7 @@ full-clean:
rm -rf **/**/.deps
.PHONY: test-release
test-release: clean clean-release
test-release: clean full-clean
aclocal
autoconf
automake --add-missing
@@ -78,7 +81,7 @@ test-release: clean clean-release
cp $(TARGET)-steel-*.tar.gz build/
.PHONY: release-%
release-%: clean clean-release
release-%: clean full-clean
git pull origin main
sed -i -E "s/[0-9]+\\.[0-9]+\\.[0-9]+/$*/g" configure.ac
aclocal
+1 -1
View File
@@ -247,7 +247,7 @@ Working with pages and items, you can use the following predefined sources and e
| **1** | **0** | Feedback + Thru | _Hue_ | _Saturation_ | _Light_ | Thru | _Hue_ | _Saturation_ | _Light_ |
| | **1** | Lines | _Thick. / Dezoom_ | _Rotation_ | _Distortion_ | Feedback + Shift | _Zoom / Dezoom_ | _X Shift_ | _Y Shift_ |
| | **2** | Dots | _Zoom_ | _Rotation_ | _Lens_ | Shift | _Zoom / Dezoom_ | _X Shift_ | _Y Shift_ |
| | **3** | Circuit | _Zoom_ | _H. connect_ | _V. connect_ | Colorize | _Black Color_ | _White Color_ | _Shift_ |
| | **3** | Bacteria | _Zoom_ | _Details_ | _Delta details_ | Colorize | _Black Color_ | _White Color_ | _Shift_ |
| | **4** | Noise | _Zoom_ | _Voronoi dist._ | _Details_ | Quantize | _Pixel Size_ | _Bit Depth_ | _Blur_ |
| **2** | **5** | Video In 1 + Thru | _Hue_ | _Saturation_ | _Light_ | Dithering | _Pixel Size_ | _Bit Depth_ | _Blur_ |
| | **6** | CP437 | _Zoom_ | _Charset_ | _Char. Delta_ | TV | _Lens_ | _Horz. Noise_ | _Dezoom_ |
+55 -49
View File
@@ -24,48 +24,48 @@ float iestep(float x, float y) {
}
float ease(float x) {
return 0.5 - cos(max(min(x, 1.0), 0.0)*PI) * 0.5;
return 0.5 - cos(max(min(x, 1.0), 0.0) * PI) * 0.5;
}
vec2 ease(vec2 x) {
return 0.5 - cos(max(min(x, 1.0), 0.0)*PI) * 0.5;
return 0.5 - cos(max(min(x, 1.0), 0.0) * PI) * 0.5;
}
vec3 ease(vec3 x) {
return 0.5 - cos(max(min(x, 1.0), 0.0)*PI) * 0.5;
return 0.5 - cos(max(min(x, 1.0), 0.0) * PI) * 0.5;
}
float saw(float x){
return abs(mod(x+1,2)-1);
float saw(float x) {
return abs(mod(x + 1, 2) - 1);
}
vec2 saw(vec2 x){
return abs(mod(x+1,2)-1);
vec2 saw(vec2 x) {
return abs(mod(x + 1, 2) - 1);
}
vec3 saw(vec3 x){
return abs(mod(x+1,2)-1);
vec3 saw(vec3 x) {
return abs(mod(x + 1, 2) - 1);
}
float cmod(float x, float k){
float cmod(float x, float k) {
return mod(x + k * 0.5, k) - k * 0.5;
}
vec2 cmod(vec2 x, float k){
vec2 cmod(vec2 x, float k) {
return mod(x + k * 0.5, k) - k * 0.5;
}
vec3 cmod(vec3 x, float k){
vec3 cmod(vec3 x, float k) {
return mod(x + k * 0.5, k) - k * 0.5;
}
// COLORS
vec3 col(float x){
vec3 col(float x) {
return vec3(
.5*(sin(x*2.*PI)+1.),
.5*(sin(x*2.*PI+2.*PI/3.)+1.),
.5*(sin(x*2.*PI-2.*PI/3.)+1.)
.5 * (sin(x * 2. * PI) + 1.),
.5 * (sin(x * 2. * PI + 2. * PI / 3.) + 1.),
.5 * (sin(x * 2. * PI - 2. * PI / 3.) + 1.)
);
}
@@ -83,8 +83,7 @@ vec3 shift3(vec3 c, float f) {
vec3 mix3(vec3 c1, vec3 c2, vec3 c3, float x) {
return istep(0.5, x) * mix(c1, c2, x * 2)
+ step(0.5, x) * mix(c2, c3, x * 2 - 1)
;
+ step(0.5, x) * mix(c2, c3, x * 2 - 1);
}
vec3 mix4(vec3 c1, vec3 c2, vec3 c3, vec3 c4, float x) {
@@ -98,8 +97,7 @@ vec3 mix5(vec3 c1, vec3 c2, vec3 c3, vec3 c4, vec3 c5, float x) {
return istep(0.25, x) * mix(c1, c2, x * 4)
+ step(0.25, x) * istep(0.5, x) * mix(c2, c3, x * 4 - 1)
+ step(0.5, x) * istep(0.75, x) * mix(c3, c4, x * 4 - 2)
+ step(0.75, x) * mix(c4, c5, x * 4 - 3)
;
+ step(0.75, x) * mix(c4, c5, x * 4 - 3);
}
vec3 mix6(vec3 c1, vec3 c2, vec3 c3, vec3 c4, vec3 c5, vec3 c6, float x) {
@@ -107,8 +105,7 @@ vec3 mix6(vec3 c1, vec3 c2, vec3 c3, vec3 c4, vec3 c5, vec3 c6, float x) {
+ step(0.2, x) * istep(0.4, x) * mix(c2, c3, x * 5 - 1)
+ step(0.4, x) * istep(0.6, x) * mix(c3, c4, x * 5 - 2)
+ step(0.6, x) * istep(0.8, x) * mix(c4, c5, x * 5 - 3)
+ step(0.8, x) * mix(c5, c6, x * 5 - 4)
;
+ step(0.8, x) * mix(c5, c6, x * 5 - 4);
}
float mean(vec3 v)
@@ -123,10 +120,10 @@ float mean(vec4 v)
// OTHER
mat2 rot(float angle){
mat2 rot(float angle) {
return mat2(
cos(angle*2.*PI),-sin(angle*2.*PI),
sin(angle*2.*PI),cos(angle*2.*PI)
cos(angle * 2. * PI), -sin(angle * 2. * PI),
sin(angle * 2. * PI), cos(angle * 2. * PI)
);
}
@@ -141,18 +138,18 @@ vec2 kal(vec2 uv, float n) {
float q = 3.0 / (2.0 * PI);
t = abs(mod(t + PI / (n), 2 * PI / n) - PI / (n));
return length(uv) * vec2(
cos(t),
sin(t)
);
cos(t),
sin(t)
);
}
vec2 kal2(vec2 uv, float n) {
float t = atan(uv.y, uv.x) + PI * 0.5;
float t2 = abs(mod(t + PI / n, 2 * PI / n) - PI / n);
return length(uv) * vec2(
cos(t2),
sin(t2)
);
cos(t2),
sin(t2)
);
}
// NOISE
@@ -182,15 +179,15 @@ float v_index(vec2 uv) {
return floor(uv.x) + floor(uv.y) * 45;
}
vec2 v_pos(float i) {
int iTimeId = int(iBeats);
float iTimeV = iBeats - iTimeId;
vec2 v_pos(float i, int seed, float time) {
int iTimeId = int(time);
float iTimeV = time - iTimeId;
float x0 = rand(i + 823 + iTimeId);
float y0 = rand(i + 328 + iTimeId);
float x0 = rand(i + seed + iTimeId);
float y0 = rand(i + seed + 10 + iTimeId);
float x1 = rand(i + 823 + iTimeId + 1);
float y1 = rand(i + 328 + iTimeId + 1);
float x1 = rand(i + seed + iTimeId + 1);
float y1 = rand(i + seed + 10 + iTimeId + 1);
return vec2(
mix(x0, x1, ease(ease(iTimeV))),
@@ -198,7 +195,7 @@ vec2 v_pos(float i) {
);
}
vec4 voronoi(vec2 uv, float dist) {
vec4 voronoi(vec2 uv, float dist, int seed, float time) {
vec4 o = vec4(0, 0, 2, 0);
vec4 t = vec4(0, 0, 2, 0);
float d, i;
@@ -207,7 +204,7 @@ vec4 voronoi(vec2 uv, float dist) {
for (int dy = -1; dy <= 1; dy++) {
uv2 = vec2(floor(uv.x) + dx, floor(uv.y) + dy);
i = v_index(uv2);
p = uv2 + v_pos(i) * dist;
p = uv2 + v_pos(i, seed, time) * dist;
d = length(p - uv);
if (d < o.z) {
t = o;
@@ -260,9 +257,9 @@ float line(vec2 uv, vec2 p1, vec2 p2, float thick) {
if (abs(p.y) > abs(p.x)) {
k = vec2(
uv.x - p.x * uv.y / p.y,
uv.y / p.y
);
uv.x - p.x * uv.y / p.y,
uv.y / p.y
);
return step(k.x, thick * 0.5)
* step(-k.x, thick * 0.5)
@@ -270,9 +267,9 @@ float line(vec2 uv, vec2 p1, vec2 p2, float thick) {
* (1 - step(k.y, 0));
} else {
k = vec2(
uv.x / p.x,
uv.y - p.y * uv.x / p.x
);
uv.x / p.x,
uv.y - p.y * uv.x / p.x
);
return step(k.y, thick * 0.5)
* step(-k.y, thick * 0.5)
@@ -281,7 +278,16 @@ float line(vec2 uv, vec2 p1, vec2 p2, float thick) {
}
}
const mat2x2 ISOMETRIC_MATRIX = {{0.5, 1}, {0.5, -1}};
const mat2x2 ISOMETRIC_MATRIX = {
{
0.5,
1
},
{
0.5,
-1
}
};
vec2 iso(vec2 p) {
return p * ISOMETRIC_MATRIX;
@@ -302,14 +308,14 @@ vec2 iso(vec3 uv) {
vec4 reframe(sampler2D tex, vec2 uv)
{
uv = uv * vec2(iResolution.y / iResolution.x, 1) + .5;
uv = uv * vec2(iResolution.y / iResolution.x, 1) + .5;
uv = saw(uv);
return texture(tex, uv);
}
vec4 reframe_b(sampler2D tex, vec2 uv)
{
uv = uv * vec2(iResolution.y / iResolution.x, 1) + .5;
uv = uv * vec2(iResolution.y / iResolution.x, 1) + .5;
return texture(tex, uv);
}
+141 -113
View File
@@ -101,7 +101,139 @@ subroutine ( src_stage_sub ) vec4 src_3(vec2 vUV, int seed, vec3 b1, vec2 f1, ve
return vec4(f);
}
// SRC 4 : circuit
// // SRC 4 : circuit
// subroutine ( src_stage_sub ) vec4 src_4(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
// {
// // start
// vec2 uv0 = vUV.st;
// float ratio = iResolution.x / iResolution.y;
// vec2 uv1 = (uv0 - .5) * vec2(ratio, 1);
// // controls
// float z = 10 + magic(f1, b1, 123) * 20;
// float h = magic(f2, b2, seed + 20) * 0.8 + 0.1;
// float v = magic_reverse(f3, b3, seed + 30) * 0.8 + 0.1;
// // logic
// uv1 *= z;
// uv1 += iBeats;
// float s0 = rand(floor(mod(uv1, 1000))) * 1000;
// float s1 = rand(floor(mod(uv1 + vec2(0, 1), 1000))) * 1000;
// float s2 = rand(floor(mod(uv1 - vec2(1, 0), 1000))) * 1000;
// bool up = rand(s1 + 1) < h;
// bool left = rand(s2 + 2) < v;
// bool down = rand(s0 + 1) < h;
// bool right = rand(s0 + 2) < v;
// bool up_down = up && down;
// bool left_right = left && right;
// uv1 = mod(uv1, 1.0) - 0.5;
// const float t = 0.1;
// float f = 0;
// int c = 0;
// if (up) {
// f += stripe(uv1.x, -t * 0.5, t * 0.5) * step(-t * 0.5, uv1.y);
// c += 1;
// }
// if (down) {
// f += stripe(uv1.x, -t * 0.5, t * 0.5) * istep(t * 0.5, uv1.y);
// c += 1;
// }
// if (left) {
// f += stripe(uv1.y, -t * 0.5, t * 0.5) * istep(t * 0.5, uv1.x);
// c += 1;
// }
// if (right) {
// f += stripe(uv1.y, -t * 0.5, t * 0.5) * step(-t * 0.5, uv1.x);
// c += 1;
// }
// if (c == 1) {
// f += istep(t, length(uv1));
// }
// f = min(f, 1);
// if ((up_down ^^ left_right) && c == 2) {
// if (up_down) {
// uv1.xy = uv1.yx;
// }
// if (rand(s0 + 3) < 0.5) {
// uv1.x = -uv1.x;
// }
// float k = rand(s0 + 4) * 60;
// f -= rect(uv1, vec2(0), vec2(t * 3, t));
// f = max(0, f);
// if (k < 10) { // resistor
// f += line(uv1, vec2(-t * 3.25, -t * 0.5), vec2(-t * 2.5, t * 2), t * 0.75);
// f += line(uv1, vec2(-t * 2.5, t * 2), vec2(-t * 1.5, -t * 2), t * 0.75);
// f += line(uv1, vec2(-t * 1.5, -t * 2), vec2(-t * 0.5, t * 2), t * 0.75);
// f += line(uv1, vec2(-t * 0.5, t * 2), vec2(t * 0.5, -t * 2), t * 0.75);
// f += line(uv1, vec2(t * 0.5, -t * 2), vec2(t * 1.5, t * 2), t * 0.75);
// f += line(uv1, vec2(t * 1.5, t * 2), vec2(t * 2.5, -t * 2), t * 0.75);
// f += line(uv1, vec2(t * 2.5, -t * 2), vec2(t * 3.25, t * 0.5), t * 0.75);
// } else if (k < 20) { // capacitor
// f += rect(uv1, vec2(-t * 2, 0), vec2(t, t * 0.5));
// f += rect(uv1, vec2(t * 2, 0), vec2(t, t * 0.5));
// f += rect(uv1, vec2(t, 0), vec2(t * 0.5, t * 3.5));
// f += rect(uv1, vec2(-t, 0), vec2(t * 0.5, t * 3.5));
// } else if (k < 30) { // diode
// f += line(uv1, vec2(-t * 2, t * 2.5), vec2(t * 2, 0), t);
// f += line(uv1, vec2(-t * 2, -t * 2.5), vec2(t * 2, 0), t);
// f += rect(uv1, vec2(t * 2.5, 0), vec2(t * 0.5, t * 3));
// f += rect(uv1, vec2(-t * 2.5, 0), vec2(t * 0.5, t * 3));
// } else if (k < 40) { // lamp
// f += istep(t * 3.5, length(uv1));
// f -= istep(t * 2.5, length(uv1));
// f += line(uv1, vec2(-t * 2), vec2(t * 2), t);
// f += line(uv1, vec2(-t * 2, t * 2), vec2(t * 2, -t * 2), t);
// } else if (k < 50) { // inductor
// f += istep(t * 2, length(uv1 - vec2(t * 2.5, 0)));
// f += istep(t * 2, length(uv1 - vec2(0, 0)));
// f += istep(t * 2, length(uv1 - vec2(-t * 2.5, 0)));
// f -= 2 * istep(t, length(uv1 - vec2(t * 2.5, 0)));
// f -= 2 * istep(t, length(uv1 - vec2(0, 0)));
// f -= 2 * istep(t, length(uv1 - vec2(-t * 2.5, 0)));
// f *= step(-t * 0.5, uv1.y);
// } else if (k < 60) { // switch
// f += istep(t, length(uv1 - vec2(t * 2.5, 0)));
// f += istep(t, length(uv1 + vec2(t * 2.5, 0)));
// f += line(uv1, vec2(t * 2, 0), vec2(-t * 2.5, t * (k < 55 ? 3 : 1)), t);
// }
// } else if (c == 3) {
// if (left_right) {
// uv1.xy = uv1.yx;
// if (up) {
// uv1.x = -uv1.x;
// }
// } else if (right) {
// uv1.x = -uv1.x;
// }
// float k = rand(s0 + 4) * 20;
// if (k < 10) {
// f -= rect(uv1, vec2(0), vec2(t * 3));
// f = max(0, f);
// f += rect(uv1, vec2(-t * 3, 0), vec2(t * 0.5, t * 3));
// f += line(uv1, vec2(t * 0.25, t * 3.25), vec2(-t * 3, t), t);
// f += line(uv1, vec2(t * 0.25, -t * 3.25), vec2(-t * 3, -t), t);
// }
// }
// return vec4(f);
// }
// SRC 4 : bacteria
subroutine ( src_stage_sub ) vec4 src_4(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
{
// start
@@ -112,123 +244,19 @@ subroutine ( src_stage_sub ) vec4 src_4(vec2 vUV, int seed, vec3 b1, vec2 f1, ve
// controls
float z = 10 + magic(f1, b1, 123) * 20;
float h = magic(f2, b2, seed + 20) * 0.8 + 0.1;
float v = magic_reverse(f3, b3, seed + 30) * 0.8 + 0.1;
float zoom = 2 + magic(f1, b1, seed + 10) * 20;
float details = 5 * magic(f2, b2, seed + 20);
float delta = magic(f3, b3, seed + 30);
// logic
uv1 *= z;
uv1 += iBeats;
uv1 *= zoom;
float s0 = rand(floor(mod(uv1, 1000))) * 1000;
float s1 = rand(floor(mod(uv1 + vec2(0, 1), 1000))) * 1000;
float s2 = rand(floor(mod(uv1 - vec2(1, 0), 1000))) * 1000;
vec4 data = voronoi(uv1, 1, seed + 40, iBeats * 0.25);
bool up = rand(s1 + 1) < h;
bool left = rand(s2 + 2) < v;
bool down = rand(s0 + 1) < h;
bool right = rand(s0 + 2) < v;
bool up_down = up && down;
bool left_right = left && right;
float f = ease(data.x) + ease(data.y);
uv1 = mod(uv1, 1.0) - 0.5;
const float t = 0.1;
float f = 0;
int c = 0;
if (up) {
f += stripe(uv1.x, -t * 0.5, t * 0.5) * step(-t * 0.5, uv1.y);
c += 1;
}
if (down) {
f += stripe(uv1.x, -t * 0.5, t * 0.5) * istep(t * 0.5, uv1.y);
c += 1;
}
if (left) {
f += stripe(uv1.y, -t * 0.5, t * 0.5) * istep(t * 0.5, uv1.x);
c += 1;
}
if (right) {
f += stripe(uv1.y, -t * 0.5, t * 0.5) * step(-t * 0.5, uv1.x);
c += 1;
}
if (c == 1) {
f += istep(t, length(uv1));
}
f = min(f, 1);
if ((up_down ^^ left_right) && c == 2) {
if (up_down) {
uv1.xy = uv1.yx;
}
if (rand(s0 + 3) < 0.5) {
uv1.x = -uv1.x;
}
float k = rand(s0 + 4) * 60;
f -= rect(uv1, vec2(0), vec2(t * 3, t));
f = max(0, f);
if (k < 10) { // resistor
f += line(uv1, vec2(-t * 3.25, -t * 0.5), vec2(-t * 2.5, t * 2), t * 0.75);
f += line(uv1, vec2(-t * 2.5, t * 2), vec2(-t * 1.5, -t * 2), t * 0.75);
f += line(uv1, vec2(-t * 1.5, -t * 2), vec2(-t * 0.5, t * 2), t * 0.75);
f += line(uv1, vec2(-t * 0.5, t * 2), vec2(t * 0.5, -t * 2), t * 0.75);
f += line(uv1, vec2(t * 0.5, -t * 2), vec2(t * 1.5, t * 2), t * 0.75);
f += line(uv1, vec2(t * 1.5, t * 2), vec2(t * 2.5, -t * 2), t * 0.75);
f += line(uv1, vec2(t * 2.5, -t * 2), vec2(t * 3.25, t * 0.5), t * 0.75);
} else if (k < 20) { // capacitor
f += rect(uv1, vec2(-t * 2, 0), vec2(t, t * 0.5));
f += rect(uv1, vec2(t * 2, 0), vec2(t, t * 0.5));
f += rect(uv1, vec2(t, 0), vec2(t * 0.5, t * 3.5));
f += rect(uv1, vec2(-t, 0), vec2(t * 0.5, t * 3.5));
} else if (k < 30) { // diode
f += line(uv1, vec2(-t * 2, t * 2.5), vec2(t * 2, 0), t);
f += line(uv1, vec2(-t * 2, -t * 2.5), vec2(t * 2, 0), t);
f += rect(uv1, vec2(t * 2.5, 0), vec2(t * 0.5, t * 3));
f += rect(uv1, vec2(-t * 2.5, 0), vec2(t * 0.5, t * 3));
} else if (k < 40) { // lamp
f += istep(t * 3.5, length(uv1));
f -= istep(t * 2.5, length(uv1));
f += line(uv1, vec2(-t * 2), vec2(t * 2), t);
f += line(uv1, vec2(-t * 2, t * 2), vec2(t * 2, -t * 2), t);
} else if (k < 50) { // inductor
f += istep(t * 2, length(uv1 - vec2(t * 2.5, 0)));
f += istep(t * 2, length(uv1 - vec2(0, 0)));
f += istep(t * 2, length(uv1 - vec2(-t * 2.5, 0)));
f -= 2 * istep(t, length(uv1 - vec2(t * 2.5, 0)));
f -= 2 * istep(t, length(uv1 - vec2(0, 0)));
f -= 2 * istep(t, length(uv1 - vec2(-t * 2.5, 0)));
f *= step(-t * 0.5, uv1.y);
} else if (k < 60) { // switch
f += istep(t, length(uv1 - vec2(t * 2.5, 0)));
f += istep(t, length(uv1 + vec2(t * 2.5, 0)));
f += line(uv1, vec2(t * 2, 0), vec2(-t * 2.5, t * (k < 55 ? 3 : 1)), t);
}
} else if (c == 3) {
if (left_right) {
uv1.xy = uv1.yx;
if (up) {
uv1.x = -uv1.x;
}
} else if (right) {
uv1.x = -uv1.x;
}
float k = rand(s0 + 4) * 20;
if (k < 10) {
f -= rect(uv1, vec2(0), vec2(t * 3));
f = max(0, f);
f += rect(uv1, vec2(-t * 3, 0), vec2(t * 0.5, t * 3));
f += line(uv1, vec2(t * 0.25, t * 3.25), vec2(-t * 3, t), t);
f += line(uv1, vec2(t * 0.25, -t * 3.25), vec2(-t * 3, -t), t);
}
}
f = saw(f * (1 + data.x * details) - delta * 2.0);
return vec4(f);
}
@@ -254,7 +282,7 @@ subroutine ( src_stage_sub ) vec4 src_5(vec2 vUV, int seed, vec3 b1, vec2 f1, ve
vec2 uv2 = uv1;
uv2 *= zoom * 20 + 3;
uv2.x += iBeats;
vec4 data = voronoi(uv2, voronoi_distort);
vec4 data = voronoi(uv2, voronoi_distort, seed + 50, iBeats);
float f = data.x / (data.x + data.y);
f = sin(f * PI * (details * 20)) * 0.5 + 1;
int nf = int(noise_factor * 6);
Binary file not shown.