#pragma once #include #include #include namespace mbgl { namespace shaders { template <> struct ShaderSource { static constexpr const char* name = "CustomGeometryShader"; static const std::array attributes; static constexpr std::array instanceAttributes{}; static const std::array textures; static constexpr auto vertex = R"( struct VertexInput { @location(3) position: vec3, @location(4) texcoord: vec2, }; struct VertexOutput { @builtin(position) position: vec4, @location(0) uv: vec2, }; struct CustomDrawableUBO { matrix: mat4x4, color: vec4, }; @group(0) @binding(0) var drawable: CustomDrawableUBO; @vertex fn main(in: VertexInput) -> VertexOutput { var out: VertexOutput; out.uv = in.texcoord; out.position = drawable.matrix * vec4(in.position, 1.0); return out; } )"; static constexpr auto fragment = R"( struct FragmentInput { @location(0) uv: vec2, }; struct CustomDrawableUBO { matrix: mat4x4, color: vec4, }; @group(0) @binding(0) var drawable: CustomDrawableUBO; @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 { return textureSample(texture_image, texture_sampler, in.uv) * drawable.color; } )"; }; } // namespace shaders } // namespace mbgl