Added support for accelerated transformations & #expand directive
This commit is contained in:
@@ -128,7 +128,7 @@
|
||||
|
||||
This will delay data output by one update frame, so it can
|
||||
desync audio with visual effects on low UPS configs. */
|
||||
#request setinterpolate true
|
||||
#request setinterpolate false
|
||||
|
||||
/* Frame limiter, set to the frames per second (FPS) desired or
|
||||
simply set to zero (or lower) to disable the frame limiter. */
|
||||
@@ -202,6 +202,14 @@
|
||||
in the application generating the output. */
|
||||
#request setsamplerate 22050
|
||||
|
||||
/* Enable GPU acceleration of the audio buffer's fourier transform.
|
||||
This drastically reduces CPU usage, but should be avoided on
|
||||
old integrated graphics hardware.
|
||||
|
||||
Enabling this also enables acceleration for post-FFT processing
|
||||
effects, such as gravity, averaging, windowing, and interpolation. */
|
||||
#request setaccelfft true
|
||||
|
||||
/* ** DEPRECATED **
|
||||
Force window geometry (locking the window in place), useful
|
||||
for some pesky WMs that try to reposition the window when
|
||||
|
||||
37
shaders/glava/util/average_pass.frag
Normal file
37
shaders/glava/util/average_pass.frag
Normal file
@@ -0,0 +1,37 @@
|
||||
out vec4 fragment;
|
||||
in vec4 gl_FragCoord;
|
||||
|
||||
#include ":util/common.glsl"
|
||||
|
||||
/*
|
||||
This averaging shader uses compile-time loop generation to ensure two things:
|
||||
|
||||
- We can avoid requiring GL 4.3 features to dynamically index texture arrays
|
||||
- We ensure no branching occurs in this shader for optimial performance.
|
||||
|
||||
The alternative is requiring the GLSL compiler to determine that a loop for
|
||||
texture array indexes (which must be determined at compile-time in 3.3) can be
|
||||
expanded if the bounds are constant. This is somewhat vendor-specific so GLava
|
||||
provides a special `#expand` macro to solve this problem in the preprocessing
|
||||
stage.
|
||||
*/
|
||||
|
||||
#define SAMPLER(I) uniform sampler1D t##I;
|
||||
#expand SAMPLER _AVG_FRAMES
|
||||
|
||||
void main() {
|
||||
float r = 0;
|
||||
#define _AVG_WINDOW 0
|
||||
#if _AVG_WINDOW == 0
|
||||
#define F(I) r += texelFetch(t##I, int(gl_FragCoord.x), 0).r
|
||||
#else
|
||||
#define F(I) r += window(I, _AVG_FRAMES - 1) * texelFetch(t##I, int(gl_FragCoord.x), 0).r
|
||||
#endif
|
||||
#expand F _AVG_FRAMES
|
||||
/* For some reason the CPU implementation of gravity/average produces the same output but
|
||||
with half the amplitude. I can't figure it out right now, so I'm just halfing the results
|
||||
here to ensure they are uniform.
|
||||
|
||||
TODO: fix this */
|
||||
fragment.r = (r / _AVG_FRAMES) / 2;
|
||||
}
|
||||
21
shaders/glava/util/common.glsl
Normal file
21
shaders/glava/util/common.glsl
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef _COMMON_GLSL
|
||||
#define _COMMON_GLSL
|
||||
|
||||
#ifndef TWOPI
|
||||
#define TWOPI 6.28318530718
|
||||
#endif
|
||||
|
||||
#ifndef PI
|
||||
#define PI 3.14159265359
|
||||
#endif
|
||||
|
||||
/* Window value t that resides in range [0, sz] */
|
||||
#define window(t, sz) (0.53836 - (0.46164 * cos(TWOPI * t / sz)))
|
||||
/* Do nothing (used as an option for configuration) */
|
||||
#define linear(x) (x)
|
||||
/* Take value x that scales linearly between [0, 1) and return its sinusoidal curve */
|
||||
#define sinusoidal(x) ((0.5 * sin((PI * (x)) - (PI / 2))) + 0.5)
|
||||
/* Take value x that scales linearly between [0, 1) and return its circlar curve */
|
||||
#define circular(x) sqrt(1 - (((x) - 1) * ((x) - 1)))
|
||||
|
||||
#endif
|
||||
9
shaders/glava/util/gravity_pass.frag
Normal file
9
shaders/glava/util/gravity_pass.frag
Normal file
@@ -0,0 +1,9 @@
|
||||
uniform sampler1D tex;
|
||||
uniform float diff;
|
||||
|
||||
out vec4 fragment;
|
||||
in vec4 gl_FragCoord;
|
||||
|
||||
void main() {
|
||||
fragment.r = texelFetch(tex, int(gl_FragCoord.x), 0).r - diff;
|
||||
}
|
||||
@@ -1,27 +1,11 @@
|
||||
|
||||
#ifndef _SMOOTH_GLSL /* include gaurd */
|
||||
#ifndef _SMOOTH_GLSL
|
||||
#define _SMOOTH_GLSL
|
||||
|
||||
#ifndef TWOPI
|
||||
#define TWOPI 6.28318530718
|
||||
#endif
|
||||
|
||||
#ifndef PI
|
||||
#define PI 3.14159265359
|
||||
#endif
|
||||
#include ":util/common.glsl"
|
||||
|
||||
#include "@smooth_parameters.glsl"
|
||||
#include ":smooth_parameters.glsl"
|
||||
|
||||
/* window value t that resides in range [0, sz)*/
|
||||
#define window(t, sz) (0.53836 - (0.46164 * cos(TWOPI * t / (sz - 1))))
|
||||
/* this does nothing, but we keep it as an option for config */
|
||||
#define linear(x) (x)
|
||||
/* take value x that scales linearly between [0, 1) and return its sinusoidal curve */
|
||||
#define sinusoidal(x) ((0.5 * sin((PI * (x)) - (PI / 2))) + 0.5)
|
||||
/* take value x that scales linearly between [0, 1) and return its circlar curve */
|
||||
#define circular(x) sqrt(1 - (((x) - 1) * ((x) - 1)))
|
||||
|
||||
#define average 0
|
||||
#define maximum 1
|
||||
#define hybrid 2
|
||||
|
||||
Reference in New Issue
Block a user