diff options
author | Vaxry <[email protected]> | 2024-11-05 16:00:39 +0000 |
---|---|---|
committer | Vaxry <[email protected]> | 2024-11-05 16:00:39 +0000 |
commit | 55ccb1a8cf2c8541a32890e9b76e7c20fc9227cd (patch) | |
tree | 5111e93de8531c9e78ae4840eacee15deea78a2b /src/render/shaders/Textures.hpp | |
parent | d1638a09bacd84b994de3f77746b74f427b9d41e (diff) | |
download | Hyprland-55ccb1a8cf2c8541a32890e9b76e7c20fc9227cd.tar.gz Hyprland-55ccb1a8cf2c8541a32890e9b76e7c20fc9227cd.zip |
shaders: fixup jagged edges in texture rounded corners
Diffstat (limited to 'src/render/shaders/Textures.hpp')
-rw-r--r-- | src/render/shaders/Textures.hpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/render/shaders/Textures.hpp b/src/render/shaders/Textures.hpp index 6ac33a0a..e99d0a49 100644 --- a/src/render/shaders/Textures.hpp +++ b/src/render/shaders/Textures.hpp @@ -5,24 +5,27 @@ inline static constexpr auto ROUNDED_SHADER_FUNC = [](const std::string colorVarName) -> std::string { return R"#( - // branchless baby! + // shoutout me: I fixed this shader being a bit pixelated while watching hentai + highp vec2 pixCoord = vec2(gl_FragCoord); pixCoord -= topLeft + fullSize * 0.5; pixCoord *= vec2(lessThan(pixCoord, vec2(0.0))) * -2.0 + 1.0; pixCoord -= fullSize * 0.5 - radius; pixCoord += vec2(1.0, 1.0) / fullSize; // center the pix dont make it top-left + const float SMOOTHING_CONSTANT = 0.651724; // smoothing constant for the edge: more = blurrier, but smoother + if (pixCoord.x + pixCoord.y > radius) { float dist = length(pixCoord); - if (dist > radius) + if (dist > radius + SMOOTHING_CONSTANT * 2.0) discard; - if (dist > radius - 1.0) { + if (dist > radius - SMOOTHING_CONSTANT * 2.0) { float dist = length(pixCoord); - float normalized = 1.0 - smoothstep(0.0, 1.0, dist - radius + 0.5); + float normalized = 1.0 - smoothstep(0.0, 1.0, (dist - radius + SMOOTHING_CONSTANT) / (SMOOTHING_CONSTANT * 2.0)); )#" + colorVarName + R"#( = )#" + colorVarName + R"#( * normalized; |