Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR revamps the logic for applying line dash patterns and textures. The prior logic had some holes and inconsistencies, including #741. It implements the following logic in the fragment shader for lines (and also replaces some conditional
if/else
shader branching with nestedmix
functions):dash
pattern (the texture is automatically generated from the dash pattern).color
parameter, available in the shader as the vertexcolor
) and background color (via thedash_background_color
parameter, available in the fragment shader asu_dash_background_color
).texture
parameter (instyle
ordraw
group).u_has_dash
indicates this, with a float value of0
or1
.mix
function controlled by the line texture alpha channel (following the monochrome texture described above).mix(u_dash_background_color, color, _line_color.a), // choose dash foreground or background color
color
to the texture color ("tinting" it), consistent with other similar behaviors, e.g. raster textures on polygons.color * _line_color, // no dash: tint the line texture with the vertex color
mix
function, controlled by theu_has_dash
uniform described above.opaque
blending is active, a simple "alpha cutout" behavior is applied, in which any alpha pixel with an alpha of less than 0.5 (TANGRAM_ALPHA_TEST
) is discarded. This enables basic transparency-like behavior for dashes and textures when using opaque blending.