Setting up UBO for fill drawables (#1175)
This commit is contained in:
committed by
Bart Louwers
parent
ad4a598975
commit
b823f036fe
@@ -1,5 +1,5 @@
|
||||
// Generated code, do not modify this file!
|
||||
// Generated on 2023-05-23T00:45:10.632Z by timsylvester using shaders/generate_shader_code.js
|
||||
// Generated on 2023-05-24T21:16:59.579Z by timsylvester using shaders/generate_shader_code.js
|
||||
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
@@ -12,7 +12,7 @@ struct ShaderSource<BuiltIn::BackgroundShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "BackgroundShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
layout (std140) uniform BackgroundDrawableUBO {
|
||||
mat4 u_matrix;
|
||||
highp mat4 u_matrix;
|
||||
};
|
||||
|
||||
void main() {
|
||||
@@ -20,8 +20,8 @@ void main() {
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform BackgroundLayerUBO {
|
||||
vec4 u_color;
|
||||
vec4 u_opacity_pad3;
|
||||
highp vec4 u_color;
|
||||
highp vec4 u_opacity_pad3;
|
||||
};
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Generated code, do not modify this file!
|
||||
// Generated on 2023-05-23T00:45:10.632Z by timsylvester using shaders/generate_shader_code.js
|
||||
// Generated on 2023-05-25T15:19:24.210Z by timsylvester using shaders/generate_shader_code.js
|
||||
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
@@ -10,27 +10,38 @@ namespace shaders {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "FillShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
static constexpr const char* vertex = R"(layout (std140) uniform FillDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec4 u_scale;
|
||||
highp vec2 u_world;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp vec2 u_texsize;
|
||||
highp float u_fade;
|
||||
|
||||
layout (std140) uniform FillDrawableUBO {
|
||||
mat4 u_matrix;
|
||||
vec2 u_world;
|
||||
vec2 pad;
|
||||
highp float u_color_t;
|
||||
highp float u_opacity_t;
|
||||
highp float u_outline_color_t;
|
||||
highp float u_pattern_from_t;
|
||||
highp float u_pattern_to_t;
|
||||
|
||||
highp vec2 u_color;
|
||||
highp vec2 u_opacity;
|
||||
highp vec2 u_outline_color_pad;
|
||||
highp vec4 u_outline_color;
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
};
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_color
|
||||
uniform lowp float u_color_t;
|
||||
layout (location = 1) in highp vec4 a_color;
|
||||
out highp vec4 color;
|
||||
#else
|
||||
uniform highp vec4 u_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
uniform lowp float u_opacity_t;
|
||||
layout (location = 2) in lowp vec2 a_opacity;
|
||||
out lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
@@ -48,15 +59,34 @@ lowp float opacity = u_opacity;
|
||||
gl_Position = u_matrix * vec4(a_pos, 0, 1);
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(#ifndef HAS_UNIFORM_u_color
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform FillDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec4 u_scale;
|
||||
highp vec2 u_world;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp vec2 u_texsize;
|
||||
highp float u_fade;
|
||||
|
||||
highp float u_color_t;
|
||||
highp float u_opacity_t;
|
||||
highp float u_outline_color_t;
|
||||
highp float u_pattern_from_t;
|
||||
highp float u_pattern_to_t;
|
||||
|
||||
highp vec2 u_color;
|
||||
highp vec2 u_opacity;
|
||||
highp vec2 u_outline_color_pad;
|
||||
highp vec4 u_outline_color;
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
};
|
||||
|
||||
#ifndef HAS_UNIFORM_u_color
|
||||
in highp vec4 color;
|
||||
#else
|
||||
uniform highp vec4 u_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
in lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Generated code, do not modify this file!
|
||||
// Generated on 2023-05-23T00:45:10.632Z by timsylvester using shaders/generate_shader_code.js
|
||||
// Generated on 2023-05-25T15:19:24.210Z by timsylvester using shaders/generate_shader_code.js
|
||||
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
@@ -10,29 +10,40 @@ namespace shaders {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillOutlineShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "FillOutlineShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
static constexpr const char* vertex = R"(layout (std140) uniform FillDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec4 u_scale;
|
||||
highp vec2 u_world;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp vec2 u_texsize;
|
||||
highp float u_fade;
|
||||
|
||||
layout (std140) uniform FillDrawableUBO {
|
||||
mat4 u_matrix;
|
||||
vec2 u_world;
|
||||
vec2 pad;
|
||||
highp float u_color_t;
|
||||
highp float u_opacity_t;
|
||||
highp float u_outline_color_t;
|
||||
highp float u_pattern_from_t;
|
||||
highp float u_pattern_to_t;
|
||||
|
||||
highp vec2 u_color;
|
||||
highp vec2 u_opacity;
|
||||
highp vec2 u_outline_color_pad;
|
||||
highp vec4 u_outline_color;
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
};
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
|
||||
out vec2 v_pos;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_outline_color
|
||||
uniform lowp float u_outline_color_t;
|
||||
layout (location = 1) in highp vec4 a_outline_color;
|
||||
out highp vec4 outline_color;
|
||||
#else
|
||||
uniform highp vec4 u_outline_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
uniform lowp float u_opacity_t;
|
||||
layout (location = 2) in lowp vec2 a_opacity;
|
||||
out lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
@@ -51,17 +62,36 @@ lowp float opacity = u_opacity;
|
||||
v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world;
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(in vec2 v_pos;
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform FillDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec4 u_scale;
|
||||
highp vec2 u_world;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp vec2 u_texsize;
|
||||
highp float u_fade;
|
||||
|
||||
highp float u_color_t;
|
||||
highp float u_opacity_t;
|
||||
highp float u_outline_color_t;
|
||||
highp float u_pattern_from_t;
|
||||
highp float u_pattern_to_t;
|
||||
|
||||
highp vec2 u_color;
|
||||
highp vec2 u_opacity;
|
||||
highp vec2 u_outline_color_pad;
|
||||
highp vec4 u_outline_color;
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
};
|
||||
|
||||
in vec2 v_pos;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_outline_color
|
||||
in highp vec4 outline_color;
|
||||
#else
|
||||
uniform highp vec4 u_outline_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
in lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Generated code, do not modify this file!
|
||||
// Generated on 2023-05-23T18:10:10.798Z by timsylvester using shaders/generate_shader_code.js
|
||||
// Generated on 2023-05-25T14:44:39.644Z by timsylvester using shaders/generate_shader_code.js
|
||||
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
@@ -10,11 +10,28 @@ namespace shaders {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillOutlinePatternShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "FillOutlinePatternShader";
|
||||
static constexpr const char* vertex = R"(uniform mat4 u_matrix;
|
||||
uniform vec2 u_world;
|
||||
uniform vec2 u_pixel_coord_upper;
|
||||
uniform vec2 u_pixel_coord_lower;
|
||||
uniform vec4 u_scale;
|
||||
static constexpr const char* vertex = R"(layout (std140) uniform FillDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec4 u_scale;
|
||||
highp vec2 u_world;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp vec2 u_texsize;
|
||||
highp float u_fade;
|
||||
|
||||
highp float u_color_t;
|
||||
highp float u_opacity_t;
|
||||
highp float u_outline_color_t;
|
||||
highp float u_pattern_from_t;
|
||||
highp float u_pattern_to_t;
|
||||
|
||||
highp vec2 u_color;
|
||||
highp vec2 u_opacity;
|
||||
highp vec2 u_outline_color_pad;
|
||||
highp vec4 u_outline_color;
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
};
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
|
||||
@@ -23,25 +40,16 @@ out vec2 v_pos_b;
|
||||
out vec2 v_pos;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
uniform lowp float u_opacity_t;
|
||||
layout (location = 1) in lowp vec2 a_opacity;
|
||||
out lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_from
|
||||
uniform lowp float u_pattern_from_t;
|
||||
layout (location = 2) in lowp vec4 a_pattern_from;
|
||||
out lowp vec4 pattern_from;
|
||||
#else
|
||||
uniform lowp vec4 u_pattern_from;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_to
|
||||
uniform lowp float u_pattern_to_t;
|
||||
layout (location = 3) in lowp vec4 a_pattern_to;
|
||||
out lowp vec4 pattern_to;
|
||||
#else
|
||||
uniform lowp vec4 u_pattern_to;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
@@ -82,10 +90,30 @@ mediump vec4 pattern_to = u_pattern_to;
|
||||
v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world;
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(
|
||||
uniform vec2 u_texsize;
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform FillDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec4 u_scale;
|
||||
highp vec2 u_world;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp vec2 u_texsize;
|
||||
highp float u_fade;
|
||||
|
||||
highp float u_color_t;
|
||||
highp float u_opacity_t;
|
||||
highp float u_outline_color_t;
|
||||
highp float u_pattern_from_t;
|
||||
highp float u_pattern_to_t;
|
||||
|
||||
highp vec2 u_color;
|
||||
highp vec2 u_opacity;
|
||||
highp vec2 u_outline_color_pad;
|
||||
highp vec4 u_outline_color;
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
};
|
||||
|
||||
uniform sampler2D u_image;
|
||||
uniform float u_fade;
|
||||
|
||||
in vec2 v_pos_a;
|
||||
in vec2 v_pos_b;
|
||||
@@ -93,18 +121,12 @@ in vec2 v_pos;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
in lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_from
|
||||
in lowp vec4 pattern_from;
|
||||
#else
|
||||
uniform lowp vec4 u_pattern_from;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_to
|
||||
in lowp vec4 pattern_to;
|
||||
#else
|
||||
uniform lowp vec4 u_pattern_to;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Generated code, do not modify this file!
|
||||
// Generated on 2023-05-23T18:10:10.798Z by timsylvester using shaders/generate_shader_code.js
|
||||
// Generated on 2023-05-25T14:44:39.644Z by timsylvester using shaders/generate_shader_code.js
|
||||
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
@@ -10,10 +10,28 @@ namespace shaders {
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillPatternShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "FillPatternShader";
|
||||
static constexpr const char* vertex = R"(uniform mat4 u_matrix;
|
||||
uniform vec2 u_pixel_coord_upper;
|
||||
uniform vec2 u_pixel_coord_lower;
|
||||
uniform vec4 u_scale;
|
||||
static constexpr const char* vertex = R"(layout (std140) uniform FillDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec4 u_scale;
|
||||
highp vec2 u_world;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp vec2 u_texsize;
|
||||
highp float u_fade;
|
||||
|
||||
highp float u_color_t;
|
||||
highp float u_opacity_t;
|
||||
highp float u_outline_color_t;
|
||||
highp float u_pattern_from_t;
|
||||
highp float u_pattern_to_t;
|
||||
|
||||
highp vec2 u_color;
|
||||
highp vec2 u_opacity;
|
||||
highp vec2 u_outline_color_pad;
|
||||
highp vec4 u_outline_color;
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
};
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
|
||||
@@ -21,25 +39,16 @@ out vec2 v_pos_a;
|
||||
out vec2 v_pos_b;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
uniform lowp float u_opacity_t;
|
||||
layout (location = 1) in lowp vec2 a_opacity;
|
||||
out lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_from
|
||||
uniform lowp float u_pattern_from_t;
|
||||
layout (location = 2) in lowp vec4 a_pattern_from;
|
||||
out lowp vec4 pattern_from;
|
||||
#else
|
||||
uniform lowp vec4 u_pattern_from;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_to
|
||||
uniform lowp float u_pattern_to_t;
|
||||
layout (location = 3) in lowp vec4 a_pattern_to;
|
||||
out lowp vec4 pattern_to;
|
||||
#else
|
||||
uniform lowp vec4 u_pattern_to;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
@@ -77,8 +86,28 @@ mediump vec4 pattern_to = u_pattern_to;
|
||||
v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, toScale * display_size_b, tileZoomRatio, a_pos);
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(uniform vec2 u_texsize;
|
||||
uniform float u_fade;
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform FillDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec4 u_scale;
|
||||
highp vec2 u_world;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp vec2 u_texsize;
|
||||
highp float u_fade;
|
||||
|
||||
highp float u_color_t;
|
||||
highp float u_opacity_t;
|
||||
highp float u_outline_color_t;
|
||||
highp float u_pattern_from_t;
|
||||
highp float u_pattern_to_t;
|
||||
|
||||
highp vec2 u_color;
|
||||
highp vec2 u_opacity;
|
||||
highp vec2 u_outline_color_pad;
|
||||
highp vec4 u_outline_color;
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
};
|
||||
|
||||
uniform sampler2D u_image;
|
||||
|
||||
@@ -87,18 +116,12 @@ in vec2 v_pos_b;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
in lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_from
|
||||
in lowp vec4 pattern_from;
|
||||
#else
|
||||
uniform lowp vec4 u_pattern_from;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_to
|
||||
in lowp vec4 pattern_to;
|
||||
#else
|
||||
uniform lowp vec4 u_pattern_to;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
layout (std140) uniform BackgroundLayerUBO {
|
||||
vec4 u_color;
|
||||
vec4 u_opacity_pad3;
|
||||
highp vec4 u_color;
|
||||
highp vec4 u_opacity_pad3;
|
||||
};
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
layout (std140) uniform BackgroundDrawableUBO {
|
||||
mat4 u_matrix;
|
||||
highp mat4 u_matrix;
|
||||
};
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -1,3 +1,26 @@
|
||||
layout (std140) uniform FillDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec4 u_scale;
|
||||
highp vec2 u_world;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp vec2 u_texsize;
|
||||
highp float u_fade;
|
||||
|
||||
highp float u_color_t;
|
||||
highp float u_opacity_t;
|
||||
highp float u_outline_color_t;
|
||||
highp float u_pattern_from_t;
|
||||
highp float u_pattern_to_t;
|
||||
|
||||
highp vec2 u_color;
|
||||
highp vec2 u_opacity;
|
||||
highp vec2 u_outline_color_pad;
|
||||
highp vec4 u_outline_color;
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
};
|
||||
|
||||
#pragma mapbox: define highp vec4 color
|
||||
#pragma mapbox: define lowp float opacity
|
||||
|
||||
|
||||
@@ -1,11 +1,28 @@
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
|
||||
layout (std140) uniform FillDrawableUBO {
|
||||
mat4 u_matrix;
|
||||
vec2 u_world;
|
||||
vec2 pad;
|
||||
highp mat4 u_matrix;
|
||||
highp vec4 u_scale;
|
||||
highp vec2 u_world;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp vec2 u_texsize;
|
||||
highp float u_fade;
|
||||
|
||||
highp float u_color_t;
|
||||
highp float u_opacity_t;
|
||||
highp float u_outline_color_t;
|
||||
highp float u_pattern_from_t;
|
||||
highp float u_pattern_to_t;
|
||||
|
||||
highp vec2 u_color;
|
||||
highp vec2 u_opacity;
|
||||
highp vec2 u_outline_color_pad;
|
||||
highp vec4 u_outline_color;
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
};
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
|
||||
#pragma mapbox: define highp vec4 color
|
||||
#pragma mapbox: define lowp float opacity
|
||||
|
||||
|
||||
@@ -1,3 +1,26 @@
|
||||
layout (std140) uniform FillDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec4 u_scale;
|
||||
highp vec2 u_world;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp vec2 u_texsize;
|
||||
highp float u_fade;
|
||||
|
||||
highp float u_color_t;
|
||||
highp float u_opacity_t;
|
||||
highp float u_outline_color_t;
|
||||
highp float u_pattern_from_t;
|
||||
highp float u_pattern_to_t;
|
||||
|
||||
highp vec2 u_color;
|
||||
highp vec2 u_opacity;
|
||||
highp vec2 u_outline_color_pad;
|
||||
highp vec4 u_outline_color;
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
};
|
||||
|
||||
in vec2 v_pos;
|
||||
|
||||
#pragma mapbox: define highp vec4 outline_color
|
||||
|
||||
@@ -1,11 +1,28 @@
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
|
||||
layout (std140) uniform FillDrawableUBO {
|
||||
mat4 u_matrix;
|
||||
vec2 u_world;
|
||||
vec2 pad;
|
||||
highp mat4 u_matrix;
|
||||
highp vec4 u_scale;
|
||||
highp vec2 u_world;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp vec2 u_texsize;
|
||||
highp float u_fade;
|
||||
|
||||
highp float u_color_t;
|
||||
highp float u_opacity_t;
|
||||
highp float u_outline_color_t;
|
||||
highp float u_pattern_from_t;
|
||||
highp float u_pattern_to_t;
|
||||
|
||||
highp vec2 u_color;
|
||||
highp vec2 u_opacity;
|
||||
highp vec2 u_outline_color_pad;
|
||||
highp vec4 u_outline_color;
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
};
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
|
||||
out vec2 v_pos;
|
||||
|
||||
#pragma mapbox: define highp vec4 outline_color
|
||||
|
||||
@@ -1,7 +1,27 @@
|
||||
layout (std140) uniform FillDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec4 u_scale;
|
||||
highp vec2 u_world;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp vec2 u_texsize;
|
||||
highp float u_fade;
|
||||
|
||||
highp float u_color_t;
|
||||
highp float u_opacity_t;
|
||||
highp float u_outline_color_t;
|
||||
highp float u_pattern_from_t;
|
||||
highp float u_pattern_to_t;
|
||||
|
||||
highp vec2 u_color;
|
||||
highp vec2 u_opacity;
|
||||
highp vec2 u_outline_color_pad;
|
||||
highp vec4 u_outline_color;
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
};
|
||||
|
||||
uniform vec2 u_texsize;
|
||||
uniform sampler2D u_image;
|
||||
uniform float u_fade;
|
||||
|
||||
in vec2 v_pos_a;
|
||||
in vec2 v_pos_b;
|
||||
|
||||
@@ -1,8 +1,25 @@
|
||||
uniform mat4 u_matrix;
|
||||
uniform vec2 u_world;
|
||||
uniform vec2 u_pixel_coord_upper;
|
||||
uniform vec2 u_pixel_coord_lower;
|
||||
uniform vec4 u_scale;
|
||||
layout (std140) uniform FillDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec4 u_scale;
|
||||
highp vec2 u_world;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp vec2 u_texsize;
|
||||
highp float u_fade;
|
||||
|
||||
highp float u_color_t;
|
||||
highp float u_opacity_t;
|
||||
highp float u_outline_color_t;
|
||||
highp float u_pattern_from_t;
|
||||
highp float u_pattern_to_t;
|
||||
|
||||
highp vec2 u_color;
|
||||
highp vec2 u_opacity;
|
||||
highp vec2 u_outline_color_pad;
|
||||
highp vec4 u_outline_color;
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
};
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
|
||||
|
||||
@@ -1,5 +1,25 @@
|
||||
uniform vec2 u_texsize;
|
||||
uniform float u_fade;
|
||||
layout (std140) uniform FillDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec4 u_scale;
|
||||
highp vec2 u_world;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp vec2 u_texsize;
|
||||
highp float u_fade;
|
||||
|
||||
highp float u_color_t;
|
||||
highp float u_opacity_t;
|
||||
highp float u_outline_color_t;
|
||||
highp float u_pattern_from_t;
|
||||
highp float u_pattern_to_t;
|
||||
|
||||
highp vec2 u_color;
|
||||
highp vec2 u_opacity;
|
||||
highp vec2 u_outline_color_pad;
|
||||
highp vec4 u_outline_color;
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
};
|
||||
|
||||
uniform sampler2D u_image;
|
||||
|
||||
|
||||
@@ -1,7 +1,25 @@
|
||||
uniform mat4 u_matrix;
|
||||
uniform vec2 u_pixel_coord_upper;
|
||||
uniform vec2 u_pixel_coord_lower;
|
||||
uniform vec4 u_scale;
|
||||
layout (std140) uniform FillDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec4 u_scale;
|
||||
highp vec2 u_world;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp vec2 u_texsize;
|
||||
highp float u_fade;
|
||||
|
||||
highp float u_color_t;
|
||||
highp float u_opacity_t;
|
||||
highp float u_outline_color_t;
|
||||
highp float u_pattern_from_t;
|
||||
highp float u_pattern_to_t;
|
||||
|
||||
highp vec2 u_color;
|
||||
highp vec2 u_opacity;
|
||||
highp vec2 u_outline_color_pad;
|
||||
highp vec4 u_outline_color;
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
};
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
|
||||
|
||||
@@ -18,28 +18,28 @@
|
||||
"header": "drawable_fill",
|
||||
"glsl_vert": "drawable.fill.vertex.glsl",
|
||||
"glsl_frag": "drawable.fill.fragment.glsl",
|
||||
"uses_ubos": false
|
||||
"uses_ubos": true
|
||||
},
|
||||
{
|
||||
"name": "FillOutlineShader",
|
||||
"header": "drawable_fill_outline",
|
||||
"glsl_vert": "drawable.fill_outline.vertex.glsl",
|
||||
"glsl_frag": "drawable.fill_outline.fragment.glsl",
|
||||
"uses_ubos": false
|
||||
"uses_ubos": true
|
||||
},
|
||||
{
|
||||
"name": "FillPatternShader",
|
||||
"header": "drawable_fill_pattern",
|
||||
"glsl_vert": "drawable.fill_pattern.vertex.glsl",
|
||||
"glsl_frag": "drawable.fill_pattern.fragment.glsl",
|
||||
"uses_ubos": false
|
||||
"uses_ubos": true
|
||||
},
|
||||
{
|
||||
"name": "FillOutlinePatternShader",
|
||||
"header": "drawable_fill_outline_pattern",
|
||||
"glsl_vert": "drawable.fill_outline_pattern.vertex.glsl",
|
||||
"glsl_frag": "drawable.fill_outline_pattern.fragment.glsl",
|
||||
"uses_ubos": false
|
||||
"uses_ubos": true
|
||||
},
|
||||
|
||||
{
|
||||
|
||||
@@ -14,13 +14,40 @@ using namespace style;
|
||||
|
||||
struct alignas(16) FillDrawableUBO {
|
||||
std::array<float, 4 * 4> matrix;
|
||||
/* 64 */ std::array<float, 4> scale;
|
||||
std::array<float, 2> world;
|
||||
std::array<float, 2> padding;
|
||||
/* 88 */ std::array<float, 2> pixel_coord_upper;
|
||||
/* 96 */ std::array<float, 2> pixel_coord_lower;
|
||||
/* 104 */ std::array<float, 2> texsize;
|
||||
/* 112 */ float fade;
|
||||
|
||||
// Attribute interpolations (used without HAS_UNIFORM_u_*)
|
||||
/* 116 */ float color_t;
|
||||
/* 120 */ float opacity_t;
|
||||
/* 124 */ float outline_color_t;
|
||||
/* 128 */ float pattern_from_t;
|
||||
/* 132 */ float pattern_to_t;
|
||||
|
||||
// Uniform alternates for attributes (used with HAS_UNIFORM_u_*)
|
||||
/* 136 */ std::array<float, 2> color;
|
||||
/* 144 */ std::array<float, 2> opacity;
|
||||
/* 152 */ std::array<float, 2> outline_color_pad;
|
||||
/* 160 */ std::array<float, 4> outline_color;
|
||||
/* 176 */ std::array<float, 4> pattern_from;
|
||||
/* 208 */ std::array<float, 4> pattern_to;
|
||||
|
||||
// Pattern texture
|
||||
/* ? */ // Drawable::TextureAttachment? image;
|
||||
|
||||
/* */ // std::array<float, 3> padding;
|
||||
/* 208 */
|
||||
};
|
||||
static_assert(sizeof(FillDrawableUBO) % 16 == 0);
|
||||
static_assert(sizeof(FillDrawableUBO) == 208);
|
||||
|
||||
void FillLayerTweaker::execute(LayerGroup& layerGroup, const PaintParameters& parameters) {
|
||||
// const auto& evaluated = static_cast<const FillLayerProperties&>(*evaluatedProperties).evaluated;
|
||||
const auto& props = static_cast<const FillLayerProperties&>(*evaluatedProperties);
|
||||
// const auto& evaluated = props.evaluated;
|
||||
const auto& crossfade = props.crossfade;
|
||||
|
||||
layerGroup.observeDrawables([&](gfx::Drawable& drawable) {
|
||||
if (!drawable.getTileID()) {
|
||||
@@ -48,11 +75,43 @@ void FillLayerTweaker::execute(LayerGroup& layerGroup, const PaintParameters& pa
|
||||
matrix::multiply(matrix, drawable.getMatrix(), tileMat);
|
||||
matrix = tileMat;
|
||||
|
||||
const auto renderableSize = parameters.backend.getDefaultRenderable().getSize();
|
||||
// matrix = tile.translatedMatrix(evaluated.get<FillTranslate>(), evaluated.get<FillTranslateAnchor>(),
|
||||
// parameters.state),
|
||||
|
||||
// from FillPatternProgram::layoutUniformValues
|
||||
const auto renderableSize = parameters.backend.getDefaultRenderable().getSize();
|
||||
const auto intZoom = parameters.state.getIntegerZoom();
|
||||
const auto tileRatio = 1 / tileID.pixelsToTileUnits(1, intZoom);
|
||||
const int32_t tileSizeAtNearestZoom = static_cast<int32_t>(
|
||||
util::tileSize_D * parameters.state.zoomScale(intZoom - tileID.canonical.z));
|
||||
const int32_t pixelX = static_cast<int32_t>(
|
||||
tileSizeAtNearestZoom *
|
||||
(tileID.canonical.x + tileID.wrap * parameters.state.zoomScale(tileID.canonical.z)));
|
||||
const int32_t pixelY = tileSizeAtNearestZoom * tileID.canonical.y;
|
||||
const auto pixelRatio = parameters.pixelRatio;
|
||||
|
||||
const FillDrawableUBO drawableUBO = {
|
||||
/*.matrix=*/util::cast<float>(matrix),
|
||||
/*.scale=*/{pixelRatio, tileRatio, crossfade.fromScale, crossfade.toScale},
|
||||
/*.world=*/{(float)renderableSize.width, (float)renderableSize.height},
|
||||
/*.pixel_coord_upper=*/{static_cast<float>(pixelX >> 16), static_cast<float>(pixelY >> 16)},
|
||||
/*.pixel_coord_lower=*/{static_cast<float>(pixelX & 0xFFFF), static_cast<float>(pixelY & 0xFFFF)},
|
||||
/*.texsize=*/{0.0f, 0.0f}, // tile.getIconAtlasTexture().size
|
||||
/*.fade=*/crossfade.t,
|
||||
/*.color_t=*/0.0f,
|
||||
/*.opacity_t=*/0.0f,
|
||||
/*.outline_color_t=*/0.0f,
|
||||
/*.pattern_from_t=*/0.0f,
|
||||
/*.pattern_to_t=*/0.0f,
|
||||
/*.color=*/{0.0f},
|
||||
/*.opacity=*/{0.0f},
|
||||
/*.outline_color_pad=*/{0.0f},
|
||||
/*.outline_color=*/{0.0f},
|
||||
/*.pattern_from=*/{0.0f},
|
||||
/*.pattern_to=*/{0.0f},
|
||||
/*.image=*/ // TextureAttachment(tile.getIconAtlasTexture().getResource(), Linear)
|
||||
};
|
||||
|
||||
FillDrawableUBO drawableUBO;
|
||||
drawableUBO.matrix = util::cast<float>(matrix);
|
||||
drawableUBO.world = {(float)renderableSize.width, (float)renderableSize.height};
|
||||
auto drawableUniformBuffer = parameters.context.createUniformBuffer(&drawableUBO, sizeof(drawableUBO));
|
||||
drawable.mutableUniformBuffers().addOrReplace("FillDrawableUBO", drawableUniformBuffer);
|
||||
});
|
||||
|
||||
@@ -340,6 +340,16 @@ void RenderFillLayer::update(const int32_t layerIndex,
|
||||
gfx::VertexAttributeArray fillVertexAttrs;
|
||||
gfx::VertexAttributeArray outlineVertexAttrs;
|
||||
|
||||
const auto finish = [&](gfx::DrawableBuilder& builder, RenderPass pass, const OverscaledTileID& tileID) {
|
||||
builder.flush();
|
||||
|
||||
for (auto& drawable : builder.clearDrawables()) {
|
||||
drawable->setTileID(tileID);
|
||||
tileLayerGroup->addDrawable(pass, tileID, std::move(drawable));
|
||||
++stats.tileDrawablesAdded;
|
||||
}
|
||||
};
|
||||
|
||||
for (const auto renderPass : {RenderPass::Opaque, RenderPass::Translucent}) {
|
||||
if (!(mbgl::underlying_type(renderPass) & evaluatedProperties->renderPasses)) {
|
||||
continue;
|
||||
@@ -370,6 +380,7 @@ void RenderFillLayer::update(const int32_t layerIndex,
|
||||
|
||||
auto& bucket = static_cast<FillBucket&>(*renderData->bucket);
|
||||
const auto& evaluated = getEvaluated<FillLayerProperties>(renderData->layerProperties);
|
||||
const auto& crossfade = getCrossfade<FillLayerProperties>(renderData->layerProperties);
|
||||
|
||||
std::vector<std::array<int16_t, 2>> rawVerts;
|
||||
const auto buildVertices = [&]() {
|
||||
@@ -512,14 +523,7 @@ void RenderFillLayer::update(const int32_t layerIndex,
|
||||
fillBuilder->addTriangles(bucket.triangles.vector(), seg.indexOffset, seg.indexLength);
|
||||
}
|
||||
|
||||
fillBuilder->flush();
|
||||
|
||||
for (auto& drawable : fillBuilder->clearDrawables()) {
|
||||
drawable->setTileID(tileID);
|
||||
|
||||
tileLayerGroup->addDrawable(renderPass, tileID, std::move(drawable));
|
||||
++stats.tileDrawablesAdded;
|
||||
}
|
||||
finish(*fillBuilder, renderPass, tileID);
|
||||
}
|
||||
if (outlineBuilder) {
|
||||
buildVertices();
|
||||
@@ -529,21 +533,13 @@ void RenderFillLayer::update(const int32_t layerIndex,
|
||||
outlineBuilder->addLines(bucket.lines.vector(), seg.indexOffset, seg.indexLength);
|
||||
}
|
||||
|
||||
outlineBuilder->flush();
|
||||
|
||||
for (auto& drawable : outlineBuilder->clearDrawables()) {
|
||||
drawable->setTileID(tileID);
|
||||
|
||||
tileLayerGroup->addDrawable(renderPass, tileID, std::move(drawable));
|
||||
++stats.tileDrawablesAdded;
|
||||
}
|
||||
finish(*outlineBuilder, renderPass, tileID);
|
||||
}
|
||||
} else { // FillPattern is defined
|
||||
if (renderPass != RenderPass::Translucent) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto& crossfade = getCrossfade<FillLayerProperties>(renderData->layerProperties);
|
||||
const auto doOutline = evaluated.get<FillAntialias>() &&
|
||||
unevaluated.get<FillOutlineColor>().isUndefined();
|
||||
const auto& fillPatternValue = evaluated.get<FillPattern>().constantOr(
|
||||
@@ -560,7 +556,7 @@ void RenderFillLayer::update(const int32_t layerIndex,
|
||||
patternBuilder->setDepthType(gfx::DepthMaskType::ReadWrite);
|
||||
patternBuilder->setCullFaceMode(gfx::CullFaceMode::disabled());
|
||||
patternBuilder->setLayerIndex(layerIndex);
|
||||
outlinePatternBuilder->setSubLayerIndex(1);
|
||||
patternBuilder->setSubLayerIndex(1);
|
||||
}
|
||||
if (doOutline && !outlinePatternBuilder && outlinePatternShader) {
|
||||
outlinePatternBuilder = context.createDrawableBuilder("fill-outline-pattern");
|
||||
@@ -595,14 +591,7 @@ void RenderFillLayer::update(const int32_t layerIndex,
|
||||
patternBuilder->addTriangles(bucket.triangles.vector(), seg.indexOffset, seg.indexLength);
|
||||
}
|
||||
|
||||
patternBuilder->flush();
|
||||
|
||||
for (auto& drawable : patternBuilder->clearDrawables()) {
|
||||
drawable->setTileID(tileID);
|
||||
|
||||
// tileLayerGroup->addDrawable(renderPass, tileID, std::move(drawable));
|
||||
++stats.tileDrawablesAdded;
|
||||
}
|
||||
finish(*patternBuilder, renderPass, tileID);
|
||||
}
|
||||
if (outlinePatternBuilder) {
|
||||
buildVertices();
|
||||
@@ -612,14 +601,8 @@ void RenderFillLayer::update(const int32_t layerIndex,
|
||||
outlinePatternBuilder->addLines(bucket.lines.vector(), seg.indexOffset, seg.indexLength);
|
||||
}
|
||||
|
||||
finish(*outlinePatternBuilder, renderPass, tileID);
|
||||
outlinePatternBuilder->flush();
|
||||
|
||||
for (auto& drawable : outlinePatternBuilder->clearDrawables()) {
|
||||
drawable->setTileID(tileID);
|
||||
|
||||
// tileLayerGroup->addDrawable(renderPass, tileID, std::move(drawable));
|
||||
++stats.tileDrawablesAdded;
|
||||
}
|
||||
}
|
||||
|
||||
// auto draw = [&](auto& programInstance,
|
||||
|
||||
Reference in New Issue
Block a user