From c9041e2e6fe59d6127bb1085b874e8e3cda8000e Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Thu, 7 May 2026 10:12:11 -0400 Subject: more intense position-relative rendering to fix some precision problems --- assets/shaders/tacmap/body.wgsl | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'assets/shaders/tacmap/body.wgsl') diff --git a/assets/shaders/tacmap/body.wgsl b/assets/shaders/tacmap/body.wgsl index e91c841..0cfd5f9 100644 --- a/assets/shaders/tacmap/body.wgsl +++ b/assets/shaders/tacmap/body.wgsl @@ -6,14 +6,16 @@ struct InstanceInput { struct VertexOutput { @builtin(position) clip_position: vec4, - @location(0) local_position: vec3 + @location(0) local_position: vec3, + @location(1) distance: f32 }; struct CameraUniform { view: mat4x4, proj: mat4x4, - pos: vec3, - scale: f32 + abs_pos: vec3, + rel_pos: vec3, + scale: f32, }; @group(0) @binding(0) @@ -49,18 +51,18 @@ fn vs_main( //Scale the world around the camera scale and translate about the camera's //absolute (/target) position let relative_pos = instance.position; - let origin_pos = (instance.origin - camera.pos); + let origin_pos = instance.origin - camera.abs_pos; - if all(relative_pos != origin_pos) { + /*if all(relative_pos != origin_pos) { if length(relative_pos) < 0.01 / camera.scale { if length(relative_pos) != 0.0 { out.clip_position = vec4(0.0, 0.0, 0.0, 1.0); return out; } } - } + }*/ - let instance_pos = (relative_pos + origin_pos) * camera.scale; + let instance_pos = (relative_pos + origin_pos - camera.rel_pos) * camera.scale; let view_proj = camera.proj * view; @@ -76,6 +78,7 @@ fn vs_main( } out.local_position = model; + out.distance = length(instance_pos); return out; } @@ -88,5 +91,6 @@ fn fs_main(in: VertexOutput if point_dist > 1.0 { alpha = 0.0; } - return vec4(1.0, 1.0, 1.0, alpha); + let color = vec3(1.0, 1.0, 1.0) / clamp(in.distance, 1.0, 1.5); + return vec4(color, alpha); } -- cgit v1.2.3