wip value input

This commit is contained in:
2025-10-02 21:12:08 +02:00
parent 0119ed2fec
commit a2ba37df16
14 changed files with 256 additions and 176 deletions
+4 -3
View File
@@ -16,6 +16,7 @@ UNIFORM_SRC_PREFIX=midi
UNIFORM_PAGE=iPage
UNIFORM_SELECTED=iSelected
UNIFORM_ACTIVE_PREFIX=active
UNIFORM_SRC_PREFIX=src
SUB_TYPE_COUNT=2
SUB_1_PREFIX=src_
@@ -71,7 +72,7 @@ SRC_COUNT=3
SRC_1_ACTIVE_COUNT=2
SRC_1_ACTIVE_1=32
SRC_1_ACTIVE_2=64
SRC_1_COUNT=7
SRC_1_COUNT=6
SRC_1_1_X=33
SRC_1_1_Y=49
SRC_1_1_Z=65
@@ -93,8 +94,8 @@ SRC_1_6_Z=
SRC_2_ACTIVE_COUNT=3
SRC_2_ACTIVE_1=36
SRC_2_ACTIVE_2=68
SRC_2_ACTIVE_3=52
SRC_2_ACTIVE_2=52
SRC_2_ACTIVE_3=68
SRC_2_COUNT=7
SRC_2_1_X=37
SRC_2_1_Y=53
+123 -118
View File
@@ -35,6 +35,11 @@ uniform int state8;
uniform int active1;
uniform int active2;
uniform vec3 src2_1[7];
uniform vec3 src2_2[7];
uniform vec3 src2_3[7];
uniform vec3 src3_1[2];
// 2. textures
// ---------------
@@ -879,11 +884,11 @@ int guess_char(sampler2D tex, vec2 uv, float k, float t)
// 5. generators
// -------------
subroutine vec4 src_stage_sub(vec2 vUV, int seed);
subroutine vec4 src_stage_sub(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3);
subroutine uniform src_stage_sub src_stage;
vec4 src_thru(vec2 vUV, sampler2D tex, int seed)
vec4 src_thru(vec2 vUV, sampler2D tex, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
{
// start
@@ -891,9 +896,9 @@ vec4 src_thru(vec2 vUV, sampler2D tex, int seed)
// controls
float hue = magic(seed + 10);
float saturation = magic(seed + 20);
float light = magic(seed + 30);
float hue = magic(f1, b1, seed + 10);
float saturation = magic(f2, b2, seed + 20);
float light = magic(f3, b3, seed + 30);
// logic
@@ -910,13 +915,13 @@ vec4 src_thru(vec2 vUV, sampler2D tex, int seed)
}
// SRC 1: feedback + thru
subroutine(src_stage_sub) vec4 src_1(vec2 vUV, int seed)
subroutine(src_stage_sub) vec4 src_1(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
{
return src_thru(vUV, tex0, seed);
return src_thru(vUV, tex0, seed, b1, f1, b2, f2, b3, f3);
}
// SRC 2 : lines
subroutine(src_stage_sub) vec4 src_2(vec2 vUV, int seed)
subroutine(src_stage_sub) vec4 src_2(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
{
// start
@@ -926,9 +931,9 @@ subroutine(src_stage_sub) vec4 src_2(vec2 vUV, int seed)
// controls
float thickness = magic(seed + 10);
float rotation = magic(seed + 20);
float distort = magic(seed + 30);
float thickness = magic(f1, b1, seed + 10);
float rotation = magic(f2, b2, seed + 20);
float distort = magic(f3, b3, seed + 30);
// logic
@@ -943,7 +948,7 @@ subroutine(src_stage_sub) vec4 src_2(vec2 vUV, int seed)
}
// SRC 3 : dots
subroutine(src_stage_sub) vec4 src_3(vec2 vUV, int seed)
subroutine(src_stage_sub) vec4 src_3(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
{
// start
@@ -953,9 +958,9 @@ subroutine(src_stage_sub) vec4 src_3(vec2 vUV, int seed)
// controls
float zoom = magic(seed + 10);
float rotation = magic(seed + 20);
float lens_v = magic(seed + 30);
float zoom = magic(f1, b1, seed + 10);
float rotation = magic(f2, b2, seed + 20);
float lens_v = magic(f3, b3, seed + 30);
// logic
@@ -972,7 +977,7 @@ subroutine(src_stage_sub) vec4 src_3(vec2 vUV, int seed)
}
// SRC 4 : waves
subroutine(src_stage_sub) vec4 src_4(vec2 vUV, int seed)
subroutine(src_stage_sub) vec4 src_4(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
{
// start
@@ -982,9 +987,9 @@ subroutine(src_stage_sub) vec4 src_4(vec2 vUV, int seed)
// controls
float spacing = magic(seed + 10);
float thickness = magic(seed + 20);
float scroll = magic_reverse(seed + 30);
float spacing = magic(f1, b1, seed + 10);
float thickness = magic(f2, b2, seed + 20);
float scroll = magic_reverse(f3, b3, seed + 30);
// logic
@@ -1015,7 +1020,7 @@ subroutine(src_stage_sub) vec4 src_4(vec2 vUV, int seed)
}
// SRC 5 : noise
subroutine(src_stage_sub) vec4 src_5(vec2 vUV, int seed)
subroutine(src_stage_sub) vec4 src_5(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
{
// start
@@ -1025,9 +1030,9 @@ subroutine(src_stage_sub) vec4 src_5(vec2 vUV, int seed)
// controls
float zoom = magic(seed + 10);
float voronoi_distort = magic(seed + 20);
float details = magic(seed + 30);
float zoom = magic(f1, b1, seed + 10);
float voronoi_distort = magic(f2, b2, seed + 20);
float details = magic(f3, b3, seed + 30);
float noise_factor = magic(seed + 40);
// logic
@@ -1045,13 +1050,13 @@ subroutine(src_stage_sub) vec4 src_5(vec2 vUV, int seed)
}
// SRC 6 : video in 1 + thru
subroutine(src_stage_sub) vec4 src_6(vec2 vUV, int seed)
subroutine(src_stage_sub) vec4 src_6(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
{
return src_thru(vUV, tex3, seed);
return src_thru(vUV, tex3, seed, b1, f1, b2, f2, b3, f3);
}
// SRC 7 : cp437
subroutine(src_stage_sub) vec4 src_7(vec2 vUV, int seed)
subroutine(src_stage_sub) vec4 src_7(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
{
// start
@@ -1061,10 +1066,10 @@ subroutine(src_stage_sub) vec4 src_7(vec2 vUV, int seed)
// controls
float zoom = magic(seed + 10);
vec2 charset = magic_f(seed + 20);
vec3 charset_ctrl = magic_b(seed + 20);
float char_delta = magic(seed + 30);
float zoom = magic(f1, b1, seed + 10);
vec2 charset = magic_f(f2, b2, seed + 20);
vec3 charset_ctrl = magic_b(b2, seed + 20);
float char_delta = magic(f3, b3, seed + 30);
// logic
@@ -1103,7 +1108,7 @@ const int lengths[SENTENCE_COUNT] = {
5, 17, 13, 13, 13, 17, 8, 8, 11, 19
};
subroutine(src_stage_sub) vec4 src_8(vec2 vUV, int seed)
subroutine(src_stage_sub) vec4 src_8(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
{
// start
@@ -1113,10 +1118,10 @@ subroutine(src_stage_sub) vec4 src_8(vec2 vUV, int seed)
// controls
float zoom = magic(seed + 10);
float sentence = magic_reverse(seed + 20);
float h_delta = magic(seed + 30);
vec3 h_delta_b = magic_b(seed + 30);
float zoom = magic(f1, b1, seed + 10);
float sentence = magic_reverse(f2, b2, seed + 20);
float h_delta = magic(f3, b3, seed + 30);
vec3 h_delta_b = magic_b(b3, seed + 30);
// logic
@@ -1131,7 +1136,7 @@ subroutine(src_stage_sub) vec4 src_8(vec2 vUV, int seed)
}
// TODO SRC 9
subroutine(src_stage_sub) vec4 src_9(vec2 vUV, int seed)
subroutine(src_stage_sub) vec4 src_9(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
{
// start
@@ -1147,7 +1152,7 @@ subroutine(src_stage_sub) vec4 src_9(vec2 vUV, int seed)
}
// TODO SRC 10
subroutine(src_stage_sub) vec4 src_10(vec2 vUV, int seed)
subroutine(src_stage_sub) vec4 src_10(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
{
// start
@@ -1163,13 +1168,13 @@ subroutine(src_stage_sub) vec4 src_10(vec2 vUV, int seed)
}
// SRC 11 : video in 2 + thru
subroutine(src_stage_sub) vec4 src_11(vec2 vUV, int seed)
subroutine(src_stage_sub) vec4 src_11(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
{
return src_thru(vUV, tex4, seed);
return src_thru(vUV, tex4, seed, b1, f1, b2, f2, b3, f3);
}
// TODO SRC 12
subroutine(src_stage_sub) vec4 src_12(vec2 vUV, int seed)
subroutine(src_stage_sub) vec4 src_12(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
{
// start
@@ -1185,7 +1190,7 @@ subroutine(src_stage_sub) vec4 src_12(vec2 vUV, int seed)
}
// TODO SRC 13
subroutine(src_stage_sub) vec4 src_13(vec2 vUV, int seed)
subroutine(src_stage_sub) vec4 src_13(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
{
// start
@@ -1201,7 +1206,7 @@ subroutine(src_stage_sub) vec4 src_13(vec2 vUV, int seed)
}
// TODO SRC 14
subroutine(src_stage_sub) vec4 src_14(vec2 vUV, int seed)
subroutine(src_stage_sub) vec4 src_14(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
{
// start
@@ -1217,7 +1222,7 @@ subroutine(src_stage_sub) vec4 src_14(vec2 vUV, int seed)
}
// TODO SRC 15
subroutine(src_stage_sub) vec4 src_15(vec2 vUV, int seed)
subroutine(src_stage_sub) vec4 src_15(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
{
// start
@@ -1233,7 +1238,7 @@ subroutine(src_stage_sub) vec4 src_15(vec2 vUV, int seed)
}
// SRC 16 : debug
subroutine(src_stage_sub) vec4 src_16(vec2 vUV, int seed)
subroutine(src_stage_sub) vec4 src_16(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
{
// start
@@ -1248,11 +1253,11 @@ subroutine(src_stage_sub) vec4 src_16(vec2 vUV, int seed)
int selected_fxa = state5;
int selected_fxb = state6;
int selected_mfx = state8;
float fxa_value = magic(seed5);
float fxb_value = magic(seed6);
float mfx_value = magic(seed8);
float mix_value = magic(seed7);
bool mix_type = magic_trigger(seed7 + 10);
float fxa_value = magic(src2_1[6].xy, vec3(1, 0, 0), seed5);
float fxb_value = magic(src2_2[6].xy, vec3(1, 0, 0), seed6);
float mfx_value = magic(src2_3[6].xy, vec3(1, 0, 0), seed8);
float mix_value = magic(src3_1[1].xy, vec3(1, 0, 0), seed7);
bool mix_type = magic_trigger(vec3(src3_1[0].x, 0, 0), seed7 + 10);
// logic
@@ -1378,12 +1383,12 @@ subroutine(src_stage_sub) vec4 src_16(vec2 vUV, int seed)
// 6. effects
// ----------
subroutine vec4 fx_stage_sub(vec2 vUV, sampler2D previous, sampler2D feedback, int seed);
subroutine vec4 fx_stage_sub(vec2 vUV, sampler2D previous, sampler2D feedback, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec2 f0);
subroutine uniform fx_stage_sub fx_stage;
// FX 1 : thru
subroutine(fx_stage_sub) vec4 fx_1(vec2 vUV, sampler2D previous, sampler2D feedback, int seed)
subroutine(fx_stage_sub) vec4 fx_1(vec2 vUV, sampler2D previous, sampler2D feedback, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec2 f0)
{
// start
@@ -1391,11 +1396,11 @@ subroutine(fx_stage_sub) vec4 fx_1(vec2 vUV, sampler2D previous, sampler2D feedb
// controls
float fx = magic(seed);
float fx = magic(f0, vec3(1,0,0), seed);
float hue = magic(seed + 10);
float saturation = magic(seed + 20);
float light = magic(seed + 30);
float hue = magic(f1, b1, seed + 10);
float saturation = magic(f2, b2, seed + 20);
float light = magic(f3, b3, seed + 30);
// logic
@@ -1409,7 +1414,7 @@ subroutine(fx_stage_sub) vec4 fx_1(vec2 vUV, sampler2D previous, sampler2D feedb
}
// FX 2 : feedback + shift
vec4 fx_shift(vec2 vUV, sampler2D src0, sampler2D src1, int seed)
vec4 fx_shift(vec2 vUV, sampler2D src0, sampler2D src1, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec2 f0)
{
// start
@@ -1419,11 +1424,11 @@ vec4 fx_shift(vec2 vUV, sampler2D src0, sampler2D src1, int seed)
// controls
float fx = magic(seed);
float fx = magic(f0, vec3(1,0,0), seed);
float zoom = magic(seed + 10);
float x_shift = magic(seed + 20);
float y_shift = magic(seed + 30);
float zoom = magic(f1, b1, seed + 10);
float x_shift = magic(f2, b2, seed + 20);
float y_shift = magic(f3, b3, seed + 30);
// logic
@@ -1437,19 +1442,19 @@ vec4 fx_shift(vec2 vUV, sampler2D src0, sampler2D src1, int seed)
return vec4(mix(c0, c, fx), 1.0);
}
subroutine(fx_stage_sub) vec4 fx_2(vec2 vUV, sampler2D previous, sampler2D feedback, int seed)
subroutine(fx_stage_sub) vec4 fx_2(vec2 vUV, sampler2D previous, sampler2D feedback, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec2 f0)
{
return fx_shift(vUV, previous, feedback, seed);
return fx_shift(vUV, previous, feedback, seed, b1, f1, b2, f2, b3, f3, f0);
}
// FX 3 : shift
subroutine(fx_stage_sub) vec4 fx_3(vec2 vUV, sampler2D previous, sampler2D feedback, int seed)
subroutine(fx_stage_sub) vec4 fx_3(vec2 vUV, sampler2D previous, sampler2D feedback, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec2 f0)
{
return fx_shift(vUV, previous, previous, seed);
return fx_shift(vUV, previous, previous, seed, b1, f1, b2, f2, b3, f3, f0);
}
// FX 4 : colorize
subroutine(fx_stage_sub) vec4 fx_4(vec2 vUV, sampler2D previous, sampler2D feedback, int seed)
subroutine(fx_stage_sub) vec4 fx_4(vec2 vUV, sampler2D previous, sampler2D feedback, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec2 f0)
{
// start
@@ -1457,13 +1462,13 @@ subroutine(fx_stage_sub) vec4 fx_4(vec2 vUV, sampler2D previous, sampler2D feedb
// controls
float fx = magic(seed);
float fx = magic(f0, vec3(1,0,0), seed);
float c_black = magic(seed + 10);
bool c_black_trigger = magic_trigger(seed + 10);
float c_white = magic(seed + 20);
bool c_white_trigger = magic_trigger(seed + 20);
float delta = magic(seed + 30);
float c_black = magic(f1, b1, seed + 10);
bool c_black_trigger = magic_trigger(b1, seed + 10);
float c_white = magic(f2, b2, seed + 20);
bool c_white_trigger = magic_trigger(b2, seed + 20);
float delta = magic(f3, b3, seed + 30);
// logic
@@ -1477,7 +1482,7 @@ subroutine(fx_stage_sub) vec4 fx_4(vec2 vUV, sampler2D previous, sampler2D feedb
}
// FX 5 : quantize
subroutine(fx_stage_sub) vec4 fx_5(vec2 vUV, sampler2D previous, sampler2D feedback, int seed)
subroutine(fx_stage_sub) vec4 fx_5(vec2 vUV, sampler2D previous, sampler2D feedback, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec2 f0)
{
// start
@@ -1487,12 +1492,12 @@ subroutine(fx_stage_sub) vec4 fx_5(vec2 vUV, sampler2D previous, sampler2D feedb
// controls
float fx = magic(seed);
float fx = magic(f0, vec3(1,0,0), seed);
float pixel_size = magic(seed + 10);
float quantize = magic(seed + 20);
bool quantize_trigger = magic_trigger(seed + 20);
float blur = magic(seed + 30);
float pixel_size = magic(f1, b1, seed + 10);
float quantize = magic(f2, b2, seed + 20);
bool quantize_trigger = magic_trigger(b2, seed + 20);
float blur = magic(f3, b3, seed + 30);
// logic
@@ -1512,7 +1517,7 @@ subroutine(fx_stage_sub) vec4 fx_5(vec2 vUV, sampler2D previous, sampler2D feedb
}
// FX 6 : dithering
subroutine(fx_stage_sub) vec4 fx_6(vec2 vUV, sampler2D previous, sampler2D feedback, int seed)
subroutine(fx_stage_sub) vec4 fx_6(vec2 vUV, sampler2D previous, sampler2D feedback, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec2 f0)
{
// start
@@ -1522,13 +1527,13 @@ subroutine(fx_stage_sub) vec4 fx_6(vec2 vUV, sampler2D previous, sampler2D feedb
// controls
float fx = magic(seed);
float fx = magic(f0, vec3(1,0,0), seed);
float pixel_size = magic(seed + 10);
bool pixel_size_trigger = magic_trigger(seed + 10);
float quantize = magic(seed + 20);
bool quantize_trigger = magic_trigger(seed + 20);
float blur = magic(seed + 30);
float pixel_size = magic(f1, b1, seed + 10);
bool pixel_size_trigger = magic_trigger(b1, seed + 10);
float quantize = magic(f2, b2, seed + 20);
bool quantize_trigger = magic_trigger(b2, seed + 20);
float blur = magic(f3, b3, seed + 30);
// logic
@@ -1556,7 +1561,7 @@ subroutine(fx_stage_sub) vec4 fx_6(vec2 vUV, sampler2D previous, sampler2D feedb
}
// FX 7 : tv
subroutine(fx_stage_sub) vec4 fx_7(vec2 vUV, sampler2D previous, sampler2D feedback, int seed)
subroutine(fx_stage_sub) vec4 fx_7(vec2 vUV, sampler2D previous, sampler2D feedback, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec2 f0)
{
// start
@@ -1566,11 +1571,11 @@ subroutine(fx_stage_sub) vec4 fx_7(vec2 vUV, sampler2D previous, sampler2D feedb
// controls
float fx = magic(seed);
float fx = magic(f0, vec3(1,0,0), seed);
float lens_v = magic(seed + 10);
float horizontal_noise = magic(seed + 20);
float zoom = magic(seed + 30);
float lens_v = magic(f1, b1, seed + 10);
float horizontal_noise = magic(f2, b2, seed + 20);
float zoom = magic(f3, b3, seed + 30);
// logic
@@ -1591,7 +1596,7 @@ subroutine(fx_stage_sub) vec4 fx_7(vec2 vUV, sampler2D previous, sampler2D feedb
}
// FX 8 : kaleidoscope
subroutine(fx_stage_sub) vec4 fx_8(vec2 vUV, sampler2D previous, sampler2D feedback, int seed)
subroutine(fx_stage_sub) vec4 fx_8(vec2 vUV, sampler2D previous, sampler2D feedback, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec2 f0)
{
// start
@@ -1601,12 +1606,12 @@ subroutine(fx_stage_sub) vec4 fx_8(vec2 vUV, sampler2D previous, sampler2D feedb
// controls
float fx = magic(seed);
float fx = magic(f0, vec3(1,0,0), seed);
float axes = magic(seed + 10);
float axes_trigger = magic_b(seed + 10).x;
float rotation = magic(seed + 20);
float h_scroll = magic(seed + 30);
float axes = magic(f1, b1, seed + 10);
float axes_trigger = magic_b(b1, seed + 10).x;
float rotation = magic(f2, b2, seed + 20);
float h_scroll = magic(f3, b3, seed + 30);
// logic
@@ -1622,7 +1627,7 @@ subroutine(fx_stage_sub) vec4 fx_8(vec2 vUV, sampler2D previous, sampler2D feedb
}
// FX 9 : cp437
subroutine(fx_stage_sub) vec4 fx_9(vec2 vUV, sampler2D previous, sampler2D feedback, int seed)
subroutine(fx_stage_sub) vec4 fx_9(vec2 vUV, sampler2D previous, sampler2D feedback, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec2 f0)
{
// start
@@ -1632,12 +1637,12 @@ subroutine(fx_stage_sub) vec4 fx_9(vec2 vUV, sampler2D previous, sampler2D feedb
// controls
float fx = magic(seed);
float fx = magic(f0, vec3(1,0,0), seed);
float zoom = magic(seed + 10);
vec2 charset = magic_f(seed + 20);
vec3 charset_ctrl = magic_b(seed + 20);
float char_delta = magic(seed + 30);
float zoom = magic(f1, b1, seed + 10);
vec2 charset = magic_f(f2, b2, seed + 20);
vec3 charset_ctrl = magic_b(b2, seed + 20);
float char_delta = magic(f3, b3, seed + 30);
float t = magic(seed + 40);
// logic
@@ -1664,7 +1669,7 @@ subroutine(fx_stage_sub) vec4 fx_9(vec2 vUV, sampler2D previous, sampler2D feedb
}
// FX 10 : lens
subroutine(fx_stage_sub) vec4 fx_10(vec2 vUV, sampler2D previous, sampler2D feedback, int seed)
subroutine(fx_stage_sub) vec4 fx_10(vec2 vUV, sampler2D previous, sampler2D feedback, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec2 f0)
{
// start
@@ -1674,11 +1679,11 @@ subroutine(fx_stage_sub) vec4 fx_10(vec2 vUV, sampler2D previous, sampler2D feed
// controls
float fx = magic(seed);
float fx = magic(f0, vec3(1,0,0), seed);
float lens_v1 = magic(seed + 10);
float lens_v2 = magic(seed + 20);
float zoom = magic(seed + 30);
float lens_v1 = magic(f1, b1, seed + 10);
float lens_v2 = magic(f2, b2, seed + 20);
float zoom = magic(f3, b3, seed + 30);
float k = magic(seed + 40);
// logic
@@ -1694,7 +1699,7 @@ subroutine(fx_stage_sub) vec4 fx_10(vec2 vUV, sampler2D previous, sampler2D feed
}
// TODO FX 11
subroutine(fx_stage_sub) vec4 fx_11(vec2 vUV, sampler2D previous, sampler2D feedback, int seed)
subroutine(fx_stage_sub) vec4 fx_11(vec2 vUV, sampler2D previous, sampler2D feedback, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec2 f0)
{
// start
@@ -1704,7 +1709,7 @@ subroutine(fx_stage_sub) vec4 fx_11(vec2 vUV, sampler2D previous, sampler2D feed
// controls
float fx = magic(seed);
float fx = magic(f0, vec3(1,0,0), seed);
// logic
@@ -1715,7 +1720,7 @@ subroutine(fx_stage_sub) vec4 fx_11(vec2 vUV, sampler2D previous, sampler2D feed
}
// TODO FX 12
subroutine(fx_stage_sub) vec4 fx_12(vec2 vUV, sampler2D previous, sampler2D feedback, int seed)
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, vec2 f0)
{
// start
@@ -1725,7 +1730,7 @@ subroutine(fx_stage_sub) vec4 fx_12(vec2 vUV, sampler2D previous, sampler2D feed
// controls
float fx = magic(seed);
float fx = magic(f0, vec3(1,0,0), seed);
// logic
@@ -1736,7 +1741,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)
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, vec2 f0)
{
// start
@@ -1746,7 +1751,7 @@ subroutine(fx_stage_sub) vec4 fx_13(vec2 vUV, sampler2D previous, sampler2D feed
// controls
float fx = magic(seed);
float fx = magic(f0, vec3(1,0,0), seed);
// logic
@@ -1757,7 +1762,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)
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, vec2 f0)
{
// start
@@ -1767,7 +1772,7 @@ subroutine(fx_stage_sub) vec4 fx_14(vec2 vUV, sampler2D previous, sampler2D feed
// controls
float fx = magic(seed);
float fx = magic(f0, vec3(1,0,0), seed);
// logic
@@ -1778,7 +1783,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)
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, vec2 f0)
{
// start
@@ -1788,7 +1793,7 @@ subroutine(fx_stage_sub) vec4 fx_15(vec2 vUV, sampler2D previous, sampler2D feed
// controls
float fx = magic(seed);
float fx = magic(f0, vec3(1,0,0), seed);
// logic
@@ -1799,7 +1804,7 @@ subroutine(fx_stage_sub) vec4 fx_15(vec2 vUV, sampler2D previous, sampler2D feed
}
// TODO FX 16
subroutine(fx_stage_sub) vec4 fx_16(vec2 vUV, sampler2D previous, sampler2D feedback, int seed)
subroutine(fx_stage_sub) vec4 fx_16(vec2 vUV, sampler2D previous, sampler2D feedback, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec2 f0)
{
// start
@@ -1809,7 +1814,7 @@ subroutine(fx_stage_sub) vec4 fx_16(vec2 vUV, sampler2D previous, sampler2D feed
// controls
float fx = magic(seed);
float fx = magic(f0, vec3(1,0,0), seed);
// logic
+1 -1
View File
@@ -40,7 +40,7 @@ void main() {
c += s(uv2,1,1) * texture(tex6, uv2);
c += s(uv2,2,1) * texture(tex8, uv2);
c += s(uv2,0,0) * src_16(mod(uv2, 1), 0);
c += s(uv2,0,0) * src_16(mod(uv2, 1), 0, vec3(0), vec2(0), vec3(0), vec2(0), vec3(0), vec2(0));
c += s(uv2,1,0) * texture(tex9, uv2);
c += s(uv2,2,0) * texture(tex0, uv2);
+3 -1
View File
@@ -5,6 +5,8 @@
in vec2 vUV;
out vec4 fragColor;
uniform vec3 src1_1[6];
void main() {
fragColor = src_stage(vUV, seed3);
fragColor = src_stage(vUV, seed3, src1_1[0], src1_1[1].xy, src1_1[2], src1_1[3].xy, src1_1[4], src1_1[5].xy);
}
+3 -1
View File
@@ -5,6 +5,8 @@
in vec2 vUV;
out vec4 fragColor;
uniform vec3 src1_2[6];
void main() {
fragColor = src_stage(vUV, seed4);
fragColor = src_stage(vUV, seed4, src1_2[0], src1_2[1].xy, src1_2[2], src1_2[3].xy, src1_2[4], src1_2[5].xy);
}
+1 -1
View File
@@ -8,5 +8,5 @@ in vec2 vUV;
out vec4 fragColor;
void main() {
fragColor = fx_stage(vUV, tex5, tex7, seed5);
fragColor = fx_stage(vUV, tex5, tex7, seed5, src2_1[0], src2_1[1].xy, src2_1[2], src2_1[3].xy, src2_1[4], src2_1[5].xy, src2_1[6].xy);
}
+1 -1
View File
@@ -8,5 +8,5 @@ in vec2 vUV;
out vec4 fragColor;
void main() {
fragColor = fx_stage(vUV, tex6, tex8, seed6);
fragColor = fx_stage(vUV, tex6, tex8, seed6, src2_2[0], src2_2[1].xy, src2_2[2], src2_2[3].xy, src2_2[4], src2_2[5].xy, src2_2[6].xy);
}
+3 -3
View File
@@ -8,13 +8,13 @@ in vec2 vUV;
out vec4 fragColor;
void main() {
float mix_src = magic(seed7);
bool key = magic_trigger(seed7 + 10);
float mix_value = magic(src3_1[1].xy, vec3(1, 0, 0), seed7);
bool mix_type = magic_trigger(vec3(src3_1[0].x, 0, 0), seed7 + 10);
vec4 color_a = texture(tex7, vUV);
vec4 color_b = texture(tex8, vUV);
float k = mean(color_a);
fragColor = mix(color_b, color_a, key ? step(mix_src, k) : mix_src);
fragColor = mix(color_b, color_a, mix_type ? step(mix_value, k) : mix_value);
}
+1 -1
View File
@@ -8,5 +8,5 @@ in vec2 vUV;
out vec4 fragColor;
void main() {
fragColor = fx_stage(vUV, tex9, tex0, seed8);
fragColor = fx_stage(vUV, tex9, tex0, seed8, src2_3[0], src2_3[1].xy, src2_3[2], src2_3[3].xy, src2_3[4], src2_3[5].xy, src2_3[6].xy);
}
+1 -1
View File
@@ -23,4 +23,4 @@ unsigned int arr_uint_remap_index(UintArray offsets, unsigned int *index) {
}
return 0;
}
}
+2
View File
@@ -4,6 +4,7 @@
#include <stdlib.h>
#include <sys/wait.h>
#include "arr.h"
#include "config.h"
#include "config_file.h"
#include "file.h"
@@ -68,6 +69,7 @@ static void init_context(Parameters params, unsigned int in_count,
}
memset(context->active, 0, sizeof(context->active));
memset(context->values, 0, sizeof(context->values));
context->page = 0;
context->selected = 0;
+41 -17
View File
@@ -3,6 +3,7 @@
#include <stddef.h>
#include <stdio.h>
#include "arr.h"
#include "config.h"
#include "config_file.h"
#include "constants.h"
@@ -234,8 +235,8 @@ static void init_shaders(ShaderProgram *program, FileArray fragment_shaders) {
}
static void init_single_program(ShaderProgram *program, unsigned int i,
ConfigFile config) {
unsigned int j, k;
ConfigFile config, StateConfig state_config) {
unsigned int j, k, index1, index2;
char name[256];
char *prefix;
program->programs[i] = glCreateProgram();
@@ -325,6 +326,18 @@ static void init_single_program(ShaderProgram *program, unsigned int i,
glGetUniformLocation(program->programs[i], name);
}
prefix = config_file_get_str(config, "UNIFORM_SRC_PREFIX", "src");
index1 = index2 = 0;
for (j = 0; j < state_config.src_active_counts.length; j++) {
for (k = 0; k < state_config.src_active_counts.values[j]; k++) {
program->src_lengths.values[index1++] = state_config.src_counts.values[j];
sprintf(name, "%s%d_%d", prefix, j + 1, k + 1);
program->isrc_locations[index2++] =
glGetUniformLocation(program->programs[i], name);
}
}
program->src_lengths.length = index1;
// create texX uniforms pointer
prefix = config_file_get_str(config, "UNIFORM_TEX_PREFIX", "tex");
for (j = 0; j < program->tex_count; j++) {
@@ -340,11 +353,12 @@ static void init_single_program(ShaderProgram *program, unsigned int i,
log_info("Program %d initialized", i + 1);
}
static void init_programs(ShaderProgram *program, ConfigFile config) {
static void init_programs(ShaderProgram *program, ConfigFile config,
StateConfig state_config) {
unsigned int i;
for (i = 0; i < program->frag_count; i++) {
init_single_program(program, i, config);
init_single_program(program, i, config, state_config);
}
}
@@ -366,7 +380,7 @@ ShaderProgram shaders_init(FileArray fragment_shaders, ConfigFile config,
program.sub_type_count = config_file_get_int(config, "SUB_TYPE_COUNT", 0);
program.in_count = config_file_get_int(config, "IN_COUNT", 0);
program.sub_variant_count = state_config.state_max;
program.active_count = state_config.src_count;
program.active_count = state_config.src_active_counts.length;
if (program.frag_count > MAX_FRAG) {
log_error("FRAG_COUNT over %d", MAX_FRAG);
@@ -388,7 +402,7 @@ ShaderProgram shaders_init(FileArray fragment_shaders, ConfigFile config,
init_framebuffers(&program, config);
init_programs(&program, config);
init_programs(&program, config, state_config);
init_vertices(&program);
@@ -451,16 +465,18 @@ static void write_uniform_2f(GLuint location, vec2 *value) {
}
}
// static void write_uniform_3f(GLuint location, vec3 *value) {
// if (location != unused_uniform) {
// glUniform3fv(location, 1, (const GLfloat *)value);
// }
// }
static void write_uniform_multi_3f(GLuint location, unsigned int count,
vec3 *value) {
if (location != unused_uniform) {
glUniform3fv(location, count, (const GLfloat *)value);
}
}
static void use_program(ShaderProgram program, int i, bool output,
SharedContext *context) {
unsigned int j, k;
unsigned int j, k, offset;
GLuint subroutines[ARRAY_SIZE];
// TODO direct vec2 in context
vec2 resolution, tex_resolution, in_resolution;
resolution[0] = (float)context->width;
@@ -519,6 +535,19 @@ static void use_program(ShaderProgram program, int i, bool output,
context->seeds[j]);
}
for (j = 0; j < program.frag_count; j++) {
write_uniform_1i(program.istate_locations[i * program.frag_count + j],
context->state[j]);
}
offset = 0;
for (j = 0; j < program.src_lengths.length; j++) {
write_uniform_multi_3f(program.isrc_locations[j],
program.src_lengths.values[j],
context->values + offset);
offset += program.src_lengths.values[j];
}
// set subroutines for fragment and update state uniforms
k = context->state[i];
for (j = 0; j < program.sub_type_count; j++) {
@@ -527,11 +556,6 @@ static void use_program(ShaderProgram program, int i, bool output,
j * program.sub_variant_count + k];
}
for (j = 0; j < program.frag_count; j++) {
write_uniform_1i(program.istate_locations[i * program.frag_count + j],
context->state[j]);
}
glUniformSubroutinesuiv(GL_FRAGMENT_SHADER, program.sub_type_count,
subroutines);
+45 -15
View File
@@ -10,8 +10,8 @@
StateConfig state_parse_config(ConfigFile config) {
unsigned int i, j, offset, total;
// TODO rename total var
StateConfig state_config;
UintArray tmp_counts;
char name[256];
state_config.select_page_codes.length =
@@ -44,22 +44,24 @@ StateConfig state_parse_config(ConfigFile config) {
config_file_get_int(config, name, UNSET_MIDI_CODE);
}
state_config.src_count = tmp_counts.length =
state_config.src_active_counts.length = state_config.src_counts.length =
state_config.src_active_offsets.length = state_config.src_offsets.length =
config_file_get_int(config, "SRC_COUNT", 0);
state_config.values_offsets.length =
config_file_get_int(config, "SRC_COUNT", 0);
total = 0;
for (i = 0; i < tmp_counts.length; i++) {
for (i = 0; i < state_config.src_active_counts.length; i++) {
sprintf(name, "SRC_%d_ACTIVE_COUNT", i + 1);
tmp_counts.values[i] = config_file_get_int(config, name, 0);
state_config.src_active_counts.values[i] =
config_file_get_int(config, name, 1);
state_config.src_active_offsets.values[i] = total;
total += tmp_counts.values[i];
total += state_config.src_active_counts.values[i];
}
state_config.src_active_codes.length = total;
for (i = 0; i < tmp_counts.length; i++) {
for (j = 0; j < tmp_counts.values[i]; j++) {
for (i = 0; i < state_config.src_active_counts.length; i++) {
for (j = 0; j < state_config.src_active_counts.values[i]; j++) {
sprintf(name, "SRC_%d_ACTIVE_%d", i + 1, j + 1);
state_config.src_active_codes
.values[state_config.src_active_offsets.values[i] + j] =
@@ -68,18 +70,22 @@ StateConfig state_parse_config(ConfigFile config) {
}
total = 0;
for (i = 0; i < tmp_counts.length; i++) {
offset = 0;
for (i = 0; i < state_config.src_counts.length; i++) {
sprintf(name, "SRC_%d_COUNT", i + 1);
tmp_counts.values[i] = config_file_get_int(config, name, 0);
state_config.src_counts.values[i] = config_file_get_int(config, name, 0);
state_config.src_offsets.values[i] = total;
total += tmp_counts.values[i];
state_config.values_offsets.values[i] = offset;
offset += state_config.src_counts.values[i] *
state_config.src_active_counts.values[i];
total += state_config.src_counts.values[i];
}
state_config.src_codes.length = total * 3;
for (i = 0; i < tmp_counts.length; i++) {
for (i = 0; i < state_config.src_counts.length; i++) {
offset = state_config.src_offsets.values[i];
for (j = 0; j < tmp_counts.values[i]; j++) {
for (j = 0; j < state_config.src_counts.values[i]; j++) {
sprintf(name, "SRC_%d_%d_X", i + 1, j + 1);
state_config.src_codes.values[(offset + j) * 3] =
config_file_get_int(config, name, UNSET_MIDI_CODE);
@@ -157,7 +163,7 @@ static void update_selected(SharedContext *context, StateConfig state_config,
void state_apply_event(SharedContext *context, StateConfig state_config,
MidiDevice midi, unsigned char code,
unsigned char value) {
unsigned int index, part;
unsigned int index, sub_index, src_index, part;
bool found;
found = false;
@@ -201,7 +207,30 @@ void state_apply_event(SharedContext *context, StateConfig state_config,
if (value > 0) {
part = arr_uint_remap_index(state_config.src_active_offsets, &index);
context->active[part] = index;
// TODO things
// TODO update values
}
}
// VALUE CHANGE
index = arr_uint_index_of(state_config.src_codes, code);
if (index != ARRAY_NOT_FOUND) {
found = true;
sub_index = index / 3;
part = arr_uint_remap_index(state_config.src_offsets, &sub_index);
src_index = state_config.values_offsets.values[part] +
context->active[part] * state_config.src_counts.values[part] +
sub_index;
if (arr_uint_index_of(state_config.fader_codes, code) != ARRAY_NOT_FOUND) {
context->values[src_index][index % 3] = (float)value / MIDI_MAX;
} else if (value > 0) {
if (context->values[src_index][index % 3] > 0.5) {
context->values[src_index][index % 3] = 0;
midi_write(midi, code, 0);
} else {
context->values[src_index][index % 3] = 1;
midi_write(midi, code, MIDI_MAX);
}
}
}
@@ -230,6 +259,7 @@ bool state_background_midi_write(SharedContext *context,
update_page(context, state_config, midi);
update_selected(context, state_config, midi);
// TODO init values
while (!context->stop) {
// TODO tap tempo and more
+27 -13
View File
@@ -14,10 +14,16 @@
#ifndef TYPES_H
#define TYPES_H
typedef struct UintArray {
unsigned int values[ARRAY_SIZE];
unsigned int length;
} UintArray;
#define ARRAY(X, Y) \
struct X { \
Y values[ARRAY_SIZE]; \
unsigned int length; \
} X
typedef ARRAY(UintArray, unsigned int);
typedef ARRAY(StringArray, char *);
typedef ARRAY(Vec3Array, vec3);
typedef ARRAY(GLuintArray, GLuint);
typedef struct Parameters {
bool hot_reload;
@@ -32,6 +38,7 @@ typedef struct Parameters {
float base_tempo;
bool demo;
bool windowed;
// TODO use array
char *video_in[MAX_VIDEO];
unsigned int video_in_count;
} Parameters;
@@ -47,10 +54,7 @@ typedef struct File {
time_t last_write;
} File;
typedef struct FileArray {
File values[ARRAY_SIZE];
unsigned int length;
} FileArray;
typedef ARRAY(FileArray, File);
typedef struct ShaderProgram {
bool error;
@@ -71,11 +75,14 @@ typedef struct ShaderProgram {
unsigned int frag_output_index;
unsigned int frag_monitor_index;
// TODO use array
GLuint programs[ARRAY_SIZE];
// TODO use array
GLuint frame_buffers[ARRAY_SIZE];
GLuint fragment_shaders[ARRAY_SIZE];
// TODO use array
GLuint itime_locations[ARRAY_SIZE];
GLuint itempo_locations[ARRAY_SIZE];
GLuint ifps_locations[ARRAY_SIZE];
@@ -91,8 +98,13 @@ typedef struct ShaderProgram {
GLuint iselected_locations[ARRAY_SIZE];
GLuint iactive_locations[ARRAY_SIZE];
// TODO rename inputs_xxx
UintArray src_lengths;
GLuint isrc_locations[ARRAY_SIZE];
GLuint vpos_locations[ARRAY_SIZE];
// TODO use array
GLuint textures_locations[ARRAY_SIZE];
unsigned int sub_type_count;
@@ -119,10 +131,7 @@ typedef struct VideoCapture {
EGLImageKHR dma_image;
} VideoCapture;
typedef struct VideoCaptureArray {
VideoCapture values[ARRAY_SIZE];
unsigned int length;
} VideoCaptureArray;
typedef ARRAY(VideoCaptureArray, VideoCapture);
typedef GLFWwindow Window;
@@ -137,10 +146,12 @@ typedef struct SharedContext {
double time;
unsigned int fps;
float tempo;
// TODO use array
unsigned int state[MAX_FRAG];
unsigned int page;
unsigned int selected;
unsigned int active[ARRAY_SIZE];
vec3 values[ARRAY_SIZE];
bool demo;
unsigned int seeds[MAX_FRAG];
bool monitor;
@@ -153,16 +164,19 @@ typedef struct SharedContext {
typedef struct StateConfig {
unsigned int state_max;
unsigned int src_count;
UintArray select_page_codes;
UintArray select_item_codes;
UintArray select_frag_codes;
// TODO rename input_xxx
UintArray src_active_counts;
UintArray src_active_offsets;
UintArray src_active_codes;
UintArray src_counts;
UintArray src_offsets;
UintArray src_codes;
UintArray fader_codes;
UintArray values_offsets;
unsigned int tap_tempo_code;
} StateConfig;