From 6fe103cf06e99e4cd8c03e616b5a939067e7e165 Mon Sep 17 00:00:00 2001 From: Felix Dick Date: Sat, 1 Oct 2022 02:45:36 +0200 Subject: [PATCH] Cut the number of pixels that call length() in half. --- src/render/shaders/Textures.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/render/shaders/Textures.hpp b/src/render/shaders/Textures.hpp index 1e8281d0..de5f0358 100644 --- a/src/render/shaders/Textures.hpp +++ b/src/render/shaders/Textures.hpp @@ -7,11 +7,11 @@ inline static constexpr auto ROUNDED_SHADER_FUNC = [](const std::string colorVar // branchless baby! highp vec2 pixCoord = vec2(gl_FragCoord); - pixCoord -= topLeft + fullSize / vec2(2.0); - pixCoord *= vec2(lessThan(pixCoord, vec2(0.0))) * vec2(-2.0) + vec2(1.0); - pixCoord -= fullSize * vec2(0.5) - vec2(radius); + pixCoord -= topLeft + fullSize * 0.5; + pixCoord *= vec2(lessThan(pixCoord, vec2(0.0))) * -2.0 + 1.0; + pixCoord -= fullSize * 0.5 - radius; - if (all(greaterThan(pixCoord, vec2(0.0)))) { + if (pixCoord.x + pixCoord.y > radius) { if (ignoreCorners == 1) discard;