summaryrefslogtreecommitdiff
path: root/src/render/Shaders.hpp
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-04-17 13:15:56 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-04-17 13:15:56 +0200
commit748a787ba2935f62b1a6f986a3fd6c758a8ba626 (patch)
tree5d1b97749c07ee69a0b06affa15c3bd6142bdb0b /src/render/Shaders.hpp
parent74dbf196c1676c964821e4023bd5a4759485c977 (diff)
Don't blur behind opaque pixels
Diffstat (limited to 'src/render/Shaders.hpp')
-rw-r--r--src/render/Shaders.hpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/render/Shaders.hpp b/src/render/Shaders.hpp
index 53a8c439..0263f22f 100644
--- a/src/render/Shaders.hpp
+++ b/src/render/Shaders.hpp
@@ -47,8 +47,17 @@ uniform vec2 bottomRight;
uniform vec2 fullSize;
uniform float radius;
+uniform int discardOpaque;
+
void main() {
+ vec4 pixColor = texture2D(tex, v_texcoord);
+
+ if (discardOpaque == 1 && pixColor[3] == 1.0) {
+ discard;
+ return;
+ }
+
vec2 pixCoord = fullSize * v_texcoord;
if (pixCoord[0] < topLeft[0]) {
@@ -84,7 +93,7 @@ void main() {
}
}
- gl_FragColor = texture2D(tex, v_texcoord) * alpha;
+ gl_FragColor = pixColor * alpha;
})#";
inline const std::string TEXFRAGSRCRGBX = R"#(
@@ -98,7 +107,14 @@ uniform vec2 bottomRight;
uniform vec2 fullSize;
uniform float radius;
+uniform int discardOpaque;
+
void main() {
+
+ if (discardOpaque == 1) {
+ discard;
+ return;
+ }
vec2 pixCoord = fullSize * v_texcoord;
@@ -252,8 +268,17 @@ uniform vec2 bottomRight;
uniform vec2 fullSize;
uniform float radius;
+uniform int discardOpaque;
+
void main() {
+ vec4 pixColor = texture2D(texture0, v_texcoord);
+
+ if (discardOpaque == 1 && pixColor[3] == 1.0) {
+ discard;
+ return;
+ }
+
vec2 pixCoord = fullSize * v_texcoord;
if (pixCoord[0] < topLeft[0]) {
@@ -289,5 +314,5 @@ void main() {
}
}
- gl_FragColor = texture2D(texture0, v_texcoord) * alpha;
+ gl_FragColor = pixColor * alpha;
})#";