From 7699d657d91a3f54e0c4a6980fcb79abda0ebd4e Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 27 Nov 2022 00:29:51 +0000 Subject: [PATCH] optimize border shader Do not calculate gradient for discarded fragments --- src/render/shaders/Border.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/render/shaders/Border.hpp b/src/render/shaders/Border.hpp index aa0329fe..ab3c7d5b 100644 --- a/src/render/shaders/Border.hpp +++ b/src/render/shaders/Border.hpp @@ -55,8 +55,7 @@ void main() { highp vec2 originalPixCoord = v_texcoord; originalPixCoord *= fullSizeUntransformed; - vec4 pixColor = getColorForCoord(v_texcoord); - pixColor[3] *= alpha; + vec4 pixColor = vec4(1.0, 1.0, 1.0, 1.0); bool done = false; @@ -112,6 +111,9 @@ void main() { if (pixColor[3] == 0.0) discard; + pixColor = getColorForCoord(v_texcoord) * pixColor[3]; + pixColor[3] *= alpha; + gl_FragColor = pixColor; } )#";