From ec151d398e65fe219929f74101d28394de1d8f72 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Wed, 2 Oct 2024 07:49:20 -0500 Subject: [PATCH] Fix the near clip plane appearing at high vanilla render distances --- .../com/seibel/distanthorizons/core/util/RenderUtil.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/util/RenderUtil.java b/core/src/main/java/com/seibel/distanthorizons/core/util/RenderUtil.java index 9c484fa94..494de968d 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/util/RenderUtil.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/util/RenderUtil.java @@ -59,6 +59,15 @@ public class RenderUtil // in James' testing a near clip plane distance of 2 blocks is enough to allow the fragment // culling to take effect instead of seeing the near clip plane. float nearClipDist = RenderUtil.getNearClipPlaneDistanceInBlocks(partialTicks); + // limit the near clip plane if we are close to the ground + if (getHeightBasedNearClipOverride() == -1) + { + // min() used to prevent the near clip plane from becoming visible at large vanilla render distances + // DH's dithering/discard shader handles everything farther away anyway so the near clip plane + // would just need to be far enough to prevent depth precision errors + nearClipDist = Math.min(nearClipDist, 7.5f); + } + float farClipDist = (float) RenderUtil.getFarClipPlaneDistanceInBlocks(); // Create a copy of the current matrix, so it won't be modified.