diff options
| author | Jon Santmyer <jon@jonsantmyer.com> | 2026-05-01 16:02:59 -0400 |
|---|---|---|
| committer | Jon Santmyer <jon@jonsantmyer.com> | 2026-05-01 16:02:59 -0400 |
| commit | b14dd1c1f3e198137fa8b9e0c4f5e56949b11cd0 (patch) | |
| tree | 68d47ea946136025890265cc2185a728e4593b96 /assets | |
| parent | 961f8c6d405c9c6fcf9aaf4fb6f199b0e5c60d88 (diff) | |
| download | systemic4x-b14dd1c1f3e198137fa8b9e0c4f5e56949b11cd0.tar.gz systemic4x-b14dd1c1f3e198137fa8b9e0c4f5e56949b11cd0.tar.bz2 systemic4x-b14dd1c1f3e198137fa8b9e0c4f5e56949b11cd0.zip | |
i don't know how to get the line segments to render right
Diffstat (limited to 'assets')
| -rw-r--r-- | assets/shaders/tacmap/body.wgsl | 15 | ||||
| -rw-r--r-- | assets/shaders/tacmap/orbit.wgsl | 34 |
2 files changed, 34 insertions, 15 deletions
diff --git a/assets/shaders/tacmap/body.wgsl b/assets/shaders/tacmap/body.wgsl index 7156150..217a0b2 100644 --- a/assets/shaders/tacmap/body.wgsl +++ b/assets/shaders/tacmap/body.wgsl @@ -1,6 +1,7 @@ struct InstanceInput { @location(0) position: vec3<f32>, - @location(1) radius: f32 + @location(1) origin: vec3<f32>, + @location(2) radius: f32 }; struct VertexOutput { @@ -47,7 +48,17 @@ fn vs_main( //Scale the world around the camera scale and translate about the camera's //absolute (/target) position - let instance_pos = (instance.position - camera.pos) * camera.scale; + let relative_pos = instance.position * camera.scale; + let origin_pos = (instance.origin - camera.pos) * camera.scale; + + if all(relative_pos != origin_pos) { + if length(relative_pos) < 0.01 { + out.clip_position = vec4<f32>(0.0, 0.0, 0.0, 1.0); + return out; + } + } + + let instance_pos = relative_pos + origin_pos; let view_proj = camera.proj * view; diff --git a/assets/shaders/tacmap/orbit.wgsl b/assets/shaders/tacmap/orbit.wgsl index d054a05..901200f 100644 --- a/assets/shaders/tacmap/orbit.wgsl +++ b/assets/shaders/tacmap/orbit.wgsl @@ -1,7 +1,7 @@ struct VertexInput { @builtin(vertex_index) index: u32, @location(0) origin: u32, - @location(1) position: vec3<f32>, + @location(1) position: vec3<f32> }; struct VertexOutput { @@ -21,11 +21,8 @@ var<uniform> camera: CameraUniform; @group(1) @binding(0) var<storage> origins: array<array<f32,3>>; -const POINT_NORMALS = array<vec2<f32>,4>( - vec2<f32>(0.0, -0.5), - vec2<f32>(0.0, 0.5), - vec2<f32>(0.5, -0.5), - vec2<f32>(0.5, 0.5) +const POINT_NORMALS = array<f32,2>( + -0.5, 0.5 ); @vertex @@ -34,22 +31,33 @@ fn vs_main( ) -> VertexOutput { var out: VertexOutput; - let index = model.index % 4u; - let normal = POINT_NORMALS[index]; + let index = model.index % 2u; let origin = vec3<f32>( origins[model.origin][0], origins[model.origin][1], origins[model.origin][2]); - let model_pos = (origin + model.position - camera.pos) * camera.scale; + let model_pos = ((origin - camera.pos) + model.position) * camera.scale; + let origin_pos = (origin - camera.pos) * camera.scale; + + let view = camera.view; + let camera_right = vec3<f32>(view[0][0], view[1][0], view[2][0]); + let camera_up = vec3<f32>(view[0][1], view[1][1], view[2][1]); + let camera_forward = vec3<f32>(view[0][2], view[1][2], view[2][2]); + + let orbit_normal = normalize(model.position); + var normal = orbit_normal; + + if length(model_pos - origin_pos) > 0.01 { + normal *= POINT_NORMALS[index]; + } + let view_proj = camera.proj * camera.view; //Scale the world around the camera scale and translate about the camera's //absolute (/target) position - - let point_view_pos = view_proj * vec4<f32>(model_pos, 1.0); + let point_view_pos = view_proj * vec4<f32>(model_pos + normal * 0.005, 1.0); out.clip_position = point_view_pos; - out.clip_position += vec4<f32>(normal * 0.01, 0.0, 0.0) * point_view_pos.w; return out; } @@ -57,5 +65,5 @@ fn vs_main( @fragment fn fs_main(in: VertexOutput ) -> @location(0) vec4<f32> { - return vec4<f32>(0.25, 1.0, 0.25, 1.0); + return vec4<f32>(0.0, 0.5, 0.0, 1.0); } |
