From 5e72b945c4ee40a36f5af7ceb6f8f1a56b3ffc7f Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Tue, 24 Sep 2024 13:38:49 +1000 Subject: [PATCH] debug pain --- .../voxy/client/core/rendering/RenderService.java | 6 +++--- .../voxy/client/core/rendering/util/HiZBuffer.java | 2 +- src/main/resources/assets/voxy/shaders/hiz/blit.fsh | 1 + .../voxy/shaders/lod/hierarchical/screenspace.glsl | 10 +++++++--- .../voxy/shaders/lod/hierarchical/traversal_dev.comp | 6 +++--- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/RenderService.java b/src/main/java/me/cortex/voxy/client/core/rendering/RenderService.java index 6af7059c..d67044e8 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/RenderService.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/RenderService.java @@ -69,7 +69,7 @@ public class RenderService, J extends Vi this.sectionUpdateQueue.push(section); }); - this.traversal = new HierarchicalOcclusionTraverser(this.nodeManager, 512); + this.traversal = new HierarchicalOcclusionTraverser(this.nodeManager, 256); world.setDirtyCallback(router::forward); @@ -79,7 +79,7 @@ public class RenderService, J extends Vi //this.nodeManager.insertTopLevelNode(WorldEngine.getWorldSectionId(0, 0,0,0)); //this.nodeManager.insertTopLevelNode(WorldEngine.getWorldSectionId(4, 0,0,0)); - + /* final int H_WIDTH = 10; for (int x = -H_WIDTH; x <= H_WIDTH; x++) { for (int y = -1; y <= 0; y++) { @@ -87,7 +87,7 @@ public class RenderService, J extends Vi this.nodeManager.insertTopLevelNode(WorldEngine.getWorldSectionId(4, x, y, z)); } } - } + }*/ } public void setup(Camera camera) { diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/util/HiZBuffer.java b/src/main/java/me/cortex/voxy/client/core/rendering/util/HiZBuffer.java index 7d17d2fb..03205562 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/util/HiZBuffer.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/util/HiZBuffer.java @@ -38,7 +38,7 @@ public class HiZBuffer { private void alloc(int width, int height) { this.levels = (int)Math.ceil(Math.log(Math.max(width, height))/Math.log(2)); //We dont care about e.g. 1x1 size texture since you dont get meshlets that big to cover such a large area - this.levels -= 3;//Arbitrary size, shinks the max level by alot and saves a significant amount of processing time + this.levels -= 1;//Arbitrary size, shinks the max level by alot and saves a significant amount of processing time // (could probably increase it to be defined by a max meshlet coverage computation thing) //GL_DEPTH_COMPONENT32F //Cant use this as it does not match the depth format of the provided depth buffer diff --git a/src/main/resources/assets/voxy/shaders/hiz/blit.fsh b/src/main/resources/assets/voxy/shaders/hiz/blit.fsh index 8dc82bc1..1052ff9e 100644 --- a/src/main/resources/assets/voxy/shaders/hiz/blit.fsh +++ b/src/main/resources/assets/voxy/shaders/hiz/blit.fsh @@ -5,5 +5,6 @@ layout(location = 0) in vec2 uv; layout(binding = 0) uniform sampler2D depthTex; void main() { vec4 depths = textureGather(depthTex, uv, 0); // Get depth values from all surrounding texels. + //depths = mix(vec4(0), depths, lessThanEqual(vec4(0.99999999), depths)); gl_FragDepth = max(max(depths.x, depths.y), max(depths.z, depths.w)); // Write conservative depth. } \ No newline at end of file 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 a969f5ed..ffdf9f91 100644 --- a/src/main/resources/assets/voxy/shaders/lod/hierarchical/screenspace.glsl +++ b/src/main/resources/assets/voxy/shaders/lod/hierarchical/screenspace.glsl @@ -69,7 +69,7 @@ void setupScreenspace(in UnpackedNode node) { maxBB = maxBB*0.5f+0.5f; minBB = minBB*0.5f+0.5f; - size = (maxBB.xy - minBB.xy);//We half it for implicit conversion to screenspace + size = clamp(maxBB.xy - minBB.xy, vec2(0), vec2(1));//We half it for implicit conversion to screenspace } @@ -85,8 +85,12 @@ bool isCulledByHiz() { vec2 ssize = size.xy * vec2(screenW, screenH); float miplevel = ceil(log2(max(max(ssize.x, ssize.y),1))); vec2 midpoint = (maxBB.xy + minBB.xy)*0.5f; - // printf("HiZ sample point culled: (%f,%f)@%f against %f", midpoint.x, midpoint.y, miplevel, minBB.z); - return textureLod(hizDepthSampler, vec3(midpoint, minBB.z), miplevel) < 0.0001f; + bool culled = textureLod(hizDepthSampler, vec3(midpoint, minBB.z), miplevel) < 0.0001f; + /* + if (culled) { + printf("HiZ sample point not culled: (%f,%f)@%f against %f, level %d", midpoint.x, midpoint.y, miplevel, minBB.z, lod); + }*/ + return culled; } //Returns if we should decend into its children or not diff --git a/src/main/resources/assets/voxy/shaders/lod/hierarchical/traversal_dev.comp b/src/main/resources/assets/voxy/shaders/lod/hierarchical/traversal_dev.comp index c3062d7a..510929fa 100644 --- a/src/main/resources/assets/voxy/shaders/lod/hierarchical/traversal_dev.comp +++ b/src/main/resources/assets/voxy/shaders/lod/hierarchical/traversal_dev.comp @@ -72,7 +72,7 @@ void traverse(in UnpackedNode node) { //printf("A"); enqueueChildren(node); } else { - printf("B"); + //printf("B"); addRequest(node); //TODO: use self mesh (is error state if it doesnt have one since all leaf nodes should have a mesh) // Basicly guarenteed to have a mesh, if it doesnt it is very very bad and incorect since its a violation of the graph properties @@ -81,10 +81,10 @@ void traverse(in UnpackedNode node) { } } else { if (hasMesh(node)) { - printf("C"); + //printf("C"); enqueueSelfForRender(node); } else { - printf("D"); + //printf("D"); //!! not ideal, we want to render this mesh but dont have it. If we havent sent a request // then send a request for a mesh for this node. addRequest(node);