Skip to content

Commit

Permalink
Fix some frustum issues
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Aug 14, 2023
1 parent 7d0d4e0 commit d4f16ce
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ public int fastAabbTest(float minX, float minY, float minZ, float maxX, float ma

return isVisible(minX, minY, minZ, maxX, maxY, maxZ);
}

public boolean testAab(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
return !boxCuller.isCulledSodium(minX, minY, minZ, maxX, maxY, maxZ) || this.checkCornerVisibility(minX, minY, minZ, maxX, maxY, maxZ) > 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@Mixin(DefaultChunkRenderer.class)
public class MixinDefaultChunkRenderer {
@Redirect(method = "render", at = @At(value = "FIELD", target = "Lme/jellysquid/mods/sodium/client/gui/SodiumGameOptions$PerformanceSettings;useBlockFaceCulling:Z"))
@Redirect(method = "render", at = @At(value = "FIELD", target = "Lme/jellysquid/mods/sodium/client/gui/SodiumGameOptions$PerformanceSettings;useBlockFaceCulling:Z"), remap = false)
private boolean iris$disableBlockFaceCullingInShadowPass(SodiumGameOptions.PerformanceSettings instance) {
if (ShadowRenderingState.areShadowsCurrentlyBeingRendered()) return false;
return instance.useBlockFaceCulling;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ private void cancelIfShadow(Camera camera, Viewport viewport, int frame, boolean
"getRenderLists",
"getVisibleChunkCount",
"renderLayer"
}, at = @At(value = "FIELD", target = "Lme/jellysquid/mods/sodium/client/render/chunk/RenderSectionManager;renderLists:Lme/jellysquid/mods/sodium/client/render/chunk/lists/SortedRenderLists;"))
}, at = @At(value = "FIELD", target = "Lme/jellysquid/mods/sodium/client/render/chunk/RenderSectionManager;renderLists:Lme/jellysquid/mods/sodium/client/render/chunk/lists/SortedRenderLists;"), remap = false)
private SortedRenderLists useShadowRenderList2(RenderSectionManager instance) {
return ShadowRenderingState.areShadowsCurrentlyBeingRendered() ? shadowRenderLists : renderLists;
}

@Redirect(method = {
"resetRenderLists"
}, at = @At(value = "FIELD", target = "Lme/jellysquid/mods/sodium/client/render/chunk/RenderSectionManager;renderLists:Lme/jellysquid/mods/sodium/client/render/chunk/lists/SortedRenderLists;"))
}, at = @At(value = "FIELD", target = "Lme/jellysquid/mods/sodium/client/render/chunk/RenderSectionManager;renderLists:Lme/jellysquid/mods/sodium/client/render/chunk/lists/SortedRenderLists;"), remap = false)
private void useShadowRenderList3(RenderSectionManager instance, SortedRenderLists value) {
if (ShadowRenderingState.areShadowsCurrentlyBeingRendered()) shadowRenderLists = value;
else renderLists = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import me.jellysquid.mods.sodium.client.render.viewport.Viewport;
import me.jellysquid.mods.sodium.client.render.viewport.ViewportProvider;
import me.jellysquid.mods.sodium.client.render.viewport.frustum.Frustum;
import net.coderbot.iris.shadows.frustum.BoxCuller;
import net.coderbot.iris.shadows.frustum.advanced.AdvancedShadowCullingFrustum;
import org.joml.FrustumIntersection;
import org.joml.Vector3d;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
Expand All @@ -24,9 +26,13 @@ public abstract class MixinAdvancedShadowCullingFrustum implements ViewportProvi
@Shadow
public double z;

@Shadow
@Final
protected BoxCuller boxCuller;

@Override
public boolean testAab(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
return this.checkCornerVisibility(minX, minY, minZ, maxX, maxY, maxZ) > 0;
return (boxCuller == null || !boxCuller.isCulledSodium(minX, minY, minZ, maxX, maxY, maxZ)) && this.checkCornerVisibility(minX, minY, minZ, maxX, maxY, maxZ) > 0;
}

@Unique
Expand Down

0 comments on commit d4f16ce

Please sign in to comment.