From f35d44c295efa0ffff6fac3cf50c86b2ca5c7351 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Fri, 19 Dec 2025 15:40:13 -0800 Subject: [PATCH] project ideal point --- strafe-client/src/shader.wgsl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/strafe-client/src/shader.wgsl b/strafe-client/src/shader.wgsl index fdf1f08d..cf4b905a 100644 --- a/strafe-client/src/shader.wgsl +++ b/strafe-client/src/shader.wgsl @@ -202,20 +202,24 @@ fn ms_debug_edge(){ var v0_world_position: vec4 = model_instance.transform * ve_verts[0]; var v1_world_position: vec4 = model_instance.transform * ve_verts[1]; + var v0_screen_position: vec4 = camera.proj * camera.view * v0_world_position; var v1_screen_position: vec4 = camera.proj * camera.view * v1_world_position; + var edge_dir_world: vec4 = normalize(v0_world_position - v1_world_position); + var edge_dir_screen: vec4 = camera.proj * camera.view * edge_dir_world; + for (var i:u32 = 0; i<=N/2; i++){ // two half circles that make a whole var theta: f32 = f32(i) * tau / f32(N); var cos_sin: vec2 = vec2(cos(theta), sin(theta)); // construct basis vectors - var y_axis: vec4 = normalize(v0_screen_position - v1_screen_position); - var x_axis: vec4 = y_axis.yxzw; + var y_axis: vec2 = edge_dir_screen.xy; + var x_axis: vec2 = y_axis.yx; x_axis.x = -x_axis.x; - var offset: vec4 = x_axis * cos_sin.x + y_axis * cos_sin.y; + var offset: vec4 = vec4(0.5 * (x_axis * cos_sin.x + y_axis * cos_sin.y), 0.0, 0.0);; mesh_output.vertices[i].position = v0_screen_position + offset; mesh_output.vertices[N/2+1+i].position = v1_screen_position - offset;