sodium extra culling

This commit is contained in:
mcrcortex
2025-12-02 08:57:26 +10:00
parent d371e80e3b
commit 18b13370d8
4 changed files with 36 additions and 2 deletions

View File

@@ -124,6 +124,8 @@ dependencies {
//modCompileOnly("maven.modrinth:immersiveportals:v5.1.7-mc1.20.4") //modCompileOnly("maven.modrinth:immersiveportals:v5.1.7-mc1.20.4")
modCompileOnly("maven.modrinth:sodium-extra:mc1.21.10-0.7.1+fabric")
modRuntimeOnlyMsk("maven.modrinth:sodium-extra:mc1.21.10-0.7.1+fabric")
modCompileOnly("maven.modrinth:chunky:1.4.40-fabric") modCompileOnly("maven.modrinth:chunky:1.4.40-fabric")
//modRuntimeOnlyMsk("maven.modrinth:chunky:1.4.40-fabric") //modRuntimeOnlyMsk("maven.modrinth:chunky:1.4.40-fabric")

View File

@@ -0,0 +1,18 @@
package me.cortex.voxy.client.compat;
import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod;
import net.fabricmc.loader.api.FabricLoader;
public class SodiumExtra {
public static final boolean HAS_SODIUM_EXTRA = FabricLoader.getInstance().isModLoaded("sodium-extra");
public static boolean useSodiumExtraCulling() {
if (!HAS_SODIUM_EXTRA) {
return false;
}
return useSodiumExtraCulling0();
}
private static boolean useSodiumExtraCulling0() {
return !SodiumExtraClientMod.options().renderSettings.globalFog;
}
}

View File

@@ -2,6 +2,8 @@ package me.cortex.voxy.client.core.rendering;
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import me.cortex.voxy.client.VoxyClient;
import me.cortex.voxy.client.compat.SodiumExtra;
import me.cortex.voxy.client.core.AbstractRenderPipeline; import me.cortex.voxy.client.core.AbstractRenderPipeline;
import me.cortex.voxy.client.core.gl.GlBuffer; import me.cortex.voxy.client.core.gl.GlBuffer;
import me.cortex.voxy.client.core.gl.GlVertexArray; import me.cortex.voxy.client.core.gl.GlVertexArray;
@@ -54,6 +56,7 @@ public class ChunkBoundRenderer {
this.rasterShader = Shader.makeAuto() this.rasterShader = Shader.makeAuto()
.addSource(ShaderType.VERTEX, vert) .addSource(ShaderType.VERTEX, vert)
.defineIf("TAA", taa != null) .defineIf("TAA", taa != null)
.defineIf("USE_SODIUM_EXTRA_CULLING", SodiumExtra.useSodiumExtraCulling())
.add(ShaderType.FRAGMENT, "voxy:chunkoutline/outline.fsh") .add(ShaderType.FRAGMENT, "voxy:chunkoutline/outline.fsh")
.compile() .compile()
.ubo(0, this.uniformBuffer) .ubo(0, this.uniformBuffer)

View File

@@ -15,8 +15,19 @@ ivec3 unpackPos(ivec2 pos) {
} }
bool shouldRender(ivec3 icorner) { bool shouldRender(ivec3 icorner) {
vec3 corner = vec3(mix(mix(ivec3(0), icorner-1, greaterThan(icorner-1, ivec3(0))), icorner+17, lessThan(icorner+17, ivec3(0))))-negInnerSec.xyz; #ifdef USE_SODIUM_EXTRA_CULLING
return (corner.x*corner.x + corner.z*corner.z < negInnerSec.w*negInnerSec.w) && abs(corner.y) < negInnerSec.w; #define MIN 0
#define MAX 16
#else
#define MIN 1
#define MAX 17
#endif
vec3 corner = vec3(mix(mix(ivec3(0), icorner-MIN, greaterThan(icorner-MIN, ivec3(0))), icorner+MAX, lessThan(icorner+MAX, ivec3(0))))-negInnerSec.xyz;
bool visible = (corner.x*corner.x + corner.z*corner.z) < (negInnerSec.w*negInnerSec.w);
#ifndef USE_SODIUM_EXTRA_CULLING
visible = visible && abs(corner.y) < negInnerSec.w;
#endif
return visible;
} }
#ifdef TAA #ifdef TAA