This commit is contained in:
s809
2023-07-24 10:48:28 +05:00
4 changed files with 15 additions and 14 deletions
@@ -16,18 +16,20 @@ 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)
public static float[] overwriteMinecraftNearFarClipPlanes(Matrix4f minecraftProjectionMatrix, float previousPartialTicks)
{
FloatBuffer matrixFloatBuffer = FloatBuffer.allocate(16);
float[] matrixFloatArray;
#if PRE_MC_1_19_4
FloatBuffer matrixFloatBuffer = FloatBuffer.allocate(16);
minecraftProjectionMatrix.store(matrixFloatBuffer);
matrixFloatArray = matrixFloatBuffer.array();
#else
minecraftProjectionMatrix.get(matrixFloatBuffer);
// 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
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.
@@ -36,8 +38,7 @@ public class SeamlessOverdraw
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;
return matrixFloatArray;
}
}
@@ -247,7 +247,7 @@ public class ChunkLoader
if (chunkType == ChunkStatus.ChunkType.PROTOCHUNK && (blendingData == null || !blendingData.oldNoise()))
return null;
#else
if (chunkType == ChunkStatus.ChunkType.PROTOCHUNK && (blendingData == null || level.getChunk(chunkPos.getMiddleBlockX(),chunkPos.getMiddleBlockZ()).isOldNoiseGeneration()))
if (chunkType == ChunkStatus.ChunkType.PROTOCHUNK && blendingData == null)
return null;
#endif
#endif
@@ -207,12 +207,12 @@ public class FabricClientProxy
// experimental proof-of-concept option
if (Config.Client.Advanced.Graphics.AdvancedGraphics.seamlessOverdraw.get())
{
FloatBuffer modifiedMatrixBuffer = SeamlessOverdraw.overwriteMinecraftNearFarClipPlanes(renderContext.projectionMatrix(), renderContext.tickDelta());
float[] matrixFloatArray = SeamlessOverdraw.overwriteMinecraftNearFarClipPlanes(renderContext.projectionMatrix(), renderContext.tickDelta());
#if PRE_MC_1_19_4
renderContext.projectionMatrix().load(modifiedMatrixBuffer);
renderContext.projectionMatrix().load(FloatBuffer.wrap(matrixFloatArray));
#else
renderContext.projectionMatrix().set(modifiedMatrixBuffer);
renderContext.projectionMatrix().set(matrixFloatArray);
#endif
}
}
@@ -137,12 +137,12 @@ public class MixinLevelRenderer
// experimental proof-of-concept option
if (Config.Client.Advanced.Graphics.AdvancedGraphics.seamlessOverdraw.get())
{
FloatBuffer modifiedMatrixBuffer = SeamlessOverdraw.overwriteMinecraftNearFarClipPlanes(projectionMatrix, previousPartialTicks);
float[] matrixFloatArray = SeamlessOverdraw.overwriteMinecraftNearFarClipPlanes(projectionMatrix, previousPartialTicks);
#if PRE_MC_1_19_4
projectionMatrix.load(modifiedMatrixBuffer);
projectionMatrix.load(FloatBuffer.wrap(matrixFloatArray));
#else
projectionMatrix.set(modifiedMatrixBuffer);
projectionMatrix.set(matrixFloatArray);
#endif
}
}