From fe798bf90c8b9da8697831dba7473c8c2c586102 Mon Sep 17 00:00:00 2001 From: CodeF53 <37855219+CodeF53@users.noreply.github.com> Date: Tue, 22 Mar 2022 00:21:49 -0600 Subject: [PATCH] Skylight culling below Y https://canary.discord.com/channels/881614130614767666/881748253228531772/955696258754961429 --- .../core/objects/opengl/LodQuadBuilder.java | 19 +++++++++++-------- .../lod/core/objects/opengl/RenderRegion.java | 4 +++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/seibel/lod/core/objects/opengl/LodQuadBuilder.java b/src/main/java/com/seibel/lod/core/objects/opengl/LodQuadBuilder.java index 995af90bc..042973d78 100644 --- a/src/main/java/com/seibel/lod/core/objects/opengl/LodQuadBuilder.java +++ b/src/main/java/com/seibel/lod/core/objects/opengl/LodQuadBuilder.java @@ -7,6 +7,7 @@ import java.util.Iterator; import java.util.ListIterator; import com.seibel.lod.core.api.ApiShared; +import com.seibel.lod.core.builders.lodBuilding.LodBuilder; import com.seibel.lod.core.enums.LodDirection; import com.seibel.lod.core.enums.LodDirection.Axis; import com.seibel.lod.core.enums.config.GpuUploadMethod; @@ -24,6 +25,7 @@ public class LodQuadBuilder { static final ILodConfigWrapperSingleton CONFIG = SingletonHandler.get(ILodConfigWrapperSingleton.class); public final boolean skipSkylight0Quads; + public final short skyLightCullingBelow; static class Quad { final short x; @@ -231,49 +233,50 @@ public class LodQuadBuilder { final ArrayList[] quads = new ArrayList[6]; - public LodQuadBuilder(int initialSize, boolean enableSkylightCulling) { + public LodQuadBuilder(int initialSize, boolean enableSkylightCulling, int skyLightCullingBelow) { for (int i=0; i<6; i++) quads[i] = new ArrayList(); this.skipSkylight0Quads = enableSkylightCulling; + this.skyLightCullingBelow = (short) (skyLightCullingBelow - LodBuilder.MIN_WORLD_HEIGHT); } public void addQuadAdj(LodDirection dir, short x, short y, short z, short w0, short wy, int color, byte skylight, byte blocklight) { if (dir.ordinal() <= LodDirection.DOWN.ordinal()) throw new IllegalArgumentException("addQuadAdj() is only for adj direction! Not UP or Down!"); - if (skipSkylight0Quads && skylight==0) return; + if (skipSkylight0Quads && skylight==0 && y < skyLightCullingBelow) return; quads[dir.ordinal()].add(new Quad(x, y, z, w0, wy, color, skylight, blocklight, dir)); } // XZ public void addQuadUp(short x, short y, short z, short wx, short wz, int color, byte skylight, byte blocklight) { - if (skipSkylight0Quads && skylight==0) return; + if (skipSkylight0Quads && skylight==0 && y < skyLightCullingBelow) return; quads[LodDirection.UP.ordinal()].add(new Quad(x, y, z, wx, wz, color, skylight, blocklight, LodDirection.UP)); } public void addQuadDown(short x, short y, short z, short wx, short wz, int color, byte skylight, byte blocklight) { - if (skipSkylight0Quads && skylight==0) return; + if (skipSkylight0Quads && skylight==0 && y < skyLightCullingBelow) return; quads[LodDirection.DOWN.ordinal()].add(new Quad(x, y, z, wx, wz, color, skylight, blocklight, LodDirection.DOWN)); } // XY public void addQuadN(short x, short y, short z, short wx, short wy, int color, byte skylight, byte blocklight) { - if (skipSkylight0Quads && skylight==0) return; + if (skipSkylight0Quads && skylight==0 && y < skyLightCullingBelow) return; quads[LodDirection.NORTH.ordinal()].add(new Quad(x, y, z, wx, wy, color, skylight, blocklight, LodDirection.NORTH)); } public void addQuadS(short x, short y, short z, short wx, short wy, int color, byte skylight, byte blocklight) { - if (skipSkylight0Quads && skylight==0) return; + if (skipSkylight0Quads && skylight==0 && y < skyLightCullingBelow) return; quads[LodDirection.SOUTH.ordinal()].add(new Quad(x, y, z, wx, wy, color, skylight, blocklight, LodDirection.SOUTH)); } // ZY public void addQuadW(short x, short y, short z, short wz, short wy, int color, byte skylight, byte blocklight) { - if (skipSkylight0Quads && skylight==0) return; + if (skipSkylight0Quads && skylight==0 && y < skyLightCullingBelow) return; quads[LodDirection.WEST.ordinal()].add(new Quad(x, y, z, wz, wy, color, skylight, blocklight, LodDirection.WEST)); } public void addQuadE(short x, short y, short z, short wz, short wy, int color, byte skylight, byte blocklight) { - if (skipSkylight0Quads && skylight==0) return; + if (skipSkylight0Quads && skylight==0 && y < skyLightCullingBelow) return; quads[LodDirection.EAST.ordinal()].add(new Quad(x, y, z, wz, wy, color, skylight, blocklight, LodDirection.EAST)); } diff --git a/src/main/java/com/seibel/lod/core/objects/opengl/RenderRegion.java b/src/main/java/com/seibel/lod/core/objects/opengl/RenderRegion.java index bdf3d04fd..7a3395297 100644 --- a/src/main/java/com/seibel/lod/core/objects/opengl/RenderRegion.java +++ b/src/main/java/com/seibel/lod/core/objects/opengl/RenderRegion.java @@ -172,7 +172,9 @@ public class RenderRegion implements AutoCloseable boolean useSkylightCulling = CONFIG.client().graphics().advancedGraphics().getEnableCaveCulling(); useSkylightCulling &= !lodDim.dimension.hasCeiling(); useSkylightCulling &= lodDim.dimension.hasSkyLight(); - LodQuadBuilder builder = new LodQuadBuilder(10, useSkylightCulling); + //TODO: Add config for skyLightCullingBelow + int skyLightCullingBelow = 40; + LodQuadBuilder builder = new LodQuadBuilder(10, useSkylightCulling, skyLightCullingBelow); Runnable buildRun = ()->{ makeLodRenderData(builder, region, adjRegions, playerPosX, playerPosZ); };