fast-nuclear-sim/assets/shader/blur.fsh

27 lines
424 B
Plaintext
Raw Normal View History

2024-02-20 23:42:19 +11:00
#version 460 core
uniform sampler2D tex;
2024-03-18 21:57:06 +11:00
uniform vec2 direction;
uniform int samples;
2024-02-20 23:42:19 +11:00
2024-03-18 21:57:06 +11:00
in vec2 FragPos;
2024-02-20 23:42:19 +11:00
out vec4 FragColour;
void main()
{
2024-03-18 21:57:06 +11:00
int radius = (samples - 1) / 2;
ivec2 size = textureSize(tex, 0);
vec2 step = direction / size;
vec4 sum = vec4(0.f);
for(int i = -radius; i <= radius; i++)
2024-02-20 23:42:19 +11:00
{
2024-03-18 21:57:06 +11:00
vec2 offset = vec2(i) * step;
sum += texture(tex, FragPos + offset);
2024-02-20 23:42:19 +11:00
}
2024-03-18 21:57:06 +11:00
FragColour = sum / float(samples);
2024-02-20 23:42:19 +11:00
}