refactoring shader configs

This commit is contained in:
Jarcode
2017-12-02 14:00:39 -08:00
parent 8c3d9a76ea
commit d0aec12eaf
5 changed files with 38 additions and 36 deletions

26
shaders/graph.glsl Normal file
View File

@@ -0,0 +1,26 @@
/* Distance (in pixels) for each fragment to sample the audio data */
#define SAMPLE_RANGE 0.2
/* Amount of samples for each fragment, using the above range for each sample */
#define SAMPLE_AMT 22
/* Inverse horizontal scale, larger means less higher frequencies displayed */
#define WSCALE 11
/* Vertical scale, larger values will amplify output */
#define VSCALE 300
/* Rendering direction, either -1 (inwards) or 1 (outwards). */
#define DIRECTION -1
/* Graph color logic. The shader will only use the `COLOR` macro definition for output. */
/* right color offset */
#define RCOL_OFF (gl_FragCoord.x / 3000)
/* left color offset */
#define LCOL_OFF ((screen.x - gl_FragCoord.x) / 3000)
/* vertical color step */
#define LSTEP (gl_FragCoord.y / 170)
/* actual color definition */
#define COLOR vec4((0.3 + RCOL_OFF) + LSTEP, 0.6 - LSTEP, (0.3 + LCOL_OFF) + LSTEP, 1)

View File

@@ -1,28 +0,0 @@
layout(pixel_center_integer) in vec4 gl_FragCoord;
#request uniform "screen" screen
#request uniform "prev" tex
uniform sampler2D tex; /* screen texture */
uniform ivec2 screen; /* screen dimensions */
out vec4 fragment; /* output */
void main() {
fragment = texture(tex, vec2(gl_FragCoord.x / screen.x, gl_FragCoord.y / screen.y));
float a0 = texture(tex, vec2((gl_FragCoord.x + 1) / screen.x, (gl_FragCoord.y + 0) / screen.y)).a;
float a1 = texture(tex, vec2((gl_FragCoord.x + 1) / screen.x, (gl_FragCoord.y + 1) / screen.y)).a;
float a2 = texture(tex, vec2((gl_FragCoord.x + 0) / screen.x, (gl_FragCoord.y + 1) / screen.y)).a;
float a3 = texture(tex, vec2((gl_FragCoord.x + 1) / screen.x, (gl_FragCoord.y + 0) / screen.y)).a;
float a4 = texture(tex, vec2((gl_FragCoord.x - 1) / screen.x, (gl_FragCoord.y - 0) / screen.y)).a;
float a5 = texture(tex, vec2((gl_FragCoord.x - 1) / screen.x, (gl_FragCoord.y - 1) / screen.y)).a;
float a6 = texture(tex, vec2((gl_FragCoord.x - 0) / screen.x, (gl_FragCoord.y - 1) / screen.y)).a;
float a7 = texture(tex, vec2((gl_FragCoord.x - 1) / screen.x, (gl_FragCoord.y - 0) / screen.y)).a;
float avg = (a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7) / 8.0;
if (gl_FragCoord.y > 1) fragment *= avg;
}

View File

@@ -1,4 +0,0 @@
#define MIN_THICKNESS 1
#define MAX_THICKNESS 12
#define BASE_COLOR vec4(0.7, 0.2, 0.45, 1)
#define AMPLIFY 500

12
shaders/wave.glsl Normal file
View File

@@ -0,0 +1,12 @@
/* min (vertical) line thickness */
#define MIN_THICKNESS 1
/* max (vertical) line thickness */
#define MAX_THICKNESS 10
/* base color to use, distance from center will multiply the RGB components */
#define BASE_COLOR vec4(0.7, 0.2, 0.45, 1)
/* amplitude */
#define AMPLIFY 500

View File

@@ -1,4 +0,0 @@
#define MIN_THICKNESS 1
#define MAX_THICKNESS 10
#define BASE_COLOR vec4(0.7, 0.2, 0.45, 1)
#define AMPLIFY 500