From 11f7041df01dcb647648df14d47e818cc10d43c6 Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Sun, 10 Aug 2025 09:44:20 +1000 Subject: [PATCH] misc --- .../cortex/voxy/client/config/VoxyConfig.java | 4 ++++ .../core/model/bakery/GlViewCapture.java | 1 + .../core/model/bakery/ModelTextureBakery.java | 2 ++ .../core/rendering/section/MDICViewport.java | 2 +- .../MixinClientLoginNetworkHandler.java | 2 +- .../mixin/minecraft/MixinWorldRenderer.java | 2 +- .../world/service/VoxelIngestService.java | 18 ++++++++++++++++++ .../post/blit_texture_depth_cutout.frag | 2 +- .../assets/voxy/shaders/post/fullscreen2.vert | 2 +- 9 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/main/java/me/cortex/voxy/client/config/VoxyConfig.java b/src/main/java/me/cortex/voxy/client/config/VoxyConfig.java index c7f0c311..9135b6fc 100644 --- a/src/main/java/me/cortex/voxy/client/config/VoxyConfig.java +++ b/src/main/java/me/cortex/voxy/client/config/VoxyConfig.java @@ -79,4 +79,8 @@ public class VoxyConfig implements OptionStorage { public VoxyConfig getData() { return this; } + + public boolean isRenderingEnabled() { + return VoxyCommon.isAvailable() && this.enabled && this.enableRendering; + } } diff --git a/src/main/java/me/cortex/voxy/client/core/model/bakery/GlViewCapture.java b/src/main/java/me/cortex/voxy/client/core/model/bakery/GlViewCapture.java index d8906083..8931369d 100644 --- a/src/main/java/me/cortex/voxy/client/core/model/bakery/GlViewCapture.java +++ b/src/main/java/me/cortex/voxy/client/core/model/bakery/GlViewCapture.java @@ -62,6 +62,7 @@ public class GlViewCapture { glBindBufferRange(GL_SHADER_STORAGE_BUFFER, 3, buffer, offset, (this.width*3L)*(this.height*2L)*4L*2);//its 2*4 because colour + depth stencil glMemoryBarrier(GL_FRAMEBUFFER_BARRIER_BIT|GL_TEXTURE_UPDATE_BARRIER_BIT|GL_PIXEL_BUFFER_BARRIER_BIT|GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);//Am not sure if barriers are right glDispatchCompute(3, 2, 1); + glBindBufferRange(GL_SHADER_STORAGE_BUFFER, 3, 0, 0, 4);//WHY DOES THIS FIX FUCKING BINDING ISSUES HERE WHEN DOING THIS IN THE RENDER SYSTEM DOESNT } public void clear() { diff --git a/src/main/java/me/cortex/voxy/client/core/model/bakery/ModelTextureBakery.java b/src/main/java/me/cortex/voxy/client/core/model/bakery/ModelTextureBakery.java index bb0dd219..c0eb5a34 100644 --- a/src/main/java/me/cortex/voxy/client/core/model/bakery/ModelTextureBakery.java +++ b/src/main/java/me/cortex/voxy/client/core/model/bakery/ModelTextureBakery.java @@ -242,6 +242,7 @@ public class ModelTextureBakery { } glBindVertexArray(0); } else {//Is fluid, slow path :( + if (!(state.getBlock() instanceof FluidBlock)) throw new IllegalStateException(); var mat = new Matrix4f(); @@ -300,6 +301,7 @@ public class ModelTextureBakery { } + //"Restore" gl state glViewport(viewdat[0], viewdat[1], viewdat[2], viewdat[3]); glDisable(GL_STENCIL_TEST); diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/section/MDICViewport.java b/src/main/java/me/cortex/voxy/client/core/rendering/section/MDICViewport.java index e28ffb47..e92f18f3 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/section/MDICViewport.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/section/MDICViewport.java @@ -8,7 +8,7 @@ public class MDICViewport extends Viewport { public final GlBuffer drawCountCallBuffer = new GlBuffer(1024).zero(); public final GlBuffer drawCallBuffer = new GlBuffer(5*4*(400_000+100_000+100_000)).zero();//400k draw calls public final GlBuffer positionScratchBuffer = new GlBuffer(8*400000).zero();//400k positions - public final GlBuffer indirectLookupBuffer = new GlBuffer(HierarchicalOcclusionTraverser.MAX_QUEUE_SIZE *4+4); + public final GlBuffer indirectLookupBuffer = new GlBuffer(HierarchicalOcclusionTraverser.MAX_QUEUE_SIZE *4+4);//In theory, this could be global/not unique to the viewport public final GlBuffer visibilityBuffer; public MDICViewport(int maxSectionCount) { diff --git a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinClientLoginNetworkHandler.java b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinClientLoginNetworkHandler.java index 173b1d41..bf4a0f01 100644 --- a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinClientLoginNetworkHandler.java +++ b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinClientLoginNetworkHandler.java @@ -12,7 +12,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ClientPlayNetworkHandler.class) public class MixinClientLoginNetworkHandler { - @Inject(method = "onGameJoin", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;(Lnet/minecraft/client/MinecraftClient;Lnet/minecraft/client/network/ClientPlayNetworkHandler;)V", shift = At.Shift.BY, by = 2)) + @Inject(method = "onGameJoin", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/GameJoinS2CPacket;commonPlayerSpawnInfo()Lnet/minecraft/network/packet/s2c/play/CommonPlayerSpawnInfo;")) private void voxy$init(GameJoinS2CPacket packet, CallbackInfo ci) { if (VoxyCommon.isAvailable()) { VoxyClientInstance.isInGame = true; diff --git a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinWorldRenderer.java b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinWorldRenderer.java index 2cf670d7..cdb10039 100644 --- a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinWorldRenderer.java +++ b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinWorldRenderer.java @@ -61,7 +61,7 @@ public abstract class MixinWorldRenderer implements IGetVoxyRenderSystem { @Override public void createRenderer() { if (this.renderer != null) throw new IllegalStateException("Cannot have multiple renderers"); - if ((!VoxyConfig.CONFIG.enableRendering)||(!VoxyConfig.CONFIG.enabled)) { + if (!VoxyConfig.CONFIG.isRenderingEnabled()) { Logger.info("Not creating renderer due to disabled"); return; } diff --git a/src/main/java/me/cortex/voxy/common/world/service/VoxelIngestService.java b/src/main/java/me/cortex/voxy/common/world/service/VoxelIngestService.java index 6bf28192..e58f6b1c 100644 --- a/src/main/java/me/cortex/voxy/common/world/service/VoxelIngestService.java +++ b/src/main/java/me/cortex/voxy/common/world/service/VoxelIngestService.java @@ -96,9 +96,11 @@ public class VoxelIngestService { boolean gotLighting = false; int i = chunk.getBottomSectionCoord() - 1; + boolean allEmpty = true; for (var section : chunk.getSectionArray()) { i++; if (section == null || !shouldIngestSection(section, chunk.getPos().x, i, chunk.getPos().z)) continue; + allEmpty&=section.isEmpty(); //if (section.isEmpty()) continue; var pos = ChunkSectionPos.from(chunk.getPos(), i); if (lightingProvider.getStatus(LightType.SKY, pos) != LightStorage.Status.LIGHT_AND_DATA && lightingProvider.getStatus(LightType.BLOCK, pos) != LightStorage.Status.LIGHT_AND_DATA) @@ -106,6 +108,22 @@ public class VoxelIngestService { gotLighting = true; } + if (allEmpty&&!gotLighting) { + //Special case all empty chunk columns, we need to clear it out + i = chunk.getBottomSectionCoord() - 1; + for (var section : chunk.getSectionArray()) { + i++; + if (section == null || !shouldIngestSection(section, chunk.getPos().x, i, chunk.getPos().z)) continue; + this.ingestQueue.add(new IngestSection(chunk.getPos().x, i, chunk.getPos().z, engine, section, null, null)); + try { + this.threads.execute(); + } catch (Exception e) { + Logger.error("Executing had an error: assume shutting down, aborting",e); + break; + } + } + } + if (!gotLighting) { return; } diff --git a/src/main/resources/assets/voxy/shaders/post/blit_texture_depth_cutout.frag b/src/main/resources/assets/voxy/shaders/post/blit_texture_depth_cutout.frag index 84c2384c..c3121ce2 100644 --- a/src/main/resources/assets/voxy/shaders/post/blit_texture_depth_cutout.frag +++ b/src/main/resources/assets/voxy/shaders/post/blit_texture_depth_cutout.frag @@ -26,7 +26,7 @@ float projDepth(vec3 pos) { void main() { float depth = texture(depthTex, UV.xy).r; - if (depth == 0.0f) { + if (depth == 0.0f || depth == 1.0) { discard; } diff --git a/src/main/resources/assets/voxy/shaders/post/fullscreen2.vert b/src/main/resources/assets/voxy/shaders/post/fullscreen2.vert index 884b1d56..49889387 100644 --- a/src/main/resources/assets/voxy/shaders/post/fullscreen2.vert +++ b/src/main/resources/assets/voxy/shaders/post/fullscreen2.vert @@ -2,6 +2,6 @@ out vec2 UV; void main() { - gl_Position = vec4(vec2(gl_VertexID&1, (gl_VertexID>>1)&1) * 4 - 1, 1f, 1); + gl_Position = vec4(vec2(gl_VertexID&1, (gl_VertexID>>1)&1) * 4 - 1, 1.0f, 1); UV = gl_Position.xy*0.5+0.5; } \ No newline at end of file