From 94223738ecaca5d16c4ec174f5bcedc74511fce1 Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Sun, 4 May 2025 11:50:49 +1000 Subject: [PATCH] tinker --- .../client/core/rendering/ChunkBoundRenderer.java | 8 ++++++-- .../assets/voxy/shaders/lod/gl46/quads.frag | 14 ++++++++++---- .../assets/voxy/shaders/lod/gl46/quads2.vert | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/ChunkBoundRenderer.java b/src/main/java/me/cortex/voxy/client/core/rendering/ChunkBoundRenderer.java index 44b18bb9..3f1476cf 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/ChunkBoundRenderer.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/ChunkBoundRenderer.java @@ -66,18 +66,22 @@ public class ChunkBoundRenderer { //Bind and render, changing as little gl state as possible so that the caller may configure how it wants to render public void render(Viewport viewport) { if (!this.remQueue.isEmpty()) { + boolean wasEmpty = this.chunk2idx.isEmpty(); this.remQueue.forEach(this::_remPos); this.remQueue.clear(); + if (this.chunk2idx.isEmpty()&&!wasEmpty) {//When going from stuff to nothing need to clear the depth buffer + glClearNamedFramebufferfv(this.frameBuffer.id, GL_DEPTH, 0, new float[]{0}); + } } - if (this.chunk2idx.isEmpty() && this.addQueue.isEmpty()) return; - if (this.depthBuffer.getWidth() != viewport.width || this.depthBuffer.getHeight() != viewport.height) { this.depthBuffer.free(); this.depthBuffer = new GlTexture().store(GL_DEPTH_COMPONENT24, 1, viewport.width, viewport.height); this.frameBuffer.bind(GL_DEPTH_ATTACHMENT, this.depthBuffer).verify(); } + if (this.chunk2idx.isEmpty() && this.addQueue.isEmpty()) return; + long ptr = UploadStream.INSTANCE.upload(this.uniformBuffer, 0, 128); long matPtr = ptr; ptr += 4*4*4; {//This is recomputed to be in chunk section space not worldsection diff --git a/src/main/resources/assets/voxy/shaders/lod/gl46/quads.frag b/src/main/resources/assets/voxy/shaders/lod/gl46/quads.frag index 9d8b13d8..08ac61a2 100644 --- a/src/main/resources/assets/voxy/shaders/lod/gl46/quads.frag +++ b/src/main/resources/assets/voxy/shaders/lod/gl46/quads.frag @@ -25,12 +25,18 @@ void main() { discard; } vec2 uv = mod(uv, vec2(1.0))*(1.0/(vec2(3.0,2.0)*256.0)); + vec2 texPos = uv + baseUV; //vec4 colour = solidColour; - vec4 colour = texture(blockModelAtlas, uv + baseUV, ((flags>>1)&1u)*-4.0); + vec4 colour = texture(blockModelAtlas, texPos, ((flags>>1)&1u)*-5.0);//TODO: FIXME mipping needs to be fixed so that it doesnt go cross model bounds + //Also, small quad is really fking over the mipping level somehow if ((flags&1u) == 1 && colour.a <= 0.25f) { - #ifndef DEBUG_RENDER - discard; - #endif + //This is stupidly stupidly bad for divergence + //TODO: FIXME, basicly what this do is sample the exact pixel (no lod) for discarding, this stops mipmapping fucking it over + if (texture(blockModelAtlas, texPos, -4.0).a <= 0.1f) { + #ifndef DEBUG_RENDER + discard; + #endif + } } //Conditional tinting, TODO: FIXME: REPLACE WITH MASK OR SOMETHING, like encode data into the top bit of alpha diff --git a/src/main/resources/assets/voxy/shaders/lod/gl46/quads2.vert b/src/main/resources/assets/voxy/shaders/lod/gl46/quads2.vert index a1f6cc21..bc54bbe8 100644 --- a/src/main/resources/assets/voxy/shaders/lod/gl46/quads2.vert +++ b/src/main/resources/assets/voxy/shaders/lod/gl46/quads2.vert @@ -42,7 +42,7 @@ vec4 uint2vec4RGBA(uint colour) { } vec4 getFaceSize(uint faceData) { - float EPSILON = 0.001f; + float EPSILON = 0.0005f; vec4 faceOffsetsSizes = extractFaceSizes(faceData);