Even less branching (taken more or less from the border shader).

This commit is contained in:
Felix Dick 2022-09-29 06:56:17 +02:00
parent 0549aa193f
commit 65fb526d5c

View file

@ -22,15 +22,15 @@ inline static constexpr auto ROUNDED_SHADER_FUNC = [](const std::string colorVar
if (primitiveMultisample == 1 && dist > radius - 1.0) {
float distances = 0.0;
if (length(pixCoord + vec2(0.25, 0.25)) < radius) { distances = distances + 1.0; }
if (length(pixCoord + vec2(0.75, 0.25)) < radius) { distances = distances + 1.0; }
if (length(pixCoord + vec2(0.25, 0.75)) < radius) { distances = distances + 1.0; }
if (length(pixCoord + vec2(0.75, 0.75)) < radius) { distances = distances + 1.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 (distances == 0.0)
discard;
distances = distances / 4.0;
distances /= 4.0;
)#" + colorVarName + R"#( = )#" + colorVarName + R"#( * distances;
}