From f91165857d1bb0e9bf29e01617c8b5774b7a41ae Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 8 Jul 2024 06:02:01 +0200 Subject: [PATCH] scale and fade out dither pattern makes the image a bit cleaner and easier to look at in palrender --- src/hardware/hw_shaders.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index 5c349555c..07f44471e 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -72,6 +72,9 @@ "if (scr_resolution.y > 720.0) {\n" \ "halfResolutiony = scr_resolution.y * 0.5;\n" \ "}\n" \ + "float zFactor = clamp((z - 768.0) / (2304.0 - 768.0), 0.0, 1.0);\n" \ + "halfResolutionx = mix(halfResolutionx, halfResolutionx * 2.0, zFactor);\n" \ + "halfResolutiony = mix(halfResolutiony, halfResolutiony * 2.0, zFactor);\n" \ "vec2 normalizedPosition = position * vec2(halfResolutionx / scr_resolution.x, halfResolutiony / scr_resolution.y);\n" \ "int x = int(mod(normalizedPosition.x, 4.0));\n" \ "int y = int(mod(normalizedPosition.y, 4.0));\n" \ @@ -82,9 +85,9 @@ "15.0, 7.0, 13.0, 5.0\n" \ ");\n" \ "#ifdef SRB2_PALETTE_RENDERING\n" \ - "float threshold = bayerMatrix[y*4 + x] / 12.0;\n" \ + "float threshold = (1.0 - pow(zFactor, 2.0)) * (bayerMatrix[y*4 + x] / 11.0);\n" \ "#else\n" \ - "float threshold = bayerMatrix[y*4 + x] / 16.0;\n" \ + "float threshold = (1.0 - pow(zFactor, 2.0)) * (bayerMatrix[y*4 + x] / 16.0);\n" \ "#endif\n" \ "return baseValue + threshold - 0.5 / 16.0;\n" \