From 0d4ab847519dfa7be84c562d6fe4e24761c96e7d Mon Sep 17 00:00:00 2001 From: JellySquid Date: Tue, 17 Dec 2024 15:37:50 -0600 Subject: [PATCH] Do not cache ambient brightness at initialization The world may not be assigned to the renderer at initialization, which is the case for non-terrain rendering (i.e. block entities.) Likely, there is no performance benefit to caching this data in the first place, so the easiest solution is to just remove the code. --- .../model/light/smooth/SmoothLightPipeline.java | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/model/light/smooth/SmoothLightPipeline.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/model/light/smooth/SmoothLightPipeline.java index 1cbe1b1014..09f888520a 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/model/light/smooth/SmoothLightPipeline.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/model/light/smooth/SmoothLightPipeline.java @@ -6,7 +6,6 @@ import net.caffeinemc.mods.sodium.client.model.light.data.QuadLightData; import net.caffeinemc.mods.sodium.client.model.quad.ModelQuadView; import net.caffeinemc.mods.sodium.client.model.quad.properties.ModelQuadFlags; -import net.caffeinemc.mods.sodium.client.util.DirectionUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.util.Mth; @@ -58,23 +57,12 @@ public class SmoothLightPipeline implements LightPipeline { */ private final float[] weights = new float[4]; - // Cached per-face brightness received from the dimension's ambient lighting. - // This data is static for a given world and dimension. - private final float[] ambientBrightnessShaded = new float[6]; - private final float[] ambientBrightnessUnshaded = new float[6]; - public SmoothLightPipeline(LightDataAccess cache) { this.lightCache = cache; for (int i = 0; i < this.cachedFaceData.length; i++) { this.cachedFaceData[i] = new AoFaceData(); } - - for (Direction direction : DirectionUtil.ALL_DIRECTIONS) { - var level = cache.getLevel(); - this.ambientBrightnessShaded[direction.ordinal()] = level.getShade(direction, true); - this.ambientBrightnessUnshaded[direction.ordinal()] = level.getShade(direction, false); - } } @Override @@ -348,7 +336,8 @@ private void applyAmbientLighting(final float[] brightness, Direction face, bool * @param shade Whether the block face is receiving directional light */ private float getAmbientBrightness(Direction face, boolean shade) { - return (shade ? this.ambientBrightnessShaded : this.ambientBrightnessUnshaded)[face.ordinal()]; + return this.lightCache.getLevel() + .getShade(face, shade); } /**