diff --git a/.gitignore b/.gitignore index 2701f1c..7467778 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +!default/sentences.txt !images/* *.bmp *.cache @@ -8,7 +9,6 @@ *.pkg.tar.zst *.tar.gz *.txt -!default/sentences.txt .deps .dirstamp .vscode @@ -28,5 +28,8 @@ error.glsl forge forge-* install-sh +lab/*.glsl +!lab/*.example.glsl +!lab/inc_*.glsl missing pkg diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index f594769..a64a739 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -13,6 +13,7 @@ full-clean remove any residual files build build project build-no-video build project no video in run run project with $RUN_ARGS +run-lab run lab for working on default project run-% run {project} with $RUN_ARGS format format project release-test test release diff --git a/Makefile.dev b/Makefile.dev index e4e7e99..a37b81d 100644 --- a/Makefile.dev +++ b/Makefile.dev @@ -65,6 +65,9 @@ default/inc_cp437.glsl: default/inc_sentences.glsl: default/sentences.txt $(MAKE) glsl-glyphs +lab/frag%.glsl: + cp lab/frag$*.example.glsl lab/frag$*.glsl + # ACTIONS .PHONY: init @@ -86,6 +89,10 @@ build-no-video: ## build project no video in .PHONY: run run: exec-build ## run project with $RUN_ARGS +.PHONY: run-lab +run-lab: lab/frag1.glsl lab/frag2.glsl lab/frag3.glsl ## run lab for working on default project + RUN_ARGS="-nmr -is=480 --hot-reload" $(MAKE) exec-build-lab + .PHONY: run-% run-%: ## run {project} with $RUN_ARGS $(MAKE) exec-build-$* diff --git a/default/forge_project.cfg b/default/forge_project.cfg index da5606f..7fd4d0c 100644 --- a/default/forge_project.cfg +++ b/default/forge_project.cfg @@ -92,7 +92,7 @@ SUB_2_PREFIX=fx_ # =========== -# Total number of internal textures +# Total number of internal textures (including texture 0) TEX_COUNT=12 # === VIDEO DEVICES diff --git a/lab/forge_project.cfg b/lab/forge_project.cfg new file mode 100644 index 0000000..1c27c7b --- /dev/null +++ b/lab/forge_project.cfg @@ -0,0 +1,160 @@ +# ================ +# FRAGMENT SHADERS +# ================ + +# === UNIFORMS === + +# --- uniform float --- + +UNIFORM_TIME=iTime +UNIFORM_TEMPO=iTempo +UNIFORM_BEATS=iBeats + +# --- uniform int --- + +UNIFORM_FPS=iFPS +UNIFORM_IN_FPS_PREFIX=iInputFPS +UNIFORM_DEMO=iDemo +UNIFORM_AUTORAND=iAutoRand +UNIFORM_AUTORANDCYCLE=iAutoRandCycle +UNIFORM_PAGE=iPage +UNIFORM_SELECTED=iSelected +UNIFORM_SEED_PREFIX=iSeed +UNIFORM_STATE_PREFIX=iState +UNIFORM_ACTIVE_PREFIX=iActive +UNIFORM_IN_FORMAT_PREFIX=iInputFormat + +# --- uniform vec2 --- + +UNIFORM_RESOLUTION=iResolution +UNIFORM_TEX_RESOLUTION=iTexResolution +UNIFORM_IN_RESOLUTION_PREFIX=iInputResolution + +# --- uniform vec3 --- + +UNIFORM_GROUP_PREFIX=iGroup + +# --- uniform sampler2D --- + +UNIFORM_TEX_PREFIX=iTex + +# =========== +# TEXTURE I/O +# =========== + +TEX_COUNT=2 + +# === FRAGMENT SHADERS +FRAG_FILE_PREFIX=frag + +FRAG_COUNT=3 + +FRAG_1_OUT=1 +FRAG_2_OUT=0 +FRAG_OUTPUT=3 +FRAG_MONITOR=3 + +# ========== +# I/O Inputs +# ========== +MIDI_HW=hw:CARD=nanoKONTROL2 + +# === TYPES OF EVENTS + +FADER_COUNT=16 +FADER_1=0 +FADER_2=1 +FADER_3=2 +FADER_4=3 +FADER_5=4 +FADER_6=5 +FADER_7=6 +FADER_8=7 +FADER_9=16 +FADER_10=17 +FADER_11=18 +FADER_12=19 +FADER_13=20 +FADER_14=21 +FADER_15=22 +FADER_16=23 +TAP_TEMPO=46 + +# === GROUP INPUT STATES +GROUP_COUNT=3 + +GROUP_1_COUNT=1 +GROUP_1_1_X=33 +GROUP_1_1_Y=49 +GROUP_1_1_Z=65 +GROUP_1_2_X=1 +GROUP_1_2_Y=17 +GROUP_1_2_Z= +GROUP_1_3_X=34 +GROUP_1_3_Y=50 +GROUP_1_3_Z=66 +GROUP_1_4_X=2 +GROUP_1_4_Y=18 +GROUP_1_4_Z= +GROUP_1_5_X=35 +GROUP_1_5_Y=51 +GROUP_1_5_Z=67 +GROUP_1_6_X=3 +GROUP_1_6_Y=19 +GROUP_1_6_Z= + +GROUP_2_COUNT=1 +GROUP_2_1_X=37 +GROUP_2_1_Y=53 +GROUP_2_1_Z=69 +GROUP_2_2_X=5 +GROUP_2_2_Y=21 +GROUP_2_2_Z= +GROUP_2_3_X=38 +GROUP_2_3_Y=54 +GROUP_2_3_Z=70 +GROUP_2_4_X=6 +GROUP_2_4_Y=22 +GROUP_2_4_Z= +GROUP_2_5_X=39 +GROUP_2_5_Y=55 +GROUP_2_5_Z=71 +GROUP_2_6_X=7 +GROUP_2_6_Y=23 +GROUP_2_6_Z= +GROUP_2_7_X=4 +GROUP_2_7_Y=20 +GROUP_2_7_Z=59 + +GROUP_3_COUNT=2 +GROUP_3_1_X=48 +GROUP_3_1_Y=58 +GROUP_3_1_Z= +GROUP_3_2_X=0 +GROUP_3_2_Y=16 +GROUP_3_2_Z=11089 + +ARI_COUNT=2 +ARI_1=GROUP_3_1_Y +ARI_2=GROUP_3_2_Z + +# ===== +# OTHER +# ===== + +# R on (qwerty) +KEY_RANDOMIZE=1082 +# SHIFT+R (qwerty) +KEY_RESET=11082 +# D (qwerty) +KEY_DEMO=1068 +# A (qwerty) +KEY_AUTORAND=1065 +# Left arrow +KEY_AUTORAND_DOWN=1263 +# Right arrow +KEY_AUTORAND_UP=1262 +# Down arrow +KEY_TEMPO_DOWN=1264 +# Up arrow +KEY_TEMPO_UP=1265 diff --git a/lab/frag1.example.glsl b/lab/frag1.example.glsl new file mode 100644 index 0000000..05ef345 --- /dev/null +++ b/lab/frag1.example.glsl @@ -0,0 +1,40 @@ +#version 460 + +#include inc_functions.glsl +#include inc_magic.glsl + +in vec2 vUV; +out vec4 fragColor; + +uniform sampler2D iTex0; // feedback +uniform int iSeed1; +uniform vec3 iGroup1_1[6]; + +vec4 src_stage(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 ctrl1 = magic(f1, b1, seed + 10.); + float ctrl2 = magic(f2, b2, seed + 20.); + float ctrl3 = magic(f3, b3, seed + 30.); + + // logic + + // logic + + vec3 c = vec3(uv1.x, uv1.y, cos(iBeats) * 0.5 + 0.5); + + // output + + return vec4(c, 1.); +} + +void main() { + fragColor = src_stage(vUV, iSeed1, iGroup1_1[0], iGroup1_1[1].xy, iGroup1_1[2], iGroup1_1[3].xy, iGroup1_1[4], iGroup1_1[5].xy); +} diff --git a/lab/frag2.example.glsl b/lab/frag2.example.glsl new file mode 100644 index 0000000..66a56e4 --- /dev/null +++ b/lab/frag2.example.glsl @@ -0,0 +1,53 @@ +#version 460 + +#include inc_functions.glsl +#include inc_magic.glsl + +in vec2 vUV; +out vec4 fragColor; + +uniform sampler2D iTex0; // feedback/self +uniform sampler2D iTex1; // previous +uniform int iSeed2; +uniform vec3 iGroup2_1[7]; + +vec4 fx_master(vec3 c0, vec3 c, int seed, vec3 m0) { + float fx = magic(m0.xy, vec3(1., 0., 0.), seed); + bool invert = magic_trigger(vec3(m0.z, 0., 0.), seed); + + vec3 c_out = mix(c0, c, fx); + + c_out = mix(c_out, 1. - c_out, invert ? 1. : 0.); + + return vec4(c_out, 1.); +} + +vec4 fx_stage(vec2 vUV, sampler2D previous, sampler2D feedback, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec3 m0) +{ + // start + + vec2 uv0 = vUV.st; + float ratio = iResolution.x / iResolution.y; + vec2 uv1 = (uv0 - .5) * vec2(ratio, 1.); + + // controls + + float ctrl1 = magic(f1, b1, seed + 10.); + float ctrl2 = magic(f2, b2, seed + 20.); + float ctrl3 = magic(f3, b3, seed + 30.); + + // logic + + vec3 c0 = texture(previous, uv0).xyz; + + vec2 uv2 = uv1; + vec3 c = reframe(previous, uv2).xyz; + + // output + + return fx_master(c0, c, seed, m0); +} + +void main() { + fragColor = fx_stage(vUV, iTex1, iTex0, iSeed2, iGroup2_1[0], iGroup2_1[1].xy, iGroup2_1[2], iGroup2_1[3].xy, iGroup2_1[4], iGroup2_1[5].xy, iGroup2_1[6]); +} diff --git a/lab/frag3.example.glsl b/lab/frag3.example.glsl new file mode 100644 index 0000000..7f9ae21 --- /dev/null +++ b/lab/frag3.example.glsl @@ -0,0 +1,10 @@ +#version 460 + +in vec2 vUV; +out vec4 fragColor; + +uniform sampler2D iTex0; + +void main() { + fragColor = texture(iTex0, vUV); +} \ No newline at end of file diff --git a/lab/inc_cp437.glsl b/lab/inc_cp437.glsl new file mode 120000 index 0000000..a8591ea --- /dev/null +++ b/lab/inc_cp437.glsl @@ -0,0 +1 @@ +../default/inc_cp437.glsl \ No newline at end of file diff --git a/lab/inc_debug.glsl b/lab/inc_debug.glsl new file mode 120000 index 0000000..0367c98 --- /dev/null +++ b/lab/inc_debug.glsl @@ -0,0 +1 @@ +../default/inc_debug.glsl \ No newline at end of file diff --git a/lab/inc_functions.glsl b/lab/inc_functions.glsl new file mode 120000 index 0000000..e5df8d3 --- /dev/null +++ b/lab/inc_functions.glsl @@ -0,0 +1 @@ +../default/inc_functions.glsl \ No newline at end of file diff --git a/lab/inc_magic.glsl b/lab/inc_magic.glsl new file mode 120000 index 0000000..492f3d8 --- /dev/null +++ b/lab/inc_magic.glsl @@ -0,0 +1 @@ +../default/inc_magic.glsl \ No newline at end of file diff --git a/lab/inc_map.glsl b/lab/inc_map.glsl new file mode 120000 index 0000000..2050aa5 --- /dev/null +++ b/lab/inc_map.glsl @@ -0,0 +1 @@ +../default/inc_map.glsl \ No newline at end of file diff --git a/lab/inc_rand.glsl b/lab/inc_rand.glsl new file mode 120000 index 0000000..7b5a161 --- /dev/null +++ b/lab/inc_rand.glsl @@ -0,0 +1 @@ +../default/inc_rand.glsl \ No newline at end of file diff --git a/lab/inc_res.glsl b/lab/inc_res.glsl new file mode 120000 index 0000000..f567274 --- /dev/null +++ b/lab/inc_res.glsl @@ -0,0 +1 @@ +../default/inc_res.glsl \ No newline at end of file diff --git a/lab/inc_sentences.glsl b/lab/inc_sentences.glsl new file mode 120000 index 0000000..3092200 --- /dev/null +++ b/lab/inc_sentences.glsl @@ -0,0 +1 @@ +../default/inc_sentences.glsl \ No newline at end of file diff --git a/lab/inc_template.glsl b/lab/inc_template.glsl new file mode 120000 index 0000000..d353cde --- /dev/null +++ b/lab/inc_template.glsl @@ -0,0 +1 @@ +../default/inc_template.glsl \ No newline at end of file diff --git a/lab/inc_time.glsl b/lab/inc_time.glsl new file mode 120000 index 0000000..42aed0b --- /dev/null +++ b/lab/inc_time.glsl @@ -0,0 +1 @@ +../default/inc_time.glsl \ No newline at end of file diff --git a/lab/inc_write.glsl b/lab/inc_write.glsl new file mode 120000 index 0000000..68f2438 --- /dev/null +++ b/lab/inc_write.glsl @@ -0,0 +1 @@ +../default/inc_write.glsl \ No newline at end of file