diff options
Diffstat (limited to 'assets/shaders/tacmap/body.wgsl')
| -rw-r--r-- | assets/shaders/tacmap/body.wgsl | 20 |
1 files changed, 12 insertions, 8 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); } |
