From a62413ed0b65d82b12e771fdd907ba2636096b71 Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Fri, 13 Dec 2024 15:57:51 +1000 Subject: [PATCH] Thanks gore for the help, add extra frustum check --- .../shaders/lod/hierarchical/screenspace.glsl | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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 c92cce0d..3316d477 100644 --- a/src/main/resources/assets/voxy/shaders/lod/hierarchical/screenspace.glsl +++ b/src/main/resources/assets/voxy/shaders/lod/hierarchical/screenspace.glsl @@ -20,6 +20,7 @@ layout(binding = HIZ_BINDING) uniform sampler2DShadow hizDepthSampler; vec3 minBB; vec3 maxBB; vec2 size; +float zThing; //Sets up screenspace with the given node id, returns true on success false on failure/should not continue //Accesses data that is setup in the main traversal and is just shared to here @@ -43,11 +44,13 @@ void setupScreenspace(in UnpackedNode node) { minBB = base.xyz/base.w; maxBB = minBB; + zThing = -999999999999.0f; for (int i = 1; i < 8; i++) { //NOTE!: cant this be precomputed and put in an array?? in the scene uniform?? vec4 pPoint = (VP*vec4(vec3((i&1)!=0,(i&2)!=0,(i&4)!=0)*(32< 1) { - return false; - } + vec2 ssize = size * vec2(screenW, screenH); float miplevel = ceil(log2(max(max(ssize.x, ssize.y),1)))-1; @@ -92,7 +93,7 @@ bool isCulledByHiz() { //TODO: maybe get rid of clamp //Todo: replace with some rasterization, e.g. especially for request back to cpu midpoint = clamp(midpoint, vec2(0), vec2(1)); - bool culled = textureLod(hizDepthSampler, vec3(midpoint, minBB.z*0.5f+0.5f), miplevel) < 0.0001f; + bool culled = textureLod(hizDepthSampler, vec3(midpoint, minBB.z), miplevel) < 0.0001f; if (culled) { printf("HiZ sample point culled: (%f,%f)@%f against %f", midpoint.x, midpoint.y, miplevel, minBB.z);