From 3b25d2d535fc6b040b8ba39d666c8f41fc23b67d Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Thu, 5 Dec 2024 00:28:06 +1000 Subject: [PATCH] Fix postprocessing being weird --- .../voxy/client/core/rendering/post/PostProcessing.java | 3 +++ .../assets/voxy/shaders/post/blit_texture_depth_cutout.frag | 4 ++++ src/main/resources/assets/voxy/shaders/post/ssao.comp | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/post/PostProcessing.java b/src/main/java/me/cortex/voxy/client/core/rendering/post/PostProcessing.java index 0b150799..cf6ec1d8 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/post/PostProcessing.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/post/PostProcessing.java @@ -108,6 +108,9 @@ public class PostProcessing { this.setSize(width, height); glBindFramebuffer(GL_FRAMEBUFFER, this.framebuffer.id); + + //glClearColor(0,0,0,0);//TODO: RESTORE THIS TO THE ORIGINAL VALUE + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glBlitNamedFramebuffer(sourceFB, this.framebuffer.id, 0,0, width, height, 0,0, width, height, GL_DEPTH_BUFFER_BIT, GL_NEAREST); diff --git a/src/main/resources/assets/voxy/shaders/post/blit_texture_depth_cutout.frag b/src/main/resources/assets/voxy/shaders/post/blit_texture_depth_cutout.frag index 11727125..805e43ca 100644 --- a/src/main/resources/assets/voxy/shaders/post/blit_texture_depth_cutout.frag +++ b/src/main/resources/assets/voxy/shaders/post/blit_texture_depth_cutout.frag @@ -24,6 +24,10 @@ void main() { } float depth = texture(depthTex, UV.xy).r; + if (depth == 0.0f) { + discard; + } + depth = projDepth(rev3d(vec3(UV.xy, depth))); depth = min(1.0f-(2.0f/((1<<24)-1)), depth); depth = depth * 0.5f + 0.5f; diff --git a/src/main/resources/assets/voxy/shaders/post/ssao.comp b/src/main/resources/assets/voxy/shaders/post/ssao.comp index e291e1c9..61c0bf2c 100644 --- a/src/main/resources/assets/voxy/shaders/post/ssao.comp +++ b/src/main/resources/assets/voxy/shaders/post/ssao.comp @@ -53,7 +53,7 @@ void main() { point += scale*0.5f;//Offset to the center of the textile float depth = texture(depthTex, point).r; vec4 ocolour = vec4(0); - if (depth < 1.0f) { + if (depth!=0.0f && depth < 1.0f) { vec4 colour = texture(colourTex, point); if (colour == vec4(0.0f, 0.0f, 0.0f, 0.0f)) { ocolour = vec4(1.0f, 0.0f, 0.0f, 1.0f);