diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 74a5cc8..d6d8c69 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -86,7 +86,7 @@ make -f Makefile.dev release-arch - [x] Share openGL state between monitor and screen - [ ] Other - [ ] Update readme with usage documentation - - [ ] Documentation in default config file + - [x] Documentation in default config file - [x] Clone "shaders" and config in system path at setup - [ ] Minimal sample shaders - [ ] Find and fix opengl errors 0500 ? diff --git a/default.cfg b/default.cfg index bd3875c..062a40b 100644 --- a/default.cfg +++ b/default.cfg @@ -1,37 +1,112 @@ -# FRAGMENT SHADERS +########### +## FORGE ## +########### +# Your reading a FORGE configuration file, don't panic +# Everything here is designed to link elements between them +# (shaders, video devices, textures, midi inputs, etc.) +# Every number based constant will be "one-based" (1,2,3,etc.) +# To read more, go to +# https://github.com/klemek/forge-steel + +# ================ +# FRAGMENT SHADERS +# ================ + + +# === UNIFORMS === +# GLSL uniform names or prefixes +# Prefixed uniforms are "iVariableX" with a number + +# --- uniform float --- + +# Elapsed time UNIFORM_TIME=iTime +# Current tempo UNIFORM_TEMPO=iTempo + +# --- uniform int --- + +# Output frame per second UNIFORM_FPS=iFPS -UNIFORM_DEMO=iDemo -UNIFORM_RESOLUTION=iResolution -UNIFORM_TEX_RESOLUTION=iTexResolution -UNIFORM_IN_RESOLUTION_PREFIX=iInputResolution -UNIFORM_IN_FORMAT_PREFIX=iInputFormat +# Input X frame per second UNIFORM_IN_FPS_PREFIX=iInputFPS -UNIFORM_SEED_PREFIX=iSeed -UNIFORM_STATE_PREFIX=iState -UNIFORM_TEX_PREFIX=iTex +# 0/1 if demo +UNIFORM_DEMO=iDemo +# Current page UNIFORM_PAGE=iPage +# Current selected shader UNIFORM_SELECTED=iSelected +# Seed for shader X +UNIFORM_SEED_PREFIX=iSeed +# State for shader X +UNIFORM_STATE_PREFIX=iState +# Midi group X active layer number UNIFORM_ACTIVE_PREFIX=iActive +# Input X format raw integer value +UNIFORM_IN_FORMAT_PREFIX=iInputFormat + +# --- uniform vec2 --- + +# Output resolution +UNIFORM_RESOLUTION=iResolution +# Internal textures resolution +UNIFORM_TEX_RESOLUTION=iTexResolution +# Input X resolution +UNIFORM_IN_RESOLUTION_PREFIX=iInputResolution + +# --- uniform vec3 --- + +# Midi group X layer Y (beware of group size) +# Injected as "iMidiX_Y[Z]" UNIFORM_MIDI_PREFIX=iMidi +# --- uniform sampler2D --- + +# Internal texture X +UNIFORM_TEX_PREFIX=iTex + +# === SUBROUTINES === +# GLSL subroutines prefixes +# You can then use them as: +# subroutine() () {} +# (see: https://wikis.khronos.org/opengl/Shader_Subroutine) +# Numbers go from 1 to SELECT_PAGE_COUNT * SELECT_ITEM_COUNT +# Each fragment shader is injected its current state subroutine + +# Total subroutine variants SUB_TYPE_COUNT=2 +# Each subroutine variant prefix SUB_1_PREFIX=src_ SUB_2_PREFIX=fx_ -# TEXTURE I/O +# =========== +# TEXTURE I/O +# =========== + + +# Total number of internal textures TEX_COUNT=10 -IN_COUNT=2 +# === VIDEO DEVICES +# Video devices will be read from CLI arguments +# and used in the same order inside FORGE +# Number of video devices +IN_COUNT=2 +# To which texture will be bound video device X IN_1_OUT=1 IN_2_OUT=2 +# === FRAGMENT SHADERS +# Fragment shaders will be read from the CLI directory as "fragX.glsl" +# Special shader "frag0.glsl" will be prepend to each one + +# Total number of fragment shaders (excluding frag0.glsl) FRAG_COUNT=10 +# To which texture will the shader fragX.glsl will render to FRAG_1_OUT=3 FRAG_2_OUT=4 FRAG_3_OUT=5 @@ -40,38 +115,91 @@ FRAG_5_OUT=7 FRAG_6_OUT=8 FRAG_7_OUT=9 FRAG_8_OUT=0 - +# Which fragment shader renders to output window FRAG_OUTPUT=9 +# Which fragment shader renders to monitor window FRAG_MONITOR=10 -# MIDI +# ======== +# MIDI I/O +# ======== + + +# The recognized ALSA name of the midi device MIDI_HW=hw:CARD=nanoKONTROL2 +# === TYPES OF EVENTS +# FORGE needs to differentiate between fader and buttons +# In the next configurations, when an event is not configured, +# it will be skipped + +# Total number of faders +FADER_COUNT=16 +# Midi codes of faders +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 +# Midi code for tap tempo +TAP_TEMPO=46 + +# === FRAGMENT SUBROUTINE SELECT +# You can manipulate which subroutine is sent to which fragment shader + +# Midi codes to select fragment X +SELECT_FRAG_3=32 +SELECT_FRAG_4=64 +SELECT_FRAG_5=36 +SELECT_FRAG_6=68 +SELECT_FRAG_8=52 +# Total number of pages (can be 1) SELECT_PAGE_COUNT=3 +# Midi codes to select page X SELECT_PAGE_1=60 SELECT_PAGE_2=61 SELECT_PAGE_3=62 - +# Total number of items per page SELECT_ITEM_COUNT=5 +# Midi codes to select item Y on page X SELECT_ITEM_1=43 SELECT_ITEM_2=44 SELECT_ITEM_3=42 SELECT_ITEM_4=41 SELECT_ITEM_5=45 -SELECT_FRAG_3=32 -SELECT_FRAG_4=64 -SELECT_FRAG_5=36 -SELECT_FRAG_6=68 -SELECT_FRAG_8=52 +# === MIDI INPUT STATES +# Midi inputs will control FORGE's state as follows +# X groups of Y layers sized Z +# You can manipulate only 1 layer at a time +# Every layer of every groups will be send as uniforms +# Each active layer will be sent back to the device +# with the same codes for nice display +# Total number of groups MIDI_COUNT=3 +# Total number of layers of group 1 MIDI_1_ACTIVE_COUNT=2 +# Midi codes to change layer of group 1 MIDI_1_ACTIVE_1=32 MIDI_1_ACTIVE_2=64 + +# Size of group 1 MIDI_1_COUNT=6 +# Every code of active layer manipulation of group 1 MIDI_1_1_X=33 MIDI_1_1_Y=49 MIDI_1_1_Z=65 @@ -91,6 +219,7 @@ MIDI_1_6_X=3 MIDI_1_6_Y=19 MIDI_1_6_Z= +# Same for group 2 MIDI_2_ACTIVE_COUNT=3 MIDI_2_ACTIVE_1=36 MIDI_2_ACTIVE_2=68 @@ -118,6 +247,7 @@ MIDI_2_7_X=4 MIDI_2_7_Y=20 MIDI_2_7_Z= +# Same for group 3 MIDI_3_COUNT=2 MIDI_3_1_X=48 MIDI_3_1_Y=58 @@ -125,23 +255,3 @@ MIDI_3_1_Z=59 MIDI_3_2_X=0 MIDI_3_2_Y=16 MIDI_3_2_Z= - -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 \ No newline at end of file diff --git a/shaders/frag0.glsl b/shaders/frag0.glsl index 231b373..70b8dbb 100644 --- a/shaders/frag0.glsl +++ b/shaders/frag0.glsl @@ -1221,7 +1221,7 @@ subroutine(src_stage_sub) vec4 src_14(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 return texture(iTex0, vUV); } -// TODO SRC 15 +// SRC 15 : debug subroutine(src_stage_sub) vec4 src_15(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3) { // start @@ -1230,22 +1230,6 @@ subroutine(src_stage_sub) vec4 src_15(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 float ratio = iResolution.x / iResolution.y; vec2 uv1 = (uv0 - .5) * vec2(ratio, 1); - // controls - - // logic - - return texture(iTex0, vUV); -} - -// SRC 16 : debug -subroutine(src_stage_sub) vec4 src_16(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); - // inputs int selected_srca = iState3; @@ -1803,27 +1787,6 @@ subroutine(fx_stage_sub) vec4 fx_15(vec2 vUV, sampler2D previous, sampler2D feed return vec4(mix(c0, c, fx), 1.0); } -// TODO FX 16 -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 - - vec2 uv0 = vUV.st; - float ratio = iResolution.x / iResolution.y; - vec2 uv1 = (uv0 - .5) * vec2(ratio, 1); - - // controls - - float fx = magic(f0, vec3(1,0,0), seed); - - // logic - - vec3 c0 = texture(previous, uv0).xyz; - vec3 c = c0; - - return vec4(mix(c0, c, fx), 1.0); -} - const mat3x3 yuv_to_rgb = {{1,1,1},{0,-0.39465,2.03211},{1.13983,-0.5806,0}}; const int YUYV_FOURCC = 1448695129; diff --git a/shaders/frag10.glsl b/shaders/frag10.glsl index 79a1de9..9fefcb4 100644 --- a/shaders/frag10.glsl +++ b/shaders/frag10.glsl @@ -40,7 +40,7 @@ void main() { c += s(uv2,1,1) * texture(iTex6, 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_15(mod(uv2, 1), 0, vec3(0), vec2(0), vec3(0), vec2(0), vec3(0), vec2(0)); c += s(uv2,1,0) * texture(iTex9, uv2); c += s(uv2,2,0) * texture(iTex0, uv2);