-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve zoom culling, and make it toggleable
Yeah! My laptop didn't handle it well! but lowering the rendered chunks did help make the culling instantaneous once more; Really, you can overwhelm Minecraft with too much terrain at once, and only Sodium can fix this (heck, throw shaders on top of it, you can get 50 FPS but Sodium will still fix the pipeline)
- Loading branch information
Showing
7 changed files
with
69 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
common/src/main/java/io/github/ennuil/ok_zoomer/mixin/common/LevelRendererMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package io.github.ennuil.ok_zoomer.mixin.common; | ||
|
||
import io.github.ennuil.ok_zoomer.config.OkZoomerConfigManager; | ||
import io.github.ennuil.ok_zoomer.zoom.Zoom; | ||
import net.minecraft.client.Camera; | ||
import net.minecraft.client.renderer.LevelRenderer; | ||
import net.minecraft.client.renderer.SectionOcclusionGraph; | ||
import net.minecraft.client.renderer.culling.Frustum; | ||
import net.minecraft.util.Mth; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(LevelRenderer.class) | ||
public abstract class LevelRendererMixin { | ||
@Shadow | ||
@Final | ||
private SectionOcclusionGraph sectionOcclusionGraph; | ||
|
||
@Unique | ||
private int prevZoomDivisor = 1; | ||
|
||
@Inject( | ||
method = "setupRender", | ||
at = @At( | ||
value = "FIELD", | ||
target = "Lnet/minecraft/client/renderer/LevelRenderer;prevCamX:D", | ||
ordinal = 1 | ||
) | ||
) | ||
private void accountForZooming(Camera camera, Frustum frustum, boolean hasCapturedFrustum, boolean isSpectator, CallbackInfo ci) { | ||
if (OkZoomerConfigManager.CONFIG.tweaks.zoomAwareOcclusion.value()) { | ||
int divisor = Zoom.isZooming() ? Mth.floor(Zoom.getZoomDivisor()) : 1; | ||
|
||
if (divisor != this.prevZoomDivisor) { | ||
this.sectionOcclusionGraph.invalidate(); | ||
} | ||
|
||
this.prevZoomDivisor = divisor; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
{ | ||
"required": true, | ||
"minVersion": "0.8", | ||
"package": "io.github.ennuil.ok_zoomer.mixin", | ||
"compatibilityLevel": "JAVA_21", | ||
"client": [ | ||
"common.AbstractClientPlayerMixin", | ||
"common.EditBoxAccessor", | ||
"common.EditBoxMixin", | ||
"common.GameRendererMixin", | ||
"common.GuiMixin", | ||
"common.MouseHandlerMixin", | ||
"common.RenderStateShardMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
"required": true, | ||
"minVersion": "0.8", | ||
"package": "io.github.ennuil.ok_zoomer.mixin", | ||
"compatibilityLevel": "JAVA_21", | ||
"client": [ | ||
"common.AbstractClientPlayerMixin", | ||
"common.EditBoxAccessor", | ||
"common.EditBoxMixin", | ||
"common.GameRendererMixin", | ||
"common.GuiMixin", | ||
"common.LevelRendererMixin", | ||
"common.MouseHandlerMixin", | ||
"common.RenderStateShardMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
} |