BLT-With-Graphics-Template/include/blt/gfx/renderer/shaders/pp_gaussian_blur.frag

28 lines
698 B
GLSL
Raw Permalink Normal View History

2024-05-05 17:03:50 -04:00
#ifdef __cplusplus
#include <string>
const std::string shader_gaussian_blur_frag = R"("
#version 300 es
precision mediump float;
out vec4 FragColor;
in vec2 uv;
in vec2 pos;
uniform sampler2D tex;
uniform ivec4 size;
void main() {
vec2 texelSize = 1.0 / vec2(float(size.x), float(size.y));
vec4 result = vec4(0.0, 0.0, 0.0, 0.0);
for (int x = -size.z; x <= size.z; ++x) {
for (int y = -size.w; y <= size.w; ++y) {
vec2 offset = (vec2(float(x), float(y)) * texelSize);
result += texture(tex, uv + offset);
}
}
//FragColor = result;
FragColor = result / vec4((float(size.z) * 2.0 + 1.0) * (float(size.w) * 2.0 + 1.0));
}
")";
#endif