diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/hierachical/HierarchicalOcclusionTraverser.java b/src/main/java/me/cortex/voxy/client/core/rendering/hierachical/HierarchicalOcclusionTraverser.java index cc203ad7..02a4e779 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/hierachical/HierarchicalOcclusionTraverser.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/hierachical/HierarchicalOcclusionTraverser.java @@ -103,12 +103,10 @@ public class HierarchicalOcclusionTraverser { this.nodeBuffer = new GlBuffer(nodeManager.maxNodeCount*16L).fill(-1); - glSamplerParameteri(this.hizSampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); - glSamplerParameteri(this.hizSampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glSamplerParameteri(this.hizSampler, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); + glSamplerParameteri(this.hizSampler, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glSamplerParameteri(this.hizSampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glSamplerParameteri(this.hizSampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glSamplerParameteri(this.hizSampler, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); - glSamplerParameteri(this.hizSampler, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); this.traversal .ubo("SCENE_UNIFORM_BINDING", this.uniformBuffer) diff --git a/src/main/resources/assets/voxy/shaders/lod/hierarchical/screenspace.glsl b/src/main/resources/assets/voxy/shaders/lod/hierarchical/screenspace.glsl index c1ed54b0..fbf78835 100644 --- a/src/main/resources/assets/voxy/shaders/lod/hierarchical/screenspace.glsl +++ b/src/main/resources/assets/voxy/shaders/lod/hierarchical/screenspace.glsl @@ -12,7 +12,7 @@ // substantually for performance (for both persistent threads and incremental) -layout(binding = HIZ_BINDING) uniform sampler2DShadow hizDepthSampler; +layout(binding = HIZ_BINDING) uniform sampler2D hizDepthSampler; //TODO: maybe do spher bounds aswell? cause they have different accuracies but are both over estimates (liberals (non conservative xD)) // so can do && @@ -147,13 +147,23 @@ bool isCulledByHiz() { //the *2.0f-1.0f converts from the 0->1 range to -1->1 range that depth is in (not having this causes tighter bounds, but causes culling issues in caves) testAgainst = testAgainst*2.0f-1.0f; - bool culled = textureLod(hizDepthSampler, clamp(vec3(midpoint, testAgainst), vec3(0), vec3(1)), miplevel) < 0.0001f; + + /* + ivec2 msize = textureSize(hizDepthSampler, int(miplevel)); + ivec2 mxbb = ivec2(maxBB.xy); + ivec2 mnbb = ivec2(minBB.xy);*/ + + float pointSample = textureLod(hizDepthSampler, maxBB.xy, miplevel).x; + pointSample = max(pointSample, textureLod(hizDepthSampler, vec2(maxBB.x, minBB.y), miplevel).x); + pointSample = max(pointSample, textureLod(hizDepthSampler, vec2(minBB.x, maxBB.y), miplevel).x); + pointSample = max(pointSample, textureLod(hizDepthSampler, minBB.xy, miplevel).x); + //printf("HiZ sample point: (%f,%f)@%f against %f", midpoint.x, midpoint.y, miplevel, minBB.z); //if ((culled) && node22.lodLevel == 0) { // printf("HiZ sample point: (%f,%f)@%f against %f, value %f", midpoint.x, midpoint.y, miplevel, minBB.z, textureLod(hizDepthSampler, vec3(0.5f,0.5f, 0.000000001f), 9.0f)); //} - return culled; + return pointSample<=testAgainst; }