summaryrefslogtreecommitdiff
path: root/src/render/shaders
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2023-09-30 01:41:05 +0100
committervaxerski <43317083+vaxerski@users.noreply.github.com>2023-09-30 01:41:05 +0100
commitc298439433f9b6861c7c62ea587289ac2e4ef2f8 (patch)
treee07cfa9d74005b0bda1c7ce4bc8fa38039680bf3 /src/render/shaders
parent495d4f2d11f250d8a5ddde840cd0d38861f84623 (diff)
renderer: nuke multisample_edges in favor of a faster algorithm
Diffstat (limited to 'src/render/shaders')
-rw-r--r--src/render/shaders/Border.hpp1
-rw-r--r--src/render/shaders/Textures.hpp24
2 files changed, 5 insertions, 20 deletions
diff --git a/src/render/shaders/Border.hpp b/src/render/shaders/Border.hpp
index 30227804..a4ab50ee 100644
--- a/src/render/shaders/Border.hpp
+++ b/src/render/shaders/Border.hpp
@@ -13,7 +13,6 @@ uniform vec2 fullSize;
uniform vec2 fullSizeUntransformed;
uniform float radius;
uniform float thick;
-uniform int primitiveMultisample;
uniform vec4 gradient[10];
uniform int gradientLength;
diff --git a/src/render/shaders/Textures.hpp b/src/render/shaders/Textures.hpp
index 98cd8907..dac511c7 100644
--- a/src/render/shaders/Textures.hpp
+++ b/src/render/shaders/Textures.hpp
@@ -10,6 +10,7 @@ inline static constexpr auto ROUNDED_SHADER_FUNC = [](const std::string colorVar
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
if (pixCoord.x + pixCoord.y > radius) {
@@ -18,20 +19,13 @@ inline static constexpr auto ROUNDED_SHADER_FUNC = [](const std::string colorVar
if (dist > radius)
discard;
- if (primitiveMultisample == 1 && dist > radius - 1.0) {
- float distances = 0.0;
- distances += float(length(pixCoord + vec2(0.25, 0.25)) < radius);
- distances += float(length(pixCoord + vec2(0.75, 0.25)) < radius);
- distances += float(length(pixCoord + vec2(0.25, 0.75)) < radius);
- distances += float(length(pixCoord + vec2(0.75, 0.75)) < radius);
+ if (dist > radius - 1.0) {
+ float dist = length(pixCoord);
- if (distances == 0.0)
- discard;
-
- distances /= 4.0;
+ float normalized = 1.0 - clamp(smoothstep(0.0, 1.0, dist - radius + 0.5), 0.0, 1.0);
)#" +
- colorVarName + R"#( = )#" + colorVarName + R"#( * distances;
+ colorVarName + R"#( = )#" + colorVarName + R"#( * normalized;
}
}
@@ -60,8 +54,6 @@ uniform vec2 topLeft;
uniform vec2 fullSize;
uniform float radius;
-uniform int primitiveMultisample;
-
void main() {
vec4 pixColor = v_color;
@@ -102,8 +94,6 @@ uniform float discardAlphaValue;
uniform int applyTint;
uniform vec3 tint;
-uniform int primitiveMultisample;
-
void main() {
vec4 pixColor = texture2D(tex, v_texcoord);
@@ -154,8 +144,6 @@ uniform int discardAlphaValue;
uniform int applyTint;
uniform vec3 tint;
-uniform int primitiveMultisample;
-
void main() {
if (discardOpaque == 1 && alpha == 1.0)
@@ -274,8 +262,6 @@ uniform int discardAlphaValue;
uniform int applyTint;
uniform vec3 tint;
-uniform int primitiveMultisample;
-
void main() {
vec4 pixColor = texture2D(texture0, v_texcoord);