From 8bedb3dbaa0456d56e19d5eca0ff79ae8db0052b Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 16 Mar 2024 21:03:27 -0500 Subject: [PATCH] Remove Seamless Overdraw Test The result wasn't very good due to rendering issues with entities --- .../common/rendering/SeamlessOverdraw.java | 94 ------------------- coreSubProjects | 2 +- .../fabric/FabricClientProxy.java | 16 ---- .../mixins/client/MixinLevelRenderer.java | 15 --- .../mixins/client/MixinLevelRenderer.java | 15 --- 5 files changed, 1 insertion(+), 141 deletions(-) delete mode 100644 common/src/main/java/com/seibel/distanthorizons/common/rendering/SeamlessOverdraw.java diff --git a/common/src/main/java/com/seibel/distanthorizons/common/rendering/SeamlessOverdraw.java b/common/src/main/java/com/seibel/distanthorizons/common/rendering/SeamlessOverdraw.java deleted file mode 100644 index e6795c666..000000000 --- a/common/src/main/java/com/seibel/distanthorizons/common/rendering/SeamlessOverdraw.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * This file is part of the Distant Horizons mod - * licensed under the GNU LGPL v3 License. - * - * Copyright (C) 2020-2023 James Seibel - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.seibel.distanthorizons.common.rendering; - -#if MC_VER < MC_1_19_4 -import com.mojang.math.Matrix4f; -#else -import org.joml.Matrix4f; -#endif -import com.seibel.distanthorizons.core.config.Config; -import com.seibel.distanthorizons.core.util.RenderUtil; -import com.seibel.distanthorizons.coreapi.util.math.Mat4f; -import org.lwjgl.opengl.GL15; - -import java.nio.FloatBuffer; - -public class SeamlessOverdraw -{ - /** - * Proof-of-concept experimental option, not intended for normal use.
- * (Poorly) replaces Minecraft's far clip plane so it lines up with DH's near clip plane. - */ - public static float[] overwriteMinecraftNearFarClipPlanes(Matrix4f minecraftProjectionMatrix, float previousPartialTicks) - { - float[] matrixFloatArray; - - #if MC_VER < MC_1_19_4 - FloatBuffer matrixFloatBuffer = FloatBuffer.allocate(16); - minecraftProjectionMatrix.store(matrixFloatBuffer); - matrixFloatArray = matrixFloatBuffer.array(); - #else - // Passing float buffers in caused native code crashes, so we are passing in a float array instead - matrixFloatArray = new float[16]; - minecraftProjectionMatrix.get(matrixFloatArray); - #endif - - return overwriteMinecraftNearFarClipPlanes(matrixFloatArray, previousPartialTicks); - } - - public static float[] overwriteMinecraftNearFarClipPlanes(Mat4f minecraftProjectionMatrix, float previousPartialTicks) - { - return overwriteMinecraftNearFarClipPlanes(minecraftProjectionMatrix.getValuesAsArray(), previousPartialTicks); - } - - private static float[] overwriteMinecraftNearFarClipPlanes(float[] projectionMatrixFloatArray, float previousPartialTicks) - { - float dhFarClipPlane = RenderUtil.getNearClipPlaneDistanceInBlocks(previousPartialTicks); - - // works for fabric, bad not for forge for some reason :/ - float farClip = dhFarClipPlane * 5.1f; // magic number found via trial and error, James has no idea what it represents, except that it makes the seam between DH and vanilla rendering pretty close - float nearClip = 0.5f; // this causes issues with some vanilla rendering, specifically the wireframe around selected blocks is slightly off. Unfortunately the ratio between the near and far clip plane can't be easily modified without completely screwing up the rendering. - - // these may be the wrong index locations in any version of MC other than 1.18.2 - projectionMatrixFloatArray[10] = -((farClip + nearClip) / (farClip - nearClip)); // near clip plane - projectionMatrixFloatArray[11] = -((2 * farClip * nearClip) / (farClip - nearClip)); // far clip plane - - - return projectionMatrixFloatArray; - } - - - - //================// - // helper methods // - //================// - - public static void applyLegacyProjectionMatrix(float[] projectionMatrixFloatArray) - { - int glMatrixMode = GL15.glGetInteger(GL15.GL_MATRIX_MODE); - GL15.glMatrixMode(GL15.GL_PROJECTION); - - GL15.glLoadMatrixf(projectionMatrixFloatArray); - - GL15.glMatrixMode(glMatrixMode); - } - -} diff --git a/coreSubProjects b/coreSubProjects index 6413e17e4..b20cbab01 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 6413e17e4b80a48a58adea30df83cc7ef7598cad +Subproject commit b20cbab012b1edd0386b671625e5917a9d4678db diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java index d9216458d..bcde63d5b 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java @@ -20,7 +20,6 @@ package com.seibel.distanthorizons.fabric; import com.seibel.distanthorizons.common.AbstractModInitializer; -import com.seibel.distanthorizons.common.rendering.SeamlessOverdraw; import com.seibel.distanthorizons.common.wrappers.McObjectConverter; import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper; import com.seibel.distanthorizons.core.api.internal.ClientApi; @@ -197,21 +196,6 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy McObjectConverter.Convert(renderContext.matrixStack().last().pose()), McObjectConverter.Convert(renderContext.projectionMatrix()), renderContext.tickDelta()); - - - // experimental proof-of-concept option - if (Config.Client.Advanced.Graphics.AdvancedGraphics.seamlessOverdraw.get()) - { - float[] matrixFloatArray = SeamlessOverdraw.overwriteMinecraftNearFarClipPlanes(renderContext.projectionMatrix(), renderContext.tickDelta()); - - #if MC_VER == MC_1_16_5 - SeamlessOverdraw.applyLegacyProjectionMatrix(matrixFloatArray); - #elif MC_VER < MC_1_19_4 - renderContext.projectionMatrix().load(FloatBuffer.wrap(matrixFloatArray)); - #else - renderContext.projectionMatrix().set(matrixFloatArray); - #endif - } }); // Debug keyboard event diff --git a/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/client/MixinLevelRenderer.java b/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/client/MixinLevelRenderer.java index 01a172de6..a04df23bd 100644 --- a/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/client/MixinLevelRenderer.java +++ b/forge/src/main/java/com/seibel/distanthorizons/forge/mixins/client/MixinLevelRenderer.java @@ -29,7 +29,6 @@ import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.LightTexture; import org.joml.Matrix4f; #endif -import com.seibel.distanthorizons.common.rendering.SeamlessOverdraw; import com.seibel.distanthorizons.common.wrappers.McObjectConverter; import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper; @@ -141,20 +140,6 @@ public class MixinLevelRenderer if (renderType.equals(RenderType.solid())) { ClientApi.INSTANCE.renderLods(ClientLevelWrapper.getWrapper(this.level), mcModelViewMatrix, mcProjectionMatrix, Minecraft.getInstance().getFrameTime()); - - // experimental proof-of-concept option - if (Config.Client.Advanced.Graphics.AdvancedGraphics.seamlessOverdraw.get()) - { - float[] matrixFloatArray = SeamlessOverdraw.overwriteMinecraftNearFarClipPlanes(mcProjectionMatrix, previousPartialTicks); - - #if MC_VER == MC_1_16_5 - SeamlessOverdraw.applyLegacyProjectionMatrix(matrixFloatArray); - #elif MC_VER < MC_1_19_4 - projectionMatrix.load(FloatBuffer.wrap(matrixFloatArray)); - #else - projectionMatrix.set(matrixFloatArray); - #endif - } } else if (renderType.equals(RenderType.translucent())) { diff --git a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinLevelRenderer.java b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinLevelRenderer.java index ad0dc6d61..e885b13e9 100644 --- a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinLevelRenderer.java +++ b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinLevelRenderer.java @@ -29,7 +29,6 @@ import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.LightTexture; import org.joml.Matrix4f; #endif -import com.seibel.distanthorizons.common.rendering.SeamlessOverdraw; import com.seibel.distanthorizons.common.wrappers.McObjectConverter; import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper; import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper; @@ -138,20 +137,6 @@ public class MixinLevelRenderer if (renderType.equals(RenderType.solid())) { ClientApi.INSTANCE.renderLods(ClientLevelWrapper.getWrapper(level), mcModelViewMatrix, mcProjectionMatrix, Minecraft.getInstance().getFrameTime()); - - // experimental proof-of-concept option - if (Config.Client.Advanced.Graphics.AdvancedGraphics.seamlessOverdraw.get()) - { - float[] matrixFloatArray = SeamlessOverdraw.overwriteMinecraftNearFarClipPlanes(mcProjectionMatrix, previousPartialTicks); - - #if MC_VER == MC_1_16_5 - SeamlessOverdraw.applyLegacyProjectionMatrix(matrixFloatArray); - #elif MC_VER < MC_1_19_4 - projectionMatrix.load(FloatBuffer.wrap(matrixFloatArray)); - #else - projectionMatrix.set(matrixFloatArray); - #endif - } } else if (renderType.equals(RenderType.translucent())) {