From 4e1430bd76dbf43702df0096513a7753861112bf Mon Sep 17 00:00:00 2001 From: Xenthio Date: Tue, 10 Sep 2024 13:49:43 +1000 Subject: [PATCH 1/3] Less Z fighting with DepthFunc GL_LESS+PolyOffset --- .../voxy/client/core/rendering/post/PostProcessing.java | 6 ++++++ 1 file changed, 6 insertions(+) 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 8aaab9bf..fdf69fbb 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 @@ -188,6 +188,12 @@ public void renderPost(Matrix4f fromProjection, Matrix4f tooProjection, int outp glBindTexture(GL_TEXTURE_2D, this.didSSAO?this.colourSSAO.id:this.colour.id); glEnable(GL_DEPTH_TEST); glDepthMask(true); + + // This helps avoid some overlap and z fighting in transparency. + glEnable( GL_POLYGON_OFFSET_FILL ); + glPolygonOffset( 1.0f, 4.0f ); + glDepthFunc(GL_LESS); + this.blitTexture.blit(); glDisable(GL_DEPTH_TEST); glDepthMask(true); From 6149ce9466f1acb36c10b1aa9e74746733286f81 Mon Sep 17 00:00:00 2001 From: Xenthio Date: Fri, 20 Sep 2024 15:39:35 +1000 Subject: [PATCH 2/3] Disable offset once done --- .../cortex/voxy/client/core/rendering/post/PostProcessing.java | 1 + 1 file changed, 1 insertion(+) 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 fdf69fbb..9dda2089 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 @@ -197,6 +197,7 @@ public void renderPost(Matrix4f fromProjection, Matrix4f tooProjection, int outp this.blitTexture.blit(); glDisable(GL_DEPTH_TEST); glDepthMask(true); + glDisable( GL_POLYGON_OFFSET_FILL ); this.glStateCapture.restore(); } From 8b89e02012ba73184c49e77f875eeb1a6332c541 Mon Sep 17 00:00:00 2001 From: Xenthio Date: Fri, 20 Sep 2024 18:08:03 +1000 Subject: [PATCH 3/3] Reset DepthFunc too --- .../cortex/voxy/client/core/rendering/post/PostProcessing.java | 1 + 1 file changed, 1 insertion(+) 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 9dda2089..8f87b55b 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 @@ -198,6 +198,7 @@ public void renderPost(Matrix4f fromProjection, Matrix4f tooProjection, int outp glDisable(GL_DEPTH_TEST); glDepthMask(true); glDisable( GL_POLYGON_OFFSET_FILL ); + glDepthFunc(GL_LEQUAL); this.glStateCapture.restore(); }