From e1af5b2533e896698ff8a4d9a4a5bb865695be91 Mon Sep 17 00:00:00 2001 From: PepperCode1 <44146161+PepperCode1@users.noreply.github.com> Date: Tue, 8 Feb 2022 21:37:09 -0800 Subject: [PATCH] Remove force diffuse - The batching engine may run in parallel, meaning the force diffuse state will not be read correctly - ModelTransformers only process vertices that will be rendered in the world - Add 0.6.1 to the issue template --- .github/ISSUE_TEMPLATE/bug_report.yml | 1 + .../flywheel/backend/OptifineHandler.java | 23 ------------------- .../batching/BatchedMaterialGroup.java | 2 +- .../flywheel/core/model/ModelTransformer.java | 12 ++-------- 4 files changed, 4 insertions(+), 34 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 099e65cce..36205ebd9 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -59,6 +59,7 @@ body: label: Mod Version description: The version of the mod you were using when the bug occured options: + - "0.6.1" - "0.6.0" - "0.5.1" - "0.5.0a" diff --git a/src/main/java/com/jozufozu/flywheel/backend/OptifineHandler.java b/src/main/java/com/jozufozu/flywheel/backend/OptifineHandler.java index 201438ecd..4462359da 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/OptifineHandler.java +++ b/src/main/java/com/jozufozu/flywheel/backend/OptifineHandler.java @@ -7,16 +7,12 @@ import java.io.IOException; import java.lang.reflect.Field; import java.util.function.BooleanSupplier; -import org.apache.commons.lang3.mutable.MutableInt; - import net.minecraft.client.Minecraft; public final class OptifineHandler { public static final String OPTIFINE_ROOT_PACKAGE = "net.optifine"; public static final String SHADER_PACKAGE = "net.optifine.shaders"; - private static final ThreadLocal FORCE_DIFFUSE = ThreadLocal.withInitial(MutableInt::new); - private static boolean isOptifineInstalled; private static boolean isUsingShaders; private static BooleanSupplier shadowPassSupplier; @@ -99,23 +95,4 @@ public final class OptifineHandler { public static boolean isShadowPass() { return shadowPassSupplier.getAsBoolean(); } - - public static void pushForceDiffuse() { - if (isOptifineInstalled) { - FORCE_DIFFUSE.get().increment(); - } - } - - public static void popForceDiffuse() { - if (isOptifineInstalled) { - FORCE_DIFFUSE.get().decrement(); - } - } - - public static boolean shouldApplyDiffuse() { - if (isOptifineInstalled) { - return !isUsingShaders || (FORCE_DIFFUSE.get().intValue() > 0); - } - return true; - } } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/batching/BatchedMaterialGroup.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/batching/BatchedMaterialGroup.java index f9bf34d17..14b2cd212 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/batching/BatchedMaterialGroup.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/batching/BatchedMaterialGroup.java @@ -56,7 +56,7 @@ public class BatchedMaterialGroup implements MaterialGroup { for (BatchedMaterial material : materials.values()) { for (CPUInstancer instancer : material.models.values()) { - instancer.sbb.context.outputColorDiffuse = !consumer.hasOverlay() && OptifineHandler.shouldApplyDiffuse(); + instancer.sbb.context.outputColorDiffuse = !consumer.hasOverlay() && !OptifineHandler.isUsingShaders(); instancer.submitTasks(stack, pool, consumer); } } diff --git a/src/main/java/com/jozufozu/flywheel/core/model/ModelTransformer.java b/src/main/java/com/jozufozu/flywheel/core/model/ModelTransformer.java index 75ebc8ee4..10eafd1c4 100644 --- a/src/main/java/com/jozufozu/flywheel/core/model/ModelTransformer.java +++ b/src/main/java/com/jozufozu/flywheel/core/model/ModelTransformer.java @@ -47,12 +47,9 @@ public class ModelTransformer { normalMat = params.normal.copy(); } - DiffuseLightCalculator diffuseCalculator = params.diffuseCalculator; - if (diffuseCalculator == null) { - diffuseCalculator = DiffuseLightCalculator.forCurrentLevel(); - } + final DiffuseLightCalculator diffuseCalculator = DiffuseLightCalculator.forCurrentLevel(); - int vertexCount = reader.getVertexCount(); + final int vertexCount = reader.getVertexCount(); for (int i = 0; i < vertexCount; i++) { float x = reader.getX(i); float y = reader.getY(i); @@ -173,9 +170,6 @@ public class ModelTransformer { public boolean useParamLight; public int packedLightCoords; - // Diffuse - public DiffuseLightCalculator diffuseCalculator; - public Params() { model = new Matrix4f(); normal = new Matrix3f(); @@ -193,7 +187,6 @@ public class ModelTransformer { overlay = OverlayTexture.NO_OVERLAY; useParamLight = false; packedLightCoords = LightTexture.FULL_BRIGHT; - diffuseCalculator = null; } public void load(Params from) { @@ -208,7 +201,6 @@ public class ModelTransformer { overlay = from.overlay; useParamLight = from.useParamLight; packedLightCoords = from.packedLightCoords; - diffuseCalculator = from.diffuseCalculator; } public Params color(int r, int g, int b, int a) {