summaryrefslogtreecommitdiffstats
path: root/src/video_core/host_shaders
diff options
context:
space:
mode:
authorFernandoS27 <fsahmkow27@gmail.com>2021-10-21 01:27:54 +0200
committerFernando Sahmkow <fsahmkow27@gmail.com>2021-11-16 22:11:32 +0100
commit9e065b9c7d3b25ddfe20afa4a945cca6e9767fa9 (patch)
treef9d3d14332d7a0f83c5a60541e2d3fb1e2522669 /src/video_core/host_shaders
parentTextureCache: Improve Reaper. (diff)
downloadyuzu-9e065b9c7d3b25ddfe20afa4a945cca6e9767fa9.tar
yuzu-9e065b9c7d3b25ddfe20afa4a945cca6e9767fa9.tar.gz
yuzu-9e065b9c7d3b25ddfe20afa4a945cca6e9767fa9.tar.bz2
yuzu-9e065b9c7d3b25ddfe20afa4a945cca6e9767fa9.tar.lz
yuzu-9e065b9c7d3b25ddfe20afa4a945cca6e9767fa9.tar.xz
yuzu-9e065b9c7d3b25ddfe20afa4a945cca6e9767fa9.tar.zst
yuzu-9e065b9c7d3b25ddfe20afa4a945cca6e9767fa9.zip
Diffstat (limited to 'src/video_core/host_shaders')
-rw-r--r--src/video_core/host_shaders/CMakeLists.txt1
-rw-r--r--src/video_core/host_shaders/present_gaussian.frag74
2 files changed, 75 insertions, 0 deletions
diff --git a/src/video_core/host_shaders/CMakeLists.txt b/src/video_core/host_shaders/CMakeLists.txt
index 32e2ab500..b0e15773c 100644
--- a/src/video_core/host_shaders/CMakeLists.txt
+++ b/src/video_core/host_shaders/CMakeLists.txt
@@ -19,6 +19,7 @@ set(SHADER_FILES
pitch_unswizzle.comp
present_scaleforce.frag
present_bicubic.frag
+ present_gaussian.frag
vulkan_blit_color_float.frag
vulkan_blit_depth_stencil.frag
vulkan_fidelityfx_fsr_easu.comp
diff --git a/src/video_core/host_shaders/present_gaussian.frag b/src/video_core/host_shaders/present_gaussian.frag
new file mode 100644
index 000000000..d5e2b1781
--- /dev/null
+++ b/src/video_core/host_shaders/present_gaussian.frag
@@ -0,0 +1,74 @@
+// Copyright 2019 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#version 460 core
+
+#ifdef VULKAN
+
+#define BINDING_COLOR_TEXTURE 1
+
+#else // ^^^ Vulkan ^^^ // vvv OpenGL vvv
+
+#define BINDING_COLOR_TEXTURE 0
+
+#endif
+
+layout (location = 0) in vec2 frag_tex_coord;
+
+layout (location = 0) out vec4 color;
+
+layout (binding = BINDING_COLOR_TEXTURE) uniform sampler2D color_texture;
+
+const float offset[3] = float[](0.0, 1.3846153846, 3.2307692308);
+const float weight[3] = float[](0.2270270270, 0.3162162162, 0.0702702703);
+
+vec4 blurVertical(sampler2D textureSampler, vec2 coord, vec2 norm) {
+ vec4 result = vec4(0.0f);
+ for (int i=1; i<3; i++) {
+ result +=
+ texture(textureSampler, vec2(coord) + (vec2(0.0, offset[i]) * norm))
+ * weight[i];
+ result +=
+ texture(textureSampler, vec2(coord) - (vec2(0.0, offset[i]) * norm))
+ * weight[i];
+ }
+ return result;
+}
+
+vec4 blurHorizontal(sampler2D textureSampler, vec2 coord, vec2 norm) {
+ vec4 result = vec4(0.0f);
+ for (int i=1; i<3; i++) {
+ result +=
+ texture(textureSampler, vec2(coord) + (vec2(offset[i], 0.0) * norm))
+ * weight[i];
+ result +=
+ texture(textureSampler, vec2(coord) - (vec2(offset[i], 0.0) * norm))
+ * weight[i];
+ }
+ return result;
+}
+
+vec4 blurDiagonal(sampler2D textureSampler, vec2 coord, vec2 norm) {
+ vec4 result = vec4(0.0f);
+ for (int i=1; i<3; i++) {
+ result +=
+ texture(textureSampler, vec2(coord) + (vec2(offset[i], offset[i]) * norm))
+ * weight[i];
+ result +=
+ texture(textureSampler, vec2(coord) - (vec2(offset[i], offset[i]) * norm))
+ * weight[i];
+ }
+ return result;
+}
+
+void main() {
+ vec3 base = texture(color_texture, vec2(frag_tex_coord)).rgb * weight[0];
+ vec2 tex_offset = 1.0f / textureSize(color_texture, 0);
+ vec3 horizontal = blurHorizontal(color_texture, frag_tex_coord, tex_offset).rgb;
+ vec3 vertical = blurVertical(color_texture, frag_tex_coord, tex_offset).rgb;
+ vec3 diagonalA = blurVertical(color_texture, frag_tex_coord, tex_offset).rgb;
+ vec3 diagonalB = blurVertical(color_texture, frag_tex_coord, -tex_offset).rgb;
+ vec3 combination = mix(mix(horizontal, vertical, 0.5f), mix(diagonalA, diagonalB, 0.5f), 0.5f);
+ color = vec4(combination + base, 1.0f);
+}