Skip to content

Commit

Permalink
Merge pull request #329 from TP-David/TextDisableOutline
Browse files Browse the repository at this point in the history
Disable text outline alpha calculation if width is 0
  • Loading branch information
robertosfield authored Nov 29, 2024
2 parents 7a9bf4c + 71db484 commit 6233302
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions data/shaders/text.frag
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@ vec2 glyph_alpha(vec2 texcoord, vec2 dx, vec2 dy)
float min_distance_from_edge = distance_from_edge - delta;
float max_distance_from_edge = distance_from_edge + delta;

//min_distance_from_edge += 0.0;
min_distance_from_edge += innerCutOff;
float inner_alpha = 0.0;
if (min_distance_from_edge >= 0.0) inner_alpha = 1.0;
else if (max_distance_from_edge >= 0.0) inner_alpha = max_distance_from_edge/(max_distance_from_edge-min_distance_from_edge);

min_distance_from_edge += outlineWidth;
float outer_alpha = 0.0;
if (min_distance_from_edge >= 0.0) outer_alpha = 1.0;
else if (max_distance_from_edge >= 0.0) outer_alpha = max_distance_from_edge/(max_distance_from_edge-min_distance_from_edge);
if (outlineWidth > 0.0)
{
min_distance_from_edge += outlineWidth;
if (min_distance_from_edge >= 0.0) outer_alpha = 1.0;
else if (max_distance_from_edge >= 0.0) outer_alpha = max_distance_from_edge/(max_distance_from_edge-min_distance_from_edge);
}

return vec2(inner_alpha, outer_alpha);
}
Expand Down

0 comments on commit 6233302

Please sign in to comment.