bibliotheca/shader/audio/visualizer.frag

27 lines
458 B
GLSL

#version 430 core
in VS_OUT {
vec4 Texture;
} fs_in;
layout (location = 0) out vec4 Color;
layout (r16i, binding = 0) readonly uniform iimageBuffer Image;
float get_sample(int coordinate)
{
int red = imageLoad(Image, coordinate).r;
return float(red) * (1.0 / 32768.0);
}
void main()
{
float value = get_sample(int(gl_FragCoord.x));
float y = -(fs_in.Texture.y * 2 - 1);
float c = float(abs(y) < abs(value));
Color = vec4(c, 0, 0, 1);
}