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
|
|
|
|
|
|
|
|
#if defined(VERTEX)
|
|
|
|
|
|
|
|
#if __VERSION__ >= 130
|
|
|
|
#define COMPAT_VARYING out
|
|
|
|
#define COMPAT_ATTRIBUTE in
|
|
|
|
#define COMPAT_TEXTURE texture
|
|
|
|
#else
|
|
|
|
#define COMPAT_VARYING varying
|
|
|
|
#define COMPAT_ATTRIBUTE attribute
|
|
|
|
#define COMPAT_TEXTURE texture2D
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef GL_ES
|
|
|
|
#define COMPAT_PRECISION mediump
|
|
|
|
#else
|
|
|
|
#define COMPAT_PRECISION
|
|
|
|
#endif
|
|
|
|
|
|
|
|
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
|
|
|
COMPAT_ATTRIBUTE vec4 COLOR;
|
|
|
|
COMPAT_ATTRIBUTE vec4 TexCoord;
|
|
|
|
COMPAT_VARYING vec4 COL0;
|
|
|
|
COMPAT_VARYING vec4 TEX0;
|
|
|
|
|
|
|
|
vec4 _oPosition1;
|
|
|
|
uniform mat4 MVPMatrix;
|
|
|
|
uniform COMPAT_PRECISION int FrameDirection;
|
|
|
|
uniform COMPAT_PRECISION int FrameCount;
|
|
|
|
uniform COMPAT_PRECISION vec2 OutputSize;
|
|
|
|
uniform COMPAT_PRECISION vec2 TextureSize;
|
|
|
|
uniform COMPAT_PRECISION vec2 InputSize;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2020-09-12 10:14:48 +00:00
|
|
|
gl_Position = MVPMatrix * gl_Vertex;
|
2020-09-04 16:59:19 +00:00
|
|
|
COL0 = COLOR;
|
2020-09-12 10:14:48 +00:00
|
|
|
TEX0.xy = gl_MultiTexCoord0.xy;
|
2020-09-04 16:59:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#elif defined(FRAGMENT)
|
|
|
|
|
|
|
|
#if __VERSION__ >= 130
|
|
|
|
#define COMPAT_VARYING in
|
|
|
|
#define COMPAT_TEXTURE texture
|
|
|
|
out vec4 FragColor;
|
|
|
|
#else
|
|
|
|
#define COMPAT_VARYING varying
|
|
|
|
#define FragColor gl_FragColor
|
|
|
|
#define COMPAT_TEXTURE texture2D
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef GL_ES
|
|
|
|
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
|
|
precision highp float;
|
|
|
|
#else
|
|
|
|
precision mediump float;
|
|
|
|
#endif
|
|
|
|
#define COMPAT_PRECISION mediump
|
|
|
|
#else
|
|
|
|
#define COMPAT_PRECISION
|
|
|
|
#endif
|
|
|
|
|
|
|
|
uniform COMPAT_PRECISION int FrameDirection;
|
|
|
|
uniform COMPAT_PRECISION int FrameCount;
|
|
|
|
uniform COMPAT_PRECISION vec2 OutputSize;
|
|
|
|
uniform COMPAT_PRECISION vec2 TextureSize;
|
|
|
|
uniform COMPAT_PRECISION vec2 InputSize;
|
|
|
|
uniform sampler2D Texture;
|
|
|
|
COMPAT_VARYING vec4 TEX0;
|
|
|
|
|
2021-05-14 13:12:53 +00:00
|
|
|
// Compatibility #defines
|
2020-09-04 16:59:19 +00:00
|
|
|
#define Source Texture
|
|
|
|
#define vTexCoord TEX0.xy
|
|
|
|
|
2021-05-14 13:12:53 +00:00
|
|
|
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) // Either TextureSize or InputSize.
|
2020-09-04 16:59:19 +00:00
|
|
|
#define outsize vec4(OutputSize, 1.0 / OutputSize)
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2022-02-15 21:17:24 +00:00
|
|
|
vec2 texcoord = vTexCoord;
|
2020-09-12 10:14:48 +00:00
|
|
|
vec2 PIXEL_SIZE = vec2(SourceSize.z, SourceSize.w);
|
2021-05-14 13:12:53 +00:00
|
|
|
|
2022-02-15 21:17:24 +00:00
|
|
|
#if __VERSION__ < 130
|
2020-09-12 10:14:48 +00:00
|
|
|
float sampleOffsets1 = 0.0;
|
|
|
|
float sampleOffsets2 = 1.4347826;
|
|
|
|
float sampleOffsets3 = 3.3478260;
|
|
|
|
float sampleOffsets4 = 5.2608695;
|
|
|
|
float sampleOffsets5 = 7.1739130;
|
2020-09-04 16:59:19 +00:00
|
|
|
|
2020-09-12 10:14:48 +00:00
|
|
|
float sampleWeights1 = 0.16818994;
|
|
|
|
float sampleWeights2 = 0.27276957;
|
|
|
|
float sampleWeights3 = 0.11690125;
|
|
|
|
float sampleWeights4 = 0.024067905;
|
|
|
|
float sampleWeights5 = 0.0021112196;
|
2020-09-04 16:59:19 +00:00
|
|
|
|
2021-02-28 14:00:13 +00:00
|
|
|
// Alpha is handled differently depending on the graphics driver, so set it explicitly to 1.0.
|
2021-02-28 11:59:08 +00:00
|
|
|
vec4 color = COMPAT_TEXTURE(Source, texcoord);
|
|
|
|
color = vec4(color.rgb, 1.0) * sampleWeights1;
|
2020-09-04 16:59:19 +00:00
|
|
|
|
2022-02-15 21:17:24 +00:00
|
|
|
color += COMPAT_TEXTURE(Source, texcoord + vec2(sampleOffsets2 * HW * PIXEL_SIZE.x, 0.0)) *
|
|
|
|
sampleWeights2;
|
|
|
|
color += COMPAT_TEXTURE(Source, texcoord - vec2(sampleOffsets2 * HW * PIXEL_SIZE.x, 0.0)) *
|
|
|
|
sampleWeights2;
|
|
|
|
|
|
|
|
color += COMPAT_TEXTURE(Source, texcoord + vec2(sampleOffsets3 * HW * PIXEL_SIZE.x, 0.0)) *
|
|
|
|
sampleWeights3;
|
|
|
|
color += COMPAT_TEXTURE(Source, texcoord - vec2(sampleOffsets3 * HW * PIXEL_SIZE.x, 0.0)) *
|
|
|
|
sampleWeights3;
|
|
|
|
|
|
|
|
color += COMPAT_TEXTURE(Source, texcoord + vec2(sampleOffsets4 * HW * PIXEL_SIZE.x, 0.0)) *
|
|
|
|
sampleWeights4;
|
|
|
|
color += COMPAT_TEXTURE(Source, texcoord - vec2(sampleOffsets4 * HW * PIXEL_SIZE.x, 0.0)) *
|
|
|
|
sampleWeights4;
|
|
|
|
|
|
|
|
color += COMPAT_TEXTURE(Source, texcoord + vec2(sampleOffsets5 * HW * PIXEL_SIZE.x, 0.0)) *
|
|
|
|
sampleWeights5;
|
|
|
|
color += COMPAT_TEXTURE(Source, texcoord - vec2(sampleOffsets5 * HW * PIXEL_SIZE.x, 0.0)) *
|
|
|
|
sampleWeights5;
|
|
|
|
#else
|
2020-09-04 16:59:19 +00:00
|
|
|
|
2022-02-15 21:17:24 +00:00
|
|
|
float sampleOffsets[5] = {0.0, 1.4347826, 3.3478260, 5.2608695, 7.1739130};
|
|
|
|
float sampleWeights[5] = {0.16818994, 0.27276957, 0.11690125, 0.024067905, 0.0021112196};
|
2020-09-04 16:59:19 +00:00
|
|
|
|
2020-09-12 10:14:48 +00:00
|
|
|
vec4 color = COMPAT_TEXTURE(Source, 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 +=
|
|
|
|
COMPAT_TEXTURE(Source, texcoord + vec2(sampleOffsets[i] * HW * PIXEL_SIZE.x, 0.0)) *
|
|
|
|
sampleWeights[i];
|
|
|
|
color +=
|
|
|
|
COMPAT_TEXTURE(Source, texcoord - vec2(sampleOffsets[i] * HW * PIXEL_SIZE.x, 0.0)) *
|
|
|
|
sampleWeights[i];
|
2020-09-12 10:14:48 +00:00
|
|
|
}
|
2022-02-15 21:17:24 +00:00
|
|
|
#endif
|
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
|