This commit is contained in:
mcrcortex
2025-07-12 18:48:25 +10:00
parent 4a140c110f
commit 132c6aa2e8
2 changed files with 10 additions and 2 deletions

View File

@@ -101,7 +101,7 @@ public class GlTexture extends TrackedObject {
private long getEstimatedSize() { private long getEstimatedSize() {
this.assertAllocated(); this.assertAllocated();
long elemSize = switch (this.format) { long elemSize = switch (this.format) {
case GL_RGBA8, GL_DEPTH24_STENCIL8 -> 4; case GL_RGBA8, GL_DEPTH24_STENCIL8, GL_R32F -> 4;
case GL_DEPTH_COMPONENT24 -> 4;//TODO: check this is right???? case GL_DEPTH_COMPONENT24 -> 4;//TODO: check this is right????
case GL_DEPTH_COMPONENT32F -> 4; case GL_DEPTH_COMPONENT32F -> 4;
case GL_DEPTH_COMPONENT32 -> 4; case GL_DEPTH_COMPONENT32 -> 4;

View File

@@ -3,6 +3,9 @@
layout(location = 0) in vec2 uv; layout(location = 0) in vec2 uv;
layout(binding = 0) uniform sampler2D depthTex; layout(binding = 0) uniform sampler2D depthTex;
#ifdef OUTPUT_COLOUR
layout(location=0) out vec4 colour;
#endif
void main() { void main() {
vec4 depths = textureGather(depthTex, uv, 0); // Get depth values from all surrounding texels. vec4 depths = textureGather(depthTex, uv, 0); // Get depth values from all surrounding texels.
@@ -10,6 +13,11 @@ void main() {
if (any(cv)) {//Patch holes (its very dodgy but should work :tm:, should clamp it to the first 3 levels) if (any(cv)) {//Patch holes (its very dodgy but should work :tm:, should clamp it to the first 3 levels)
depths = mix(vec4(0.0f), depths, cv); depths = mix(vec4(0.0f), depths, cv);
} }
float res = max(max(depths.x, depths.y), max(depths.z, depths.w));
gl_FragDepth = max(max(depths.x, depths.y), max(depths.z, depths.w)); // Write conservative depth. #ifdef OUTPUT_COLOUR
colour = vec4(res);
#else
gl_FragDepth = res; // Write conservative depth.
#endif
} }