Skip to content

Commit 6f28ca4

Browse files
committed
fix no render fog
1 parent 4de7879 commit 6f28ca4

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright 2025 Lambda
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.lambda.mixin.render;
19+
20+
import com.lambda.module.modules.render.NoRender;
21+
import com.mojang.blaze3d.buffers.GpuBuffer;
22+
import com.mojang.blaze3d.buffers.GpuBufferSlice;
23+
import net.minecraft.client.render.fog.FogRenderer;
24+
import org.spongepowered.asm.mixin.Final;
25+
import org.spongepowered.asm.mixin.Mixin;
26+
import org.spongepowered.asm.mixin.Shadow;
27+
import org.spongepowered.asm.mixin.injection.At;
28+
import org.spongepowered.asm.mixin.injection.Inject;
29+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
30+
31+
import static net.minecraft.client.render.fog.FogRenderer.FOG_UBO_SIZE;
32+
33+
@Mixin(FogRenderer.class)
34+
public class FogRendererMixin {
35+
@Final
36+
@Shadow
37+
private GpuBuffer emptyBuffer;
38+
39+
@Inject(method = "getFogBuffer", at = @At("HEAD"), cancellable = true)
40+
private void modify(FogRenderer.FogType fogType, CallbackInfoReturnable<GpuBufferSlice> cir) {
41+
if (fogType == FogRenderer.FogType.WORLD && NoRender.INSTANCE.isEnabled() && NoRender.getNoTerrainFog())
42+
cir.setReturnValue(emptyBuffer.slice(0L, FOG_UBO_SIZE));
43+
}
44+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2025 Lambda
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.lambda.mixin.render;
19+
20+
import com.lambda.module.modules.render.NoRender;
21+
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22+
import net.caffeinemc.mods.sodium.client.render.SodiumWorldRenderer;
23+
import net.caffeinemc.mods.sodium.client.util.FogParameters;
24+
import org.objectweb.asm.Opcodes;
25+
import org.spongepowered.asm.mixin.Mixin;
26+
import org.spongepowered.asm.mixin.Unique;
27+
import org.spongepowered.asm.mixin.injection.At;
28+
29+
@Mixin(SodiumWorldRenderer.class)
30+
public class SodiumWorldRendererMixin {
31+
@Unique
32+
private final FogParameters NO_FOG = new FogParameters(0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f);
33+
34+
@ModifyExpressionValue(method = "drawChunkLayer(Lnet/minecraft/client/render/BlockRenderLayerGroup;Lnet/caffeinemc/mods/sodium/client/render/chunk/ChunkRenderMatrices;DDDLnet/minecraft/client/gl/GpuSampler;)V", at = @At(value = "FIELD", target = "Lnet/caffeinemc/mods/sodium/client/render/SodiumWorldRenderer;lastFogParameters:Lnet/caffeinemc/mods/sodium/client/util/FogParameters;", opcode = Opcodes.GETFIELD))
35+
private FogParameters modifyFogParameters(FogParameters original) {
36+
if (NoRender.INSTANCE.isEnabled() && NoRender.getNoTerrainFog()) return NO_FOG;
37+
return original;
38+
}
39+
}

src/main/resources/lambda.mixins.common.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"render.ElytraFeatureRendererMixin",
5050
"render.EntityRendererMixin",
5151
"render.FluidRendererMixin",
52+
"render.FogRendererMixin",
5253
"render.GameRendererMixin",
5354
"render.GlStateManagerMixin",
5455
"render.HandledScreenMixin",
@@ -66,6 +67,7 @@
6667
"render.SodiumBlockRendererMixin",
6768
"render.SodiumFluidRendererImplMixin",
6869
"render.SodiumLightDataAccessMixin",
70+
"render.SodiumWorldRendererMixin",
6971
"render.SplashOverlayMixin",
7072
"render.SplashOverlayMixin$LogoTextureMixin",
7173
"render.TooltipComponentMixin",

0 commit comments

Comments
 (0)