fixed config load order, cleaning up shaders

This commit is contained in:
Jarcode
2017-12-02 17:34:22 -08:00
parent 4a6ba00ec4
commit bb9fbfc4fc
8 changed files with 58 additions and 26 deletions

View File

@@ -9,12 +9,17 @@
#define WSCALE 11
/* Vertical scale, larger values will amplify output */
#define VSCALE 300
#define VSCALE 2800
/* Whether to apply a window function to samples or not (0 or 1). Slightly
slower but removes some jagged results. Has a side effect of reducing the
graph magnitude, so you should increase the `VSCALE` macro to compensate. */
#define WINDOW_SAMPLES 1
/* 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. */
/* Graph color logic. The shader uses the `COLOR` macro definition for output. */
/* right color offset */
#define RCOL_OFF (gl_FragCoord.x / 3000)
@@ -24,3 +29,6 @@
#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)
/* outline color */
#define OUTLINE vec4(0.15, 0.15, 0.15, 1)

View File

@@ -89,6 +89,9 @@ out vec4 fragment;
#define HDIST CDIST
#endif
#define TWOPI 6.28318530718
#define window(t, sz) (0.53836 - (0.46164 * cos(TWOPI * t / (sz - 1))))
float half_w;
void render_side(sampler1D tex, float idx) {
@@ -96,7 +99,13 @@ void render_side(sampler1D tex, float idx) {
int t;
/* perform samples */
for (t = -SAMPLE_AMT; t <= SAMPLE_AMT; ++t) {
s += (texture(tex, log((idx + (t * SAMPLE_RANGE)) / half_w) / WSCALE).r);
#if WINDOW_SAMPLES != 0
#define WFACTOR window(t + SAMPLE_AMT, float((SAMPLE_AMT * 2) + 1))
#else
#define WFACTOR int(1)
#endif
s += (texture(tex, log((idx + (t * SAMPLE_RANGE)) / half_w) / WSCALE).r) * WFACTOR;
#undef WFACTOR
}
/* compute average on samples */
s /= float(SAMPLE_AMT * 2) + 1;

View File

@@ -8,7 +8,7 @@ uniform ivec2 screen; /* screen dimensions */
out vec4 fragment; /* output */
#define OUTLINE vec4(0.15, 0.15, 0.15, 1)
#include "../graph.glsl"
void main() {
fragment = texture(tex, vec2(gl_FragCoord.x / screen.x, gl_FragCoord.y / screen.y));

View File

@@ -1,12 +1,14 @@
/* min (vertical) line thickness */
#define MIN_THICKNESS 1
/* max (vertical) line thickness */
#define MAX_THICKNESS 10
#define MAX_THICKNESS 6
/* 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
/* outline color */
#define OUTLINE vec4(0.15, 0.15, 0.15, 1)

View File

@@ -13,10 +13,24 @@ out vec4 fragment;
#include "../wave.glsl"
#define index(offset) ((texture(audio_l, (gl_FragCoord.x + offset) / screen.x).r - 0.5) * AMPLIFY) + 0.5f
void main() {
float os = ((texture(audio_l, gl_FragCoord.x / screen.x).r - 0.5) * AMPLIFY) + 0.5f;
float
os = index(0),
adj0 = index(-1),
adj1 = index(1);
float
s0 = adj0 - os,
s1 = adj1 - os;
float
dmax = max(s0, s1),
dmin = min(s0, s1);
float s = (os + (screen.y * 0.5f) - 0.5f); /* center to screen coords */
if (abs(s - gl_FragCoord.y) < clamp(abs(s - (screen.y * 0.5)) * 6, MIN_THICKNESS, MAX_THICKNESS)) {
float diff = gl_FragCoord.y - s;
if (abs(diff) < clamp(abs(s - (screen.y * 0.5)) * 6, MIN_THICKNESS, MAX_THICKNESS)
|| (diff <= dmax && diff >= dmin)) {
fragment = BASE_COLOR + (abs((screen.y * 0.5f) - s) * 0.02);
} else {
fragment = vec4(0, 0, 0, 0);

View File

@@ -8,19 +8,25 @@ uniform ivec2 screen; /* screen dimensions */
out vec4 fragment; /* output */
#include "../wave.glsl"
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;
vec4
a0 = texture(tex, vec2((gl_FragCoord.x + 1) / screen.x, (gl_FragCoord.y + 0) / screen.y)),
a1 = texture(tex, vec2((gl_FragCoord.x + 1) / screen.x, (gl_FragCoord.y + 1) / screen.y)),
a2 = texture(tex, vec2((gl_FragCoord.x + 0) / screen.x, (gl_FragCoord.y + 1) / screen.y)),
a3 = texture(tex, vec2((gl_FragCoord.x + 1) / screen.x, (gl_FragCoord.y + 0) / screen.y)),
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;
a4 = texture(tex, vec2((gl_FragCoord.x - 1) / screen.x, (gl_FragCoord.y - 0) / screen.y)),
a5 = texture(tex, vec2((gl_FragCoord.x - 1) / screen.x, (gl_FragCoord.y - 1) / screen.y)),
a6 = texture(tex, vec2((gl_FragCoord.x - 0) / screen.x, (gl_FragCoord.y - 1) / screen.y)),
a7 = texture(tex, vec2((gl_FragCoord.x - 1) / screen.x, (gl_FragCoord.y - 0) / screen.y));
float avg = (a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7) / 8.0;
fragment *= avg;
vec4 avg = (a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7) / 8.0;
if (avg.a > 0){
if (fragment.a <= 0 || gl_FragCoord.x == 0 || gl_FragCoord.x == screen.x - 1)
fragment = OUTLINE;
}
}