From 22e4e973104caacbbe6b8251ee79dc9efd33c7b4 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Thu, 4 May 2023 12:42:37 +0200 Subject: [PATCH] macOS: Reduce Edit Mode Drawing Artifacts Apple Silicon uses tile rendering and can discard tiles if it is covered. The retopology overlay made some changes to the shader that introduced some blocking and striping artifacts when the overlay was disabled. This PR changes the minimum used offset to reduce the drawing artifacts. Tweaking the GLSL shader itself didn't work. Fix #105830 Pull Request: https://projects.blender.org/blender/blender/pulls/107611 --- source/blender/editors/include/ED_view3d.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 9e0c1404761..911e9864bf1 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -1330,8 +1330,19 @@ void ED_view3d_shade_update(struct Main *bmain, struct View3D *v3d, struct ScrAr #define OVERLAY_RETOPOLOGY_ENABLED(overlay) \ (((overlay).edit_flag & V3D_OVERLAY_EDIT_RETOPOLOGY) != 0) +#if __APPLE__ +/* Apple silicon tile depth test requires a higher value to reduce drawing artifacts.*/ +# define OVERLAY_RETOPOLOGY_MIN_OFFSET_ENABLED 0.0015f +# define OVERLAY_RETOPOLOGY_MIN_OFFSET_DISABLED 0.0015f +#else +# define OVERLAY_RETOPOLOGY_MIN_OFFSET_ENABLED FLT_EPSILON +# define OVERLAY_RETOPOLOGY_MIN_OFFSET_DISABLED 0.0f +#endif + #define OVERLAY_RETOPOLOGY_OFFSET(overlay) \ - (OVERLAY_RETOPOLOGY_ENABLED(overlay) ? max_ff((overlay).retopology_offset, FLT_EPSILON) : 0.0f) + (OVERLAY_RETOPOLOGY_ENABLED(overlay) ? \ + max_ff((overlay).retopology_offset, OVERLAY_RETOPOLOGY_MIN_OFFSET_ENABLED) : \ + OVERLAY_RETOPOLOGY_MIN_OFFSET_DISABLED) #define RETOPOLOGY_ENABLED(v3d) (OVERLAY_RETOPOLOGY_ENABLED((v3d)->overlay)) #define RETOPOLOGY_OFFSET(v3d) (OVERLAY_RETOPOLOGY_OFFSET((v3d)->overlay))