wip shader config
This commit is contained in:
@@ -106,6 +106,9 @@ make -f Makefile.dev release-arch
|
|||||||
- [ ] 16 input + 16 fx definition and selection (with const param)
|
- [ ] 16 input + 16 fx definition and selection (with const param)
|
||||||
- [x] Feedback texture
|
- [x] Feedback texture
|
||||||
- [ ] Shaders config file
|
- [ ] Shaders config file
|
||||||
|
- [ ] uniform config
|
||||||
|
- [ ] fragment output config
|
||||||
|
- [ ] subroutines config
|
||||||
- [ ] Clean code
|
- [ ] Clean code
|
||||||
- [ ] Midi
|
- [ ] Midi
|
||||||
- [ ] Read Midi events
|
- [ ] Read Midi events
|
||||||
|
|||||||
+19
-19
@@ -855,13 +855,13 @@ subroutine vec4 src_stage_sub(vec2 vUV);
|
|||||||
|
|
||||||
subroutine uniform src_stage_sub src_stage;
|
subroutine uniform src_stage_sub src_stage;
|
||||||
|
|
||||||
subroutine(src_stage_sub) vec4 src_0(vec2 vUV)
|
subroutine(src_stage_sub) vec4 src_1(vec2 vUV)
|
||||||
{
|
{
|
||||||
// TODO tmp
|
// TODO tmp
|
||||||
return vec4(vUV, 0.0, 0.0);
|
return vec4(vUV, 0.0, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
subroutine(src_stage_sub) vec4 src_1(vec2 vUV)
|
subroutine(src_stage_sub) vec4 src_2(vec2 vUV)
|
||||||
{
|
{
|
||||||
// TODO tmp
|
// TODO tmp
|
||||||
vec2 uv0 = vUV.st;
|
vec2 uv0 = vUV.st;
|
||||||
@@ -873,7 +873,7 @@ subroutine(src_stage_sub) vec4 src_1(vec2 vUV)
|
|||||||
return mix(color, gauss(tex0, vUV - 0.01) * 0.5, f);
|
return mix(color, gauss(tex0, vUV - 0.01) * 0.5, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
subroutine(src_stage_sub) vec4 src_2(vec2 vUV)
|
subroutine(src_stage_sub) vec4 src_3(vec2 vUV)
|
||||||
{
|
{
|
||||||
const int text[5] = {0x66, 0x70, 0x73, 0x00, 0x00};
|
const int text[5] = {0x66, 0x70, 0x73, 0x00, 0x00};
|
||||||
vec2 uv0 = vUV.st;
|
vec2 uv0 = vUV.st;
|
||||||
@@ -890,12 +890,6 @@ subroutine(src_stage_sub) vec4 src_2(vec2 vUV)
|
|||||||
return vec4(v);
|
return vec4(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
subroutine(src_stage_sub) vec4 src_3(vec2 vUV)
|
|
||||||
{
|
|
||||||
// TODO tmp
|
|
||||||
return vec4(vUV, 0.0, 0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
subroutine(src_stage_sub) vec4 src_4(vec2 vUV)
|
subroutine(src_stage_sub) vec4 src_4(vec2 vUV)
|
||||||
{
|
{
|
||||||
// TODO tmp
|
// TODO tmp
|
||||||
@@ -968,6 +962,12 @@ subroutine(src_stage_sub) vec4 src_15(vec2 vUV)
|
|||||||
return vec4(vUV, 0.0, 0.0);
|
return vec4(vUV, 0.0, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
subroutine(src_stage_sub) vec4 src_16(vec2 vUV)
|
||||||
|
{
|
||||||
|
// TODO tmp
|
||||||
|
return vec4(vUV, 0.0, 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
// 6. effects
|
// 6. effects
|
||||||
// ----------
|
// ----------
|
||||||
|
|
||||||
@@ -975,22 +975,16 @@ subroutine vec4 fx_stage_sub(vec2 vUV, sampler2D previous, sampler2D feedback);
|
|||||||
|
|
||||||
subroutine uniform fx_stage_sub fx_stage;
|
subroutine uniform fx_stage_sub fx_stage;
|
||||||
|
|
||||||
subroutine(fx_stage_sub) vec4 fx_0(vec2 vUV, sampler2D previous, sampler2D feedback)
|
|
||||||
{
|
|
||||||
// TODO tmp
|
|
||||||
return texture(previous, vUV);
|
|
||||||
}
|
|
||||||
|
|
||||||
subroutine(fx_stage_sub) vec4 fx_1(vec2 vUV, sampler2D previous, sampler2D feedback)
|
subroutine(fx_stage_sub) vec4 fx_1(vec2 vUV, sampler2D previous, sampler2D feedback)
|
||||||
{
|
{
|
||||||
// TODO tmp
|
// TODO tmp
|
||||||
return gauss(previous, vUV);
|
return texture(previous, vUV);
|
||||||
}
|
}
|
||||||
|
|
||||||
subroutine(fx_stage_sub) vec4 fx_2(vec2 vUV, sampler2D previous, sampler2D feedback)
|
subroutine(fx_stage_sub) vec4 fx_2(vec2 vUV, sampler2D previous, sampler2D feedback)
|
||||||
{
|
{
|
||||||
// TODO tmp
|
// TODO tmp
|
||||||
return texture(previous, vUV);
|
return gauss(previous, vUV);
|
||||||
}
|
}
|
||||||
|
|
||||||
subroutine(fx_stage_sub) vec4 fx_3(vec2 vUV, sampler2D previous, sampler2D feedback)
|
subroutine(fx_stage_sub) vec4 fx_3(vec2 vUV, sampler2D previous, sampler2D feedback)
|
||||||
@@ -1071,6 +1065,12 @@ subroutine(fx_stage_sub) vec4 fx_15(vec2 vUV, sampler2D previous, sampler2D feed
|
|||||||
return texture(previous, vUV);
|
return texture(previous, vUV);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
subroutine(fx_stage_sub) vec4 fx_16(vec2 vUV, sampler2D previous, sampler2D feedback)
|
||||||
|
{
|
||||||
|
// TODO tmp
|
||||||
|
return texture(previous, vUV);
|
||||||
|
}
|
||||||
|
|
||||||
// 7. mix
|
// 7. mix
|
||||||
// ----------
|
// ----------
|
||||||
|
|
||||||
@@ -1078,7 +1078,7 @@ subroutine vec4 mix_stage_sub(vec2 vUV, sampler2D tex_a, sampler2D tex_a, float
|
|||||||
|
|
||||||
subroutine uniform mix_stage_sub mix_stage;
|
subroutine uniform mix_stage_sub mix_stage;
|
||||||
|
|
||||||
subroutine(mix_stage_sub) vec4 mix_0(vec2 vUV, sampler2D ta, sampler2D tb, float lvl)
|
subroutine(mix_stage_sub) vec4 mix_1(vec2 vUV, sampler2D ta, sampler2D tb, float lvl)
|
||||||
{
|
{
|
||||||
vec4 color_a = texture(ta, vUV);
|
vec4 color_a = texture(ta, vUV);
|
||||||
vec4 color_b = texture(tb, vUV);
|
vec4 color_b = texture(tb, vUV);
|
||||||
@@ -1086,7 +1086,7 @@ subroutine(mix_stage_sub) vec4 mix_0(vec2 vUV, sampler2D ta, sampler2D tb, float
|
|||||||
return color_a + color_b;// TODOmix(color_b, color_a, lvl);
|
return color_a + color_b;// TODOmix(color_b, color_a, lvl);
|
||||||
}
|
}
|
||||||
|
|
||||||
subroutine(mix_stage_sub) vec4 mix_1(vec2 vUV, sampler2D ta, sampler2D tb, float lvl)
|
subroutine(mix_stage_sub) vec4 mix_2(vec2 vUV, sampler2D ta, sampler2D tb, float lvl)
|
||||||
{
|
{
|
||||||
vec4 color_a = texture(ta, vUV);
|
vec4 color_a = texture(ta, vUV);
|
||||||
vec4 color_b = texture(tb, vUV);
|
vec4 color_b = texture(tb, vUV);
|
||||||
|
|||||||
+14
-1
@@ -1,8 +1,21 @@
|
|||||||
SUB_COUNT=16
|
UNIFORM_TIME=iTime
|
||||||
|
UNIFORM_TEMPO=iTempo
|
||||||
|
UNIFORM_FPS=iFPS
|
||||||
|
UNIFORM_RESOLUTION=iResolution
|
||||||
|
|
||||||
FRAG_COUNT=6
|
FRAG_COUNT=6
|
||||||
|
|
||||||
FRAG_OUT_1=2
|
FRAG_OUT_1=2
|
||||||
FRAG_OUT_2=5
|
FRAG_OUT_2=5
|
||||||
FRAG_OUT_3=3
|
FRAG_OUT_3=3
|
||||||
FRAG_OUT_4=6
|
FRAG_OUT_4=6
|
||||||
FRAG_OUT_5=7
|
FRAG_OUT_5=7
|
||||||
FRAG_OUT_6=0
|
FRAG_OUT_6=0
|
||||||
|
|
||||||
|
SUB_TYPE_COUNT=3
|
||||||
|
SUB_1_PREFIX=src_
|
||||||
|
SUB_1_COUNT=16
|
||||||
|
SUB_2_PREFIX=fx_
|
||||||
|
SUB_2_COUNT=16
|
||||||
|
SUB_3_PREFIX=mix_
|
||||||
|
SUB_3_COUNT=2
|
||||||
|
|||||||
+7
-1
@@ -4,6 +4,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "config_file.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "forge.h"
|
#include "forge.h"
|
||||||
#include "logs.h"
|
#include "logs.h"
|
||||||
@@ -126,15 +127,18 @@ void forge_run(Parameters params) {
|
|||||||
Window *window;
|
Window *window;
|
||||||
Timer timer;
|
Timer timer;
|
||||||
Context context;
|
Context context;
|
||||||
|
ConfigFile shader_config;
|
||||||
|
|
||||||
init_files(params.frag_path, &common_shader_code, fragment_shaders);
|
init_files(params.frag_path, &common_shader_code, fragment_shaders);
|
||||||
|
|
||||||
|
shader_config = config_file_read(params.frag_config_path, false);
|
||||||
|
|
||||||
window = window_init(PACKAGE " " VERSION, params.screen, error_callback,
|
window = window_init(PACKAGE " " VERSION, params.screen, error_callback,
|
||||||
key_callback);
|
key_callback);
|
||||||
|
|
||||||
context = window_get_context(window);
|
context = window_get_context(window);
|
||||||
|
|
||||||
program = shaders_init(fragment_shaders, context);
|
program = shaders_init(fragment_shaders, shader_config, context);
|
||||||
|
|
||||||
if (program.error) {
|
if (program.error) {
|
||||||
window_close(window, true);
|
window_close(window, true);
|
||||||
@@ -151,4 +155,6 @@ void forge_run(Parameters params) {
|
|||||||
window_close(window, true);
|
window_close(window, true);
|
||||||
|
|
||||||
free_files(&common_shader_code, fragment_shaders);
|
free_files(&common_shader_code, fragment_shaders);
|
||||||
|
|
||||||
|
config_file_free(shader_config);
|
||||||
}
|
}
|
||||||
+5
-4
@@ -160,14 +160,14 @@ static void init_single_program(ShaderProgram *program, unsigned int i,
|
|||||||
glGetUniformLocation(program->programs[i], "iResolution");
|
glGetUniformLocation(program->programs[i], "iResolution");
|
||||||
|
|
||||||
for (j = 0; j < SUB_COUNT; j++) {
|
for (j = 0; j < SUB_COUNT; j++) {
|
||||||
sprintf(name, "src_%d", j);
|
sprintf(name, "src_%d", j + 1);
|
||||||
program->sub_src_indexes[i][j] =
|
program->sub_src_indexes[i][j] =
|
||||||
glGetSubroutineIndex(program->programs[i], GL_FRAGMENT_SHADER, name);
|
glGetSubroutineIndex(program->programs[i], GL_FRAGMENT_SHADER, name);
|
||||||
sprintf(name, "fx_%d", j);
|
sprintf(name, "fx_%d", j + 1);
|
||||||
program->sub_fx_indexes[i][j] =
|
program->sub_fx_indexes[i][j] =
|
||||||
glGetSubroutineIndex(program->programs[i], GL_FRAGMENT_SHADER, name);
|
glGetSubroutineIndex(program->programs[i], GL_FRAGMENT_SHADER, name);
|
||||||
if (j < 2) {
|
if (j < 2) {
|
||||||
sprintf(name, "mix_%d", j);
|
sprintf(name, "mix_%d", j + 1);
|
||||||
program->sub_mix_indexes[i][j] = glGetSubroutineIndex(
|
program->sub_mix_indexes[i][j] = glGetSubroutineIndex(
|
||||||
program->programs[i], GL_FRAGMENT_SHADER, name);
|
program->programs[i], GL_FRAGMENT_SHADER, name);
|
||||||
}
|
}
|
||||||
@@ -194,7 +194,8 @@ static void init_single_program(ShaderProgram *program, unsigned int i,
|
|||||||
log_success("Program %d initialized", i + 1);
|
log_success("Program %d initialized", i + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderProgram shaders_init(File *fragment_shaders, Context context) {
|
ShaderProgram shaders_init(File *fragment_shaders, ConfigFile shader_config,
|
||||||
|
Context context) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
ShaderProgram program;
|
ShaderProgram program;
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -3,7 +3,8 @@
|
|||||||
#ifndef SHADERS_H
|
#ifndef SHADERS_H
|
||||||
#define SHADERS_H
|
#define SHADERS_H
|
||||||
|
|
||||||
ShaderProgram shaders_init(File *fragment_shader, Context context);
|
ShaderProgram shaders_init(File *fragment_shaders, ConfigFile shader_config,
|
||||||
|
Context context);
|
||||||
|
|
||||||
void shaders_update(ShaderProgram program, File *fragment_shaders,
|
void shaders_update(ShaderProgram program, File *fragment_shaders,
|
||||||
unsigned int i);
|
unsigned int i);
|
||||||
|
|||||||
Reference in New Issue
Block a user