Fix broken fog when using Chroma Key with Sodium (fixes #726)

This commit is contained in:
Jonas Herzig
2022-05-01 20:05:00 +02:00
parent f2c96174bc
commit 8b2d42f801
2 changed files with 14 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
package com.replaymod.render.mixin;
import com.mojang.blaze3d.platform.GlStateManager;
import com.replaymod.core.versions.MCVer;
import com.replaymod.render.hooks.EntityRendererHandler;
import net.minecraft.client.render.BackgroundRenderer;
@@ -20,6 +21,17 @@ public abstract class Mixin_ChromaKeyDisableFog {
((EntityRendererHandler.IEntityRenderer) MCVer.getMinecraft().gameRenderer).replayModRender_getHandler();
if (handler == null) return;
if (handler.getSettings().getChromaKeyingColor() != null) {
// Starting with 1.15, fog is no longer enabled in this method but is instead managed by the RenderLayer
// system (and with 1.17, they are enabled permanently / depend only on the shader). Therefore, cancelling
// this method is no longer sufficient, and we additionally also need to set the start value to get rid of
// fog (this doesn't hurt on 1.14 either).
// Note: This only becomes noticeable with Sodium because Vanilla would already set the start to max for
// unrelated reasons. But Sodium does some math which gives wrong results if end isn't greater than
// start, as would be the case in these cases. Sodium doing math is also the reason we don't set start
// equal to end (that'll result in undefined behavior because it sticks those into a smoothstep on old
// versions), and we don't set it to MAX_VALUE because that also gives wrong results.
GlStateManager.fogStart(1E10F);
GlStateManager.fogEnd(2E10F);
ci.cancel();
}
}

View File

@@ -1,4 +1,6 @@
com.mojang.blaze3d.systems.RenderSystem com.mojang.blaze3d.platform.GlStateManager
com.mojang.blaze3d.systems.RenderSystem setShaderFogStart() fogStart()
com.mojang.blaze3d.systems.RenderSystem setShaderFogEnd() fogEnd()
net.minecraft.network.packet.s2c.play.PlayerRespawnS2CPacket getDimensionType() method_29445()
net.minecraft.entity.Entity getId() getEntityId()
net.minecraft.client.network.ClientPlayerEntity init() net.minecraft.entity.player.PlayerEntity afterSpawn()