refactor(glsl): rename uniforms as iXxx

This commit is contained in:
2025-11-01 18:23:13 +01:00
parent e7ad7fabb5
commit a44f701e45
13 changed files with 89 additions and 90 deletions
+5 -6
View File
@@ -9,14 +9,13 @@ UNIFORM_TEX_RESOLUTION=iTexResolution
UNIFORM_IN_RESOLUTION_PREFIX=iInputResolution UNIFORM_IN_RESOLUTION_PREFIX=iInputResolution
UNIFORM_IN_FORMAT_PREFIX=iInputFormat UNIFORM_IN_FORMAT_PREFIX=iInputFormat
UNIFORM_IN_FPS_PREFIX=iInputFPS UNIFORM_IN_FPS_PREFIX=iInputFPS
UNIFORM_SEED_PREFIX=seed UNIFORM_SEED_PREFIX=iSeed
UNIFORM_STATE_PREFIX=state UNIFORM_STATE_PREFIX=iState
UNIFORM_TEX_PREFIX=tex UNIFORM_TEX_PREFIX=iTex
UNIFORM_SRC_PREFIX=midi
UNIFORM_PAGE=iPage UNIFORM_PAGE=iPage
UNIFORM_SELECTED=iSelected UNIFORM_SELECTED=iSelected
UNIFORM_ACTIVE_PREFIX=active UNIFORM_ACTIVE_PREFIX=iActive
UNIFORM_SRC_PREFIX=src UNIFORM_MIDI_PREFIX=iMidi
SUB_TYPE_COUNT=2 SUB_TYPE_COUNT=2
SUB_1_PREFIX=src_ SUB_1_PREFIX=src_
+53 -53
View File
@@ -17,42 +17,42 @@ uniform int iDemo;
uniform int iPage; uniform int iPage;
uniform int iSelected; uniform int iSelected;
uniform int seed1; uniform int iSeed1;
uniform int seed2; uniform int iSeed2;
uniform int seed3; uniform int iSeed3;
uniform int seed4; uniform int iSeed4;
uniform int seed5; uniform int iSeed5;
uniform int seed6; uniform int iSeed6;
uniform int seed7; uniform int iSeed7;
uniform int seed8; uniform int iSeed8;
uniform int state3; uniform int iState3;
uniform int state4; uniform int iState4;
uniform int state5; uniform int iState5;
uniform int state6; uniform int iState6;
uniform int state8; uniform int iState8;
uniform int active1; uniform int iActive1;
uniform int active2; uniform int iActive2;
uniform vec3 src2_1[7]; uniform vec3 iMidi2_1[7];
uniform vec3 src2_2[7]; uniform vec3 iMidi2_2[7];
uniform vec3 src2_3[7]; uniform vec3 iMidi2_3[7];
uniform vec3 src3_1[2]; uniform vec3 iMidi3_1[2];
// 2. textures // 2. textures
// --------------- // ---------------
uniform sampler2D tex0; uniform sampler2D iTex0;
uniform sampler2D tex1; uniform sampler2D iTex1;
uniform sampler2D tex2; uniform sampler2D iTex2;
uniform sampler2D tex3; uniform sampler2D iTex3;
uniform sampler2D tex4; uniform sampler2D iTex4;
uniform sampler2D tex5; uniform sampler2D iTex5;
uniform sampler2D tex6; uniform sampler2D iTex6;
uniform sampler2D tex7; uniform sampler2D iTex7;
uniform sampler2D tex8; uniform sampler2D iTex8;
uniform sampler2D tex9; uniform sampler2D iTex9;
// 3. definitions // 3. definitions
// -------------- // --------------
@@ -917,7 +917,7 @@ vec4 src_thru(vec2 vUV, sampler2D tex, int seed, vec3 b1, vec2 f1, vec3 b2, vec2
// SRC 1: feedback + thru // SRC 1: feedback + thru
subroutine(src_stage_sub) vec4 src_1(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3) 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, b1, f1, b2, f2, b3, f3); return src_thru(vUV, iTex0, seed, b1, f1, b2, f2, b3, f3);
} }
// SRC 2 : lines // SRC 2 : lines
@@ -1052,7 +1052,7 @@ subroutine(src_stage_sub) vec4 src_5(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3
// SRC 6 : video in 1 + thru // SRC 6 : video in 1 + thru
subroutine(src_stage_sub) vec4 src_6(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3) 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, b1, f1, b2, f2, b3, f3); return src_thru(vUV, iTex3, seed, b1, f1, b2, f2, b3, f3);
} }
// SRC 7 : cp437 // SRC 7 : cp437
@@ -1148,7 +1148,7 @@ subroutine(src_stage_sub) vec4 src_9(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3
// logic // logic
return texture(tex0, vUV); return texture(iTex0, vUV);
} }
// TODO SRC 10 // TODO SRC 10
@@ -1164,13 +1164,13 @@ subroutine(src_stage_sub) vec4 src_10(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3
// logic // logic
return texture(tex0, vUV); return texture(iTex0, vUV);
} }
// SRC 11 : video in 2 + thru // SRC 11 : video in 2 + thru
subroutine(src_stage_sub) vec4 src_11(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3) 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, b1, f1, b2, f2, b3, f3); return src_thru(vUV, iTex4, seed, b1, f1, b2, f2, b3, f3);
} }
// TODO SRC 12 // TODO SRC 12
@@ -1186,7 +1186,7 @@ subroutine(src_stage_sub) vec4 src_12(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3
// logic // logic
return texture(tex0, vUV); return texture(iTex0, vUV);
} }
// TODO SRC 13 // TODO SRC 13
@@ -1202,7 +1202,7 @@ subroutine(src_stage_sub) vec4 src_13(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3
// logic // logic
return texture(tex0, vUV); return texture(iTex0, vUV);
} }
// TODO SRC 14 // TODO SRC 14
@@ -1218,7 +1218,7 @@ subroutine(src_stage_sub) vec4 src_14(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3
// logic // logic
return texture(tex0, vUV); return texture(iTex0, vUV);
} }
// TODO SRC 15 // TODO SRC 15
@@ -1234,7 +1234,7 @@ subroutine(src_stage_sub) vec4 src_15(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3
// logic // logic
return texture(tex0, vUV); return texture(iTex0, vUV);
} }
// SRC 16 : debug // SRC 16 : debug
@@ -1248,16 +1248,16 @@ subroutine(src_stage_sub) vec4 src_16(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3
// inputs // inputs
int selected_srca = state3; int selected_srca = iState3;
int selected_srcb = state4; int selected_srcb = iState4;
int selected_fxa = state5; int selected_fxa = iState5;
int selected_fxb = state6; int selected_fxb = iState6;
int selected_mfx = state8; int selected_mfx = iState8;
float fxa_value = magic(src2_1[6].xy, vec3(1, 0, 0), seed5); float fxa_value = magic(iMidi2_1[6].xy, vec3(1, 0, 0), iSeed5);
float fxb_value = magic(src2_2[6].xy, vec3(1, 0, 0), seed6); float fxb_value = magic(iMidi2_2[6].xy, vec3(1, 0, 0), iSeed6);
float mfx_value = magic(src2_3[6].xy, vec3(1, 0, 0), seed8); float mfx_value = magic(iMidi2_3[6].xy, vec3(1, 0, 0), iSeed8);
float mix_value = magic(src3_1[1].xy, vec3(1, 0, 0), seed7); float mix_value = magic(iMidi3_1[1].xy, vec3(1, 0, 0), iSeed7);
bool mix_type = magic_trigger(vec3(src3_1[0].x, 0, 0), seed7 + 10); bool mix_type = magic_trigger(vec3(iMidi3_1[0].x, 0, 0), iSeed7 + 10);
// logic // logic
@@ -1310,11 +1310,11 @@ subroutine(src_stage_sub) vec4 src_16(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3
f += iSelected == 8 ? h_rect(uv2, vec2(5, 0), vec2(1.2), 0.1) : 0; f += iSelected == 8 ? h_rect(uv2, vec2(5, 0), vec2(1.2), 0.1) : 0;
// show selected src/fx // show selected src/fx
f += active1 == 1 ? h_rect(uv2, vec2(-5, 0.8), vec2(1, 0), 0.1) : 0; f += iActive1 == 1 ? h_rect(uv2, vec2(-5, 0.8), vec2(1, 0), 0.1) : 0;
f += active1 == 2 ? h_rect(uv2, vec2(-5, -3.2), vec2(1, 0), 0.1) : 0; f += iActive1 == 2 ? h_rect(uv2, vec2(-5, -3.2), vec2(1, 0), 0.1) : 0;
f += active2 == 1 ? h_rect(uv2, vec2(-2, 0.8), vec2(1.2, 0), 0.1) : 0; f += iActive2 == 1 ? h_rect(uv2, vec2(-2, 0.8), vec2(1.2, 0), 0.1) : 0;
f += active2 == 2 ? h_rect(uv2, vec2(-2, -3.2), vec2(1, 0), 0.1) : 0; f += iActive2 == 2 ? h_rect(uv2, vec2(-2, -3.2), vec2(1, 0), 0.1) : 0;
f += active2 == 3 ? h_rect(uv2, vec2(5, -1.2), vec2(1, 0), 0.1) : 0; f += iActive2 == 3 ? h_rect(uv2, vec2(5, -1.2), vec2(1, 0), 0.1) : 0;
// show inputs / feedback // show inputs / feedback
float line_a_a = rect(uv2, vec2(-8, 2), vec2(2, 0.1)); float line_a_a = rect(uv2, vec2(-8, 2), vec2(2, 0.1));
+2 -2
View File
@@ -10,8 +10,8 @@ uniform int iInputFormat1;
void main() { void main() {
if (iInputFormat1 == YUYV_FOURCC) { if (iInputFormat1 == YUYV_FOURCC) {
fragColor = yuyvTex(tex1, vUV, int(iInputResolution1.x)); fragColor = yuyvTex(iTex1, vUV, int(iInputResolution1.x));
} else { } else {
fragColor = texture(tex0, vUV); fragColor = texture(iTex0, vUV);
} }
} }
+8 -8
View File
@@ -34,22 +34,22 @@ void main() {
vec4 c = vec4(0); vec4 c = vec4(0);
c += s(uv2,1,2) * texture(tex5, uv2); c += s(uv2,1,2) * texture(iTex5, uv2);
c += s(uv2,2,2) * texture(tex7, uv2); c += s(uv2,2,2) * texture(iTex7, uv2);
c += s(uv2,1,1) * texture(tex6, uv2); c += s(uv2,1,1) * texture(iTex6, uv2);
c += s(uv2,2,1) * texture(tex8, uv2); c += s(uv2,2,1) * texture(iTex8, uv2);
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,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,1,0) * texture(iTex9, uv2);
c += s(uv2,2,0) * texture(tex0, uv2); c += s(uv2,2,0) * texture(iTex0, uv2);
float f = 0; float f = 0;
float t = 0; float t = 0;
if (iInputResolution1.x > 0) { if (iInputResolution1.x > 0) {
c += s(uv2,0,2) * texture(tex3, uv2); c += s(uv2,0,2) * texture(iTex3, uv2);
f += rect(uv3, vec2(-51, 28.5), vec2(2.1, 0.7)); f += rect(uv3, vec2(-51, 28.5), vec2(2.1, 0.7));
t += write_5(uv3, vec2(-53,28), texts[0]); t += write_5(uv3, vec2(-53,28), texts[0]);
f += rect(uv3, vec2(-50.4, 26.5), vec2(2.8, 0.7)); f += rect(uv3, vec2(-50.4, 26.5), vec2(2.8, 0.7));
@@ -58,7 +58,7 @@ void main() {
} }
if (iInputResolution2.x > 0) { if (iInputResolution2.x > 0) {
c += s(uv2,0,1) * texture(tex4, uv2); c += s(uv2,0,1) * texture(iTex4, uv2);
f += rect(uv3, vec2(-51, 8.5), vec2(2.1, 0.7)); f += rect(uv3, vec2(-51, 8.5), vec2(2.1, 0.7));
t += write_5(uv3, vec2(-53,8), texts[1]); t += write_5(uv3, vec2(-53,8), texts[1]);
f += rect(uv3, vec2(-50.4, 6.5), vec2(2.8, 0.7)); f += rect(uv3, vec2(-50.4, 6.5), vec2(2.8, 0.7));
+2 -2
View File
@@ -10,8 +10,8 @@ uniform int iInputFormat2;
void main() { void main() {
if (iInputFormat2 == YUYV_FOURCC) { if (iInputFormat2 == YUYV_FOURCC) {
fragColor = yuyvTex(tex2, vUV, int(iInputResolution2.x)); fragColor = yuyvTex(iTex2, vUV, int(iInputResolution2.x));
} else { } else {
fragColor = texture(tex0, vUV); fragColor = texture(iTex0, vUV);
} }
} }
+2 -2
View File
@@ -5,8 +5,8 @@
in vec2 vUV; in vec2 vUV;
out vec4 fragColor; out vec4 fragColor;
uniform vec3 src1_1[6]; uniform vec3 iMidi1_1[6];
void main() { void main() {
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); fragColor = src_stage(vUV, iSeed3, iMidi1_1[0], iMidi1_1[1].xy, iMidi1_1[2], iMidi1_1[3].xy, iMidi1_1[4], iMidi1_1[5].xy);
} }
+2 -2
View File
@@ -5,8 +5,8 @@
in vec2 vUV; in vec2 vUV;
out vec4 fragColor; out vec4 fragColor;
uniform vec3 src1_2[6]; uniform vec3 iMidi1_2[6];
void main() { void main() {
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); fragColor = src_stage(vUV, iSeed4, iMidi1_2[0], iMidi1_2[1].xy, iMidi1_2[2], iMidi1_2[3].xy, iMidi1_2[4], iMidi1_2[5].xy);
} }
+1 -1
View File
@@ -8,5 +8,5 @@ in vec2 vUV;
out vec4 fragColor; out vec4 fragColor;
void main() { void main() {
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); fragColor = fx_stage(vUV, iTex5, iTex7, iSeed5, iMidi2_1[0], iMidi2_1[1].xy, iMidi2_1[2], iMidi2_1[3].xy, iMidi2_1[4], iMidi2_1[5].xy, iMidi2_1[6].xy);
} }
+1 -1
View File
@@ -8,5 +8,5 @@ in vec2 vUV;
out vec4 fragColor; out vec4 fragColor;
void main() { void main() {
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); fragColor = fx_stage(vUV, iTex6, iTex8, iSeed6, iMidi2_2[0], iMidi2_2[1].xy, iMidi2_2[2], iMidi2_2[3].xy, iMidi2_2[4], iMidi2_2[5].xy, iMidi2_2[6].xy);
} }
+4 -4
View File
@@ -8,11 +8,11 @@ in vec2 vUV;
out vec4 fragColor; out vec4 fragColor;
void main() { void main() {
float mix_value = magic(src3_1[1].xy, vec3(1, 0, 0), seed7); float mix_value = magic(iMidi3_1[1].xy, vec3(1, 0, 0), iSeed7);
bool mix_type = magic_trigger(vec3(src3_1[0].x, 0, 0), seed7 + 10); bool mix_type = magic_trigger(vec3(iMidi3_1[0].x, 0, 0), iSeed7 + 10);
vec4 color_a = texture(tex7, vUV); vec4 color_a = texture(iTex7, vUV);
vec4 color_b = texture(tex8, vUV); vec4 color_b = texture(iTex8, vUV);
float k = mean(color_a); float k = mean(color_a);
+3 -3
View File
@@ -8,11 +8,11 @@ in vec2 vUV;
out vec4 fragColor; out vec4 fragColor;
void main() { void main() {
vec4 color = 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); vec4 color = fx_stage(vUV, iTex9, iTex0, iSeed8, iMidi2_3[0], iMidi2_3[1].xy, iMidi2_3[2], iMidi2_3[3].xy, iMidi2_3[4], iMidi2_3[5].xy, iMidi2_3[6].xy);
color = mix(color, vec4(0), src3_1[0].y); color = mix(color, vec4(0), iMidi3_1[0].y);
color = mix(color, 1 - color, src3_1[0].z); color = mix(color, 1 - color, iMidi3_1[0].z);
fragColor = color; fragColor = color;
} }
+1 -1
View File
@@ -5,5 +5,5 @@ in vec2 vUV;
out vec4 fragColor; out vec4 fragColor;
void main() { void main() {
fragColor = texture(tex0, vUV); fragColor = texture(iTex0, vUV);
} }
+5 -5
View File
@@ -293,14 +293,14 @@ static void init_single_program(ShaderProgram *program, unsigned int i,
glGetUniformLocation(program->programs[i], name); glGetUniformLocation(program->programs[i], name);
} }
prefix = config_file_get_str(config, "UNIFORM_SEED_PREFIX", "seed"); prefix = config_file_get_str(config, "UNIFORM_SEED_PREFIX", "iSeed");
for (j = 0; j < program->frag_count; j++) { for (j = 0; j < program->frag_count; j++) {
sprintf(name, "%s%d", prefix, j + 1); sprintf(name, "%s%d", prefix, j + 1);
program->iseed_locations[i * program->frag_count + j] = program->iseed_locations[i * program->frag_count + j] =
glGetUniformLocation(program->programs[i], name); glGetUniformLocation(program->programs[i], name);
} }
prefix = config_file_get_str(config, "UNIFORM_STATE_PREFIX", "state"); prefix = config_file_get_str(config, "UNIFORM_STATE_PREFIX", "iState");
for (j = 0; j < program->frag_count; j++) { for (j = 0; j < program->frag_count; j++) {
sprintf(name, "%s%d", prefix, j + 1); sprintf(name, "%s%d", prefix, j + 1);
program->istate_locations[i * program->frag_count + j] = program->istate_locations[i * program->frag_count + j] =
@@ -319,7 +319,7 @@ static void init_single_program(ShaderProgram *program, unsigned int i,
} }
} }
prefix = config_file_get_str(config, "UNIFORM_ACTIVE_PREFIX", "active"); prefix = config_file_get_str(config, "UNIFORM_ACTIVE_PREFIX", "iActive");
for (j = 0; j < program->active_count; j++) { for (j = 0; j < program->active_count; j++) {
sprintf(name, "%s%d", prefix, j + 1); sprintf(name, "%s%d", prefix, j + 1);
program->iactive_locations[i * program->active_count + j] = program->iactive_locations[i * program->active_count + j] =
@@ -337,7 +337,7 @@ static void init_single_program(ShaderProgram *program, unsigned int i,
program->src_lengths.length = index1; program->src_lengths.length = index1;
} }
prefix = config_file_get_str(config, "UNIFORM_SRC_PREFIX", "src"); prefix = config_file_get_str(config, "UNIFORM_MIDI_PREFIX", "iMidi");
index2 = 0; index2 = 0;
for (j = 0; j < state_config.src_active_counts.length; j++) { for (j = 0; j < state_config.src_active_counts.length; j++) {
for (k = 0; k < state_config.src_active_counts.values[j]; k++) { for (k = 0; k < state_config.src_active_counts.values[j]; k++) {
@@ -348,7 +348,7 @@ static void init_single_program(ShaderProgram *program, unsigned int i,
} }
// create texX uniforms pointer // create texX uniforms pointer
prefix = config_file_get_str(config, "UNIFORM_TEX_PREFIX", "tex"); prefix = config_file_get_str(config, "UNIFORM_TEX_PREFIX", "iTex");
for (j = 0; j < program->tex_count; j++) { for (j = 0; j < program->tex_count; j++) {
sprintf(name, "%s%d", prefix, j); sprintf(name, "%s%d", prefix, j);
program->textures_locations[i * program->tex_count + j] = program->textures_locations[i * program->tex_count + j] =