diff --git a/src/DynamoCoreWpf/ViewModels/Watch3D/HelixWatch3DViewModel.cs b/src/DynamoCoreWpf/ViewModels/Watch3D/HelixWatch3DViewModel.cs index 364434596c0..6513290feb1 100644 --- a/src/DynamoCoreWpf/ViewModels/Watch3D/HelixWatch3DViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Watch3D/HelixWatch3DViewModel.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; @@ -183,7 +183,9 @@ public class HelixWatch3DViewModel : DefaultWatch3DViewModel private int currentFrameSkipCount; private const double EqualityTolerance = 0.000001; - private double nearPlaneDistanceFactor = 0.001; + //near plane distance also affects depth precision. + //https://developer.nvidia.com/content/depth-precision-visualized + private double nearPlaneDistanceFactor = 0.01; internal const double DefaultNearClipDistance = 0.1f; internal const double DefaultFarClipDistance = 100000; @@ -2483,6 +2485,10 @@ internal static void ComputeClipPlaneDistances(Vector3 cameraPosition, Vector3 c // Set the near clip plane to some fraction of the // of the distance to the first point. var closest = distances.First(d => d >= 0); + + //near plane distance disproportionately affects depth (zbuffer) precision. + //keep it as far away as possible. + //https://developer.nvidia.com/content/depth-precision-visualized near = closest.AlmostEqualTo(0, EqualityTolerance) ? DefaultNearClipDistance : Math.Max(DefaultNearClipDistance, closest * nearPlaneDistanceFactor); far = distances.Last() * 2;