diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/Gl46MeshletsFarWorldRenderer.java b/src/main/java/me/cortex/voxy/client/core/rendering/Gl46MeshletsFarWorldRenderer.java index fdb0d8b3..35f0ccc9 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/Gl46MeshletsFarWorldRenderer.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/Gl46MeshletsFarWorldRenderer.java @@ -106,6 +106,8 @@ public class Gl46MeshletsFarWorldRenderer extends AbstractFarWorldRenderer layout(early_fragment_tests) in; diff --git a/src/main/resources/assets/voxy/shaders/lod/gl46mesh/meshletculler.comp b/src/main/resources/assets/voxy/shaders/lod/gl46mesh/meshletculler.comp index 79a45420..5892d391 100644 --- a/src/main/resources/assets/voxy/shaders/lod/gl46mesh/meshletculler.comp +++ b/src/main/resources/assets/voxy/shaders/lod/gl46mesh/meshletculler.comp @@ -35,8 +35,8 @@ bool testHiZ(PosHeader secPos, AABBHeader aabb) { minBB = minBB*0.5+0.5; maxBB = maxBB*0.5+0.5; - vec2 size = (maxBB.xy - minBB.xy) * vec2(screensize); - float miplevel = ceil(log2(max(size.x, size.y)));//NOTE: the /2 is cause the mipmaps dont include bottom level depth + vec2 size = (maxBB.xy - minBB.xy) * vec2(ivec2(screensize)); + float miplevel = ceil(log2(max(max(size.x, size.y),1))); float a = textureLod(hizSampler,minBB.xy,miplevel).r; float b = textureLod(hizSampler,vec2(minBB.x,maxBB.y),miplevel).r; @@ -63,7 +63,7 @@ void main() { PosHeader pos = geometryPool[meshletId*MESHLET_SIZE]; AABBHeader aabb = geometryPool[meshletId*MESHLET_SIZE+1]; - if (testHiZ(pos, aabb) || true) {//If didnt cull, insert it back into the stream + if (testHiZ(pos, aabb)) {//If didnt cull, insert it back into the stream meshlets[atomicAdd(drawCmd.instanceCount, 1)+fullMeshletCount] = meshletId; } } \ No newline at end of file diff --git a/src/main/resources/assets/voxy/shaders/lod/gl46mesh/quads.vert b/src/main/resources/assets/voxy/shaders/lod/gl46mesh/quads.vert index 71cabf5c..92508acb 100644 --- a/src/main/resources/assets/voxy/shaders/lod/gl46mesh/quads.vert +++ b/src/main/resources/assets/voxy/shaders/lod/gl46mesh/quads.vert @@ -1,5 +1,6 @@ #version 450 #extension GL_ARB_gpu_shader_int64 : enable +#extension GL_ARB_shader_draw_parameters : require #import #import @@ -12,7 +13,7 @@ Quad quad; bool setupMeshlet() { gl_CullDistance[0] = 1; //TODO: replace with vertexAttribute that has a divisor of 1 - uint data = meshlets[gl_InstanceID]; + uint data = meshlets[gl_InstanceID + gl_BaseInstanceARB]; if (data == uint(-1)) {//Came across a culled meshlet gl_CullDistance[0] = -1; //Since the primative is culled, dont need to do any more work or set any values as the primative is discarded