From 3d19feae426e29148cce31a80f6fc407243859d5 Mon Sep 17 00:00:00 2001 From: IntegratedQuantum Date: Fri, 22 Sep 2023 11:52:21 +0200 Subject: [PATCH] Add dithering when transitioning to raymarching lod. --- assets/cubyz/shaders/chunks/chunk_fragment.fs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/assets/cubyz/shaders/chunks/chunk_fragment.fs b/assets/cubyz/shaders/chunks/chunk_fragment.fs index a23b7cdc..2d797d13 100644 --- a/assets/cubyz/shaders/chunks/chunk_fragment.fs +++ b/assets/cubyz/shaders/chunks/chunk_fragment.fs @@ -227,7 +227,10 @@ bool passDitherTest(float alpha) { void main() { RayMarchResult result; float variance = perpendicularFwidth(direction); - if(variance <= 4.0) { + const float threshold = 1; + const float interpolationRegion = 1.25; + float interp = (variance - threshold)/threshold/(interpolationRegion - 1); + if(!passDitherTest(interp)) { result = rayMarching(startPosition, direction); } else { result = RayMarchResult(true, faceNormal, faceNormal, ivec3(startPosition)); // At some point it doesn't make sense to even draw the model.