This commit is contained in:
mcrcortex
2025-05-04 11:50:49 +10:00
parent 74bda196f0
commit 94223738ec
3 changed files with 17 additions and 7 deletions

View File

@@ -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 //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) { public void render(Viewport<?> viewport) {
if (!this.remQueue.isEmpty()) { if (!this.remQueue.isEmpty()) {
boolean wasEmpty = this.chunk2idx.isEmpty();
this.remQueue.forEach(this::_remPos); this.remQueue.forEach(this::_remPos);
this.remQueue.clear(); 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) { if (this.depthBuffer.getWidth() != viewport.width || this.depthBuffer.getHeight() != viewport.height) {
this.depthBuffer.free(); this.depthBuffer.free();
this.depthBuffer = new GlTexture().store(GL_DEPTH_COMPONENT24, 1, viewport.width, viewport.height); this.depthBuffer = new GlTexture().store(GL_DEPTH_COMPONENT24, 1, viewport.width, viewport.height);
this.frameBuffer.bind(GL_DEPTH_ATTACHMENT, this.depthBuffer).verify(); 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 ptr = UploadStream.INSTANCE.upload(this.uniformBuffer, 0, 128);
long matPtr = ptr; ptr += 4*4*4; long matPtr = ptr; ptr += 4*4*4;
{//This is recomputed to be in chunk section space not worldsection {//This is recomputed to be in chunk section space not worldsection

View File

@@ -25,12 +25,18 @@ void main() {
discard; discard;
} }
vec2 uv = mod(uv, vec2(1.0))*(1.0/(vec2(3.0,2.0)*256.0)); 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 = 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) { if ((flags&1u) == 1 && colour.a <= 0.25f) {
#ifndef DEBUG_RENDER //This is stupidly stupidly bad for divergence
discard; //TODO: FIXME, basicly what this do is sample the exact pixel (no lod) for discarding, this stops mipmapping fucking it over
#endif 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 //Conditional tinting, TODO: FIXME: REPLACE WITH MASK OR SOMETHING, like encode data into the top bit of alpha

View File

@@ -42,7 +42,7 @@ vec4 uint2vec4RGBA(uint colour) {
} }
vec4 getFaceSize(uint faceData) { vec4 getFaceSize(uint faceData) {
float EPSILON = 0.001f; float EPSILON = 0.0005f;
vec4 faceOffsetsSizes = extractFaceSizes(faceData); vec4 faceOffsetsSizes = extractFaceSizes(faceData);