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
+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);
}