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
This commit is contained in:
Jeroen Bakker
2023-05-04 12:42:37 +02:00
parent e674e32aa1
commit 22e4e97310

View File

@@ -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))