2021-05-14 13:12:53 +00:00
|
|
|
//
|
2021-05-14 16:52:38 +00:00
|
|
|
// Implementation based on the article "Efficient Gaussian blur with linear sampling"
|
|
|
|
// http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/
|
|
|
|
// A version for MasterEffect Reborn, a standalone version, and a custom shader version for SweetFX
|
|
|
|
// can be found at http://reshade.me/forum/shader-presentation/27-gaussian-blur-bloom-unsharpmask
|
2021-05-14 13:12:53 +00:00
|
|
|
//
|
2021-05-14 16:52:38 +00:00
|
|
|
// Taken from the RetroArch project and modified for ES-DE.
|
2021-05-14 13:12:53 +00:00
|
|
|
//
|
2020-09-04 16:59:19 +00:00
|
|
|
|
|
|
|
#define HW 1.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
|
|
|
|
precision mediump float;
|
|
|
|
#endif
|
|
|
|
|
2023-02-06 22:38:35 +00:00
|
|
|
uniform uint shaderFlags;
|
2022-03-14 23:14:06 +00:00
|
|
|
uniform vec2 textureSize;
|
|
|
|
uniform sampler2D textureSampler;
|
|
|
|
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
|
2020-09-04 16:59:19 +00:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2023-02-06 22:38:35 +00:00
|
|
|
vec4 SourceSize;
|
2023-02-21 17:43:18 +00:00
|
|
|
vec2 PIXEL_SIZE;
|
2023-02-06 22:38:35 +00:00
|
|
|
|
2023-02-21 17:43:18 +00:00
|
|
|
if (0x0u != (shaderFlags & 0x10u)) {
|
|
|
|
SourceSize = vec4(textureSize.yx, 1.0 / textureSize.xy);
|
|
|
|
PIXEL_SIZE = vec2(SourceSize.w, SourceSize.z);
|
|
|
|
}
|
|
|
|
else {
|
2023-02-06 22:38:35 +00:00
|
|
|
SourceSize = vec4(textureSize.xy, 1.0 / textureSize.xy);
|
2023-02-21 17:43:18 +00:00
|
|
|
PIXEL_SIZE = vec2(SourceSize.z, SourceSize.w);
|
|
|
|
}
|
2021-05-14 13:12:53 +00:00
|
|
|
|
2022-03-13 22:52:32 +00:00
|
|
|
float sampleOffsets[5] = float[5](0.0, 1.4347826, 3.3478260, 5.2608695, 7.1739130);
|
|
|
|
float sampleWeights[5] =
|
|
|
|
float[5](0.16818994, 0.27276957, 0.11690125, 0.024067905, 0.0021112196);
|
2020-09-04 16:59:19 +00:00
|
|
|
|
2022-03-14 23:14:06 +00:00
|
|
|
vec4 color = texture(textureSampler, texCoord) * sampleWeights[0];
|
2021-05-14 13:12:53 +00:00
|
|
|
for (int i = 1; i < 5; i++) {
|
2022-02-15 21:17:24 +00:00
|
|
|
color +=
|
2022-03-14 23:14:06 +00:00
|
|
|
texture(textureSampler, texCoord + vec2(sampleOffsets[i] * HW * PIXEL_SIZE.x, 0.0)) *
|
2022-02-15 21:17:24 +00:00
|
|
|
sampleWeights[i];
|
|
|
|
color +=
|
2022-03-14 23:14:06 +00:00
|
|
|
texture(textureSampler, texCoord - vec2(sampleOffsets[i] * HW * PIXEL_SIZE.x, 0.0)) *
|
2022-02-15 21:17:24 +00:00
|
|
|
sampleWeights[i];
|
2020-09-12 10:14:48 +00:00
|
|
|
}
|
2020-09-04 16:59:19 +00:00
|
|
|
|
2021-05-14 13:12:53 +00:00
|
|
|
FragColor = vec4(color);
|
2020-09-04 16:59:19 +00:00
|
|
|
}
|
|
|
|
#endif
|