2023-08-18 18:22:08 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2021-05-14 13:12:53 +00:00
|
|
|
//
|
2023-12-26 10:10:19 +00:00
|
|
|
// ES-DE
|
2023-08-18 18:22:08 +00:00
|
|
|
// blur_horizontal.glsl
|
2021-05-14 13:12:53 +00:00
|
|
|
//
|
2023-08-18 18:22:08 +00:00
|
|
|
// Horizontal gaussian blur.
|
2021-05-14 13:12:53 +00:00
|
|
|
//
|
2020-09-04 16:59:19 +00:00
|
|
|
|
2022-03-14 23:14:06 +00:00
|
|
|
// Vertex section of code:
|
2020-09-04 16:59:19 +00:00
|
|
|
#if defined(VERTEX)
|
|
|
|
|
|
|
|
uniform mat4 MVPMatrix;
|
2022-03-14 23:14:06 +00:00
|
|
|
in vec2 positionVertex;
|
|
|
|
in vec2 texCoordVertex;
|
|
|
|
out vec2 texCoord;
|
2020-09-04 16:59:19 +00:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2022-03-14 23:14:06 +00:00
|
|
|
gl_Position = MVPMatrix * vec4(positionVertex, 0.0, 1.0);
|
|
|
|
texCoord = texCoordVertex;
|
2020-09-04 16:59:19 +00:00
|
|
|
}
|
|
|
|
|
2022-03-14 23:14:06 +00:00
|
|
|
// Fragment section of code:
|
2020-09-04 16:59:19 +00:00
|
|
|
#elif defined(FRAGMENT)
|
|
|
|
|
|
|
|
#ifdef GL_ES
|
2023-12-23 18:29:43 +00:00
|
|
|
precision highp float;
|
2020-09-04 16:59:19 +00:00
|
|
|
#endif
|
|
|
|
|
2023-02-06 22:38:35 +00:00
|
|
|
uniform uint shaderFlags;
|
2023-09-07 19:02:38 +00:00
|
|
|
uniform sampler2D textureSampler0;
|
2023-08-18 18:22:08 +00:00
|
|
|
uniform float blurStrength;
|
2022-03-14 23:14:06 +00:00
|
|
|
in vec2 texCoord;
|
|
|
|
out vec4 FragColor;
|
2020-09-04 16:59:19 +00:00
|
|
|
|
2023-02-06 22:38:35 +00:00
|
|
|
// shaderFlags:
|
|
|
|
// 0x00000001 - Premultiplied alpha (BGRA)
|
|
|
|
// 0x00000002 - Font texture
|
|
|
|
// 0x00000004 - Post processing
|
|
|
|
// 0x00000008 - Clipping
|
|
|
|
// 0x00000010 - Screen rotated 90 or 270 degrees
|
2023-08-20 17:41:07 +00:00
|
|
|
// 0x00000020 - Rounded corners
|
|
|
|
// 0x00000040 - Rounded corners with no anti-aliasing
|
2023-11-20 20:33:16 +00:00
|
|
|
// 0x00000080 - Convert pixel format
|
2020-09-04 16:59:19 +00:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2023-08-18 18:22:08 +00:00
|
|
|
vec4 color = vec4(0.0);
|
|
|
|
float hstep = 1.0f;
|
|
|
|
float vstep = 0.0f;
|
|
|
|
vec2 tc;
|
2023-02-06 22:38:35 +00:00
|
|
|
|
2023-02-21 17:43:18 +00:00
|
|
|
if (0x0u != (shaderFlags & 0x10u)) {
|
2023-08-18 18:22:08 +00:00
|
|
|
// Screen rotated 90 or 270 degrees.
|
|
|
|
tc = texCoord.yx;
|
2023-02-21 17:43:18 +00:00
|
|
|
}
|
|
|
|
else {
|
2023-08-18 18:22:08 +00:00
|
|
|
tc = texCoord.xy;
|
2023-02-21 17:43:18 +00:00
|
|
|
}
|
2021-05-14 13:12:53 +00:00
|
|
|
|
2023-08-18 18:22:08 +00:00
|
|
|
// 9-tap filter.
|
2023-09-07 19:02:38 +00:00
|
|
|
color += texture(textureSampler0,
|
2023-08-18 18:22:08 +00:00
|
|
|
vec2(tc.x - 4.0 * blurStrength * hstep, tc.y - 4.0 * blurStrength * vstep)) *
|
|
|
|
0.0162162162;
|
2023-09-07 19:02:38 +00:00
|
|
|
color += texture(textureSampler0,
|
2023-08-18 18:22:08 +00:00
|
|
|
vec2(tc.x - 3.0 * blurStrength * hstep, tc.y - 3.0 * blurStrength * vstep)) *
|
|
|
|
0.0540540541;
|
2023-09-07 19:02:38 +00:00
|
|
|
color += texture(textureSampler0,
|
2023-08-18 18:22:08 +00:00
|
|
|
vec2(tc.x - 2.0 * blurStrength * hstep, tc.y - 2.0 * blurStrength * vstep)) *
|
|
|
|
0.1216216216;
|
2023-09-07 19:02:38 +00:00
|
|
|
color += texture(textureSampler0,
|
2023-08-18 18:22:08 +00:00
|
|
|
vec2(tc.x - 1.0 * blurStrength * hstep, tc.y - 1.0 * blurStrength * vstep)) *
|
|
|
|
0.1945945946;
|
2020-09-04 16:59:19 +00:00
|
|
|
|
2023-09-07 19:02:38 +00:00
|
|
|
color += texture(textureSampler0, vec2(tc.x, tc.y)) * 0.2270270270;
|
2023-08-18 18:22:08 +00:00
|
|
|
|
2023-09-07 19:02:38 +00:00
|
|
|
color += texture(textureSampler0,
|
2023-08-18 18:22:08 +00:00
|
|
|
vec2(tc.x + 1.0 * blurStrength * hstep, tc.y + 1.0 * blurStrength * vstep)) *
|
|
|
|
0.1945945946;
|
2023-09-07 19:02:38 +00:00
|
|
|
color += texture(textureSampler0,
|
2023-08-18 18:22:08 +00:00
|
|
|
vec2(tc.x + 2.0 * blurStrength * hstep, tc.y + 2.0 * blurStrength * vstep)) *
|
|
|
|
0.1216216216;
|
2023-09-07 19:02:38 +00:00
|
|
|
color += texture(textureSampler0,
|
2023-08-18 18:22:08 +00:00
|
|
|
vec2(tc.x + 3.0 * blurStrength * hstep, tc.y + 3.0 * blurStrength * vstep)) *
|
|
|
|
0.0540540541;
|
2023-09-07 19:02:38 +00:00
|
|
|
color += texture(textureSampler0,
|
2023-08-18 18:22:08 +00:00
|
|
|
vec2(tc.x + 4.0 * blurStrength * hstep, tc.y + 4.0 * blurStrength * vstep)) *
|
|
|
|
0.0162162162;
|
2020-09-04 16:59:19 +00:00
|
|
|
|
2023-08-18 18:22:08 +00:00
|
|
|
FragColor = vec4(color.rgb, 1.0);
|
2020-09-04 16:59:19 +00:00
|
|
|
}
|
|
|
|
#endif
|