#pragma once #include #include #include namespace mbgl { namespace shaders { template <> struct ShaderSource { static constexpr const char* name = "WideVectorShader"; static const std::array attributes; static const std::array instanceAttributes; static const std::array textures; // Simplified wide vector shader for WebGPU static constexpr auto vertex = R"( struct VertexInput { @location(5) position: vec3, @location(6) normal: vec2, @location(7) texCoord: vec2, }; struct InstanceInput { @location(8) instanceCenter: vec3, @location(9) instanceColor: vec4, @location(10) instancePrev: i32, @location(11) instanceNext: i32, }; struct VertexOutput { @builtin(position) position: vec4, @location(0) color: vec4, @location(1) texCoord: vec2, }; struct WideVectorUBO { mvpMatrix: mat4x4, mvpMatrixDiff: mat4x4, mvMatrix: mat4x4, mvMatrixDiff: mat4x4, pMatrix: mat4x4, pMatrixDiff: mat4x4, frameSize: vec2, color: vec4, width: f32, offset: f32, edge: f32, texRepeat: f32, texOffset: vec2, }; @group(0) @binding(0) var ubo: WideVectorUBO; @vertex fn main(in: VertexInput, instance: InstanceInput) -> VertexOutput { var out: VertexOutput; // Calculate position with offset based on normal let worldPos = instance.instanceCenter + vec3(in.normal * ubo.width, 0.0); out.position = ubo.mvpMatrix * vec4(worldPos, 1.0); // Pass through color and texture coordinates out.color = instance.instanceColor * ubo.color; out.texCoord = in.texCoord * ubo.texRepeat + ubo.texOffset; return out; } )"; static constexpr auto fragment = R"( @fragment fn main(@location(0) color: vec4, @location(1) texCoord: vec2) -> @location(0) vec4 { // Simple color output with alpha blending support return color; } )"; }; } // namespace shaders } // namespace mbgl