Files
MapLibreParticleLab/shaders/fill_outline_triangulated.fragment.glsl
Alex Cristici a650df219d Clean legacy code (#3469)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-05-15 22:53:09 +03:00

30 lines
836 B
GLSL

layout (std140) uniform FillEvaluatedPropsUBO {
highp vec4 u_color;
highp vec4 u_outline_color;
highp float u_opacity;
highp float u_fade;
highp float u_from_scale;
highp float u_to_scale;
};
in float v_width;
in vec2 v_normal;
in float v_gamma_scale;
void main() {
// Calculate the distance of the pixel from the line in pixels.
float dist = length(v_normal) * v_width;
// Calculate the antialiasing fade factor. This is either when fading in
// the line in case of an offset line (v_width2.t) or when fading out
// (v_width2.s)
float blur2 = (1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;
float alpha = clamp(min(dist + blur2, v_width - dist) / blur2, 0.0, 1.0);
fragColor = u_outline_color * (alpha * u_opacity);
#ifdef OVERDRAW_INSPECTOR
fragColor = vec4(1.0);
#endif
}