Skip to content

Commit

Permalink
fix stroke ppu for WGLMakie (#3523)
Browse files Browse the repository at this point in the history
* fix ppu for marker stroke in wglmakie

* same treatment for glowwidth
  • Loading branch information
SimonDanisch authored Dec 29, 2023
1 parent cdade9b commit 98d83c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions WGLMakie/assets/sprites.frag
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ void stroke(vec4 strokecolor, float signed_distance, float width, inout vec4 col
}

void glow(vec4 glowcolor, float signed_distance, float inside, inout vec4 color){
float glow_width = get_glowwidth();
float stroke_width = get_strokewidth();
float glow_width = get_glowwidth() * get_px_per_unit();
float stroke_width = get_strokewidth() * get_px_per_unit();
if (glow_width > 0.0){
float outside = (abs(signed_distance) - stroke_width) / glow_width;
float alpha = 1.0 - outside;
Expand Down Expand Up @@ -130,7 +130,7 @@ void main() {
signed_distance *= frag_uvscale;


float stroke_width = get_strokewidth();
float stroke_width = get_strokewidth() * get_px_per_unit();
float inside_start = max(-stroke_width, 0.0);
float inside = aastep(inside_start, signed_distance);

Expand Down
3 changes: 2 additions & 1 deletion WGLMakie/assets/sprites.vert
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ void main(){

// add padding for AA, stroke and glow (non native distancefields don't need
// AA padding but CIRCLE etc do)
float ppu = get_px_per_unit();
vec2 padded_bbox_size = bbox_radius + (
ANTIALIAS_RADIUS + max(0.0, get_strokewidth()) + max(0.0, get_glowwidth())
ANTIALIAS_RADIUS + max(0.0, get_strokewidth() * ppu) + max(0.0, get_glowwidth() * ppu)
) / viewport_from_sprite_scale;
vec2 uv_pad_scale = padded_bbox_size / bbox_radius;

Expand Down

0 comments on commit 98d83c2

Please sign in to comment.