From 98d83c2bed212a6e92380558f48321589cbca5b2 Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 29 Dec 2023 19:12:55 +0100 Subject: [PATCH] fix stroke ppu for WGLMakie (#3523) * fix ppu for marker stroke in wglmakie * same treatment for glowwidth --- WGLMakie/assets/sprites.frag | 6 +++--- WGLMakie/assets/sprites.vert | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/WGLMakie/assets/sprites.frag b/WGLMakie/assets/sprites.frag index 97e04d8fff8..468b75366ff 100644 --- a/WGLMakie/assets/sprites.frag +++ b/WGLMakie/assets/sprites.frag @@ -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; @@ -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); diff --git a/WGLMakie/assets/sprites.vert b/WGLMakie/assets/sprites.vert index e06dee067e1..421a6ce7296 100644 --- a/WGLMakie/assets/sprites.vert +++ b/WGLMakie/assets/sprites.vert @@ -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;