From 6a5263a8f457cf6ccf43787995c0733ec0df77e6 Mon Sep 17 00:00:00 2001 From: tom lee Date: Mon, 21 Mar 2022 17:29:10 +0800 Subject: [PATCH] Add overdraw offset setting --- .../lod/core/objects/opengl/LodBox.java | 19 +++++++++++++++---- .../lod/core/objects/opengl/RenderRegion.java | 3 ++- .../com/seibel/lod/core/util/LodUtil.java | 2 +- src/main/resources/assets/lod/lang/en_us.json | 4 ++++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/seibel/lod/core/objects/opengl/LodBox.java b/src/main/java/com/seibel/lod/core/objects/opengl/LodBox.java index 8c5155ff1..361a05e2f 100644 --- a/src/main/java/com/seibel/lod/core/objects/opengl/LodBox.java +++ b/src/main/java/com/seibel/lod/core/objects/opengl/LodBox.java @@ -33,7 +33,10 @@ public class LodBox { //If the adj pos is at the same level we cull the faces normally, otherwise we divide the face in two and cull the two part separately //NORTH face vertex creation - if (adjData[LodDirection.NORTH.ordinal() - 2].length == 1) + + if (adjData[LodDirection.NORTH.ordinal() - 2] == null) { + builder.addQuadAdj(LodDirection.NORTH, x, y, z, xSize, ySize, ColorUtil.rgbToInt(0, 0, 0), (byte) 15, (byte) 15); + } else if (adjData[LodDirection.NORTH.ordinal() - 2].length == 1) { makeAdjQuads(builder, adjData[LodDirection.NORTH.ordinal() - 2][0], LodDirection.NORTH, x, y, z, xSize, ySize, color, skyLightTop, blockLight); @@ -45,7 +48,9 @@ public class LodBox { } //SOUTH face vertex creation - if (adjData[LodDirection.SOUTH.ordinal() - 2].length == 1) + if (adjData[LodDirection.SOUTH.ordinal() - 2] == null) { + builder.addQuadAdj(LodDirection.SOUTH, x, y, maxZ, xSize, ySize, ColorUtil.rgbToInt(0, 0, 0), (byte) 15, (byte) 15); + } else if (adjData[LodDirection.SOUTH.ordinal() - 2].length == 1) { makeAdjQuads(builder, adjData[LodDirection.SOUTH.ordinal() - 2][0], LodDirection.SOUTH, x, y, maxZ, xSize, ySize, color, skyLightTop, blockLight); @@ -58,7 +63,10 @@ public class LodBox { } //WEST face vertex creation - if (adjData[LodDirection.WEST.ordinal() - 2].length == 1) + + if (adjData[LodDirection.WEST.ordinal() - 2] == null) { + builder.addQuadAdj(LodDirection.WEST, x, y, z, zSize, ySize, ColorUtil.rgbToInt(0, 0, 0), (byte) 15, (byte) 15); + } else if (adjData[LodDirection.WEST.ordinal() - 2].length == 1) { makeAdjQuads(builder, adjData[LodDirection.WEST.ordinal() - 2][0], LodDirection.WEST, x, y, z, zSize, ySize, color, skyLightTop, blockLight); @@ -71,7 +79,10 @@ public class LodBox { } //EAST face vertex creation - if (adjData[LodDirection.EAST.ordinal() - 2].length == 1) + + if (adjData[LodDirection.EAST.ordinal() - 2] == null) { + builder.addQuadAdj(LodDirection.EAST, maxX, y, z, zSize, ySize, ColorUtil.rgbToInt(0, 0, 0), (byte) 15, (byte) 15); + } else if (adjData[LodDirection.EAST.ordinal() - 2].length == 1) { makeAdjQuads(builder, adjData[LodDirection.EAST.ordinal() - 2][0], LodDirection.EAST, maxX, y, z, zSize, ySize, color, skyLightTop, blockLight); diff --git a/src/main/java/com/seibel/lod/core/objects/opengl/RenderRegion.java b/src/main/java/com/seibel/lod/core/objects/opengl/RenderRegion.java index d18aa9bd0..118903417 100644 --- a/src/main/java/com/seibel/lod/core/objects/opengl/RenderRegion.java +++ b/src/main/java/com/seibel/lod/core/objects/opengl/RenderRegion.java @@ -282,7 +282,7 @@ public class RenderRegion implements AutoCloseable || DataPointUtil.isVoid(posData[0])) continue; - long[][][] adjData = new long[4][1][]; + long[][][] adjData = new long[4][][]; // We extract the adj data in the four cardinal direction @@ -339,6 +339,7 @@ public class RenderRegion implements AutoCloseable } if (adjDetail == detailLevel || adjDetail > detailLevel) { + adjData[lodDirection.ordinal() - 2] = new long[1][]; adjData[lodDirection.ordinal() - 2][0] = adjRegion.getAllData(adjDetail, LevelPosUtil.convert(detailLevel, xAdj, adjDetail), LevelPosUtil.convert(detailLevel, zAdj, adjDetail)); diff --git a/src/main/java/com/seibel/lod/core/util/LodUtil.java b/src/main/java/com/seibel/lod/core/util/LodUtil.java index 430fdd110..ae3ea176a 100644 --- a/src/main/java/com/seibel/lod/core/util/LodUtil.java +++ b/src/main/java/com/seibel/lod/core/util/LodUtil.java @@ -338,7 +338,7 @@ public class LodUtil public static int computeOverdrawOffset(LodDimension lodDim) { int chunkRenderDist = MC_RENDER.getRenderDistance() + 1; - VanillaOverdraw overdraw = null;//CONFIG.client().graphics().advancedGraphics().getVanillaOverdraw(); + VanillaOverdraw overdraw = CONFIG.client().graphics().advancedGraphics().getVanillaOverdraw(); if (overdraw == VanillaOverdraw.ALWAYS) return Integer.MAX_VALUE; int offset; if (overdraw == VanillaOverdraw.NEVER) { diff --git a/src/main/resources/assets/lod/lang/en_us.json b/src/main/resources/assets/lod/lang/en_us.json index 5a229b617..d8d992ff4 100644 --- a/src/main/resources/assets/lod/lang/en_us.json +++ b/src/main/resources/assets/lod/lang/en_us.json @@ -144,6 +144,10 @@ "Vanilla overdraw", "DistantHorizons.config.client.graphics.advancedGraphics.vanillaOverdraw.@tooltip": "Determines how often fake chunks will be rendered on top of regular chunks.\n\n§6Dynamic:§r attempts to pick the best option based on vanilla render distance and dimension.\n§6Always:§r prevents holes in the world, but may look odd for transparent blocks or in caves.\n§6Border:§r renders fake chunks on the border of the vanilla render distance, preventing gaps when the player isn't moving.\n§6Never:§r fake chunks will never overlap the vanilla render distance, but there may be holes in the world.", + "DistantHorizons.config.client.graphics.advancedGraphics.overdrawOffset": + "Overdraw Offset", + "DistantHorizons.config.client.graphics.advancedGraphics.overdrawOffset.@tooltip": + "If on Vanilla Overdraw mode of NEVER, how much should should the border be offset? \n\n '1': The start of lods will be shifted inwards by 1 chunk, causing 1 chunk of overdraw. \n'-1': The start fo lods will be shifted outwards by 1 chunk, causing 1 chunk of gap. \n\nThis setting can be used to deal with gaps due to our vanilla rendered chunk \n detection not being perfect. \n", "DistantHorizons.config.client.graphics.advancedGraphics.useExtendedNearClipPlane": "Use extended near clip plane", "DistantHorizons.config.client.graphics.advancedGraphics.useExtendedNearClipPlane.@tooltip":