From e82a1cb5f50c2e72fa88c900a704b30edf330e4a Mon Sep 17 00:00:00 2001 From: mcrcortex <{ID}+{username}@users.noreply.github.com> Date: Tue, 23 Jul 2024 21:14:46 +1000 Subject: [PATCH] Include the perspective matrix when marking graph as dirty --- .../sodium/client/render/SodiumWorldRenderer.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/caffeinemc/mods/sodium/client/render/SodiumWorldRenderer.java b/src/main/java/net/caffeinemc/mods/sodium/client/render/SodiumWorldRenderer.java index 41f4204265..fe022ca6ed 100644 --- a/src/main/java/net/caffeinemc/mods/sodium/client/render/SodiumWorldRenderer.java +++ b/src/main/java/net/caffeinemc/mods/sodium/client/render/SodiumWorldRenderer.java @@ -39,6 +39,7 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; +import org.joml.Matrix4f; import org.joml.Vector3d; import java.util.Collection; @@ -57,6 +58,7 @@ public class SodiumWorldRenderer { private Vector3d lastCameraPos; private double lastCameraPitch, lastCameraYaw; private float lastFogDistance; + private Matrix4f lastProjectionMatrix; private boolean useEntityCulling; @@ -179,6 +181,7 @@ public void setupTerrain(Camera camera, Vec3 posRaw = camera.getPosition(); Vector3d pos = new Vector3d(posRaw.x(), posRaw.y(), posRaw.z()); + Matrix4f projectionMatrix = new Matrix4f(RenderSystem.getProjectionMatrix()); float pitch = camera.getXRot(); float yaw = camera.getYRot(); float fogDistance = RenderSystem.getShaderFogEnd(); @@ -186,13 +189,19 @@ public void setupTerrain(Camera camera, if (this.lastCameraPos == null) { this.lastCameraPos = new Vector3d(pos); } + if (this.lastProjectionMatrix == null) { + this.lastProjectionMatrix = new Matrix4f(projectionMatrix); + } boolean cameraLocationChanged = !pos.equals(this.lastCameraPos); boolean cameraAngleChanged = pitch != this.lastCameraPitch || yaw != this.lastCameraYaw || fogDistance != this.lastFogDistance; + boolean cameraProjectionChanged = !projectionMatrix.equals(this.lastProjectionMatrix); + + this.lastProjectionMatrix = projectionMatrix; this.lastCameraPitch = pitch; this.lastCameraYaw = yaw; - if (cameraLocationChanged || cameraAngleChanged) { + if (cameraLocationChanged || cameraAngleChanged || cameraProjectionChanged) { this.renderSectionManager.markGraphDirty(); }