summaryrefslogtreecommitdiff
path: root/src/render/shaders
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2023-08-03 15:11:10 +0200
committerGitHub <noreply@github.com>2023-08-03 15:11:10 +0200
commitd96f8ff0fe44f874700c8c132086a206132635c5 (patch)
tree59ac4147a9fcc14bbb9897618268a56ae0ca57f0 /src/render/shaders
parent5c50fac907df3463492a019f01f84d547ab93650 (diff)
renderer: Various Blur Improvements (#2877)
* move blur to its own category * blur improvements, contrast, brightness, noise
Diffstat (limited to 'src/render/shaders')
-rw-r--r--src/render/shaders/Textures.hpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/render/shaders/Textures.hpp b/src/render/shaders/Textures.hpp
index 0928487f..98cd8907 100644
--- a/src/render/shaders/Textures.hpp
+++ b/src/render/shaders/Textures.hpp
@@ -225,6 +225,36 @@ void main() {
}
)#";
+inline const std::string FRAGBLURFINISH = R"#(
+precision mediump float;
+varying vec2 v_texcoord; // is in 0-1
+uniform sampler2D tex;
+
+uniform float contrast;
+uniform float noise;
+uniform float brightness;
+
+float hash(vec2 p) {
+ return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453);
+}
+
+void main() {
+ vec4 pixColor = texture2D(tex, v_texcoord);
+
+ // contrast
+ pixColor.rgb = (pixColor.rgb - 0.5) * contrast + 0.5;
+
+ // brightness
+ pixColor.rgb *= brightness;
+
+ // noise
+ float noiseHash = hash(v_texcoord);
+ float noiseAmount = (mod(noiseHash, 1.0) - 0.5);
+ pixColor.rgb += noiseAmount * noise;
+
+ gl_FragColor = pixColor;
+})#";
+
inline const std::string TEXFRAGSRCEXT = R"#(
#extension GL_OES_EGL_image_external : require