Size 62 meshlets + major fix for hiz culling

This commit is contained in:
mcrcortex
2024-05-09 21:46:42 +10:00
parent 7a6669fb7d
commit b885d7c1ec
6 changed files with 48 additions and 13 deletions

View File

@@ -46,7 +46,7 @@ struct DispatchIndirect {
};
#ifdef BIND_SAMPLER_AS_HIZ
layout(binding = 0) uniform sampler2D hizSampler;
layout(binding = 0) uniform sampler2DShadow hizSampler;
#else
layout(binding = 0) uniform sampler2D blockModelAtlas;
#endif

View File

@@ -1,5 +1,3 @@
#define QUADS_PER_MESHLET 30
#define extractMeshletStart extractQuadStart
#define PosHeader Quad
#define AABBHeader Quad

View File

@@ -32,19 +32,22 @@ bool testHiZ(PosHeader secPos, AABBHeader aabb) {
maxBB = max(maxBB, point);
}
minBB = minBB*0.5+0.5;
maxBB = maxBB*0.5+0.5;
minBB = clamp(minBB*0.5+0.5, vec3(0), vec3(1));
maxBB = clamp(maxBB*0.5+0.5, vec3(0), vec3(1));
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;
float c = textureLod(hizSampler,maxBB.xy,miplevel).r;
float d = textureLod(hizSampler,vec2(maxBB.x,minBB.y),miplevel).r;
float depth = max(max(a,b),max(c,d));
return minBB.z <= depth;
*/
vec2 midpoint = (maxBB.xy + minBB.xy)*0.5;
return textureLod(hizSampler, vec3(midpoint, minBB.z - 0.000000001), miplevel) > 0.0001;
}