#pragma once #include #include #include namespace mbgl { namespace shaders { template <> struct ShaderSource { static constexpr const char* name = "CustomSymbolIconShader"; static const std::array attributes; static constexpr std::array instanceAttributes{}; static const std::array textures; static constexpr auto vertex = R"( struct VertexInput { @location(4) position: vec3, @location(5) texcoord: vec2, }; struct VertexOutput { @builtin(position) position: vec4, @location(0) uv: vec2, }; struct SymbolUBO { matrix: mat4x4, opacity: f32, }; @group(0) @binding(0) var symbol_ubo: SymbolUBO; @vertex fn main(in: VertexInput) -> VertexOutput { var out: VertexOutput; out.position = symbol_ubo.matrix * vec4(in.position, 1.0); out.uv = in.texcoord; return out; } )"; static constexpr auto fragment = R"( struct FragmentInput { @location(0) uv: vec2, }; struct SymbolUBO { matrix: mat4x4, opacity: f32, }; @group(0) @binding(0) var symbol_ubo: SymbolUBO; @group(1) @binding(0) var texture_sampler: sampler; @group(1) @binding(1) var texture_image: texture_2d; @fragment fn main(in: FragmentInput) -> @location(0) vec4 { var color = textureSample(texture_image, texture_sampler, in.uv); color.a = color.a * symbol_ubo.opacity; return color; } )"; }; } // namespace shaders } // namespace mbgl