Fix Iris using the wrong far clip plane
https://github.com/IrisShaders/Iris/issues/2534
This commit is contained in:
@@ -19,12 +19,17 @@
|
||||
|
||||
package com.seibel.distanthorizons.core.util;
|
||||
|
||||
import com.seibel.distanthorizons.api.DhApi;
|
||||
import com.seibel.distanthorizons.api.objects.math.DhApiMat4f;
|
||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
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.DhLogger;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IIrisAccessor;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.coreapi.util.MathUtil;
|
||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||
@@ -35,8 +40,11 @@ import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||
*/
|
||||
public class RenderUtil
|
||||
{
|
||||
private static final DhLogger LOGGER = new DhLoggerBuilder().maxCountPerSecond(1).build();
|
||||
|
||||
private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
|
||||
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
|
||||
private static final IIrisAccessor IRIS_ACCESSOR = ModAccessorInjector.INSTANCE.get(IIrisAccessor.class);
|
||||
|
||||
/**
|
||||
* all speeds are measured in blocks per second
|
||||
@@ -79,7 +87,7 @@ public class RenderUtil
|
||||
nearClipDist = Math.min(nearClipDist, 7.5f);
|
||||
}
|
||||
|
||||
float farClipDist = (float) RenderUtil.getFarClipPlaneDistanceInBlocks();
|
||||
float farClipDist = RenderUtil.getFarClipPlaneDistanceInBlocks();
|
||||
|
||||
// Create a copy of the current matrix, so it won't be modified.
|
||||
Mat4f lodProj = new Mat4f(mcProjMat);
|
||||
@@ -245,13 +253,32 @@ public class RenderUtil
|
||||
|
||||
//region
|
||||
|
||||
public static int getFarClipPlaneDistanceInBlocks()
|
||||
public static float getFarClipPlaneDistanceInBlocks()
|
||||
{
|
||||
if (IRIS_ACCESSOR != null)
|
||||
{
|
||||
// Iris doesn't use the far clip plane DH generates, instead
|
||||
// they use a manually generated one, which causes problems.
|
||||
// This is a hack so DH's far clip plane matches up with what Iris thinks it is,
|
||||
// fixing projection/depth mapping.
|
||||
// https://github.com/IrisShaders/Iris/issues/2534
|
||||
|
||||
int lodChunkDist = DhApi.Delayed.configs.graphics().chunkRenderDistance().getValue();
|
||||
int lodBlockDist = lodChunkDist * 16; /* 16 = chunk width in blocks */
|
||||
// sqrt 2 to prevent the corners from being cut off
|
||||
return (float) ((lodBlockDist + 512 /* 512 = region width in blocks */) * Math.sqrt(2));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Current DH logic
|
||||
// uses a farther depth to help when far above the world
|
||||
|
||||
int lodChunkDist = Config.Client.Advanced.Graphics.Quality.lodChunkRenderDistanceRadius.get();
|
||||
int lodBlockDist = lodChunkDist * LodUtil.CHUNK_WIDTH;
|
||||
// * 2 to prevent clipping when high above the world
|
||||
return (lodBlockDist + LodUtil.REGION_WIDTH) * 2;
|
||||
}
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user