From adc33f404add13dfe02f198da80093e933b5194f Mon Sep 17 00:00:00 2001 From: Ian Date: Mon, 8 Jul 2024 14:19:40 -0700 Subject: [PATCH 1/3] Cant replicate it in the example so pushing to replicate on priv repo --- src/render/grid.wgsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/render/grid.wgsl b/src/render/grid.wgsl index 9b6f225..23cccd1 100644 --- a/src/render/grid.wgsl +++ b/src/render/grid.wgsl @@ -118,7 +118,7 @@ fn fragment(in: VertexOutput) -> FragmentOutput { grid_color = mix(grid_color, vec4(grid_settings.z_axis_col, grid_color.a), f32(z_axis_cond)); grid_color = mix(grid_color, vec4(grid_settings.x_axis_col, grid_color.a), f32(x_axis_cond)); - let dist_fadeout = min(1., 1. - grid_settings.dist_fadeout_const * real_depth); + let dist_fadeout = min(1., 1. - max(grid_settings.dist_fadeout_const * real_depth, 1.)); let dot_fadeout = abs(dot(grid_position.normal, normalize(view.world_position - frag_pos_3d))); let alpha_fadeout = mix(dist_fadeout, 1., dot_fadeout) * min(grid_settings.dot_fadeout_const * dot_fadeout, 1.); From 208e51d2529140053b387fbe784bb4d5ed6bc8b5 Mon Sep 17 00:00:00 2001 From: Ian Date: Mon, 8 Jul 2024 14:22:49 -0700 Subject: [PATCH 2/3] should have been a min --- src/render/grid.wgsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/render/grid.wgsl b/src/render/grid.wgsl index 23cccd1..e775201 100644 --- a/src/render/grid.wgsl +++ b/src/render/grid.wgsl @@ -118,7 +118,7 @@ fn fragment(in: VertexOutput) -> FragmentOutput { grid_color = mix(grid_color, vec4(grid_settings.z_axis_col, grid_color.a), f32(z_axis_cond)); grid_color = mix(grid_color, vec4(grid_settings.x_axis_col, grid_color.a), f32(x_axis_cond)); - let dist_fadeout = min(1., 1. - max(grid_settings.dist_fadeout_const * real_depth, 1.)); + let dist_fadeout = min(1., 1. - min(grid_settings.dist_fadeout_const * real_depth, 1.)); let dot_fadeout = abs(dot(grid_position.normal, normalize(view.world_position - frag_pos_3d))); let alpha_fadeout = mix(dist_fadeout, 1., dot_fadeout) * min(grid_settings.dot_fadeout_const * dot_fadeout, 1.); From 93402e21d42202f39de5825b1e645c2c4c43256f Mon Sep 17 00:00:00 2001 From: Ian Date: Tue, 9 Jul 2024 10:18:29 -0700 Subject: [PATCH 3/3] maybe this fixes it? --- src/render/grid.wgsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/render/grid.wgsl b/src/render/grid.wgsl index e775201..50b7aba 100644 --- a/src/render/grid.wgsl +++ b/src/render/grid.wgsl @@ -108,7 +108,7 @@ fn fragment(in: VertexOutput) -> FragmentOutput { let grid2 = abs(fract((coord * 0.1) - 0.5) - 0.5) / derivative2; let mg_line = min(grid2.x, grid2.y); - let grid_alpha = 1.0 - min(lne, 1.0); + let grid_alpha = max(1.0 - min(lne, 1.0), 0.0); let base_grid_color = mix(grid_settings.major_line_col, grid_settings.minor_line_col, step(1., mg_line)); var grid_color = vec4(base_grid_color.rgb, base_grid_color.a * grid_alpha);