From 1fc7c4f7a99a3238c3af662daa7c3af7c79cee15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristram=20Gr=C3=A4bener?= Date: Sat, 18 Feb 2023 21:06:24 +0100 Subject: [PATCH] Debug line now have same pixel width (#255) Closes #230 --- maplibre/src/render/shaders/mod.rs | 6 ++++++ maplibre/src/render/shaders/tile_debug.vertex.wgsl | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/maplibre/src/render/shaders/mod.rs b/maplibre/src/render/shaders/mod.rs index 1e8c1b1c2..b9db2a654 100644 --- a/maplibre/src/render/shaders/mod.rs +++ b/maplibre/src/render/shaders/mod.rs @@ -64,6 +64,12 @@ impl Shader for TileMaskShader { format: wgpu::VertexFormat::Float32x4, shader_location: 7, }, + // zoom factor + wgpu::VertexAttribute { + offset: 4 * wgpu::VertexFormat::Float32x4.size(), + format: wgpu::VertexFormat::Float32, + shader_location: 9, + }, ], }], } diff --git a/maplibre/src/render/shaders/tile_debug.vertex.wgsl b/maplibre/src/render/shaders/tile_debug.vertex.wgsl index 5eb27e8c5..92cebd20f 100644 --- a/maplibre/src/render/shaders/tile_debug.vertex.wgsl +++ b/maplibre/src/render/shaders/tile_debug.vertex.wgsl @@ -12,6 +12,7 @@ fn main( @location(5) translate2: vec4, @location(6) translate3: vec4, @location(7) translate4: vec4, + @location(9) zoom_factor: f32, @builtin(vertex_index) vertex_idx: u32, @builtin(instance_index) instance_idx: u32 // instance_index is used when we have multiple instances of the same "object" ) -> VertexOutput { @@ -20,7 +21,7 @@ fn main( let target_width = 1.0; let target_height = 1.0; - let WIDTH = EXTENT / 1024.0; + let WIDTH = EXTENT * zoom_factor / 1024.0; var VERTICES: array, 24> = array, 24>( // Debug lines vertices