Add experimental Seamless Overdraw option
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
||||
package com.seibel.distanthorizons.common.rendering;
|
||||
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.util.RenderUtil;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
public class SeamlessOverdraw
|
||||
{
|
||||
/**
|
||||
* Proof-of-concept experimental option, not intended for normal use. <br>
|
||||
* (Poorly) replaces Minecraft's far clip plane so it lines up with DH's near clip plane.
|
||||
*/
|
||||
public static FloatBuffer overwriteMinecraftNearFarClipPlanes(Matrix4f minecraftProjectionMatrix, float previousPartialTicks)
|
||||
{
|
||||
FloatBuffer matrixFloatBuffer = FloatBuffer.allocate(16);
|
||||
minecraftProjectionMatrix.store(matrixFloatBuffer);
|
||||
float[] matrixFloatArray = matrixFloatBuffer.array();
|
||||
|
||||
float dhFarClipPlane = RenderUtil.getNearClipPlaneDistanceInBlocks(previousPartialTicks);
|
||||
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
|
||||
matrixFloatArray[10] = -((farClip + nearClip) / (farClip - nearClip)); // near clip plane
|
||||
matrixFloatArray[11] = -((2 * farClip * nearClip) / (farClip - nearClip)); // far clip plane
|
||||
|
||||
matrixFloatBuffer = FloatBuffer.wrap(matrixFloatArray);
|
||||
return matrixFloatBuffer;
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
Submodule coreSubProjects updated: f07973a1ce...5a014f163d
@@ -19,15 +19,19 @@
|
||||
|
||||
package com.seibel.distanthorizons.fabric;
|
||||
|
||||
import com.mojang.math.Matrix4f;
|
||||
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;
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.util.RenderUtil;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IImmersivePortalsAccessor;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.ISodiumAccessor;
|
||||
@@ -44,6 +48,7 @@ import net.fabricmc.fabric.api.event.player.UseBlockCallback;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
@@ -189,10 +194,18 @@ public class FabricClientProxy
|
||||
}
|
||||
else
|
||||
{
|
||||
clientApi.renderLods(ClientLevelWrapper.getWrapper(renderContext.world()),
|
||||
this.clientApi.renderLods(ClientLevelWrapper.getWrapper(renderContext.world()),
|
||||
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())
|
||||
{
|
||||
FloatBuffer modifiedMatrixBuffer = SeamlessOverdraw.overwriteMinecraftNearFarClipPlanes(renderContext.projectionMatrix(), renderContext.tickDelta());
|
||||
renderContext.projectionMatrix().load(modifiedMatrixBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
if (immersiveAccessor != null)
|
||||
|
||||
+11
@@ -25,10 +25,12 @@ import com.mojang.math.Matrix4f;
|
||||
#else
|
||||
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.world.ClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
import com.seibel.distanthorizons.core.util.RenderUtil;
|
||||
import com.seibel.distanthorizons.coreapi.util.math.Mat4f;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
@@ -40,6 +42,8 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
/**
|
||||
* This class is used to mix in my rendering code
|
||||
* before Minecraft starts rendering blocks.
|
||||
@@ -130,6 +134,13 @@ public class MixinLevelRenderer
|
||||
Mat4f mcProjectionMatrix = McObjectConverter.Convert(projectionMatrix);
|
||||
|
||||
ClientApi.INSTANCE.renderLods(ClientLevelWrapper.getWrapper(level), mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks);
|
||||
|
||||
// experimental proof-of-concept option
|
||||
if (Config.Client.Advanced.Graphics.AdvancedGraphics.seamlessOverdraw.get())
|
||||
{
|
||||
FloatBuffer modifiedMatrixBuffer = SeamlessOverdraw.overwriteMinecraftNearFarClipPlanes(projectionMatrix, previousPartialTicks);
|
||||
projectionMatrix.load(modifiedMatrixBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.Client.Advanced.Debugging.lodOnlyMode.get())
|
||||
|
||||
Reference in New Issue
Block a user