summaryrefslogtreecommitdiffstats
path: root/assets
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2026-04-15 16:53:58 -0400
committerJon Santmyer <jon@jonsantmyer.com>2026-04-15 16:53:58 -0400
commitb5ced3af46c96ceb959fbbf1addfeba3bd4f76d5 (patch)
tree06d06fc9562dc99eede655b53635576f67c37e3b /assets
downloadsystemic4x-b5ced3af46c96ceb959fbbf1addfeba3bd4f76d5.tar.gz
systemic4x-b5ced3af46c96ceb959fbbf1addfeba3bd4f76d5.tar.bz2
systemic4x-b5ced3af46c96ceb959fbbf1addfeba3bd4f76d5.zip
first commit. working body rendering
Diffstat (limited to 'assets')
-rw-r--r--assets/shaders/canvas.wgsl32
-rw-r--r--assets/shaders/tacbody.wgsl79
-rw-r--r--assets/systems/sol.csv3
3 files changed, 114 insertions, 0 deletions
diff --git a/assets/shaders/canvas.wgsl b/assets/shaders/canvas.wgsl
new file mode 100644
index 0000000..3be1a77
--- /dev/null
+++ b/assets/shaders/canvas.wgsl
@@ -0,0 +1,32 @@
+struct VertexInput {
+ @location(0) position: vec3<f32>,
+ @location(1) uv: vec2<f32>
+};
+
+struct VertexOutput {
+ @builtin(position) clip_position: vec4<f32>,
+ @location(0) uv: vec2<f32>
+};
+
+@vertex
+fn vs_main(
+ model: VertexInput,
+) -> VertexOutput {
+ var out: VertexOutput;
+
+ out.clip_position = vec4<f32>(model.position, 1.0);
+ out.uv = model.uv;
+
+ return out;
+}
+
+@group(0) @binding(0)
+var canvas_texture: texture_2d<f32>;
+@group(0) @binding(1)
+var canvas_sampler: sampler;
+
+@fragment
+fn fs_main(in: VertexOutput
+) -> @location(0) vec4<f32> {
+ return textureSample(canvas_texture, canvas_sampler, in.uv);
+}
diff --git a/assets/shaders/tacbody.wgsl b/assets/shaders/tacbody.wgsl
new file mode 100644
index 0000000..e8fb653
--- /dev/null
+++ b/assets/shaders/tacbody.wgsl
@@ -0,0 +1,79 @@
+struct VertexInput {
+ @location(0) position: vec3<f32>
+};
+
+struct InstanceInput {
+ @location(2) position: vec3<f32>,
+ @location(3) radius: f32
+};
+
+struct VertexOutput {
+ @builtin(position) clip_position: vec4<f32>,
+ @location(0) local_position: vec3<f32>
+};
+
+struct CameraUniform {
+ view: mat4x4<f32>,
+ proj: mat4x4<f32>,
+ scale: f32
+};
+
+@group(0) @binding(0)
+var<uniform> camera: CameraUniform;
+
+@vertex
+fn vs_main(
+ model: VertexInput,
+ instance: InstanceInput
+) -> VertexOutput {
+ var out: VertexOutput;
+
+ var view = camera.view;
+
+ //Billboard the circle
+ view[0][0] = 1.0;
+ view[0][1] = 0.0;
+ view[0][2] = 0.0;
+
+ view[1][0] = 0.0;
+ view[1][1] = 1.0;
+ view[1][2] = 0.0;
+
+ view[2][0] = 0.0;
+ view[2][1] = 0.0;
+ view[2][2] = 1.0;
+
+ let min_size = 0.025;
+
+ //Scale the world around the camera scale.
+ let model_pos = model.position;
+ let instance_pos = instance.position * camera.scale;
+
+ let view_proj = camera.proj * view;
+
+ let center_view_pos = view_proj * vec4<f32>(instance_pos, 1.0);
+ let vertex_view_pos = view_proj * vec4<f32>(instance_pos + (model_pos * camera.scale), 1.0);
+
+ let vertex_dist = length(vertex_view_pos - center_view_pos) / center_view_pos.w;
+ if vertex_dist < min_size {
+ out.clip_position = center_view_pos / center_view_pos.w;
+ out.clip_position += camera.proj * vec4<f32>(model_pos.xy * (min_size / 2), 0.0, 0.0);
+ }else{
+ out.clip_position = vertex_view_pos;
+ }
+
+ out.local_position = model.position;
+
+ return out;
+}
+
+@fragment
+fn fs_main(in: VertexOutput
+) -> @location(0) vec4<f32> {
+ let point_dist = length(in.local_position);
+ var alpha = 1.0;
+ if point_dist > 1.0 {
+ alpha = 0.0;
+ }
+ return vec4<f32>(1.0, 1.0, 1.0, alpha);
+}
diff --git a/assets/systems/sol.csv b/assets/systems/sol.csv
new file mode 100644
index 0000000..81fc14c
--- /dev/null
+++ b/assets/systems/sol.csv
@@ -0,0 +1,3 @@
+name,orbits,mass,radius,eccentricity,inclination,long_asc_node,long_periapsis,sgp,mean_long,semi_major_axis
+Sol,0,1.988475e30,695700.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
+Earth,0,5.97217e24,6371.0,0.0167,0.1249,-0.1965,1.7966,3.986e14,1.7534,149598023