32 lines
811 B
GLSL
32 lines
811 B
GLSL
|
#ifdef __cplusplus
|
||
|
#include <string>
|
||
|
const std::string shader_overlay_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);
|
||
|
}
|
||
|
}
|
||
|
vec4 blur_val = result / vec4((float(size.z) * 2.0) * (float(size.w) * 2.0));
|
||
|
vec4 tex_val = texture(tex, uv);
|
||
|
if (tex_val != vec4(0.0,0.0,0.0,0.0))
|
||
|
FragColor = tex_val;
|
||
|
else
|
||
|
FragColor = blur_val;
|
||
|
}
|
||
|
|
||
|
")";
|
||
|
#endif
|