monitor param

This commit is contained in:
2025-09-20 19:30:47 +02:00
parent e4c9125c18
commit ce1d0dba60
7 changed files with 60 additions and 17 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
TARGET ?= forge
INSTALL_DIR ?= $(HOME)/.local/bin
TEST_ARGS ?= --hot-reload --frag=./shaders --frag-config=./config/shaders.cfg --demo -is=480
TEST_ARGS ?= --hot-reload --frag=./shaders --frag-config=./config/shaders.cfg --demo --monitor --internal-size=480
SHELL := /bin/bash
.PHONY: build
+1 -1
View File
@@ -114,7 +114,7 @@ make -f Makefile.dev release-arch
- [x] subroutines config
- [x] demo mode
- [x] random seed injected into shaders
- [ ] internal texture size for speed
- [x] internal texture size for speed
- [ ] pass state as uniform
- [ ] debug shader (and in monitor)
- [ ] Clean code and fix things
+42 -11
View File
@@ -9,16 +9,47 @@ float s(vec2 uv, float x0, float y0) {
step(-y0 - 1, -uv.y);
}
const int texts[8][5] = {
{0x49, 0x4E, 0x20, 0x41, 0x00}, // IN A
{0x49, 0x4E, 0x20, 0x42, 0x00}, // IN B
{0x53, 0x52, 0x43, 0x20, 0x41}, // SRC A
{0x53, 0x52, 0x43, 0x20, 0x42}, // SRC B
{0x46, 0x58, 0x20, 0x41, 0x00}, // FX A
{0x46, 0x58, 0x20, 0x42, 0x00}, // FX B
{0x41, 0x2B, 0x42, 0x00, 0x00}, // A+B
{0x4D, 0x46, 0x58, 0x00, 0x00}, // MFX
};
void main() {
vec2 uv = vUV * 3;
fragColor = vec4(0);
fragColor += s(uv,0,2) * texture(tex1, uv);
fragColor += s(uv,1,2) * texture(tex2, uv);
fragColor += s(uv,2,2) * texture(tex3, uv);
fragColor += s(uv,0,1) * texture(tex4, uv);
fragColor += s(uv,1,1) * texture(tex5, uv);
fragColor += s(uv,2,1) * texture(tex6, uv);
fragColor += s(uv,0,0) * texture(tex7, uv);
fragColor += s(uv,1,0) * texture(tex8, uv);
fragColor += s(uv,2,0) * texture(tex0, uv);
vec2 uv0 = vUV.st;
float ratio = iResolution.x / iResolution.y;
vec2 uv1 = (uv0 - .5) * vec2(ratio, 1);
vec2 uv2 = uv0 * 3;
vec2 uv3 = uv1 * 30;
vec4 c = vec4(0);
c += s(uv2,0,2) * texture(tex1, uv2);
c += s(uv2,1,2) * texture(tex2, uv2);
c += s(uv2,2,2) * texture(tex3, uv2);
c += s(uv2,0,1) * texture(tex7, uv2);
c += s(uv2,1,1) * texture(tex8, uv2);
c += s(uv2,2,1) * texture(tex0, uv2);
c += s(uv2,0,0) * texture(tex4, uv2);
c += s(uv2,1,0) * texture(tex5, uv2);
c += s(uv2,2,0) * texture(tex6, uv2);
float t = 0;
t += write_5(uv3, vec2(-26.5,13.5), texts[0]);
t += write_5(uv3, vec2(-26.5,-6.5), texts[1]);
t += write_5(uv3, vec2(-8.5,13.5), texts[2]);
t += write_5(uv3, vec2(-8.5,-6.5), texts[3]);
t += write_5(uv3, vec2(9.5,13.5), texts[4]);
t += write_5(uv3, vec2(9.5,-6.5), texts[5]);
t += write_5(uv3, vec2(-8.5,3.5), texts[6]);
t += write_5(uv3, vec2(9.5,3.5), texts[7]);
fragColor = mix(c, 1 - c, t);
}
+6
View File
@@ -20,7 +20,9 @@ static void print_help(int status_code) {
"[-s=SCREEN] "
"[-f=DIR_PATH] "
"[-fc=CFG_PATH] "
"[-is=SIZE] "
"[-t=TEMPO] "
"[--monitor] "
"[--demo] "
"\n\n"
"Fusion Of Real-time Generative Effects.\n\n"
@@ -33,6 +35,7 @@ static void print_help(int status_code) {
" -fc, --frag-config fragment shaders config file (default: TODO)\n"
" -is, --internal-size internal texture height (default: 720)\n"
" -t, --tempo base tempo (default: 60)\n"
" -m, --monitor output monitor\n"
" --demo demonstration mode\n");
exit(status_code);
}
@@ -77,6 +80,7 @@ Parameters args_parse(int argc, char **argv) {
params.frag_config_path = 0;
params.internal_size = 720;
params.base_tempo = 60.0f;
params.monitor = false;
params.demo = false;
for (i = 1; i < argc; i++) {
@@ -99,6 +103,8 @@ Parameters args_parse(int argc, char **argv) {
params.base_tempo = (float)parse_uint(arg, value);
} else if (is_arg(arg, "-is") || is_arg(arg, "--internal-size")) {
params.internal_size = (float)parse_uint(arg, value);
} else if (is_arg(arg, "--monitor")) {
params.monitor = true;
} else if (is_arg(arg, "--demo")) {
params.demo = true;
} else {
+1
View File
@@ -50,6 +50,7 @@ static void init_context(ShaderProgram program, Context *context,
context->tempo = params.base_tempo;
context->demo = params.demo;
context->monitor = params.monitor;
size = program.frag_count * program.sub_type_count;
context->sub_state = malloc(size * sizeof(unsigned int));
+4 -1
View File
@@ -366,5 +366,8 @@ void shaders_apply(ShaderProgram program, Context context) {
}
}
use_program(program, program.frag_monitor_index, true, context);
use_program(program,
context.monitor ? program.frag_monitor_index
: program.frag_output_index,
true, context);
}
+5 -3
View File
@@ -10,13 +10,14 @@
#define TYPES_H
typedef struct Parameters {
bool hot_reload;
unsigned char screen;
char *frag_path;
char *frag_config_path;
bool hot_reload;
float base_tempo;
bool demo;
unsigned int internal_size;
float base_tempo;
bool monitor;
bool demo;
} Parameters;
typedef struct Vertex {
@@ -81,6 +82,7 @@ typedef struct Context {
unsigned int *sub_state;
bool demo;
unsigned int *seeds;
bool monitor;
} Context;
typedef struct Timer {