From c68d8f2d37452dabae473d2c96399bc559c73dd8 Mon Sep 17 00:00:00 2001 From: Alex Cristici Date: Wed, 15 Nov 2023 09:06:10 +0200 Subject: [PATCH] Fixed metal fill color per vertex (#1865) --- include/mbgl/shaders/mtl/fill.hpp | 8 ++++---- src/mbgl/shaders/mtl/fill.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/mbgl/shaders/mtl/fill.hpp b/include/mbgl/shaders/mtl/fill.hpp index e16881ac9..fe43c3489 100644 --- a/include/mbgl/shaders/mtl/fill.hpp +++ b/include/mbgl/shaders/mtl/fill.hpp @@ -22,7 +22,7 @@ struct ShaderSource { struct VertexStage { short2 position [[attribute(0)]]; - float2 color [[attribute(1)]]; + float4 color [[attribute(1)]]; float2 opacity [[attribute(2)]]; }; @@ -59,7 +59,7 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]], device const FillPermutationUBO& permutation [[buffer(6)]], device const ExpressionInputsUBO& expr [[buffer(7)]]) { - const auto color = colorFor(permutation.color, props.color, vertx.color, expr); + const auto color = colorFor(permutation.color, props.color, vertx.color, interp.color_t, expr); const auto opacity = valueFor(permutation.opacity, props.opacity, vertx.opacity, interp.opacity_t, expr); float4 position = drawable.matrix * float4(float2(vertx.position), 0.0f, 1.0f); @@ -97,7 +97,7 @@ struct ShaderSource { struct VertexStage { short2 position [[attribute(0)]]; - float2 outline_color [[attribute(1)]]; + float4 outline_color [[attribute(1)]]; float2 opacity [[attribute(2)]]; }; @@ -137,7 +137,7 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]], device const FillOutlinePermutationUBO& permutation [[buffer(6)]], device const ExpressionInputsUBO& expr [[buffer(7)]]) { - const auto outline_color = colorFor(permutation.outline_color, props.outline_color, vertx.outline_color, expr); + const auto outline_color = colorFor(permutation.outline_color, props.outline_color, vertx.outline_color, interp.outline_color_t, expr); const auto opacity = valueFor(permutation.opacity, props.opacity, vertx.opacity, interp.opacity_t, expr); float4 position = drawable.matrix * float4(float2(vertx.position), 0.0f, 1.0f); diff --git a/src/mbgl/shaders/mtl/fill.cpp b/src/mbgl/shaders/mtl/fill.cpp index 448a8786d..589cb330a 100644 --- a/src/mbgl/shaders/mtl/fill.cpp +++ b/src/mbgl/shaders/mtl/fill.cpp @@ -5,7 +5,7 @@ namespace shaders { const std::array ShaderSource::attributes = { AttributeInfo{0, gfx::AttributeDataType::Short2, 1, "a_pos"}, - AttributeInfo{1, gfx::AttributeDataType::Float2, 1, "a_color"}, + AttributeInfo{1, gfx::AttributeDataType::Float4, 1, "a_color"}, AttributeInfo{2, gfx::AttributeDataType::Float2, 1, "a_opacity"}, // This shader doesn't use it, but we need this so that the layer can assign the same @@ -24,7 +24,7 @@ const std::array ShaderSource ShaderSource::attributes = { AttributeInfo{0, gfx::AttributeDataType::Short2, 1, "a_pos"}, - AttributeInfo{1, gfx::AttributeDataType::Float2, 1, "a_outline_color"}, + AttributeInfo{1, gfx::AttributeDataType::Float4, 1, "a_outline_color"}, AttributeInfo{2, gfx::AttributeDataType::Float2, 1, "a_opacity"}, // See `a_outline_color` in FillShader