diff options
Diffstat (limited to 'assets/shaders')
| -rw-r--r-- | assets/shaders/tacmap/body.wgsl | 20 | ||||
| -rw-r--r-- | assets/shaders/tacmap/grid.wgsl | 3 | ||||
| -rw-r--r-- | assets/shaders/tacmap/orbit.wgsl | 10 |
3 files changed, 18 insertions, 15 deletions
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<f32>, - @location(0) local_position: vec3<f32> + @location(0) local_position: vec3<f32>, + @location(1) distance: f32 }; struct CameraUniform { view: mat4x4<f32>, proj: mat4x4<f32>, - pos: vec3<f32>, - scale: f32 + abs_pos: vec3<f32>, + rel_pos: vec3<f32>, + 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<f32>(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<f32>(1.0, 1.0, 1.0, alpha); + let color = vec3<f32>(1.0, 1.0, 1.0) / clamp(in.distance, 1.0, 1.5); + return vec4<f32>(color, alpha); } diff --git a/assets/shaders/tacmap/grid.wgsl b/assets/shaders/tacmap/grid.wgsl index 822e957..1d2c4dc 100644 --- a/assets/shaders/tacmap/grid.wgsl +++ b/assets/shaders/tacmap/grid.wgsl @@ -7,7 +7,8 @@ struct VertexOutput { struct CameraUniform { view: mat4x4<f32>, proj: mat4x4<f32>, - pos: vec3<f32>, + abs_pos: vec3<f32>, + rel_pos: vec3<f32>, scale: f32 }; diff --git a/assets/shaders/tacmap/orbit.wgsl b/assets/shaders/tacmap/orbit.wgsl index 901200f..a890fd8 100644 --- a/assets/shaders/tacmap/orbit.wgsl +++ b/assets/shaders/tacmap/orbit.wgsl @@ -11,7 +11,8 @@ struct VertexOutput { struct CameraUniform { view: mat4x4<f32>, proj: mat4x4<f32>, - pos: vec3<f32>, + abs_pos: vec3<f32>, + rel_pos: vec3<f32>, scale: f32 }; @@ -37,13 +38,10 @@ fn vs_main( origins[model.origin][1], origins[model.origin][2]); - let model_pos = ((origin - camera.pos) + model.position) * camera.scale; - let origin_pos = (origin - camera.pos) * camera.scale; + let model_pos = ((origin - camera.abs_pos - camera.rel_pos) + model.position) * camera.scale; + let origin_pos = (origin - camera.abs_pos - camera.rel_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; |
