From 2a01c778515656b334f8645d9fe35ac6e7f4dfb9 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Fri, 9 May 2025 11:40:26 +0200 Subject: [PATCH] improve wireframe poly of meshes significantly --- MakieCore/src/basic_plots.jl | 5 ++++- src/basic_recipes/poly.jl | 12 +++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/MakieCore/src/basic_plots.jl b/MakieCore/src/basic_plots.jl index 892de31286e..c204c31c3a8 100644 --- a/MakieCore/src/basic_plots.jl +++ b/MakieCore/src/basic_plots.jl @@ -711,7 +711,10 @@ Plots polygons, which are defined by """ Depth shift of stroke plot. This is useful to avoid z-fighting between the stroke and the fill. """ - stroke_depth_shift = -1.0f-5 + stroke_depth_shift = -1.0f-3 + mesh_fxaa = automatic + stroke_fxaa = false + stroke_transparency = true mixin_generic_plot_attributes()... mixin_colormap_attributes()... end diff --git a/src/basic_recipes/poly.jl b/src/basic_recipes/poly.jl index a4453f6041c..db448bb1371 100644 --- a/src/basic_recipes/poly.jl +++ b/src/basic_recipes/poly.jl @@ -32,6 +32,12 @@ convert_arguments(::Type{<: Poly}, m::GeometryBasics.Mesh) = (m,) convert_arguments(::Type{<: Poly}, m::GeometryBasics.GeometryPrimitive) = (m,) function plot!(plot::Poly{<: Tuple{Union{GeometryBasics.Mesh, GeometryPrimitive}}}) + mfxaa = lift(plot.strokewidth, plot.mesh_fxaa) do sw, fxaa + fxaa === automatic || return fxaa + # If we stroke, we need to do fxaa=false, to not have bad rendering of the stroke on top of the mesh + # If no stroke, we should enable fxaa, to not have the mesh edges be aliased + return !(sw > 0.0) + end mesh!( plot, plot[1], color = plot.color, @@ -47,15 +53,15 @@ function plot!(plot::Poly{<: Tuple{Union{GeometryBasics.Mesh, GeometryPrimitive} overdraw = plot.overdraw, inspectable = plot.inspectable, transparency = plot.transparency, - space = plot.space, + space = plot.space, fxaa=mfxaa, depth_shift = plot.depth_shift ) wireframe!( plot, plot[1], color = plot.strokecolor, linestyle = plot.linestyle, space = plot.space, linewidth = plot.strokewidth, linecap = plot.linecap, - visible = plot.visible, overdraw = plot.overdraw, - inspectable = plot.inspectable, transparency = plot.transparency, + visible = plot.visible, overdraw = plot.overdraw, fxaa=plot.stroke_fxaa, + inspectable = plot.inspectable, transparency = plot.stroke_transparency, colormap = plot.strokecolormap, depth_shift=plot.stroke_depth_shift ) end