summaryrefslogtreecommitdiffstats
path: root/assets/shaders/tacmap/orbit.wgsl
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2026-04-30 10:06:32 -0400
committerJon Santmyer <jon@jonsantmyer.com>2026-04-30 10:06:32 -0400
commit961f8c6d405c9c6fcf9aaf4fb6f199b0e5c60d88 (patch)
treea26797d6314fa8c193a459e988427c7bfe7f19a7 /assets/shaders/tacmap/orbit.wgsl
parent25255a8b9147d27aa40b28d6aadb62c0ab275d32 (diff)
downloadsystemic4x-961f8c6d405c9c6fcf9aaf4fb6f199b0e5c60d88.tar.gz
systemic4x-961f8c6d405c9c6fcf9aaf4fb6f199b0e5c60d88.tar.bz2
systemic4x-961f8c6d405c9c6fcf9aaf4fb6f199b0e5c60d88.zip
add orbit rendering for bodies
Diffstat (limited to 'assets/shaders/tacmap/orbit.wgsl')
-rw-r--r--assets/shaders/tacmap/orbit.wgsl61
1 files changed, 61 insertions, 0 deletions
diff --git a/assets/shaders/tacmap/orbit.wgsl b/assets/shaders/tacmap/orbit.wgsl
new file mode 100644
index 0000000..d054a05
--- /dev/null
+++ b/assets/shaders/tacmap/orbit.wgsl
@@ -0,0 +1,61 @@
+struct VertexInput {
+ @builtin(vertex_index) index: u32,
+ @location(0) origin: u32,
+ @location(1) position: vec3<f32>,
+};
+
+struct VertexOutput {
+ @builtin(position) clip_position: vec4<f32>,
+};
+
+struct CameraUniform {
+ view: mat4x4<f32>,
+ proj: mat4x4<f32>,
+ pos: vec3<f32>,
+ scale: f32
+};
+
+@group(0) @binding(0)
+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)
+);
+
+@vertex
+fn vs_main(
+ model: VertexInput,
+) -> VertexOutput {
+ var out: VertexOutput;
+
+ let index = model.index % 4u;
+ let normal = POINT_NORMALS[index];
+ 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 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);
+ out.clip_position = point_view_pos;
+ out.clip_position += vec4<f32>(normal * 0.01, 0.0, 0.0) * point_view_pos.w;
+
+ return out;
+}
+
+@fragment
+fn fs_main(in: VertexOutput
+) -> @location(0) vec4<f32> {
+ return vec4<f32>(0.25, 1.0, 0.25, 1.0);
+}