diff --git a/shaders/bars.glsl b/shaders/bars.glsl index c85a155..6723b0c 100644 --- a/shaders/bars.glsl +++ b/shaders/bars.glsl @@ -1,18 +1,18 @@ -/* center line thickness (pixels) */ +/* Center line thickness (pixels) */ #define C_LINE 1 -/* width (in pixels) of each bar */ +/* Width (in pixels) of each bar */ #define BAR_WIDTH 4 -/* width (in pixels) of each bar gap */ +/* Width (in pixels) of each bar gap */ #define BAR_GAP 2 -/* outline color */ +/* Outline color */ #define BAR_OUTLINE #262626 -/* outline width (in pixels, set to 0 to disable outline drawing) */ +/* Outline width (in pixels, set to 0 to disable outline drawing) */ #define BAR_OUTLINE_WIDTH 0 /* Amplify magnitude of the results each bar displays */ #define AMPLIFY 300 -/* Alpha channel for Bars color */ +/* Alpha channel for bars color */ #define ALPHA 0.7 /* How strong the gradient changes */ #define GRADIENT_POWER 60 @@ -26,4 +26,7 @@ #define INVERT 0 /* Whether to flip the output vertically */ #define FLIP 0 +/* Whether to mirror output along `Y = X`, causing output to render on the left side of the window */ +/* Use with `FLIP 1` to render on the right side */ +#define MIRROR_YX 0 diff --git a/shaders/bars/1.frag b/shaders/bars/1.frag index 7426ea3..df8c561 100644 --- a/shaders/bars/1.frag +++ b/shaders/bars/1.frag @@ -29,20 +29,33 @@ out vec4 fragment; #define PI 3.14159265359 void main() { - float dx = (gl_FragCoord.x - (screen.x / 2)); - #if FLIP == 0 - float d = gl_FragCoord.y; + + #if MIRROR_YX == 0 + #define AREA_WIDTH screen.x + #define AREA_HEIGHT screen.y + #define AREA_X gl_FragCoord.x + #define AREA_Y gl_FragCoord.y #else - float d = screen.y - gl_FragCoord.y; + #define AREA_WIDTH screen.y + #define AREA_HEIGHT screen.x + #define AREA_X gl_FragCoord.y + #define AREA_Y gl_FragCoord.x #endif - float nbars = floor((screen.x * 0.5F) / float(BAR_WIDTH + BAR_GAP)) * 2; + + float dx = (AREA_X - (AREA_WIDTH / 2)); + #if FLIP == 0 + float d = AREA_Y; + #else + float d = AREA_HEIGHT - AREA_Y; + #endif + float nbars = floor((AREA_WIDTH * 0.5F) / float(BAR_WIDTH + BAR_GAP)) * 2; float section = BAR_WIDTH + BAR_GAP; /* size of section for each bar (including gap) */ float center = section / 2.0F; /* half section, distance to center */ float m = abs(mod(dx, section)); /* position in section */ float md = m - center; /* position in section from center line */ if (md < ceil(float(BAR_WIDTH) / 2) && md >= -floor(float(BAR_WIDTH) / 2)) { /* if not in gap */ float p = int(dx / section) / float(nbars / 2); /* position, (-1.0F, 1.0F)) */ - p += sign(p) * ((0.5F + center) / screen.x); /* index center of bar position */ + p += sign(p) * ((0.5F + center) / AREA_WIDTH); /* index center of bar position */ /* Apply smooth function and index texture */ #define smooth_f(tex, p) smooth_audio(tex, audio_sz, p) float v;