Fill outline triangulated reorganized (#2266)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1025,18 +1025,19 @@ if(MLN_WITH_OPENGL)
|
|||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_debug.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_debug.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_fill.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_fill.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_fill_outline.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_fill_outline.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_line.hpp
|
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_line_gradient.hpp
|
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_line_pattern.hpp
|
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_line_sdf.hpp
|
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_fill_outline_pattern.hpp
|
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_fill_pattern.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_fill_pattern.hpp
|
||||||
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_fill_outline_pattern.hpp
|
||||||
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_fill_outline_triangulated.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_fill_extrusion.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_fill_extrusion.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_fill_extrusion_pattern.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_fill_extrusion_pattern.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_heatmap.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_heatmap.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_heatmap_texture.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_heatmap_texture.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_hillshade_prepare.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_hillshade_prepare.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_hillshade.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_hillshade.hpp
|
||||||
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_line.hpp
|
||||||
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_line_gradient.hpp
|
||||||
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_line_pattern.hpp
|
||||||
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_line_sdf.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_raster.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_raster.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_symbol_icon.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_symbol_icon.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_symbol_sdf.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_symbol_sdf.hpp
|
||||||
|
|||||||
@@ -71,10 +71,11 @@ MLN_GENERATED_OPENGL_SHADER_HEADERS = [
|
|||||||
"include/mbgl/shaders/gl/drawable_debug.hpp",
|
"include/mbgl/shaders/gl/drawable_debug.hpp",
|
||||||
"include/mbgl/shaders/gl/drawable_fill.hpp",
|
"include/mbgl/shaders/gl/drawable_fill.hpp",
|
||||||
"include/mbgl/shaders/gl/drawable_fill_outline.hpp",
|
"include/mbgl/shaders/gl/drawable_fill_outline.hpp",
|
||||||
|
"include/mbgl/shaders/gl/drawable_fill_pattern.hpp",
|
||||||
"include/mbgl/shaders/gl/drawable_fill_outline_pattern.hpp",
|
"include/mbgl/shaders/gl/drawable_fill_outline_pattern.hpp",
|
||||||
|
"include/mbgl/shaders/gl/drawable_fill_outline_triangulated.hpp",
|
||||||
"include/mbgl/shaders/gl/drawable_fill_extrusion.hpp",
|
"include/mbgl/shaders/gl/drawable_fill_extrusion.hpp",
|
||||||
"include/mbgl/shaders/gl/drawable_fill_extrusion_pattern.hpp",
|
"include/mbgl/shaders/gl/drawable_fill_extrusion_pattern.hpp",
|
||||||
"include/mbgl/shaders/gl/drawable_fill_pattern.hpp",
|
|
||||||
"include/mbgl/shaders/gl/drawable_heatmap.hpp",
|
"include/mbgl/shaders/gl/drawable_heatmap.hpp",
|
||||||
"include/mbgl/shaders/gl/drawable_heatmap_texture.hpp",
|
"include/mbgl/shaders/gl/drawable_heatmap_texture.hpp",
|
||||||
"include/mbgl/shaders/gl/drawable_hillshade_prepare.hpp",
|
"include/mbgl/shaders/gl/drawable_hillshade_prepare.hpp",
|
||||||
@@ -83,7 +84,6 @@ MLN_GENERATED_OPENGL_SHADER_HEADERS = [
|
|||||||
"include/mbgl/shaders/gl/drawable_line_pattern.hpp",
|
"include/mbgl/shaders/gl/drawable_line_pattern.hpp",
|
||||||
"include/mbgl/shaders/gl/drawable_line_sdf.hpp",
|
"include/mbgl/shaders/gl/drawable_line_sdf.hpp",
|
||||||
"include/mbgl/shaders/gl/drawable_line.hpp",
|
"include/mbgl/shaders/gl/drawable_line.hpp",
|
||||||
"include/mbgl/shaders/gl/drawable_line_basic.hpp",
|
|
||||||
"include/mbgl/shaders/gl/drawable_raster.hpp",
|
"include/mbgl/shaders/gl/drawable_raster.hpp",
|
||||||
"include/mbgl/shaders/gl/drawable_symbol_icon.hpp",
|
"include/mbgl/shaders/gl/drawable_symbol_icon.hpp",
|
||||||
"include/mbgl/shaders/gl/drawable_symbol_sdf.hpp",
|
"include/mbgl/shaders/gl/drawable_symbol_sdf.hpp",
|
||||||
|
|||||||
@@ -151,5 +151,30 @@ enum {
|
|||||||
fillOutlinePatternUBOCount
|
fillOutlinePatternUBOCount
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Fill outline triangulated
|
||||||
|
|
||||||
|
struct alignas(16) FillOutlineTriangulatedDrawableUBO {
|
||||||
|
std::array<float, 4 * 4> matrix;
|
||||||
|
std::array<float, 2> units_to_pixels;
|
||||||
|
float ratio;
|
||||||
|
float pad;
|
||||||
|
};
|
||||||
|
static_assert(sizeof(FillOutlineTriangulatedDrawableUBO) % 16 == 0);
|
||||||
|
|
||||||
|
struct alignas(16) FillOutlineTriangulatedPropertiesUBO {
|
||||||
|
Color color;
|
||||||
|
float opacity;
|
||||||
|
float width;
|
||||||
|
float pad1, pad2;
|
||||||
|
};
|
||||||
|
static_assert(sizeof(FillOutlineTriangulatedPropertiesUBO) % 16 == 0);
|
||||||
|
|
||||||
|
enum {
|
||||||
|
idFillOutlineTriangulatedDrawableUBO,
|
||||||
|
idFillOutlineTriangulatedPropertiesUBO,
|
||||||
|
fillOutlineTriangulatedUBOCount
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace shaders
|
} // namespace shaders
|
||||||
} // namespace mbgl
|
} // namespace mbgl
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ namespace mbgl {
|
|||||||
namespace shaders {
|
namespace shaders {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct ShaderSource<BuiltIn::LineBasicShader, gfx::Backend::Type::OpenGL> {
|
struct ShaderSource<BuiltIn::FillOutlineTriangulatedShader, gfx::Backend::Type::OpenGL> {
|
||||||
static constexpr const char* name = "LineBasicShader";
|
static constexpr const char* name = "FillOutlineTriangulatedShader";
|
||||||
static constexpr const char* vertex = R"(// floor(127 / 2) == 63.0
|
static constexpr const char* vertex = R"(// floor(127 / 2) == 63.0
|
||||||
// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is
|
// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is
|
||||||
// stored in a byte (-128..127). we scale regular normals up to length 63, but
|
// stored in a byte (-128..127). we scale regular normals up to length 63, but
|
||||||
@@ -19,18 +19,17 @@ struct ShaderSource<BuiltIn::LineBasicShader, gfx::Backend::Type::OpenGL> {
|
|||||||
layout (location = 0) in vec2 a_pos_normal;
|
layout (location = 0) in vec2 a_pos_normal;
|
||||||
layout (location = 1) in vec4 a_data;
|
layout (location = 1) in vec4 a_data;
|
||||||
|
|
||||||
layout (std140) uniform LineBasicUBO {
|
layout (std140) uniform FillOutlineTriangulatedDrawableUBO {
|
||||||
highp mat4 u_matrix;
|
highp mat4 u_matrix;
|
||||||
highp vec2 u_units_to_pixels;
|
highp vec2 u_units_to_pixels;
|
||||||
mediump float u_ratio;
|
mediump float u_ratio;
|
||||||
lowp float pad0;
|
lowp float pad0;
|
||||||
};
|
};
|
||||||
|
|
||||||
layout (std140) uniform LineBasicPropertiesUBO {
|
layout (std140) uniform FillOutlineTriangulatedPropertiesUBO {
|
||||||
highp vec4 u_color;
|
highp vec4 u_color;
|
||||||
lowp float u_opacity;
|
lowp float u_opacity;
|
||||||
mediump float u_width;
|
mediump float u_width;
|
||||||
|
|
||||||
highp vec2 pad1;
|
highp vec2 pad1;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -77,18 +76,10 @@ void main() {
|
|||||||
v_width = outset;
|
v_width = outset;
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
static constexpr const char* fragment = R"(layout (std140) uniform LineBasicUBO {
|
static constexpr const char* fragment = R"(layout (std140) uniform FillOutlineTriangulatedPropertiesUBO {
|
||||||
highp mat4 u_matrix;
|
|
||||||
highp vec2 u_units_to_pixels;
|
|
||||||
mediump float u_ratio;
|
|
||||||
lowp float pad0;
|
|
||||||
};
|
|
||||||
|
|
||||||
layout (std140) uniform LineBasicPropertiesUBO {
|
|
||||||
highp vec4 u_color;
|
highp vec4 u_color;
|
||||||
lowp float u_opacity;
|
lowp float u_opacity;
|
||||||
mediump float u_width;
|
mediump float u_width;
|
||||||
|
|
||||||
highp vec2 pad1;
|
highp vec2 pad1;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -107,6 +107,13 @@ struct ShaderInfo<BuiltIn::FillOutlinePatternShader, gfx::Backend::Type::OpenGL>
|
|||||||
static const std::vector<TextureInfo> textures;
|
static const std::vector<TextureInfo> textures;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct ShaderInfo<BuiltIn::FillOutlineTriangulatedShader, gfx::Backend::Type::OpenGL> {
|
||||||
|
static const std::vector<AttributeInfo> attributes;
|
||||||
|
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||||
|
static const std::vector<TextureInfo> textures;
|
||||||
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct ShaderInfo<BuiltIn::FillExtrusionShader, gfx::Backend::Type::OpenGL> {
|
struct ShaderInfo<BuiltIn::FillExtrusionShader, gfx::Backend::Type::OpenGL> {
|
||||||
static const std::vector<AttributeInfo> attributes;
|
static const std::vector<AttributeInfo> attributes;
|
||||||
@@ -177,13 +184,6 @@ struct ShaderInfo<BuiltIn::LineShader, gfx::Backend::Type::OpenGL> {
|
|||||||
static const std::vector<TextureInfo> textures;
|
static const std::vector<TextureInfo> textures;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
|
||||||
struct ShaderInfo<BuiltIn::LineBasicShader, gfx::Backend::Type::OpenGL> {
|
|
||||||
static const std::vector<AttributeInfo> attributes;
|
|
||||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
|
||||||
static const std::vector<TextureInfo> textures;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct ShaderInfo<BuiltIn::RasterShader, gfx::Backend::Type::OpenGL> {
|
struct ShaderInfo<BuiltIn::RasterShader, gfx::Backend::Type::OpenGL> {
|
||||||
static const std::vector<AttributeInfo> attributes;
|
static const std::vector<AttributeInfo> attributes;
|
||||||
|
|||||||
@@ -182,30 +182,5 @@ enum {
|
|||||||
lineSDFUBOCount
|
lineSDFUBOCount
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
|
||||||
// Line basic
|
|
||||||
|
|
||||||
struct alignas(16) LineBasicUBO {
|
|
||||||
std::array<float, 4 * 4> matrix;
|
|
||||||
std::array<float, 2> units_to_pixels;
|
|
||||||
float ratio;
|
|
||||||
float pad;
|
|
||||||
};
|
|
||||||
static_assert(sizeof(LineBasicUBO) % 16 == 0);
|
|
||||||
|
|
||||||
struct alignas(16) LineBasicPropertiesUBO {
|
|
||||||
Color color;
|
|
||||||
float opacity;
|
|
||||||
float width;
|
|
||||||
float pad1, pad2;
|
|
||||||
};
|
|
||||||
static_assert(sizeof(LineBasicPropertiesUBO) % 16 == 0);
|
|
||||||
|
|
||||||
enum {
|
|
||||||
idLineBasicUBO,
|
|
||||||
idLineBasicPropertiesUBO,
|
|
||||||
lineBasicUBOCount
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace shaders
|
} // namespace shaders
|
||||||
} // namespace mbgl
|
} // namespace mbgl
|
||||||
|
|||||||
@@ -65,13 +65,6 @@ struct alignas(16) LineUBO {
|
|||||||
float pad1, pad2, pad3;
|
float pad1, pad2, pad3;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct alignas(16) LineBasicUBO {
|
|
||||||
float4x4 matrix;
|
|
||||||
float2 units_to_pixels;
|
|
||||||
float ratio;
|
|
||||||
float pad;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct alignas(16) LineGradientUBO {
|
struct alignas(16) LineGradientUBO {
|
||||||
float4x4 matrix;
|
float4x4 matrix;
|
||||||
float ratio;
|
float ratio;
|
||||||
@@ -88,13 +81,6 @@ struct alignas(16) LinePropertiesUBO {
|
|||||||
float pad1, pad2, pad3;
|
float pad1, pad2, pad3;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct alignas(16) LineBasicPropertiesUBO {
|
|
||||||
float4 color;
|
|
||||||
float opacity;
|
|
||||||
float width;
|
|
||||||
float pad1, pad2;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct alignas(16) LineGradientPropertiesUBO {
|
struct alignas(16) LineGradientPropertiesUBO {
|
||||||
float blur;
|
float blur;
|
||||||
float opacity;
|
float opacity;
|
||||||
|
|||||||
@@ -518,5 +518,97 @@ half4 fragment fragmentMain(FragmentStage in [[stage_in]],
|
|||||||
)";
|
)";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct ShaderSource<BuiltIn::FillOutlineTriangulatedShader, gfx::Backend::Type::Metal> {
|
||||||
|
static constexpr auto name = "FillOutlineTriangulatedShader";
|
||||||
|
static constexpr auto vertexMainFunction = "vertexMain";
|
||||||
|
static constexpr auto fragmentMainFunction = "fragmentMain";
|
||||||
|
|
||||||
|
static const std::array<AttributeInfo, 2> attributes;
|
||||||
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
|
static const std::array<UniformBlockInfo, 2> uniforms;
|
||||||
|
static const std::array<TextureInfo, 0> textures;
|
||||||
|
|
||||||
|
static constexpr auto source = R"(
|
||||||
|
struct VertexStage {
|
||||||
|
short2 pos_normal [[attribute(0)]];
|
||||||
|
uchar4 data [[attribute(1)]];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FragmentStage {
|
||||||
|
float4 position [[position, invariant]];
|
||||||
|
float width2;
|
||||||
|
float2 normal;
|
||||||
|
half gamma_scale;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct alignas(16) FillOutlineTriangulatedDrawableUBO {
|
||||||
|
float4x4 matrix;
|
||||||
|
float2 units_to_pixels;
|
||||||
|
float ratio;
|
||||||
|
float pad;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct alignas(16) FillOutlineTriangulatedPropertiesUBO {
|
||||||
|
float4 color;
|
||||||
|
float opacity;
|
||||||
|
float width;
|
||||||
|
float pad1, pad2;
|
||||||
|
};
|
||||||
|
|
||||||
|
FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||||
|
device const FillOutlineTriangulatedDrawableUBO& drawable [[buffer(2)]],
|
||||||
|
device const FillOutlineTriangulatedPropertiesUBO& props [[buffer(3)]]) {
|
||||||
|
|
||||||
|
// the distance over which the line edge fades out.
|
||||||
|
// Retina devices need a smaller distance to avoid aliasing.
|
||||||
|
const float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0;
|
||||||
|
|
||||||
|
const float2 a_extrude = float2(vertx.data.xy) - 128.0;
|
||||||
|
const float2 pos = floor(float2(vertx.pos_normal) * 0.5);
|
||||||
|
|
||||||
|
// x is 1 if it's a round cap, 0 otherwise
|
||||||
|
// y is 1 if the normal points up, and -1 if it points down
|
||||||
|
// We store these in the least significant bit of a_pos_normal
|
||||||
|
const float2 normal = float2(vertx.pos_normal) - 2.0 * pos;
|
||||||
|
const float2 v_normal = float2(normal.x, normal.y * 2.0 - 1.0);
|
||||||
|
|
||||||
|
const float halfwidth = props.width / 2.0;
|
||||||
|
const float outset = halfwidth + (halfwidth == 0.0 ? 0.0 : ANTIALIASING);
|
||||||
|
|
||||||
|
// Scale the extrusion vector down to a normal and then up by the line width of this vertex.
|
||||||
|
const float2 dist = outset * a_extrude * LINE_NORMAL_SCALE;
|
||||||
|
|
||||||
|
const float4 projected_extrude = drawable.matrix * float4(dist / drawable.ratio, 0.0, 0.0);
|
||||||
|
const float4 position = drawable.matrix * float4(pos, 0.0, 1.0) + projected_extrude;
|
||||||
|
|
||||||
|
// calculate how much the perspective view squishes or stretches the extrude
|
||||||
|
const float extrude_length_without_perspective = length(dist);
|
||||||
|
const float extrude_length_with_perspective = length(projected_extrude.xy / position.w * drawable.units_to_pixels);
|
||||||
|
|
||||||
|
return {
|
||||||
|
.position = position,
|
||||||
|
.width2 = outset,
|
||||||
|
.normal = v_normal,
|
||||||
|
.gamma_scale = half(extrude_length_without_perspective / extrude_length_with_perspective),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
half4 fragment fragmentMain(FragmentStage in [[stage_in]],
|
||||||
|
device const FillOutlineTriangulatedPropertiesUBO& props [[buffer(3)]]) {
|
||||||
|
|
||||||
|
// Calculate the distance of the pixel from the line in pixels.
|
||||||
|
const float dist = length(in.normal) * in.width2;
|
||||||
|
|
||||||
|
// Calculate the antialiasing fade factor. This is either when fading in the
|
||||||
|
// line in case of an offset line (`v_width2.y`) or when fading out (`v_width2.x`)
|
||||||
|
const float blur2 = (1.0 / DEVICE_PIXEL_RATIO) * in.gamma_scale;
|
||||||
|
const float alpha = clamp(min(dist + blur2, in.width2 - dist) / blur2, 0.0, 1.0);
|
||||||
|
|
||||||
|
return half4(props.color * (alpha * props.opacity));
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace shaders
|
} // namespace shaders
|
||||||
} // namespace mbgl
|
} // namespace mbgl
|
||||||
|
|||||||
@@ -654,84 +654,5 @@ half4 fragment fragmentMain(FragmentStage in [[stage_in]],
|
|||||||
)";
|
)";
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
|
||||||
struct ShaderSource<BuiltIn::LineBasicShader, gfx::Backend::Type::Metal> {
|
|
||||||
static constexpr auto name = "LineBasicShader";
|
|
||||||
static constexpr auto vertexMainFunction = "vertexMain";
|
|
||||||
static constexpr auto fragmentMainFunction = "fragmentMain";
|
|
||||||
|
|
||||||
static const std::array<AttributeInfo, 2> attributes;
|
|
||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
|
||||||
static const std::array<UniformBlockInfo, 2> uniforms;
|
|
||||||
static const std::array<TextureInfo, 0> textures;
|
|
||||||
|
|
||||||
static constexpr auto source = R"(
|
|
||||||
struct VertexStage {
|
|
||||||
short2 pos_normal [[attribute(0)]];
|
|
||||||
uchar4 data [[attribute(1)]];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct FragmentStage {
|
|
||||||
float4 position [[position, invariant]];
|
|
||||||
float width2;
|
|
||||||
float2 normal;
|
|
||||||
half gamma_scale;
|
|
||||||
};
|
|
||||||
|
|
||||||
FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
|
||||||
device const LineBasicUBO& line [[buffer(2)]],
|
|
||||||
device const LineBasicPropertiesUBO& props [[buffer(3)]]) {
|
|
||||||
|
|
||||||
// the distance over which the line edge fades out.
|
|
||||||
// Retina devices need a smaller distance to avoid aliasing.
|
|
||||||
const float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0;
|
|
||||||
|
|
||||||
const float2 a_extrude = float2(vertx.data.xy) - 128.0;
|
|
||||||
const float2 pos = floor(float2(vertx.pos_normal) * 0.5);
|
|
||||||
|
|
||||||
// x is 1 if it's a round cap, 0 otherwise
|
|
||||||
// y is 1 if the normal points up, and -1 if it points down
|
|
||||||
// We store these in the least significant bit of a_pos_normal
|
|
||||||
const float2 normal = float2(vertx.pos_normal) - 2.0 * pos;
|
|
||||||
const float2 v_normal = float2(normal.x, normal.y * 2.0 - 1.0);
|
|
||||||
|
|
||||||
const float halfwidth = props.width / 2.0;
|
|
||||||
const float outset = halfwidth + (halfwidth == 0.0 ? 0.0 : ANTIALIASING);
|
|
||||||
|
|
||||||
// Scale the extrusion vector down to a normal and then up by the line width of this vertex.
|
|
||||||
const float2 dist = outset * a_extrude * LINE_NORMAL_SCALE;
|
|
||||||
|
|
||||||
const float4 projected_extrude = line.matrix * float4(dist / line.ratio, 0.0, 0.0);
|
|
||||||
const float4 position = line.matrix * float4(pos, 0.0, 1.0) + projected_extrude;
|
|
||||||
|
|
||||||
// calculate how much the perspective view squishes or stretches the extrude
|
|
||||||
const float extrude_length_without_perspective = length(dist);
|
|
||||||
const float extrude_length_with_perspective = length(projected_extrude.xy / position.w * line.units_to_pixels);
|
|
||||||
|
|
||||||
return {
|
|
||||||
.position = position,
|
|
||||||
.width2 = outset,
|
|
||||||
.normal = v_normal,
|
|
||||||
.gamma_scale = half(extrude_length_without_perspective / extrude_length_with_perspective),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
half4 fragment fragmentMain(FragmentStage in [[stage_in]],
|
|
||||||
device const LineBasicUBO& line [[buffer(2)]],
|
|
||||||
device const LineBasicPropertiesUBO& props [[buffer(3)]]) {
|
|
||||||
|
|
||||||
// Calculate the distance of the pixel from the line in pixels.
|
|
||||||
const float dist = length(in.normal) * in.width2;
|
|
||||||
|
|
||||||
// Calculate the antialiasing fade factor. This is either when fading in the
|
|
||||||
// line in case of an offset line (`v_width2.y`) or when fading out (`v_width2.x`)
|
|
||||||
const float blur2 = (1.0 / DEVICE_PIXEL_RATIO) * in.gamma_scale;
|
|
||||||
const float alpha = clamp(min(dist + blur2, in.width2 - dist) / blur2, 0.0, 1.0);
|
|
||||||
|
|
||||||
return half4(props.color * (alpha * props.opacity));
|
|
||||||
}
|
|
||||||
)";
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace shaders
|
} // namespace shaders
|
||||||
} // namespace mbgl
|
} // namespace mbgl
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ static constexpr auto maxUBOCountPerShader = std::max({static_cast<size_t>(backg
|
|||||||
static_cast<size_t>(fillOutlineUBOCount),
|
static_cast<size_t>(fillOutlineUBOCount),
|
||||||
static_cast<size_t>(fillPatternUBOCount),
|
static_cast<size_t>(fillPatternUBOCount),
|
||||||
static_cast<size_t>(fillOutlinePatternUBOCount),
|
static_cast<size_t>(fillOutlinePatternUBOCount),
|
||||||
|
static_cast<size_t>(fillOutlineTriangulatedUBOCount),
|
||||||
static_cast<size_t>(fillExtrusionUBOCount),
|
static_cast<size_t>(fillExtrusionUBOCount),
|
||||||
static_cast<size_t>(heatmapUBOCount),
|
static_cast<size_t>(heatmapUBOCount),
|
||||||
static_cast<size_t>(heatmapTextureUBOCount),
|
static_cast<size_t>(heatmapTextureUBOCount),
|
||||||
@@ -46,7 +47,6 @@ static constexpr auto maxUBOCountPerShader = std::max({static_cast<size_t>(backg
|
|||||||
static_cast<size_t>(lineGradientUBOCount),
|
static_cast<size_t>(lineGradientUBOCount),
|
||||||
static_cast<size_t>(linePatternUBOCount),
|
static_cast<size_t>(linePatternUBOCount),
|
||||||
static_cast<size_t>(lineSDFUBOCount),
|
static_cast<size_t>(lineSDFUBOCount),
|
||||||
static_cast<size_t>(lineBasicUBOCount),
|
|
||||||
static_cast<size_t>(rasterUBOCount),
|
static_cast<size_t>(rasterUBOCount),
|
||||||
static_cast<size_t>(symbolUBOCount),
|
static_cast<size_t>(symbolUBOCount),
|
||||||
static_cast<size_t>(wideVectorUBOCount)});
|
static_cast<size_t>(wideVectorUBOCount)});
|
||||||
|
|||||||
@@ -11,19 +11,19 @@
|
|||||||
#include <mbgl/shaders/gl/drawable_debug.hpp>
|
#include <mbgl/shaders/gl/drawable_debug.hpp>
|
||||||
#include <mbgl/shaders/gl/drawable_fill.hpp>
|
#include <mbgl/shaders/gl/drawable_fill.hpp>
|
||||||
#include <mbgl/shaders/gl/drawable_fill_outline.hpp>
|
#include <mbgl/shaders/gl/drawable_fill_outline.hpp>
|
||||||
#include <mbgl/shaders/gl/drawable_line_gradient.hpp>
|
|
||||||
#include <mbgl/shaders/gl/drawable_line_pattern.hpp>
|
|
||||||
#include <mbgl/shaders/gl/drawable_line_sdf.hpp>
|
|
||||||
#include <mbgl/shaders/gl/drawable_line.hpp>
|
|
||||||
#include <mbgl/shaders/gl/drawable_line_basic.hpp>
|
|
||||||
#include <mbgl/shaders/gl/drawable_fill_pattern.hpp>
|
#include <mbgl/shaders/gl/drawable_fill_pattern.hpp>
|
||||||
#include <mbgl/shaders/gl/drawable_fill_outline_pattern.hpp>
|
#include <mbgl/shaders/gl/drawable_fill_outline_pattern.hpp>
|
||||||
|
#include <mbgl/shaders/gl/drawable_fill_outline_triangulated.hpp>
|
||||||
#include <mbgl/shaders/gl/drawable_fill_extrusion.hpp>
|
#include <mbgl/shaders/gl/drawable_fill_extrusion.hpp>
|
||||||
#include <mbgl/shaders/gl/drawable_fill_extrusion_pattern.hpp>
|
#include <mbgl/shaders/gl/drawable_fill_extrusion_pattern.hpp>
|
||||||
#include <mbgl/shaders/gl/drawable_heatmap.hpp>
|
#include <mbgl/shaders/gl/drawable_heatmap.hpp>
|
||||||
#include <mbgl/shaders/gl/drawable_heatmap_texture.hpp>
|
#include <mbgl/shaders/gl/drawable_heatmap_texture.hpp>
|
||||||
#include <mbgl/shaders/gl/drawable_hillshade_prepare.hpp>
|
#include <mbgl/shaders/gl/drawable_hillshade_prepare.hpp>
|
||||||
#include <mbgl/shaders/gl/drawable_hillshade.hpp>
|
#include <mbgl/shaders/gl/drawable_hillshade.hpp>
|
||||||
|
#include <mbgl/shaders/gl/drawable_line.hpp>
|
||||||
|
#include <mbgl/shaders/gl/drawable_line_gradient.hpp>
|
||||||
|
#include <mbgl/shaders/gl/drawable_line_pattern.hpp>
|
||||||
|
#include <mbgl/shaders/gl/drawable_line_sdf.hpp>
|
||||||
#include <mbgl/shaders/gl/drawable_raster.hpp>
|
#include <mbgl/shaders/gl/drawable_raster.hpp>
|
||||||
#include <mbgl/shaders/gl/drawable_symbol_icon.hpp>
|
#include <mbgl/shaders/gl/drawable_symbol_icon.hpp>
|
||||||
#include <mbgl/shaders/gl/drawable_symbol_sdf.hpp>
|
#include <mbgl/shaders/gl/drawable_symbol_sdf.hpp>
|
||||||
|
|||||||
@@ -17,19 +17,19 @@ enum class BuiltIn {
|
|||||||
DebugShader,
|
DebugShader,
|
||||||
FillShader,
|
FillShader,
|
||||||
FillOutlineShader,
|
FillOutlineShader,
|
||||||
LineGradientShader,
|
|
||||||
LinePatternShader,
|
|
||||||
LineSDFShader,
|
|
||||||
LineShader,
|
|
||||||
LineBasicShader,
|
|
||||||
FillPatternShader,
|
FillPatternShader,
|
||||||
FillOutlinePatternShader,
|
FillOutlinePatternShader,
|
||||||
|
FillOutlineTriangulatedShader,
|
||||||
FillExtrusionShader,
|
FillExtrusionShader,
|
||||||
FillExtrusionPatternShader,
|
FillExtrusionPatternShader,
|
||||||
HeatmapShader,
|
HeatmapShader,
|
||||||
HeatmapTextureShader,
|
HeatmapTextureShader,
|
||||||
HillshadePrepareShader,
|
HillshadePrepareShader,
|
||||||
HillshadeShader,
|
HillshadeShader,
|
||||||
|
LineShader,
|
||||||
|
LineGradientShader,
|
||||||
|
LinePatternShader,
|
||||||
|
LineSDFShader,
|
||||||
RasterShader,
|
RasterShader,
|
||||||
SymbolIconShader,
|
SymbolIconShader,
|
||||||
SymbolSDFIconShader,
|
SymbolSDFIconShader,
|
||||||
|
|||||||
@@ -1,15 +1,7 @@
|
|||||||
layout (std140) uniform LineBasicUBO {
|
layout (std140) uniform FillOutlineTriangulatedPropertiesUBO {
|
||||||
highp mat4 u_matrix;
|
|
||||||
highp vec2 u_units_to_pixels;
|
|
||||||
mediump float u_ratio;
|
|
||||||
lowp float pad0;
|
|
||||||
};
|
|
||||||
|
|
||||||
layout (std140) uniform LineBasicPropertiesUBO {
|
|
||||||
highp vec4 u_color;
|
highp vec4 u_color;
|
||||||
lowp float u_opacity;
|
lowp float u_opacity;
|
||||||
mediump float u_width;
|
mediump float u_width;
|
||||||
|
|
||||||
highp vec2 pad1;
|
highp vec2 pad1;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -9,18 +9,17 @@
|
|||||||
layout (location = 0) in vec2 a_pos_normal;
|
layout (location = 0) in vec2 a_pos_normal;
|
||||||
layout (location = 1) in vec4 a_data;
|
layout (location = 1) in vec4 a_data;
|
||||||
|
|
||||||
layout (std140) uniform LineBasicUBO {
|
layout (std140) uniform FillOutlineTriangulatedDrawableUBO {
|
||||||
highp mat4 u_matrix;
|
highp mat4 u_matrix;
|
||||||
highp vec2 u_units_to_pixels;
|
highp vec2 u_units_to_pixels;
|
||||||
mediump float u_ratio;
|
mediump float u_ratio;
|
||||||
lowp float pad0;
|
lowp float pad0;
|
||||||
};
|
};
|
||||||
|
|
||||||
layout (std140) uniform LineBasicPropertiesUBO {
|
layout (std140) uniform FillOutlineTriangulatedPropertiesUBO {
|
||||||
highp vec4 u_color;
|
highp vec4 u_color;
|
||||||
lowp float u_opacity;
|
lowp float u_opacity;
|
||||||
mediump float u_width;
|
mediump float u_width;
|
||||||
|
|
||||||
highp vec2 pad1;
|
highp vec2 pad1;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -55,41 +55,6 @@
|
|||||||
"glsl_frag": "drawable.fill_outline.fragment.glsl",
|
"glsl_frag": "drawable.fill_outline.fragment.glsl",
|
||||||
"uses_ubos": true
|
"uses_ubos": true
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "LineGradientShader",
|
|
||||||
"header": "drawable_line_gradient",
|
|
||||||
"glsl_vert": "drawable.line_gradient.vertex.glsl",
|
|
||||||
"glsl_frag": "drawable.line_gradient.fragment.glsl",
|
|
||||||
"uses_ubos": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "LinePatternShader",
|
|
||||||
"header": "drawable_line_pattern",
|
|
||||||
"glsl_vert": "drawable.line_pattern.vertex.glsl",
|
|
||||||
"glsl_frag": "drawable.line_pattern.fragment.glsl",
|
|
||||||
"uses_ubos": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "LineSDFShader",
|
|
||||||
"header": "drawable_line_sdf",
|
|
||||||
"glsl_vert": "drawable.line_sdf.vertex.glsl",
|
|
||||||
"glsl_frag": "drawable.line_sdf.fragment.glsl",
|
|
||||||
"uses_ubos": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "LineShader",
|
|
||||||
"header": "drawable_line",
|
|
||||||
"glsl_vert": "drawable.line.vertex.glsl",
|
|
||||||
"glsl_frag": "drawable.line.fragment.glsl",
|
|
||||||
"uses_ubos": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "LineBasicShader",
|
|
||||||
"header": "drawable_line_basic",
|
|
||||||
"glsl_vert": "drawable.line_basic.vertex.glsl",
|
|
||||||
"glsl_frag": "drawable.line_basic.fragment.glsl",
|
|
||||||
"uses_ubos": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "FillPatternShader",
|
"name": "FillPatternShader",
|
||||||
"header": "drawable_fill_pattern",
|
"header": "drawable_fill_pattern",
|
||||||
@@ -104,6 +69,13 @@
|
|||||||
"glsl_frag": "drawable.fill_outline_pattern.fragment.glsl",
|
"glsl_frag": "drawable.fill_outline_pattern.fragment.glsl",
|
||||||
"uses_ubos": true
|
"uses_ubos": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "FillOutlineTriangulatedShader",
|
||||||
|
"header": "drawable_fill_outline_triangulated",
|
||||||
|
"glsl_vert": "drawable.fill_outline_triangulated.vertex.glsl",
|
||||||
|
"glsl_frag": "drawable.fill_outline_triangulated.fragment.glsl",
|
||||||
|
"uses_ubos": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "FillExtrusionShader",
|
"name": "FillExtrusionShader",
|
||||||
"header": "drawable_fill_extrusion",
|
"header": "drawable_fill_extrusion",
|
||||||
@@ -146,6 +118,34 @@
|
|||||||
"glsl_frag": "drawable.hillshade.fragment.glsl",
|
"glsl_frag": "drawable.hillshade.fragment.glsl",
|
||||||
"uses_ubos": true
|
"uses_ubos": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "LineShader",
|
||||||
|
"header": "drawable_line",
|
||||||
|
"glsl_vert": "drawable.line.vertex.glsl",
|
||||||
|
"glsl_frag": "drawable.line.fragment.glsl",
|
||||||
|
"uses_ubos": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "LineGradientShader",
|
||||||
|
"header": "drawable_line_gradient",
|
||||||
|
"glsl_vert": "drawable.line_gradient.vertex.glsl",
|
||||||
|
"glsl_frag": "drawable.line_gradient.fragment.glsl",
|
||||||
|
"uses_ubos": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "LinePatternShader",
|
||||||
|
"header": "drawable_line_pattern",
|
||||||
|
"glsl_vert": "drawable.line_pattern.vertex.glsl",
|
||||||
|
"glsl_frag": "drawable.line_pattern.fragment.glsl",
|
||||||
|
"uses_ubos": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "LineSDFShader",
|
||||||
|
"header": "drawable_line_sdf",
|
||||||
|
"glsl_vert": "drawable.line_sdf.vertex.glsl",
|
||||||
|
"glsl_frag": "drawable.line_sdf.fragment.glsl",
|
||||||
|
"uses_ubos": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "RasterShader",
|
"name": "RasterShader",
|
||||||
"header": "drawable_raster",
|
"header": "drawable_raster",
|
||||||
|
|||||||
@@ -102,19 +102,19 @@ void RendererBackend::initShaders(gfx::ShaderRegistry& shaders, const ProgramPar
|
|||||||
shaders::BuiltIn::DebugShader,
|
shaders::BuiltIn::DebugShader,
|
||||||
shaders::BuiltIn::FillShader,
|
shaders::BuiltIn::FillShader,
|
||||||
shaders::BuiltIn::FillOutlineShader,
|
shaders::BuiltIn::FillOutlineShader,
|
||||||
shaders::BuiltIn::LineBasicShader,
|
|
||||||
shaders::BuiltIn::LineShader,
|
|
||||||
shaders::BuiltIn::LineSDFShader,
|
|
||||||
shaders::BuiltIn::LinePatternShader,
|
|
||||||
shaders::BuiltIn::LineGradientShader,
|
|
||||||
shaders::BuiltIn::FillOutlinePatternShader,
|
|
||||||
shaders::BuiltIn::FillPatternShader,
|
shaders::BuiltIn::FillPatternShader,
|
||||||
|
shaders::BuiltIn::FillOutlinePatternShader,
|
||||||
|
shaders::BuiltIn::FillOutlineTriangulatedShader,
|
||||||
shaders::BuiltIn::FillExtrusionShader,
|
shaders::BuiltIn::FillExtrusionShader,
|
||||||
shaders::BuiltIn::FillExtrusionPatternShader,
|
shaders::BuiltIn::FillExtrusionPatternShader,
|
||||||
shaders::BuiltIn::HeatmapShader,
|
shaders::BuiltIn::HeatmapShader,
|
||||||
shaders::BuiltIn::HeatmapTextureShader,
|
shaders::BuiltIn::HeatmapTextureShader,
|
||||||
shaders::BuiltIn::HillshadePrepareShader,
|
shaders::BuiltIn::HillshadePrepareShader,
|
||||||
shaders::BuiltIn::HillshadeShader,
|
shaders::BuiltIn::HillshadeShader,
|
||||||
|
shaders::BuiltIn::LineShader,
|
||||||
|
shaders::BuiltIn::LineGradientShader,
|
||||||
|
shaders::BuiltIn::LinePatternShader,
|
||||||
|
shaders::BuiltIn::LineSDFShader,
|
||||||
shaders::BuiltIn::RasterShader,
|
shaders::BuiltIn::RasterShader,
|
||||||
shaders::BuiltIn::SymbolIconShader,
|
shaders::BuiltIn::SymbolIconShader,
|
||||||
shaders::BuiltIn::SymbolSDFIconShader,
|
shaders::BuiltIn::SymbolSDFIconShader,
|
||||||
|
|||||||
@@ -135,15 +135,15 @@ void RendererBackend::initShaders(gfx::ShaderRegistry& shaders, const ProgramPar
|
|||||||
shaders::BuiltIn::DebugShader,
|
shaders::BuiltIn::DebugShader,
|
||||||
shaders::BuiltIn::FillShader,
|
shaders::BuiltIn::FillShader,
|
||||||
shaders::BuiltIn::FillOutlineShader,
|
shaders::BuiltIn::FillOutlineShader,
|
||||||
shaders::BuiltIn::FillOutlinePatternShader,
|
|
||||||
shaders::BuiltIn::FillPatternShader,
|
shaders::BuiltIn::FillPatternShader,
|
||||||
|
shaders::BuiltIn::FillOutlinePatternShader,
|
||||||
|
shaders::BuiltIn::FillOutlineTriangulatedShader,
|
||||||
shaders::BuiltIn::FillExtrusionShader,
|
shaders::BuiltIn::FillExtrusionShader,
|
||||||
shaders::BuiltIn::FillExtrusionPatternShader,
|
shaders::BuiltIn::FillExtrusionPatternShader,
|
||||||
shaders::BuiltIn::HeatmapShader,
|
shaders::BuiltIn::HeatmapShader,
|
||||||
shaders::BuiltIn::HeatmapTextureShader,
|
shaders::BuiltIn::HeatmapTextureShader,
|
||||||
shaders::BuiltIn::HillshadeShader,
|
shaders::BuiltIn::HillshadeShader,
|
||||||
shaders::BuiltIn::HillshadePrepareShader,
|
shaders::BuiltIn::HillshadePrepareShader,
|
||||||
shaders::BuiltIn::LineBasicShader,
|
|
||||||
shaders::BuiltIn::LineShader,
|
shaders::BuiltIn::LineShader,
|
||||||
shaders::BuiltIn::LineGradientShader,
|
shaders::BuiltIn::LineGradientShader,
|
||||||
shaders::BuiltIn::LineSDFShader,
|
shaders::BuiltIn::LineSDFShader,
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ void FillLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
|
|||||||
fillOutlineUniformBufferUpdated = true;
|
fillOutlineUniformBufferUpdated = true;
|
||||||
fillPatternUniformBufferUpdated = true;
|
fillPatternUniformBufferUpdated = true;
|
||||||
fillOutlinePatternUniformBufferUpdated = true;
|
fillOutlinePatternUniformBufferUpdated = true;
|
||||||
|
fillOutlineTriangulatedUniformBufferUpdated = true;
|
||||||
propertiesUpdated = false;
|
propertiesUpdated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,6 +103,19 @@ void FillLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const auto UpdateFillOutlineTriangulatedUniformBuffers = [&]() {
|
||||||
|
if (!fillOutlineTriangulatedUniformBuffer || fillOutlineTriangulatedUniformBufferUpdated) {
|
||||||
|
const shaders::FillOutlineTriangulatedPropertiesUBO paramsUBO = {
|
||||||
|
/* .color = */ evaluated.get<FillOutlineColor>().constantOr(FillOutlineColor::defaultValue()),
|
||||||
|
/* .opacity = */ evaluated.get<FillOpacity>().constantOr(FillOpacity::defaultValue()),
|
||||||
|
/* .width = */ 1.f,
|
||||||
|
/* .ratio = */ 0,
|
||||||
|
0};
|
||||||
|
context.emplaceOrUpdateUniformBuffer(fillOutlineTriangulatedUniformBuffer, ¶msUBO);
|
||||||
|
fillOutlineTriangulatedUniformBufferUpdated = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const auto& translation = evaluated.get<FillTranslate>();
|
const auto& translation = evaluated.get<FillTranslate>();
|
||||||
const auto anchor = evaluated.get<FillTranslateAnchor>();
|
const auto anchor = evaluated.get<FillTranslateAnchor>();
|
||||||
|
|
||||||
@@ -193,6 +207,19 @@ void FillLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
|
|||||||
uniforms.createOrUpdate(idFillOutlinePatternDrawableUBO, &drawableUBO, context);
|
uniforms.createOrUpdate(idFillOutlinePatternDrawableUBO, &drawableUBO, context);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case RenderFillLayer::FillVariant::FillOutlineTriangulated: {
|
||||||
|
UpdateFillOutlineTriangulatedUniformBuffers();
|
||||||
|
|
||||||
|
uniforms.set(idFillOutlineTriangulatedPropertiesUBO, fillOutlineTriangulatedUniformBuffer);
|
||||||
|
|
||||||
|
const FillOutlineTriangulatedDrawableUBO drawableUBO{
|
||||||
|
/*matrix = */ util::cast<float>(matrix),
|
||||||
|
/*units_to_pixels = */ {1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]},
|
||||||
|
/*ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, parameters.state.getZoom()),
|
||||||
|
0};
|
||||||
|
uniforms.createOrUpdate(idFillOutlineTriangulatedDrawableUBO, &drawableUBO, context);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
mbgl::Log::Error(mbgl::Event::Render, "Invalid fill variant type supplied during drawable update!");
|
mbgl::Log::Error(mbgl::Event::Render, "Invalid fill variant type supplied during drawable update!");
|
||||||
|
|||||||
@@ -24,12 +24,14 @@ private:
|
|||||||
gfx::UniformBufferPtr fillOutlinePropsUniformBuffer;
|
gfx::UniformBufferPtr fillOutlinePropsUniformBuffer;
|
||||||
gfx::UniformBufferPtr fillPatternPropsUniformBuffer;
|
gfx::UniformBufferPtr fillPatternPropsUniformBuffer;
|
||||||
gfx::UniformBufferPtr fillOutlinePatternPropsUniformBuffer;
|
gfx::UniformBufferPtr fillOutlinePatternPropsUniformBuffer;
|
||||||
|
gfx::UniformBufferPtr fillOutlineTriangulatedUniformBuffer;
|
||||||
|
|
||||||
// Only run each update function once per property update
|
// Only run each update function once per property update
|
||||||
bool fillUniformBufferUpdated = true;
|
bool fillUniformBufferUpdated = true;
|
||||||
bool fillOutlineUniformBufferUpdated = true;
|
bool fillOutlineUniformBufferUpdated = true;
|
||||||
bool fillPatternUniformBufferUpdated = true;
|
bool fillPatternUniformBufferUpdated = true;
|
||||||
bool fillOutlinePatternUniformBufferUpdated = true;
|
bool fillOutlinePatternUniformBufferUpdated = true;
|
||||||
|
bool fillOutlineTriangulatedUniformBufferUpdated = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mbgl
|
} // namespace mbgl
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
#include <mbgl/renderer/update_parameters.hpp>
|
#include <mbgl/renderer/update_parameters.hpp>
|
||||||
#include <mbgl/shaders/fill_layer_ubo.hpp>
|
#include <mbgl/shaders/fill_layer_ubo.hpp>
|
||||||
#include <mbgl/shaders/shader_program_base.hpp>
|
#include <mbgl/shaders/shader_program_base.hpp>
|
||||||
#include <mbgl/shaders/line_layer_ubo.hpp>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace mbgl {
|
namespace mbgl {
|
||||||
@@ -42,12 +41,12 @@ namespace {
|
|||||||
|
|
||||||
#if MLN_DRAWABLE_RENDERER
|
#if MLN_DRAWABLE_RENDERER
|
||||||
constexpr auto FillShaderName = "FillShader";
|
constexpr auto FillShaderName = "FillShader";
|
||||||
#if MLN_TRIANGULATE_FILL_OUTLINES
|
|
||||||
constexpr auto FillOutlineTriangulatedShaderName = "LineBasicShader";
|
|
||||||
#endif
|
|
||||||
constexpr auto FillOutlineShaderName = "FillOutlineShader";
|
constexpr auto FillOutlineShaderName = "FillOutlineShader";
|
||||||
constexpr auto FillPatternShaderName = "FillPatternShader";
|
constexpr auto FillPatternShaderName = "FillPatternShader";
|
||||||
constexpr auto FillOutlinePatternShaderName = "FillOutlinePatternShader";
|
constexpr auto FillOutlinePatternShaderName = "FillOutlinePatternShader";
|
||||||
|
#if MLN_TRIANGULATE_FILL_OUTLINES
|
||||||
|
constexpr auto FillOutlineTriangulatedShaderName = "FillOutlineTriangulatedShader";
|
||||||
|
#endif
|
||||||
#endif // MLN_DRAWABLE_RENDERER
|
#endif // MLN_DRAWABLE_RENDERER
|
||||||
|
|
||||||
inline const FillLayer::Impl& impl_cast(const Immutable<style::Layer::Impl>& impl) {
|
inline const FillLayer::Impl& impl_cast(const Immutable<style::Layer::Impl>& impl) {
|
||||||
@@ -105,49 +104,6 @@ bool RenderFillLayer::hasCrossfade() const {
|
|||||||
return getCrossfade<FillLayerProperties>(evaluatedProperties).t != 1;
|
return getCrossfade<FillLayerProperties>(evaluatedProperties).t != 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MLN_TRIANGULATE_FILL_OUTLINES
|
|
||||||
void RenderFillLayer::markLayerRenderable(bool willRender, UniqueChangeRequestVec& changes) {
|
|
||||||
RenderLayer::markLayerRenderable(willRender, changes);
|
|
||||||
if (outlineLayerGroup) {
|
|
||||||
activateLayerGroup(outlineLayerGroup, willRender, changes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderFillLayer::layerRemoved(UniqueChangeRequestVec& changes) {
|
|
||||||
RenderLayer::layerRemoved(changes);
|
|
||||||
if (outlineLayerGroup) {
|
|
||||||
activateLayerGroup(outlineLayerGroup, false, changes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderFillLayer::layerIndexChanged(int32_t newLayerIndex, UniqueChangeRequestVec& changes) {
|
|
||||||
RenderLayer::layerIndexChanged(newLayerIndex, changes);
|
|
||||||
|
|
||||||
changeLayerIndex(outlineLayerGroup, newLayerIndex, changes);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::size_t RenderFillLayer::removeAllDrawables() {
|
|
||||||
auto count = RenderLayer::removeAllDrawables();
|
|
||||||
if (outlineLayerGroup) {
|
|
||||||
auto count2 = outlineLayerGroup->clearDrawables();
|
|
||||||
stats.drawablesRemoved += count2;
|
|
||||||
count += count2;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::size_t RenderFillLayer::removeTile(RenderPass renderPass, const OverscaledTileID& tileID) {
|
|
||||||
RenderLayer::removeTile(renderPass, tileID);
|
|
||||||
if (const auto tileGroup = static_cast<TileLayerGroup*>(outlineLayerGroup.get())) {
|
|
||||||
const auto n = tileGroup->removeDrawables(renderPass, tileID).size();
|
|
||||||
stats.drawablesRemoved += n;
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // MLN_TRIANGULATE_FILL_OUTLINES
|
|
||||||
|
|
||||||
#if MLN_LEGACY_RENDERER
|
#if MLN_LEGACY_RENDERER
|
||||||
void RenderFillLayer::render(PaintParameters& parameters) {
|
void RenderFillLayer::render(PaintParameters& parameters) {
|
||||||
assert(renderTiles);
|
assert(renderTiles);
|
||||||
@@ -338,60 +294,6 @@ bool RenderFillLayer::queryIntersectsFeature(const GeometryCoordinates& queryGeo
|
|||||||
|
|
||||||
#if MLN_DRAWABLE_RENDERER
|
#if MLN_DRAWABLE_RENDERER
|
||||||
|
|
||||||
#if MLN_TRIANGULATE_FILL_OUTLINES
|
|
||||||
class OutlineDrawableTweaker : public gfx::DrawableTweaker {
|
|
||||||
public:
|
|
||||||
OutlineDrawableTweaker(Color color_, float opacity_)
|
|
||||||
: color(color_),
|
|
||||||
opacity(opacity_) {}
|
|
||||||
~OutlineDrawableTweaker() override = default;
|
|
||||||
|
|
||||||
void init(gfx::Drawable&) override {};
|
|
||||||
|
|
||||||
virtual void execute(gfx::Drawable& drawable, const PaintParameters& parameters) override {
|
|
||||||
if (!drawable.getTileID().has_value()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const UnwrappedTileID tileID = drawable.getTileID()->toUnwrapped();
|
|
||||||
const auto zoom = parameters.state.getZoom();
|
|
||||||
auto& uniforms = drawable.mutableUniformBuffers();
|
|
||||||
|
|
||||||
{
|
|
||||||
const auto matrix = LayerTweaker::getTileMatrix(
|
|
||||||
tileID, parameters, {{0, 0}}, style::TranslateAnchorType::Viewport, false, false, drawable, false);
|
|
||||||
|
|
||||||
const shaders::LineBasicUBO lineBasicUBO{
|
|
||||||
/*matrix = */ util::cast<float>(matrix),
|
|
||||||
/*units_to_pixels = */ {1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]},
|
|
||||||
/*ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, zoom),
|
|
||||||
0};
|
|
||||||
parameters.context.emplaceOrUpdateUniformBuffer(lineUniformBuffer, &lineBasicUBO);
|
|
||||||
}
|
|
||||||
uniforms.set(idLineBasicUBO, lineUniformBuffer);
|
|
||||||
|
|
||||||
if (!linePropertiesUniformBuffer) {
|
|
||||||
const shaders::LineBasicPropertiesUBO linePropertiesUBO{/*color =*/color,
|
|
||||||
/*opacity =*/opacity,
|
|
||||||
/*width =*/1.f,
|
|
||||||
0,
|
|
||||||
0};
|
|
||||||
parameters.context.emplaceOrUpdateUniformBuffer(linePropertiesUniformBuffer, &linePropertiesUBO);
|
|
||||||
}
|
|
||||||
if (!uniforms.get(idLineBasicPropertiesUBO)) {
|
|
||||||
uniforms.set(idLineBasicPropertiesUBO, linePropertiesUniformBuffer);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
|
||||||
Color color;
|
|
||||||
float opacity;
|
|
||||||
|
|
||||||
gfx::UniformBufferPtr lineUniformBuffer;
|
|
||||||
gfx::UniformBufferPtr linePropertiesUniformBuffer;
|
|
||||||
};
|
|
||||||
#endif // MLN_TRIANGULATE_FILL_OUTLINES
|
|
||||||
|
|
||||||
void RenderFillLayer::update(gfx::ShaderRegistry& shaders,
|
void RenderFillLayer::update(gfx::ShaderRegistry& shaders,
|
||||||
gfx::Context& context,
|
gfx::Context& context,
|
||||||
const TransformState& state,
|
const TransformState& state,
|
||||||
@@ -414,12 +316,6 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders,
|
|||||||
auto* fillTileLayerGroup = static_cast<TileLayerGroup*>(layerGroup.get());
|
auto* fillTileLayerGroup = static_cast<TileLayerGroup*>(layerGroup.get());
|
||||||
|
|
||||||
#if MLN_TRIANGULATE_FILL_OUTLINES
|
#if MLN_TRIANGULATE_FILL_OUTLINES
|
||||||
// Set up a layer group for outlines
|
|
||||||
if (!outlineLayerGroup) {
|
|
||||||
outlineLayerGroup = context.createTileLayerGroup(layerIndex, /*initialCapacity=*/64, getID());
|
|
||||||
activateLayerGroup(outlineLayerGroup, isRenderable, changes);
|
|
||||||
}
|
|
||||||
auto* outlineTileLayerGroup = static_cast<TileLayerGroup*>(outlineLayerGroup.get());
|
|
||||||
if (!outlineTriangulatedShaderGroup) {
|
if (!outlineTriangulatedShaderGroup) {
|
||||||
outlineTriangulatedShaderGroup = shaders.getShaderGroup(std::string(FillOutlineTriangulatedShaderName));
|
outlineTriangulatedShaderGroup = shaders.getShaderGroup(std::string(FillOutlineTriangulatedShaderName));
|
||||||
}
|
}
|
||||||
@@ -460,21 +356,11 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders,
|
|||||||
builder.setEnableStencil(true);
|
builder.setEnableStencil(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
#if MLN_TRIANGULATE_FILL_OUTLINES
|
|
||||||
for (auto layer : {fillTileLayerGroup, outlineTileLayerGroup}) {
|
|
||||||
stats.drawablesRemoved += layer->removeDrawablesIf([&](gfx::Drawable& drawable) {
|
|
||||||
// If the render pass has changed or the tile has dropped out of the cover set, remove it.
|
|
||||||
const auto& tileID = drawable.getTileID();
|
|
||||||
return tileID && !hasRenderTile(*tileID);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
stats.drawablesRemoved += fillTileLayerGroup->removeDrawablesIf([&](gfx::Drawable& drawable) {
|
stats.drawablesRemoved += fillTileLayerGroup->removeDrawablesIf([&](gfx::Drawable& drawable) {
|
||||||
// If the render pass has changed or the tile has dropped out of the cover set, remove it.
|
// If the render pass has changed or the tile has dropped out of the cover set, remove it.
|
||||||
const auto& tileID = drawable.getTileID();
|
const auto& tileID = drawable.getTileID();
|
||||||
return tileID && !hasRenderTile(*tileID);
|
return tileID && !hasRenderTile(*tileID);
|
||||||
});
|
});
|
||||||
#endif
|
|
||||||
|
|
||||||
fillTileLayerGroup->setStencilTiles(renderTiles);
|
fillTileLayerGroup->setStencilTiles(renderTiles);
|
||||||
|
|
||||||
@@ -690,7 +576,7 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders,
|
|||||||
}()
|
}()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
|
||||||
auto createOutline = [&](auto& builder, Color color, float opacity) {
|
auto createOutlineTriangulated = [&](auto& builder) {
|
||||||
if (doOutline && builder && bucket.sharedLineIndexes->elements()) {
|
if (doOutline && builder && bucket.sharedLineIndexes->elements()) {
|
||||||
builder->setShader(outlineTriangulatedShader);
|
builder->setShader(outlineTriangulatedShader);
|
||||||
builder->setRawVertices({}, bucket.lineVertices.elements(), gfx::AttributeDataType::Short2);
|
builder->setRawVertices({}, bucket.lineVertices.elements(), gfx::AttributeDataType::Short2);
|
||||||
@@ -717,14 +603,12 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders,
|
|||||||
bucket.lineSegments.data(),
|
bucket.lineSegments.data(),
|
||||||
bucket.lineSegments.size());
|
bucket.lineSegments.size());
|
||||||
|
|
||||||
auto tweaker = std::make_shared<OutlineDrawableTweaker>(color, opacity);
|
|
||||||
|
|
||||||
// finish
|
// finish
|
||||||
builder->flush(context);
|
builder->flush(context);
|
||||||
for (auto& drawable : builder->clearDrawables()) {
|
for (auto& drawable : builder->clearDrawables()) {
|
||||||
drawable->setTileID(tileID);
|
drawable->setTileID(tileID);
|
||||||
drawable->addTweaker(tweaker);
|
drawable->setType(static_cast<size_t>(FillVariant::FillOutlineTriangulated));
|
||||||
outlineTileLayerGroup->addDrawable(renderPass, tileID, std::move(drawable));
|
fillTileLayerGroup->addDrawable(renderPass, tileID, std::move(drawable));
|
||||||
++stats.drawablesAdded;
|
++stats.drawablesAdded;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -808,9 +692,7 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders,
|
|||||||
if (doOutline && outlineBuilder) {
|
if (doOutline && outlineBuilder) {
|
||||||
if (!dataDrivenOutline) {
|
if (!dataDrivenOutline) {
|
||||||
outlineBuilder->setSubLayerIndex(unevaluated.get<FillOutlineColor>().isUndefined() ? 2 : 0);
|
outlineBuilder->setSubLayerIndex(unevaluated.get<FillOutlineColor>().isUndefined() ? 2 : 0);
|
||||||
createOutline(outlineBuilder,
|
createOutlineTriangulated(outlineBuilder);
|
||||||
evaluated.get<FillOutlineColor>().constantOr(FillOutlineColor::defaultValue()),
|
|
||||||
evaluated.get<FillOpacity>().constantOr(FillOpacity::defaultValue()));
|
|
||||||
} else {
|
} else {
|
||||||
if (bucket.sharedBasicLineIndexes->elements()) {
|
if (bucket.sharedBasicLineIndexes->elements()) {
|
||||||
outlineBuilder->setShader(outlineShader);
|
outlineBuilder->setShader(outlineShader);
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public:
|
|||||||
FillPattern,
|
FillPattern,
|
||||||
FillOutline,
|
FillOutline,
|
||||||
FillOutlinePattern,
|
FillOutlinePattern,
|
||||||
|
FillOutlineTriangulated,
|
||||||
Undefined = 255
|
Undefined = 255
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -45,15 +46,6 @@ public:
|
|||||||
UniqueChangeRequestVec&) override;
|
UniqueChangeRequestVec&) override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
|
||||||
#if MLN_TRIANGULATE_FILL_OUTLINES
|
|
||||||
void markLayerRenderable(bool willRender, UniqueChangeRequestVec&) override;
|
|
||||||
void layerIndexChanged(int32_t newLayerIndex, UniqueChangeRequestVec&) override;
|
|
||||||
void layerRemoved(UniqueChangeRequestVec&) override;
|
|
||||||
std::size_t removeAllDrawables() override;
|
|
||||||
std::size_t removeTile(RenderPass, const OverscaledTileID&) override;
|
|
||||||
#endif // MLN_DRAWABLE_RENDERER
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void transition(const TransitionParameters&) override;
|
void transition(const TransitionParameters&) override;
|
||||||
void evaluate(const PropertyEvaluationParameters&) override;
|
void evaluate(const PropertyEvaluationParameters&) override;
|
||||||
@@ -90,7 +82,6 @@ private:
|
|||||||
gfx::ShaderGroupPtr outlinePatternShaderGroup;
|
gfx::ShaderGroupPtr outlinePatternShaderGroup;
|
||||||
|
|
||||||
#if MLN_TRIANGULATE_FILL_OUTLINES
|
#if MLN_TRIANGULATE_FILL_OUTLINES
|
||||||
LayerGroupBasePtr outlineLayerGroup;
|
|
||||||
gfx::ShaderGroupPtr outlineTriangulatedShaderGroup;
|
gfx::ShaderGroupPtr outlineTriangulatedShaderGroup;
|
||||||
#endif // MLN_TRIANGULATE_FILL_OUTLINES
|
#endif // MLN_TRIANGULATE_FILL_OUTLINES
|
||||||
|
|
||||||
|
|||||||
@@ -177,6 +177,20 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::FillOutlinePatternShader, gfx
|
|||||||
TextureInfo{"u_image", idFillImageTexture},
|
TextureInfo{"u_image", idFillImageTexture},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Fill Outline Triangulated
|
||||||
|
const std::vector<AttributeInfo>
|
||||||
|
ShaderInfo<BuiltIn::FillOutlineTriangulatedShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||||
|
AttributeInfo{"a_pos_normal", idLinePosNormalVertexAttribute},
|
||||||
|
AttributeInfo{"a_data", idLineDataVertexAttribute},
|
||||||
|
};
|
||||||
|
const std::vector<UniformBlockInfo>
|
||||||
|
ShaderInfo<BuiltIn::FillOutlineTriangulatedShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||||
|
UniformBlockInfo{"FillOutlineTriangulatedDrawableUBO", idFillOutlineTriangulatedDrawableUBO},
|
||||||
|
UniformBlockInfo{"FillOutlineTriangulatedPropertiesUBO", idFillOutlineTriangulatedPropertiesUBO},
|
||||||
|
};
|
||||||
|
const std::vector<TextureInfo>
|
||||||
|
ShaderInfo<BuiltIn::FillOutlineTriangulatedShader, gfx::Backend::Type::OpenGL>::textures = {};
|
||||||
|
|
||||||
// Fill Extrusion
|
// Fill Extrusion
|
||||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::FillExtrusionShader, gfx::Backend::Type::OpenGL>::attributes = {
|
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::FillExtrusionShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||||
AttributeInfo{"a_pos", idFillExtrusionPosVertexAttribute},
|
AttributeInfo{"a_pos", idFillExtrusionPosVertexAttribute},
|
||||||
@@ -353,17 +367,6 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::LineSDFShader, gfx::Backend::
|
|||||||
TextureInfo{"u_image", idLineImageTexture},
|
TextureInfo{"u_image", idLineImageTexture},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Line Basic
|
|
||||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::LineBasicShader, gfx::Backend::Type::OpenGL>::attributes = {
|
|
||||||
AttributeInfo{"a_pos_normal", idLinePosNormalVertexAttribute},
|
|
||||||
AttributeInfo{"a_data", idLineDataVertexAttribute},
|
|
||||||
};
|
|
||||||
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::LineBasicShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
|
||||||
UniformBlockInfo{"LineBasicUBO", idLineBasicUBO},
|
|
||||||
UniformBlockInfo{"LineBasicPropertiesUBO", idLineBasicPropertiesUBO},
|
|
||||||
};
|
|
||||||
const std::vector<TextureInfo> ShaderInfo<BuiltIn::LineBasicShader, gfx::Backend::Type::OpenGL>::textures = {};
|
|
||||||
|
|
||||||
// Raster
|
// Raster
|
||||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::RasterShader, gfx::Backend::Type::OpenGL>::attributes = {
|
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::RasterShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||||
AttributeInfo{"a_pos", idRasterPosVertexAttribute},
|
AttributeInfo{"a_pos", idRasterPosVertexAttribute},
|
||||||
|
|||||||
@@ -62,5 +62,19 @@ const std::array<TextureInfo, 1> ShaderSource<BuiltIn::FillOutlinePatternShader,
|
|||||||
TextureInfo{0, idFillImageTexture},
|
TextureInfo{0, idFillImageTexture},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const std::array<AttributeInfo, 2>
|
||||||
|
ShaderSource<BuiltIn::FillOutlineTriangulatedShader, gfx::Backend::Type::Metal>::attributes = {
|
||||||
|
AttributeInfo{0, gfx::AttributeDataType::Short2, idLinePosNormalVertexAttribute},
|
||||||
|
AttributeInfo{1, gfx::AttributeDataType::UByte4, idLineDataVertexAttribute},
|
||||||
|
};
|
||||||
|
const std::array<UniformBlockInfo, 2> ShaderSource<BuiltIn::FillOutlineTriangulatedShader,
|
||||||
|
gfx::Backend::Type::Metal>::uniforms = {
|
||||||
|
UniformBlockInfo{2, true, true, sizeof(FillOutlineTriangulatedDrawableUBO), idFillOutlineTriangulatedDrawableUBO},
|
||||||
|
UniformBlockInfo{
|
||||||
|
3, true, true, sizeof(FillOutlineTriangulatedPropertiesUBO), idFillOutlineTriangulatedPropertiesUBO},
|
||||||
|
};
|
||||||
|
const std::array<TextureInfo, 0>
|
||||||
|
ShaderSource<BuiltIn::FillOutlineTriangulatedShader, gfx::Backend::Type::Metal>::textures = {};
|
||||||
|
|
||||||
} // namespace shaders
|
} // namespace shaders
|
||||||
} // namespace mbgl
|
} // namespace mbgl
|
||||||
|
|||||||
@@ -64,15 +64,5 @@ const std::array<TextureInfo, 1> ShaderSource<BuiltIn::LineSDFShader, gfx::Backe
|
|||||||
TextureInfo{0, idLineImageTexture},
|
TextureInfo{0, idLineImageTexture},
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::array<AttributeInfo, 2> ShaderSource<BuiltIn::LineBasicShader, gfx::Backend::Type::Metal>::attributes = {
|
|
||||||
AttributeInfo{0, gfx::AttributeDataType::Short2, idLinePosNormalVertexAttribute},
|
|
||||||
AttributeInfo{1, gfx::AttributeDataType::UByte4, idLineDataVertexAttribute},
|
|
||||||
};
|
|
||||||
const std::array<UniformBlockInfo, 2> ShaderSource<BuiltIn::LineBasicShader, gfx::Backend::Type::Metal>::uniforms = {
|
|
||||||
UniformBlockInfo{2, true, true, sizeof(LineBasicUBO), idLineBasicUBO},
|
|
||||||
UniformBlockInfo{3, true, true, sizeof(LineBasicPropertiesUBO), idLineBasicPropertiesUBO},
|
|
||||||
};
|
|
||||||
const std::array<TextureInfo, 0> ShaderSource<BuiltIn::LineBasicShader, gfx::Backend::Type::Metal>::textures = {};
|
|
||||||
|
|
||||||
} // namespace shaders
|
} // namespace shaders
|
||||||
} // namespace mbgl
|
} // namespace mbgl
|
||||||
|
|||||||
@@ -137,19 +137,19 @@ TEST(OrderIndependentHash, Shaders) {
|
|||||||
BuiltIn::DebugShader,
|
BuiltIn::DebugShader,
|
||||||
BuiltIn::FillShader,
|
BuiltIn::FillShader,
|
||||||
BuiltIn::FillOutlineShader,
|
BuiltIn::FillOutlineShader,
|
||||||
BuiltIn::LineGradientShader,
|
|
||||||
BuiltIn::LinePatternShader,
|
|
||||||
BuiltIn::LineSDFShader,
|
|
||||||
BuiltIn::LineShader,
|
|
||||||
BuiltIn::LineBasicShader,
|
|
||||||
BuiltIn::FillPatternShader,
|
BuiltIn::FillPatternShader,
|
||||||
BuiltIn::FillOutlinePatternShader,
|
BuiltIn::FillOutlinePatternShader,
|
||||||
|
BuiltIn::FillOutlineTriangulatedShader,
|
||||||
BuiltIn::FillExtrusionShader,
|
BuiltIn::FillExtrusionShader,
|
||||||
BuiltIn::FillExtrusionPatternShader,
|
BuiltIn::FillExtrusionPatternShader,
|
||||||
BuiltIn::HeatmapShader,
|
BuiltIn::HeatmapShader,
|
||||||
BuiltIn::HeatmapTextureShader,
|
BuiltIn::HeatmapTextureShader,
|
||||||
BuiltIn::HillshadePrepareShader,
|
BuiltIn::HillshadePrepareShader,
|
||||||
BuiltIn::HillshadeShader,
|
BuiltIn::HillshadeShader,
|
||||||
|
BuiltIn::LineShader,
|
||||||
|
BuiltIn::LineGradientShader,
|
||||||
|
BuiltIn::LinePatternShader,
|
||||||
|
BuiltIn::LineSDFShader,
|
||||||
BuiltIn::RasterShader,
|
BuiltIn::RasterShader,
|
||||||
BuiltIn::SymbolIconShader,
|
BuiltIn::SymbolIconShader,
|
||||||
BuiltIn::SymbolSDFIconShader,
|
BuiltIn::SymbolSDFIconShader,
|
||||||
|
|||||||
Reference in New Issue
Block a user