Skip to content

Commit

Permalink
Merge branch 'multiloader-new' into 1.21.2
Browse files Browse the repository at this point in the history
# Conflicts:
#	common/src/main/java/net/irisshaders/iris/shadows/ShadowRenderer.java
  • Loading branch information
IMS212 committed Nov 6, 2024
2 parents 167d81d + 9e87a8e commit 92a1086
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ public DHCompatInternal(IrisRenderingPipeline pipeline, boolean dhShadowEnabled)
}

public static int getDhBlockRenderDistance() {
if (DhApi.Delayed.configs == null) {
if (DhApi.Delayed.configs == null || !dhEnabled) {
// Called before DH has finished setup
return 0;
return Minecraft.getInstance().options.getEffectiveRenderDistance();
}

return DhApi.Delayed.configs.graphics().chunkRenderDistance().getValue() * 16;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class ShadowMatrices {

public static Matrix4f createOrthoMatrix(float halfPlaneLength, float nearPlane, float farPlane) {
//System.out.println("making a matrix with " + nearPlane + " / " + farPlane + " * " + halfPlaneLength);
return new Matrix4f().setOrthoSymmetric(halfPlaneLength, halfPlaneLength, nearPlane, farPlane);
return new Matrix4f().setOrthoSymmetric(halfPlaneLength * 2, halfPlaneLength * 2, nearPlane, farPlane);
}

public static Matrix4f createPerspectiveMatrix(float fov) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import net.minecraft.client.renderer.culling.Frustum;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
import net.minecraft.core.BlockPos;
import net.minecraft.util.Mth;
import net.minecraft.util.profiling.Profiler;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.entity.Entity;
Expand Down Expand Up @@ -400,7 +401,7 @@ public void renderShadows(LevelRendererAccessor levelRenderer, Camera playerCame
// If FOV is not null, the pack wants a perspective based projection matrix. (This is to support legacy packs)
shadowProjection = ShadowMatrices.createPerspectiveMatrix(this.fov);
} else {
shadowProjection = ShadowMatrices.createOrthoMatrix(halfPlaneLength, nearPlane < 0 ? -DHCompat.getRenderDistance() * 16 : nearPlane, farPlane < 0 ? DHCompat.getRenderDistance() * 16 : farPlane);
shadowProjection = ShadowMatrices.createOrthoMatrix(halfPlaneLength, Mth.equal(nearPlane, -1.0f) ? -DHCompat.getRenderDistance() * 16 : nearPlane, Mth.equal(farPlane, -1.0f) ? DHCompat.getRenderDistance() * 16 : farPlane);
}

IrisRenderSystem.setShadowProjection(shadowProjection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.irisshaders.iris.shaderpack.properties.PackDirectives;
import net.irisshaders.iris.shadows.ShadowMatrices;
import net.irisshaders.iris.shadows.ShadowRenderer;
import net.minecraft.util.Mth;
import org.joml.Matrix4f;
import org.joml.Matrix4fc;

Expand All @@ -21,10 +22,13 @@ public static void addMatrixUniforms(UniformHolder uniforms, PackDirectives dire
addMatrix(uniforms, "Projection", CapturedRenderingState.INSTANCE::getGbufferProjection);
addDHMatrix(uniforms, "Projection", DHCompat::getProjection);
addShadowMatrix(uniforms, "ModelView", () ->
new Matrix4f(ShadowRenderer.createShadowModelView(directives.getSunPathRotation(), directives.getShadowDirectives().getIntervalSize(), directives.getShadowDirectives().getNearPlane(), directives.getShadowDirectives().getFarPlane()).last().pose()));
new Matrix4f(ShadowRenderer.createShadowModelView(directives.getSunPathRotation(), directives.getShadowDirectives().getIntervalSize(),
Mth.equal(directives.getShadowDirectives().getNearPlane(), -1.0f) ? -DHCompat.getRenderDistance() * 16 : directives.getShadowDirectives().getNearPlane(),
Mth.equal(directives.getShadowDirectives().getFarPlane(), -1.0f) ? DHCompat.getRenderDistance() * 16 : directives.getShadowDirectives().getFarPlane()
).last().pose()));
addShadowMatrix(uniforms, "Projection", () -> ShadowMatrices.createOrthoMatrix(directives.getShadowDirectives().getDistance(),
directives.getShadowDirectives().getNearPlane() < 0 ? -DHCompat.getRenderDistance() * 16 : directives.getShadowDirectives().getNearPlane(),
directives.getShadowDirectives().getFarPlane() < 0 ? DHCompat.getRenderDistance() * 16 : directives.getShadowDirectives().getFarPlane()));
Mth.equal(directives.getShadowDirectives().getNearPlane(), -1.0f) ? -DHCompat.getRenderDistance() * 16 : directives.getShadowDirectives().getNearPlane(),
Mth.equal(directives.getShadowDirectives().getFarPlane(), -1.0f) ? DHCompat.getRenderDistance() * 16 : directives.getShadowDirectives().getFarPlane()));
}

private static void addMatrix(UniformHolder uniforms, String name, Supplier<Matrix4fc> supplier) {
Expand Down

0 comments on commit 92a1086

Please sign in to comment.