attempted fix for incorrect sampling of depth buffer stuffs

This commit is contained in:
MCRcortex
2025-11-10 11:23:00 +10:00
parent bf5b8d76d2
commit 560ba41fa5
3 changed files with 11 additions and 3 deletions

View File

@@ -53,6 +53,11 @@ public abstract class AbstractRenderPipeline extends TrackedObject {
private final FullscreenBlit depthMaskBlit = new FullscreenBlit("voxy:post/fullscreen2.vert", "voxy:post/noop.frag");
private final FullscreenBlit depthSetBlit = new FullscreenBlit("voxy:post/fullscreen2.vert", "voxy:post/depth0.frag");
private final FullscreenBlit depthCopy = new FullscreenBlit("voxy:post/fullscreen2.vert", "voxy:post/depth_copy.frag");
private static final int DEPTH_SAMPLER = glGenSamplers();
static {
glSamplerParameteri(DEPTH_SAMPLER, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glSamplerParameteri(DEPTH_SAMPLER, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
protected AbstractRenderPipeline(AsyncNodeManager nodeManager, NodeCleaner nodeCleaner, HierarchicalOcclusionTraverser traversal, BooleanSupplier frexSupplier) {
this.frexStillHasWork = frexSupplier;
@@ -109,9 +114,11 @@ public abstract class AbstractRenderPipeline extends TrackedObject {
// the mismatched formats in this case is the d32 to d24s8
glBindFramebuffer(GL30.GL_FRAMEBUFFER, targetFb);
this.depthCopy.bind();
int depthTexture = glGetNamedFramebufferAttachmentParameteri(sourceFrameBuffer, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME);
glBindTextureUnit(0, depthTexture);
glBindSampler(0, DEPTH_SAMPLER);
glUniform2f(1,((float)width)/srcWidth, ((float)height)/srcHeight);
glColorMask(false,false,false,false);
this.depthCopy.blit();

View File

@@ -113,7 +113,7 @@ public class IrisVoxyRenderPipeline extends AbstractRenderPipeline {
glClear(GL_COLOR_BUFFER_BIT);
}
if (this.data.useViewportDims) {
if (!this.data.useViewportDims) {
srcWidth = viewport.width;
srcHeight = viewport.height;
}

View File

@@ -1,8 +1,9 @@
#version 330 core
layout(binding = 0) uniform sampler2D depthTex;
layout(location = 1) uniform vec2 scaleFactor;
in vec2 UV;
void main() {
gl_FragDepth = texture(depthTex, UV).r;
gl_FragDepth = texture(depthTex, UV*scaleFactor).r;
}