Clean legacy code (#3469)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
#include <mbgl/tile/geometry_tile_data.hpp>
|
||||
#include <mbgl/gfx/vertex_vector.hpp>
|
||||
#include <mbgl/gfx/index_vector.hpp>
|
||||
#include <mbgl/programs/fill_program.hpp>
|
||||
#include <mbgl/programs/line_program.hpp>
|
||||
#include <mbgl/renderer/buckets/fill_bucket.hpp>
|
||||
#include <mbgl/renderer/buckets/line_bucket.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace gfx {
|
||||
@@ -14,35 +14,35 @@ namespace gfx {
|
||||
void generateFillBuffers(const GeometryCollection& geometry,
|
||||
gfx::VertexVector<FillLayoutVertex>& fillVertices,
|
||||
gfx::IndexVector<Triangles>& fillIndexes,
|
||||
SegmentVector<FillAttributes>& fillSegments);
|
||||
SegmentVector& fillSegments);
|
||||
|
||||
/// Generate fill and outline buffers, with the outline composed of line primitives.
|
||||
void generateFillAndOutineBuffers(const GeometryCollection& geometry,
|
||||
gfx::VertexVector<FillLayoutVertex>& vertices,
|
||||
gfx::IndexVector<gfx::Triangles>& fillIndexes,
|
||||
SegmentVector<FillAttributes>& fillSegments,
|
||||
SegmentVector& fillSegments,
|
||||
gfx::IndexVector<gfx::Lines>& lineIndexes,
|
||||
SegmentVector<FillAttributes>& lineSegments);
|
||||
SegmentVector& lineSegments);
|
||||
|
||||
/// Generate fill and outline buffers, where the outlines are built with triangle primitives
|
||||
void generateFillAndOutineBuffers(const GeometryCollection& geometry,
|
||||
gfx::VertexVector<FillLayoutVertex>& fillVertices,
|
||||
gfx::IndexVector<gfx::Triangles>& fillIndexes,
|
||||
SegmentVector<FillAttributes>& fillSegments,
|
||||
SegmentVector& fillSegments,
|
||||
gfx::VertexVector<LineLayoutVertex>& lineVertices,
|
||||
gfx::IndexVector<gfx::Triangles>& lineIndexes,
|
||||
SegmentVector<LineAttributes>& lineSegments);
|
||||
SegmentVector& lineSegments);
|
||||
|
||||
/// Generate fill and outline buffers, where the outlines are built both with triangle primitives AND with simple lines
|
||||
void generateFillAndOutineBuffers(const GeometryCollection& geometry,
|
||||
gfx::VertexVector<FillLayoutVertex>& fillVertices,
|
||||
gfx::IndexVector<gfx::Triangles>& fillIndexes,
|
||||
SegmentVector<FillAttributes>& fillSegments,
|
||||
SegmentVector& fillSegments,
|
||||
gfx::VertexVector<LineLayoutVertex>& lineVertices,
|
||||
gfx::IndexVector<gfx::Triangles>& lineIndexes,
|
||||
SegmentVector<LineAttributes>& lineSegments,
|
||||
SegmentVector& lineSegments,
|
||||
gfx::IndexVector<gfx::Lines>& basicLineIndexes,
|
||||
SegmentVector<FillAttributes>& basicLineSegments);
|
||||
SegmentVector& basicLineSegments);
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -6,21 +6,27 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::BackgroundProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "BackgroundProgram";
|
||||
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;
|
||||
uniform mat4 u_matrix;
|
||||
layout (std140) uniform BackgroundDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
};
|
||||
|
||||
void main() {
|
||||
gl_Position = u_matrix * vec4(a_pos, 0, 1);
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(uniform vec4 u_color;
|
||||
uniform float u_opacity;
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform BackgroundPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp float u_opacity;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
lowp float props_pad3;
|
||||
};
|
||||
|
||||
void main() {
|
||||
fragColor = u_color * u_opacity;
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
fragColor = vec4(1.0);
|
||||
#endif
|
||||
|
||||
@@ -6,20 +6,34 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::BackgroundPatternProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "BackgroundPatternProgram";
|
||||
static constexpr const char* vertex = R"(uniform mat4 u_matrix;
|
||||
uniform vec2 u_pattern_size_a;
|
||||
uniform vec2 u_pattern_size_b;
|
||||
uniform vec2 u_pixel_coord_upper;
|
||||
uniform vec2 u_pixel_coord_lower;
|
||||
uniform float u_scale_a;
|
||||
uniform float u_scale_b;
|
||||
uniform float u_tile_units_to_pixels;
|
||||
struct ShaderSource<BuiltIn::BackgroundPatternShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "BackgroundPatternShader";
|
||||
static constexpr const char* vertex = R"(layout (std140) uniform BackgroundPatternDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp float u_tile_units_to_pixels;
|
||||
lowp float drawable_pad1;
|
||||
lowp float drawable_pad2;
|
||||
lowp float drawable_pad3;
|
||||
};
|
||||
|
||||
layout (std140) uniform BackgroundPatternPropsUBO {
|
||||
highp vec2 u_pattern_tl_a;
|
||||
highp vec2 u_pattern_br_a;
|
||||
highp vec2 u_pattern_tl_b;
|
||||
highp vec2 u_pattern_br_b;
|
||||
highp vec2 u_pattern_size_a;
|
||||
highp vec2 u_pattern_size_b;
|
||||
highp float u_scale_a;
|
||||
highp float u_scale_b;
|
||||
highp float u_mix;
|
||||
highp float u_opacity;
|
||||
};
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
out vec2 v_pos_a;
|
||||
out vec2 v_pos_b;
|
||||
out mediump vec2 v_pos_a;
|
||||
out mediump vec2 v_pos_b;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_matrix * vec4(a_pos, 0, 1);
|
||||
@@ -28,26 +42,43 @@ void main() {
|
||||
v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_b * u_pattern_size_b, u_tile_units_to_pixels, a_pos);
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(uniform vec2 u_pattern_tl_a;
|
||||
uniform vec2 u_pattern_br_a;
|
||||
uniform vec2 u_pattern_tl_b;
|
||||
uniform vec2 u_pattern_br_b;
|
||||
uniform vec2 u_texsize;
|
||||
uniform float u_mix;
|
||||
uniform float u_opacity;
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform BackgroundPatternPropsUBO {
|
||||
highp vec2 u_pattern_tl_a;
|
||||
highp vec2 u_pattern_br_a;
|
||||
highp vec2 u_pattern_tl_b;
|
||||
highp vec2 u_pattern_br_b;
|
||||
highp vec2 u_pattern_size_a;
|
||||
highp vec2 u_pattern_size_b;
|
||||
highp float u_scale_a;
|
||||
highp float u_scale_b;
|
||||
highp float u_mix;
|
||||
highp float u_opacity;
|
||||
};
|
||||
|
||||
uniform sampler2D u_image;
|
||||
|
||||
in vec2 v_pos_a;
|
||||
in vec2 v_pos_b;
|
||||
in mediump vec2 v_pos_a;
|
||||
in mediump vec2 v_pos_b;
|
||||
|
||||
void main() {
|
||||
vec2 imagecoord = mod(v_pos_a, 1.0);
|
||||
vec2 pos = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, imagecoord);
|
||||
vec2 pos = mix(u_pattern_tl_a / u_pattern_atlas_texsize, u_pattern_br_a / u_pattern_atlas_texsize, imagecoord);
|
||||
vec4 color1 = texture(u_image, pos);
|
||||
|
||||
vec2 imagecoord_b = mod(v_pos_b, 1.0);
|
||||
vec2 pos2 = mix(u_pattern_tl_b / u_texsize, u_pattern_br_b / u_texsize, imagecoord_b);
|
||||
vec2 pos2 = mix(u_pattern_tl_b / u_pattern_atlas_texsize, u_pattern_br_b / u_pattern_atlas_texsize, imagecoord_b);
|
||||
vec4 color2 = texture(u_image, pos2);
|
||||
|
||||
fragColor = mix(color1, color2, u_mix) * u_opacity;
|
||||
|
||||
@@ -6,66 +6,79 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::CircleProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "CircleProgram";
|
||||
static constexpr const char* vertex = R"(uniform mat4 u_matrix;
|
||||
uniform bool u_scale_with_map;
|
||||
uniform bool u_pitch_with_map;
|
||||
uniform vec2 u_extrude_scale;
|
||||
uniform lowp float u_device_pixel_ratio;
|
||||
uniform highp float u_camera_to_center_distance;
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
struct ShaderSource<BuiltIn::CircleShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "CircleShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
out vec3 v_data;
|
||||
|
||||
layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform CircleDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_extrude_scale;
|
||||
// Interpolations
|
||||
lowp float u_color_t;
|
||||
lowp float u_radius_t;
|
||||
lowp float u_blur_t;
|
||||
lowp float u_opacity_t;
|
||||
lowp float u_stroke_color_t;
|
||||
lowp float u_stroke_width_t;
|
||||
lowp float u_stroke_opacity_t;
|
||||
lowp float drawable_pad1;
|
||||
lowp float drawable_pad2;
|
||||
lowp float drawable_pad3;
|
||||
};
|
||||
|
||||
layout (std140) uniform CircleEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec4 u_stroke_color;
|
||||
mediump float u_radius;
|
||||
lowp float u_blur;
|
||||
lowp float u_opacity;
|
||||
mediump float u_stroke_width;
|
||||
lowp float u_stroke_opacity;
|
||||
bool u_scale_with_map;
|
||||
bool u_pitch_with_map;
|
||||
lowp float props_pad1;
|
||||
};
|
||||
|
||||
#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_radius
|
||||
uniform lowp float u_radius_t;
|
||||
layout (location = 2) in mediump vec2 a_radius;
|
||||
out mediump float radius;
|
||||
#else
|
||||
uniform mediump float u_radius;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
uniform lowp float u_blur_t;
|
||||
layout (location = 3) in lowp vec2 a_blur;
|
||||
out lowp float blur;
|
||||
#else
|
||||
uniform lowp float u_blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
uniform lowp float u_opacity_t;
|
||||
layout (location = 4) in lowp vec2 a_opacity;
|
||||
out lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_stroke_color
|
||||
uniform lowp float u_stroke_color_t;
|
||||
layout (location = 5) in highp vec4 a_stroke_color;
|
||||
out highp vec4 stroke_color;
|
||||
#else
|
||||
uniform highp vec4 u_stroke_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_stroke_width
|
||||
uniform lowp float u_stroke_width_t;
|
||||
layout (location = 6) in mediump vec2 a_stroke_width;
|
||||
out mediump float stroke_width;
|
||||
#else
|
||||
uniform mediump float u_stroke_width;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_stroke_opacity
|
||||
uniform lowp float u_stroke_opacity_t;
|
||||
layout (location = 7) in lowp vec2 a_stroke_opacity;
|
||||
out lowp float stroke_opacity;
|
||||
#else
|
||||
uniform lowp float u_stroke_opacity;
|
||||
#endif
|
||||
|
||||
void main(void) {
|
||||
@@ -137,47 +150,46 @@ lowp float stroke_opacity = u_stroke_opacity;
|
||||
// This is a minimum blur distance that serves as a faux-antialiasing for
|
||||
// the circle. since blur is a ratio of the circle's size and the intent is
|
||||
// to keep the blur at roughly 1px, the two are inversely related.
|
||||
lowp float antialiasblur = 1.0 / u_device_pixel_ratio / (radius + stroke_width);
|
||||
lowp float antialiasblur = 1.0 / DEVICE_PIXEL_RATIO / (radius + stroke_width);
|
||||
|
||||
v_data = vec3(extrude.x, extrude.y, antialiasblur);
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(in vec3 v_data;
|
||||
|
||||
layout (std140) uniform CircleEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec4 u_stroke_color;
|
||||
mediump float u_radius;
|
||||
lowp float u_blur;
|
||||
lowp float u_opacity;
|
||||
mediump float u_stroke_width;
|
||||
lowp float u_stroke_opacity;
|
||||
bool u_scale_with_map;
|
||||
bool u_pitch_with_map;
|
||||
lowp float props_pad1;
|
||||
};
|
||||
|
||||
#ifndef HAS_UNIFORM_u_color
|
||||
in highp vec4 color;
|
||||
#else
|
||||
uniform highp vec4 u_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_radius
|
||||
in mediump float radius;
|
||||
#else
|
||||
uniform mediump float u_radius;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
in lowp float blur;
|
||||
#else
|
||||
uniform lowp float u_blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
in lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_stroke_color
|
||||
in highp vec4 stroke_color;
|
||||
#else
|
||||
uniform highp vec4 u_stroke_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_stroke_width
|
||||
in mediump float stroke_width;
|
||||
#else
|
||||
uniform mediump float u_stroke_width;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_stroke_opacity
|
||||
in lowp float stroke_opacity;
|
||||
#else
|
||||
uniform lowp float u_stroke_opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -6,17 +6,35 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::CollisionBoxProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "CollisionBoxProgram";
|
||||
struct ShaderSource<BuiltIn::CollisionBoxShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "CollisionBoxShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
layout (location = 1) in vec2 a_anchor_pos;
|
||||
layout (location = 2) in vec2 a_extrude;
|
||||
layout (location = 3) in vec2 a_placed;
|
||||
layout (location = 4) in vec2 a_shift;
|
||||
|
||||
uniform mat4 u_matrix;
|
||||
uniform vec2 u_extrude_scale;
|
||||
uniform float u_camera_to_center_distance;
|
||||
layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform CollisionDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
};
|
||||
|
||||
layout (std140) uniform CollisionTilePropsUBO {
|
||||
highp vec2 u_extrude_scale;
|
||||
highp float u_overscale_factor;
|
||||
lowp float drawable_pad1;
|
||||
};
|
||||
|
||||
out float v_placed;
|
||||
out float v_notUsed;
|
||||
@@ -36,8 +54,7 @@ void main() {
|
||||
v_notUsed = a_placed.y;
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(
|
||||
in float v_placed;
|
||||
static constexpr const char* fragment = R"(in float v_placed;
|
||||
in float v_notUsed;
|
||||
|
||||
void main() {
|
||||
@@ -56,7 +73,8 @@ void main() {
|
||||
// This box not used, fade it out
|
||||
fragColor *= .1;
|
||||
}
|
||||
})";
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
|
||||
@@ -6,16 +6,34 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::CollisionCircleProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "CollisionCircleProgram";
|
||||
struct ShaderSource<BuiltIn::CollisionCircleShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "CollisionCircleShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
layout (location = 1) in vec2 a_anchor_pos;
|
||||
layout (location = 2) in vec2 a_extrude;
|
||||
layout (location = 3) in vec2 a_placed;
|
||||
|
||||
uniform mat4 u_matrix;
|
||||
uniform vec2 u_extrude_scale;
|
||||
uniform float u_camera_to_center_distance;
|
||||
layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform CollisionDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
};
|
||||
|
||||
layout (std140) uniform CollisionTilePropsUBO {
|
||||
highp vec2 u_extrude_scale;
|
||||
highp float u_overscale_factor;
|
||||
lowp float drawable_pad1;
|
||||
};
|
||||
|
||||
out float v_placed;
|
||||
out float v_notUsed;
|
||||
@@ -44,7 +62,23 @@ void main() {
|
||||
v_extrude_scale = u_extrude_scale * u_camera_to_center_distance * collision_perspective_ratio;
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(uniform float u_overscale_factor;
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform CollisionTilePropsUBO {
|
||||
highp vec2 u_extrude_scale;
|
||||
highp float u_overscale_factor;
|
||||
lowp float drawable_pad1;
|
||||
};
|
||||
|
||||
in float v_placed;
|
||||
in float v_notUsed;
|
||||
|
||||
@@ -21,7 +21,8 @@ out vec2 frag_uv;
|
||||
void main() {
|
||||
frag_uv = a_uv;
|
||||
gl_Position = u_matrix * vec4(a_pos, 1.0);
|
||||
})";
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform CustomGeometryDrawableUBO {
|
||||
mat4 u_matrix;
|
||||
vec4 u_color;
|
||||
@@ -32,7 +33,8 @@ uniform sampler2D u_image;
|
||||
|
||||
void main() {
|
||||
fragColor = texture(u_image, frag_uv) * u_color;
|
||||
})";
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
@@ -6,13 +6,19 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::DebugProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "DebugProgram";
|
||||
struct ShaderSource<BuiltIn::DebugShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "DebugShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
out vec2 v_uv;
|
||||
|
||||
uniform mat4 u_matrix;
|
||||
uniform float u_overlay_scale;
|
||||
layout (std140) uniform DebugUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec4 u_color;
|
||||
highp float u_overlay_scale;
|
||||
lowp float pad1;
|
||||
lowp float pad2;
|
||||
lowp float pad3;
|
||||
};
|
||||
|
||||
void main() {
|
||||
// This vertex shader expects a EXTENT x EXTENT quad,
|
||||
@@ -21,7 +27,15 @@ void main() {
|
||||
gl_Position = u_matrix * vec4(a_pos * u_overlay_scale, 0, 1);
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(uniform highp vec4 u_color;
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform DebugUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec4 u_color;
|
||||
highp float u_overlay_scale;
|
||||
lowp float pad1;
|
||||
lowp float pad2;
|
||||
lowp float pad3;
|
||||
};
|
||||
|
||||
uniform sampler2D u_overlay;
|
||||
|
||||
in vec2 v_uv;
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
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 {
|
||||
highp mat4 u_matrix;
|
||||
};
|
||||
|
||||
void main() {
|
||||
gl_Position = u_matrix * vec4(a_pos, 0, 1);
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform BackgroundPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp float u_opacity;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
lowp float props_pad3;
|
||||
};
|
||||
|
||||
void main() {
|
||||
fragColor = u_color * u_opacity;
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
fragColor = vec4(1.0);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -1,94 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::BackgroundPatternShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "BackgroundPatternShader";
|
||||
static constexpr const char* vertex = R"(layout (std140) uniform BackgroundPatternDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp float u_tile_units_to_pixels;
|
||||
lowp float drawable_pad1;
|
||||
lowp float drawable_pad2;
|
||||
lowp float drawable_pad3;
|
||||
};
|
||||
|
||||
layout (std140) uniform BackgroundPatternPropsUBO {
|
||||
highp vec2 u_pattern_tl_a;
|
||||
highp vec2 u_pattern_br_a;
|
||||
highp vec2 u_pattern_tl_b;
|
||||
highp vec2 u_pattern_br_b;
|
||||
highp vec2 u_pattern_size_a;
|
||||
highp vec2 u_pattern_size_b;
|
||||
highp float u_scale_a;
|
||||
highp float u_scale_b;
|
||||
highp float u_mix;
|
||||
highp float u_opacity;
|
||||
};
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
out mediump vec2 v_pos_a;
|
||||
out mediump vec2 v_pos_b;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_matrix * vec4(a_pos, 0, 1);
|
||||
|
||||
v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_a * u_pattern_size_a, u_tile_units_to_pixels, a_pos);
|
||||
v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_b * u_pattern_size_b, u_tile_units_to_pixels, a_pos);
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform BackgroundPatternPropsUBO {
|
||||
highp vec2 u_pattern_tl_a;
|
||||
highp vec2 u_pattern_br_a;
|
||||
highp vec2 u_pattern_tl_b;
|
||||
highp vec2 u_pattern_br_b;
|
||||
highp vec2 u_pattern_size_a;
|
||||
highp vec2 u_pattern_size_b;
|
||||
highp float u_scale_a;
|
||||
highp float u_scale_b;
|
||||
highp float u_mix;
|
||||
highp float u_opacity;
|
||||
};
|
||||
|
||||
uniform sampler2D u_image;
|
||||
|
||||
in mediump vec2 v_pos_a;
|
||||
in mediump vec2 v_pos_b;
|
||||
|
||||
void main() {
|
||||
vec2 imagecoord = mod(v_pos_a, 1.0);
|
||||
vec2 pos = mix(u_pattern_tl_a / u_pattern_atlas_texsize, u_pattern_br_a / u_pattern_atlas_texsize, imagecoord);
|
||||
vec4 color1 = texture(u_image, pos);
|
||||
|
||||
vec2 imagecoord_b = mod(v_pos_b, 1.0);
|
||||
vec2 pos2 = mix(u_pattern_tl_b / u_pattern_atlas_texsize, u_pattern_br_b / u_pattern_atlas_texsize, imagecoord_b);
|
||||
vec4 color2 = texture(u_image, pos2);
|
||||
|
||||
fragColor = mix(color1, color2, u_mix) * u_opacity;
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
fragColor = vec4(1.0);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -1,242 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::CircleShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "CircleShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
out vec3 v_data;
|
||||
|
||||
layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform CircleDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_extrude_scale;
|
||||
// Interpolations
|
||||
lowp float u_color_t;
|
||||
lowp float u_radius_t;
|
||||
lowp float u_blur_t;
|
||||
lowp float u_opacity_t;
|
||||
lowp float u_stroke_color_t;
|
||||
lowp float u_stroke_width_t;
|
||||
lowp float u_stroke_opacity_t;
|
||||
lowp float drawable_pad1;
|
||||
lowp float drawable_pad2;
|
||||
lowp float drawable_pad3;
|
||||
};
|
||||
|
||||
layout (std140) uniform CircleEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec4 u_stroke_color;
|
||||
mediump float u_radius;
|
||||
lowp float u_blur;
|
||||
lowp float u_opacity;
|
||||
mediump float u_stroke_width;
|
||||
lowp float u_stroke_opacity;
|
||||
bool u_scale_with_map;
|
||||
bool u_pitch_with_map;
|
||||
lowp float props_pad1;
|
||||
};
|
||||
|
||||
#ifndef HAS_UNIFORM_u_color
|
||||
layout (location = 1) in highp vec4 a_color;
|
||||
out highp vec4 color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_radius
|
||||
layout (location = 2) in mediump vec2 a_radius;
|
||||
out mediump float radius;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
layout (location = 3) in lowp vec2 a_blur;
|
||||
out lowp float blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
layout (location = 4) in lowp vec2 a_opacity;
|
||||
out lowp float opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_stroke_color
|
||||
layout (location = 5) in highp vec4 a_stroke_color;
|
||||
out highp vec4 stroke_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_stroke_width
|
||||
layout (location = 6) in mediump vec2 a_stroke_width;
|
||||
out mediump float stroke_width;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_stroke_opacity
|
||||
layout (location = 7) in lowp vec2 a_stroke_opacity;
|
||||
out lowp float stroke_opacity;
|
||||
#endif
|
||||
|
||||
void main(void) {
|
||||
#ifndef HAS_UNIFORM_u_color
|
||||
color = unpack_mix_color(a_color, u_color_t);
|
||||
#else
|
||||
highp vec4 color = u_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_radius
|
||||
radius = unpack_mix_vec2(a_radius, u_radius_t);
|
||||
#else
|
||||
mediump float radius = u_radius;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
blur = unpack_mix_vec2(a_blur, u_blur_t);
|
||||
#else
|
||||
lowp float blur = u_blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
opacity = unpack_mix_vec2(a_opacity, u_opacity_t);
|
||||
#else
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_stroke_color
|
||||
stroke_color = unpack_mix_color(a_stroke_color, u_stroke_color_t);
|
||||
#else
|
||||
highp vec4 stroke_color = u_stroke_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_stroke_width
|
||||
stroke_width = unpack_mix_vec2(a_stroke_width, u_stroke_width_t);
|
||||
#else
|
||||
mediump float stroke_width = u_stroke_width;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_stroke_opacity
|
||||
stroke_opacity = unpack_mix_vec2(a_stroke_opacity, u_stroke_opacity_t);
|
||||
#else
|
||||
lowp float stroke_opacity = u_stroke_opacity;
|
||||
#endif
|
||||
|
||||
// unencode the extrusion vector that we snuck into the a_pos vector
|
||||
vec2 extrude = vec2(mod(a_pos, 2.0) * 2.0 - 1.0);
|
||||
|
||||
// multiply a_pos by 0.5, since we had it * 2 in order to sneak
|
||||
// in extrusion data
|
||||
vec2 circle_center = floor(a_pos * 0.5);
|
||||
if (u_pitch_with_map) {
|
||||
vec2 corner_position = circle_center;
|
||||
if (u_scale_with_map) {
|
||||
corner_position += extrude * (radius + stroke_width) * u_extrude_scale;
|
||||
} else {
|
||||
// Pitching the circle with the map effectively scales it with the map
|
||||
// To counteract the effect for pitch-scale: viewport, we rescale the
|
||||
// whole circle based on the pitch scaling effect at its central point
|
||||
vec4 projected_center = u_matrix * vec4(circle_center, 0, 1);
|
||||
corner_position += extrude * (radius + stroke_width) * u_extrude_scale * (projected_center.w / u_camera_to_center_distance);
|
||||
}
|
||||
|
||||
gl_Position = u_matrix * vec4(corner_position, 0, 1);
|
||||
} else {
|
||||
gl_Position = u_matrix * vec4(circle_center, 0, 1);
|
||||
|
||||
if (u_scale_with_map) {
|
||||
gl_Position.xy += extrude * (radius + stroke_width) * u_extrude_scale * u_camera_to_center_distance;
|
||||
} else {
|
||||
gl_Position.xy += extrude * (radius + stroke_width) * u_extrude_scale * gl_Position.w;
|
||||
}
|
||||
}
|
||||
|
||||
// This is a minimum blur distance that serves as a faux-antialiasing for
|
||||
// the circle. since blur is a ratio of the circle's size and the intent is
|
||||
// to keep the blur at roughly 1px, the two are inversely related.
|
||||
lowp float antialiasblur = 1.0 / DEVICE_PIXEL_RATIO / (radius + stroke_width);
|
||||
|
||||
v_data = vec3(extrude.x, extrude.y, antialiasblur);
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(in vec3 v_data;
|
||||
|
||||
layout (std140) uniform CircleEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec4 u_stroke_color;
|
||||
mediump float u_radius;
|
||||
lowp float u_blur;
|
||||
lowp float u_opacity;
|
||||
mediump float u_stroke_width;
|
||||
lowp float u_stroke_opacity;
|
||||
bool u_scale_with_map;
|
||||
bool u_pitch_with_map;
|
||||
lowp float props_pad1;
|
||||
};
|
||||
|
||||
#ifndef HAS_UNIFORM_u_color
|
||||
in highp vec4 color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_radius
|
||||
in mediump float radius;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
in lowp float blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
in lowp float opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_stroke_color
|
||||
in highp vec4 stroke_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_stroke_width
|
||||
in mediump float stroke_width;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_stroke_opacity
|
||||
in lowp float stroke_opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifdef HAS_UNIFORM_u_color
|
||||
highp vec4 color = u_color;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_radius
|
||||
mediump float radius = u_radius;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_blur
|
||||
lowp float blur = u_blur;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_opacity
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_stroke_color
|
||||
highp vec4 stroke_color = u_stroke_color;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_stroke_width
|
||||
mediump float stroke_width = u_stroke_width;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_stroke_opacity
|
||||
lowp float stroke_opacity = u_stroke_opacity;
|
||||
#endif
|
||||
|
||||
vec2 extrude = v_data.xy;
|
||||
float extrude_length = length(extrude);
|
||||
|
||||
lowp float antialiasblur = v_data.z;
|
||||
float antialiased_blur = -max(blur, antialiasblur);
|
||||
|
||||
float opacity_t = smoothstep(0.0, antialiased_blur, extrude_length - 1.0);
|
||||
|
||||
float color_t = stroke_width < 0.01 ? 0.0 : smoothstep(
|
||||
antialiased_blur,
|
||||
0.0,
|
||||
extrude_length - radius / (radius + stroke_width)
|
||||
);
|
||||
|
||||
fragColor = opacity_t * mix(color * opacity, stroke_color * stroke_opacity, color_t);
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
fragColor = vec4(1.0);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -1,80 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::CollisionBoxShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "CollisionBoxShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
layout (location = 1) in vec2 a_anchor_pos;
|
||||
layout (location = 2) in vec2 a_extrude;
|
||||
layout (location = 3) in vec2 a_placed;
|
||||
layout (location = 4) in vec2 a_shift;
|
||||
|
||||
layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform CollisionDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
};
|
||||
|
||||
layout (std140) uniform CollisionTilePropsUBO {
|
||||
highp vec2 u_extrude_scale;
|
||||
highp float u_overscale_factor;
|
||||
lowp float drawable_pad1;
|
||||
};
|
||||
|
||||
out float v_placed;
|
||||
out float v_notUsed;
|
||||
|
||||
void main() {
|
||||
vec4 projectedPoint = u_matrix * vec4(a_anchor_pos, 0, 1);
|
||||
highp float camera_to_anchor_distance = projectedPoint.w;
|
||||
highp float collision_perspective_ratio = clamp(
|
||||
0.5 + 0.5 * (u_camera_to_center_distance / camera_to_anchor_distance),
|
||||
0.0, // Prevents oversized near-field boxes in pitched/overzoomed tiles
|
||||
4.0);
|
||||
|
||||
gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);
|
||||
gl_Position.xy += (a_extrude + a_shift) * u_extrude_scale * gl_Position.w * collision_perspective_ratio;
|
||||
|
||||
v_placed = a_placed.x;
|
||||
v_notUsed = a_placed.y;
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(in float v_placed;
|
||||
in float v_notUsed;
|
||||
|
||||
void main() {
|
||||
|
||||
float alpha = 0.5;
|
||||
|
||||
// Red = collision, hide label
|
||||
fragColor = vec4(1.0, 0.0, 0.0, 1.0) * alpha;
|
||||
|
||||
// Blue = no collision, label is showing
|
||||
if (v_placed > 0.5) {
|
||||
fragColor = vec4(0.0, 0.0, 1.0, 0.5) * alpha;
|
||||
}
|
||||
|
||||
if (v_notUsed > 0.5) {
|
||||
// This box not used, fade it out
|
||||
fragColor *= .1;
|
||||
}
|
||||
})";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -1,119 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::CollisionCircleShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "CollisionCircleShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
layout (location = 1) in vec2 a_anchor_pos;
|
||||
layout (location = 2) in vec2 a_extrude;
|
||||
layout (location = 3) in vec2 a_placed;
|
||||
|
||||
layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform CollisionDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
};
|
||||
|
||||
layout (std140) uniform CollisionTilePropsUBO {
|
||||
highp vec2 u_extrude_scale;
|
||||
highp float u_overscale_factor;
|
||||
lowp float drawable_pad1;
|
||||
};
|
||||
|
||||
out float v_placed;
|
||||
out float v_notUsed;
|
||||
out float v_radius;
|
||||
out highp vec2 v_extrude;
|
||||
out vec2 v_extrude_scale;
|
||||
|
||||
void main() {
|
||||
vec4 projectedPoint = u_matrix * vec4(a_anchor_pos, 0, 1);
|
||||
highp float camera_to_anchor_distance = projectedPoint.w;
|
||||
highp float collision_perspective_ratio = clamp(
|
||||
0.5 + 0.5 * (u_camera_to_center_distance / camera_to_anchor_distance),
|
||||
0.0, // Prevents oversized near-field circles in pitched/overzoomed tiles
|
||||
4.0);
|
||||
|
||||
gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);
|
||||
|
||||
highp float padding_factor = 1.2; // Pad the vertices slightly to make room for anti-alias blur
|
||||
gl_Position.xy += a_extrude * u_extrude_scale * padding_factor * gl_Position.w * collision_perspective_ratio;
|
||||
|
||||
v_placed = a_placed.x;
|
||||
v_notUsed = a_placed.y;
|
||||
v_radius = abs(a_extrude.y); // We don't pitch the circles, so both units of the extrusion vector are equal in magnitude to the radius
|
||||
|
||||
v_extrude = a_extrude * padding_factor;
|
||||
v_extrude_scale = u_extrude_scale * u_camera_to_center_distance * collision_perspective_ratio;
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform CollisionTilePropsUBO {
|
||||
highp vec2 u_extrude_scale;
|
||||
highp float u_overscale_factor;
|
||||
lowp float drawable_pad1;
|
||||
};
|
||||
|
||||
in float v_placed;
|
||||
in float v_notUsed;
|
||||
in float v_radius;
|
||||
in highp vec2 v_extrude;
|
||||
in vec2 v_extrude_scale;
|
||||
|
||||
void main() {
|
||||
float alpha = 0.5;
|
||||
|
||||
// Red = collision, hide label
|
||||
vec4 color = vec4(1.0, 0.0, 0.0, 1.0) * alpha;
|
||||
|
||||
// Blue = no collision, label is showing
|
||||
if (v_placed > 0.5) {
|
||||
color = vec4(0.0, 0.0, 1.0, 0.5) * alpha;
|
||||
}
|
||||
|
||||
if (v_notUsed > 0.5) {
|
||||
// This box not used, fade it out
|
||||
color *= .2;
|
||||
}
|
||||
|
||||
float extrude_scale_length = length(v_extrude_scale);
|
||||
float extrude_length = length(v_extrude) * extrude_scale_length;
|
||||
float stroke_width = 15.0 * extrude_scale_length / u_overscale_factor;
|
||||
float radius = v_radius * extrude_scale_length;
|
||||
|
||||
float distance_to_edge = abs(extrude_length - radius);
|
||||
float opacity_t = smoothstep(-stroke_width, 0.0, -distance_to_edge);
|
||||
|
||||
fragColor = opacity_t * color;
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -1,51 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::DebugShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "DebugShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
out vec2 v_uv;
|
||||
|
||||
layout (std140) uniform DebugUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec4 u_color;
|
||||
highp float u_overlay_scale;
|
||||
lowp float pad1;
|
||||
lowp float pad2;
|
||||
lowp float pad3;
|
||||
};
|
||||
|
||||
void main() {
|
||||
// This vertex shader expects a EXTENT x EXTENT quad,
|
||||
// The UV co-ordinates for the overlay texture can be calculated using that knowledge
|
||||
v_uv = a_pos / 8192.0;
|
||||
gl_Position = u_matrix * vec4(a_pos * u_overlay_scale, 0, 1);
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform DebugUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec4 u_color;
|
||||
highp float u_overlay_scale;
|
||||
lowp float pad1;
|
||||
lowp float pad2;
|
||||
lowp float pad3;
|
||||
};
|
||||
|
||||
uniform sampler2D u_overlay;
|
||||
|
||||
in vec2 v_uv;
|
||||
|
||||
void main() {
|
||||
vec4 overlay_color = texture(u_overlay, v_uv);
|
||||
fragColor = mix(u_color, overlay_color, overlay_color.a);
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -1,89 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "FillShader";
|
||||
static constexpr const char* vertex = R"(layout (std140) uniform FillDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
// Interpolations
|
||||
highp float u_color_t;
|
||||
highp float u_opacity_t;
|
||||
lowp float drawable_pad1;
|
||||
lowp float drawable_pad2;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec4 u_outline_color;
|
||||
highp float u_opacity;
|
||||
highp float u_fade;
|
||||
highp float u_from_scale;
|
||||
highp float u_to_scale;
|
||||
};
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_color
|
||||
layout (location = 1) in highp vec4 a_color;
|
||||
out highp vec4 color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
layout (location = 2) in lowp vec2 a_opacity;
|
||||
out lowp float opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef HAS_UNIFORM_u_color
|
||||
color = unpack_mix_color(a_color, u_color_t);
|
||||
#else
|
||||
highp vec4 color = u_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
opacity = unpack_mix_vec2(a_opacity, u_opacity_t);
|
||||
#else
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
|
||||
gl_Position = u_matrix * vec4(a_pos, 0, 1);
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform FillEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec4 u_outline_color;
|
||||
highp float u_opacity;
|
||||
highp float u_fade;
|
||||
highp float u_from_scale;
|
||||
highp float u_to_scale;
|
||||
};
|
||||
|
||||
#ifndef HAS_UNIFORM_u_color
|
||||
in highp vec4 color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
in lowp float opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifdef HAS_UNIFORM_u_color
|
||||
highp vec4 color = u_color;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_opacity
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
|
||||
fragColor = color * opacity;
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
fragColor = vec4(1.0);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -1,139 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillExtrusionShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "FillExtrusionShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
layout (location = 1) in vec4 a_normal_ed;
|
||||
out vec4 v_color;
|
||||
|
||||
layout (std140) uniform FillExtrusionDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp float u_height_factor;
|
||||
highp float u_tile_ratio;
|
||||
// Interpolations
|
||||
highp float u_base_t;
|
||||
highp float u_height_t;
|
||||
highp float u_color_t;
|
||||
highp float u_pattern_from_t;
|
||||
highp float u_pattern_to_t;
|
||||
lowp float drawable_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillExtrusionTilePropsUBO {
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
highp vec2 u_texsize;
|
||||
lowp float tileprops_pad1;
|
||||
lowp float tileprops_pad2;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillExtrusionPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec3 u_lightcolor;
|
||||
lowp float props_pad1;
|
||||
highp vec3 u_lightpos;
|
||||
highp float u_base;
|
||||
highp float u_height;
|
||||
highp float u_lightintensity;
|
||||
highp float u_vertical_gradient;
|
||||
highp float u_opacity;
|
||||
highp float u_fade;
|
||||
highp float u_from_scale;
|
||||
highp float u_to_scale;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
#ifndef HAS_UNIFORM_u_base
|
||||
layout (location = 2) in highp vec2 a_base;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_height
|
||||
layout (location = 3) in highp vec2 a_height;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_color
|
||||
layout (location = 4) in highp vec4 a_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef HAS_UNIFORM_u_base
|
||||
highp float base = unpack_mix_vec2(a_base, u_base_t);
|
||||
#else
|
||||
highp float base = u_base;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_height
|
||||
highp float height = unpack_mix_vec2(a_height, u_height_t);
|
||||
#else
|
||||
highp float height = u_height;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_color
|
||||
highp vec4 color = unpack_mix_color(a_color, u_color_t);
|
||||
#else
|
||||
highp vec4 color = u_color;
|
||||
#endif
|
||||
|
||||
vec3 normal = a_normal_ed.xyz;
|
||||
|
||||
base = max(0.0, base);
|
||||
height = max(0.0, height);
|
||||
|
||||
float t = mod(normal.x, 2.0);
|
||||
|
||||
gl_Position = u_matrix * vec4(a_pos, t > 0.0 ? height : base, 1);
|
||||
|
||||
// Relative luminance (how dark/bright is the surface color?)
|
||||
float colorvalue = color.r * 0.2126 + color.g * 0.7152 + color.b * 0.0722;
|
||||
|
||||
v_color = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
// Add slight ambient lighting so no extrusions are totally black
|
||||
vec4 ambientlight = vec4(0.03, 0.03, 0.03, 1.0);
|
||||
color += ambientlight;
|
||||
|
||||
// Calculate cos(theta), where theta is the angle between surface normal and diffuse light ray
|
||||
float directional = clamp(dot(normal / 16384.0, u_lightpos), 0.0, 1.0);
|
||||
|
||||
// Adjust directional so that
|
||||
// the range of values for highlight/shading is narrower
|
||||
// with lower light intensity
|
||||
// and with lighter/brighter surface colors
|
||||
directional = mix((1.0 - u_lightintensity), max((1.0 - colorvalue + u_lightintensity), 1.0), directional);
|
||||
|
||||
// Add gradient along z axis of side surfaces
|
||||
if (normal.y != 0.0) {
|
||||
// This avoids another branching statement, but multiplies by a constant of 0.84 if no vertical gradient,
|
||||
// and otherwise calculates the gradient based on base + height
|
||||
directional *= (
|
||||
(1.0 - u_vertical_gradient) +
|
||||
(u_vertical_gradient * clamp((t + base) * pow(height / 150.0, 0.5), mix(0.7, 0.98, 1.0 - u_lightintensity), 1.0)));
|
||||
}
|
||||
|
||||
// Assign final color based on surface + ambient light color, diffuse light directional, and light color
|
||||
// with lower bounds adjusted to hue of light
|
||||
// so that shading is tinted with the complementary (opposite) color to the light color
|
||||
v_color.r += clamp(color.r * directional * u_lightcolor.r, mix(0.0, 0.3, 1.0 - u_lightcolor.r), 1.0);
|
||||
v_color.g += clamp(color.g * directional * u_lightcolor.g, mix(0.0, 0.3, 1.0 - u_lightcolor.g), 1.0);
|
||||
v_color.b += clamp(color.b * directional * u_lightcolor.b, mix(0.0, 0.3, 1.0 - u_lightcolor.b), 1.0);
|
||||
v_color *= u_opacity;
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(in vec4 v_color;
|
||||
|
||||
void main() {
|
||||
fragColor = v_color;
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
fragColor = vec4(1.0);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -1,237 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillExtrusionPatternShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "FillExtrusionPatternShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
layout (location = 1) in vec4 a_normal_ed;
|
||||
|
||||
out vec2 v_pos_a;
|
||||
out vec2 v_pos_b;
|
||||
out vec4 v_lighting;
|
||||
|
||||
layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillExtrusionDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp float u_height_factor;
|
||||
highp float u_tile_ratio;
|
||||
// Interpolations
|
||||
highp float u_base_t;
|
||||
highp float u_height_t;
|
||||
highp float u_color_t;
|
||||
highp float u_pattern_from_t;
|
||||
highp float u_pattern_to_t;
|
||||
lowp float drawable_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillExtrusionTilePropsUBO {
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
highp vec2 u_texsize;
|
||||
lowp float tileprops_pad1;
|
||||
lowp float tileprops_pad2;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillExtrusionPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec3 u_lightcolor;
|
||||
lowp float props_pad1;
|
||||
highp vec3 u_lightpos;
|
||||
highp float u_base;
|
||||
highp float u_height;
|
||||
highp float u_lightintensity;
|
||||
highp float u_vertical_gradient;
|
||||
highp float u_opacity;
|
||||
highp float u_fade;
|
||||
highp float u_from_scale;
|
||||
highp float u_to_scale;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
#ifndef HAS_UNIFORM_u_base
|
||||
layout (location = 2) in lowp vec2 a_base;
|
||||
out lowp float base;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_height
|
||||
layout (location = 3) in lowp vec2 a_height;
|
||||
out lowp float height;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_from
|
||||
layout (location = 4) in mediump vec4 a_pattern_from;
|
||||
out mediump vec4 pattern_from;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_to
|
||||
layout (location = 5) in mediump vec4 a_pattern_to;
|
||||
out mediump vec4 pattern_to;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef HAS_UNIFORM_u_base
|
||||
base = unpack_mix_vec2(a_base, u_base_t);
|
||||
#else
|
||||
lowp float base = u_base;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_height
|
||||
height = unpack_mix_vec2(a_height, u_height_t);
|
||||
#else
|
||||
lowp float height = u_height;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_from
|
||||
pattern_from = a_pattern_from;
|
||||
#else
|
||||
mediump vec4 pattern_from = u_pattern_from;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_to
|
||||
pattern_to = a_pattern_to;
|
||||
#else
|
||||
mediump vec4 pattern_to = u_pattern_to;
|
||||
#endif
|
||||
|
||||
vec2 pattern_tl_a = pattern_from.xy;
|
||||
vec2 pattern_br_a = pattern_from.zw;
|
||||
vec2 pattern_tl_b = pattern_to.xy;
|
||||
vec2 pattern_br_b = pattern_to.zw;
|
||||
|
||||
float pixelRatio = u_pixel_ratio;
|
||||
float tileRatio = u_tile_ratio;
|
||||
float fromScale = u_from_scale;
|
||||
float toScale = u_to_scale;
|
||||
|
||||
vec3 normal = a_normal_ed.xyz;
|
||||
float edgedistance = a_normal_ed.w;
|
||||
|
||||
vec2 display_size_a = vec2((pattern_br_a.x - pattern_tl_a.x) / pixelRatio, (pattern_br_a.y - pattern_tl_a.y) / pixelRatio);
|
||||
vec2 display_size_b = vec2((pattern_br_b.x - pattern_tl_b.x) / pixelRatio, (pattern_br_b.y - pattern_tl_b.y) / pixelRatio);
|
||||
|
||||
base = max(0.0, base);
|
||||
height = max(0.0, height);
|
||||
|
||||
float t = mod(normal.x, 2.0);
|
||||
float z = t > 0.0 ? height : base;
|
||||
|
||||
gl_Position = u_matrix * vec4(a_pos, z, 1);
|
||||
|
||||
vec2 pos = normal.x == 1.0 && normal.y == 0.0 && normal.z == 16384.0
|
||||
? a_pos // extrusion top
|
||||
: vec2(edgedistance, z * u_height_factor); // extrusion side
|
||||
|
||||
v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, fromScale * display_size_a, tileRatio, pos);
|
||||
v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, toScale * display_size_b, tileRatio, pos);
|
||||
|
||||
v_lighting = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
float directional = clamp(dot(normal / 16383.0, u_lightpos), 0.0, 1.0);
|
||||
directional = mix((1.0 - u_lightintensity), max((0.5 + u_lightintensity), 1.0), directional);
|
||||
|
||||
if (normal.y != 0.0) {
|
||||
// This avoids another branching statement, but multiplies by a constant of 0.84 if no vertical gradient,
|
||||
// and otherwise calculates the gradient based on base + height
|
||||
directional *= (
|
||||
(1.0 - u_vertical_gradient) +
|
||||
(u_vertical_gradient * clamp((t + base) * pow(height / 150.0, 0.5), mix(0.7, 0.98, 1.0 - u_lightintensity), 1.0)));
|
||||
}
|
||||
|
||||
v_lighting.rgb += clamp(directional * u_lightcolor, mix(vec3(0.0), vec3(0.3), 1.0 - u_lightcolor), vec3(1.0));
|
||||
v_lighting *= u_opacity;
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(in vec2 v_pos_a;
|
||||
in vec2 v_pos_b;
|
||||
in vec4 v_lighting;
|
||||
|
||||
layout (std140) uniform FillExtrusionTilePropsUBO {
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
highp vec2 u_texsize;
|
||||
lowp float tileprops_pad1;
|
||||
lowp float tileprops_pad2;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillExtrusionPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec3 u_lightcolor;
|
||||
lowp float props_pad1;
|
||||
highp vec3 u_lightpos;
|
||||
highp float u_base;
|
||||
highp float u_height;
|
||||
highp float u_lightintensity;
|
||||
highp float u_vertical_gradient;
|
||||
highp float u_opacity;
|
||||
highp float u_fade;
|
||||
highp float u_from_scale;
|
||||
highp float u_to_scale;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
uniform sampler2D u_image;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_base
|
||||
in lowp float base;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_height
|
||||
in lowp float height;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_from
|
||||
in mediump vec4 pattern_from;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_to
|
||||
in mediump vec4 pattern_to;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifdef HAS_UNIFORM_u_base
|
||||
lowp float base = u_base;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_height
|
||||
lowp float height = u_height;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_pattern_from
|
||||
mediump vec4 pattern_from = u_pattern_from;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_pattern_to
|
||||
mediump vec4 pattern_to = u_pattern_to;
|
||||
#endif
|
||||
|
||||
vec2 pattern_tl_a = pattern_from.xy;
|
||||
vec2 pattern_br_a = pattern_from.zw;
|
||||
vec2 pattern_tl_b = pattern_to.xy;
|
||||
vec2 pattern_br_b = pattern_to.zw;
|
||||
|
||||
vec2 imagecoord = mod(v_pos_a, 1.0);
|
||||
vec2 pos = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, imagecoord);
|
||||
vec4 color1 = texture(u_image, pos);
|
||||
|
||||
vec2 imagecoord_b = mod(v_pos_b, 1.0);
|
||||
vec2 pos2 = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, imagecoord_b);
|
||||
vec4 color2 = texture(u_image, pos2);
|
||||
|
||||
vec4 mixedColor = mix(color1, color2, u_fade);
|
||||
|
||||
fragColor = mixedColor * v_lighting;
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
fragColor = vec4(1.0);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -1,108 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillOutlineShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "FillOutlineShader";
|
||||
static constexpr const char* vertex = R"(layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillOutlineDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
// Interpolations
|
||||
highp float u_outline_color_t;
|
||||
highp float u_opacity_t;
|
||||
lowp float drawable_pad1;
|
||||
lowp float drawable_pad2;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec4 u_outline_color;
|
||||
highp float u_opacity;
|
||||
highp float u_fade;
|
||||
highp float u_from_scale;
|
||||
highp float u_to_scale;
|
||||
};
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
|
||||
out vec2 v_pos;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_outline_color
|
||||
layout (location = 1) in highp vec4 a_outline_color;
|
||||
out highp vec4 outline_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
layout (location = 2) in lowp vec2 a_opacity;
|
||||
out lowp float opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef HAS_UNIFORM_u_outline_color
|
||||
outline_color = unpack_mix_color(a_outline_color, u_outline_color_t);
|
||||
#else
|
||||
highp vec4 outline_color = u_outline_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
opacity = unpack_mix_vec2(a_opacity, u_opacity_t);
|
||||
#else
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
|
||||
gl_Position = u_matrix * vec4(a_pos, 0, 1);
|
||||
v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world_size;
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform FillEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec4 u_outline_color;
|
||||
highp float u_opacity;
|
||||
highp float u_fade;
|
||||
highp float u_from_scale;
|
||||
highp float u_to_scale;
|
||||
};
|
||||
|
||||
in vec2 v_pos;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_outline_color
|
||||
in highp vec4 outline_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
in lowp float opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifdef HAS_UNIFORM_u_outline_color
|
||||
highp vec4 outline_color = u_outline_color;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_opacity
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
|
||||
float dist = length(v_pos - gl_FragCoord.xy);
|
||||
float alpha = 1.0 - smoothstep(0.0, 1.0, dist);
|
||||
fragColor = outline_color * (alpha * opacity);
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
fragColor = vec4(1.0);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -1,181 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillOutlinePatternShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "FillOutlinePatternShader";
|
||||
static constexpr const char* vertex = R"(layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillOutlinePatternDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp float u_tile_ratio;
|
||||
// Interpolations
|
||||
highp float u_pattern_from_t;
|
||||
highp float u_pattern_to_t;
|
||||
highp float u_opacity_t;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillOutlinePatternTilePropsUBO {
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
highp vec2 u_texsize;
|
||||
lowp float tileprops_pad1;
|
||||
lowp float tileprops_pad2;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec4 u_outline_color;
|
||||
highp float u_opacity;
|
||||
highp float u_fade;
|
||||
highp float u_from_scale;
|
||||
highp float u_to_scale;
|
||||
};
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
|
||||
out vec2 v_pos_a;
|
||||
out vec2 v_pos_b;
|
||||
out vec2 v_pos;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
layout (location = 1) in lowp vec2 a_opacity;
|
||||
out lowp float opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_from
|
||||
layout (location = 2) in lowp vec4 a_pattern_from;
|
||||
out lowp vec4 pattern_from;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_to
|
||||
layout (location = 3) in lowp vec4 a_pattern_to;
|
||||
out lowp vec4 pattern_to;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
opacity = unpack_mix_vec2(a_opacity, u_opacity_t);
|
||||
#else
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_from
|
||||
pattern_from = a_pattern_from;
|
||||
#else
|
||||
mediump vec4 pattern_from = u_pattern_from;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_to
|
||||
pattern_to = a_pattern_to;
|
||||
#else
|
||||
mediump vec4 pattern_to = u_pattern_to;
|
||||
#endif
|
||||
|
||||
vec2 pattern_tl_a = pattern_from.xy;
|
||||
vec2 pattern_br_a = pattern_from.zw;
|
||||
vec2 pattern_tl_b = pattern_to.xy;
|
||||
vec2 pattern_br_b = pattern_to.zw;
|
||||
|
||||
float pixelRatio = u_pixel_ratio;
|
||||
float tileRatio = u_tile_ratio;
|
||||
float fromScale = u_from_scale;
|
||||
float toScale = u_to_scale;
|
||||
|
||||
gl_Position = u_matrix * vec4(a_pos, 0, 1);
|
||||
|
||||
vec2 display_size_a = vec2((pattern_br_a.x - pattern_tl_a.x) / pixelRatio, (pattern_br_a.y - pattern_tl_a.y) / pixelRatio);
|
||||
vec2 display_size_b = vec2((pattern_br_b.x - pattern_tl_b.x) / pixelRatio, (pattern_br_b.y - pattern_tl_b.y) / pixelRatio);
|
||||
|
||||
v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, fromScale * display_size_a, tileRatio, a_pos);
|
||||
v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, toScale * display_size_b, tileRatio, a_pos);
|
||||
|
||||
v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world_size;
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform FillOutlinePatternTilePropsUBO {
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
highp vec2 u_texsize;
|
||||
lowp float tileprops_pad1;
|
||||
lowp float tileprops_pad2;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec4 u_outline_color;
|
||||
highp float u_opacity;
|
||||
highp float u_fade;
|
||||
highp float u_from_scale;
|
||||
highp float u_to_scale;
|
||||
};
|
||||
|
||||
uniform sampler2D u_image;
|
||||
|
||||
in vec2 v_pos_a;
|
||||
in vec2 v_pos_b;
|
||||
in vec2 v_pos;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
in lowp float opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_from
|
||||
in lowp vec4 pattern_from;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_to
|
||||
in lowp vec4 pattern_to;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifdef HAS_UNIFORM_u_opacity
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_pattern_from
|
||||
mediump vec4 pattern_from = u_pattern_from;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_pattern_to
|
||||
mediump vec4 pattern_to = u_pattern_to;
|
||||
#endif
|
||||
|
||||
vec2 pattern_tl_a = pattern_from.xy;
|
||||
vec2 pattern_br_a = pattern_from.zw;
|
||||
vec2 pattern_tl_b = pattern_to.xy;
|
||||
vec2 pattern_br_b = pattern_to.zw;
|
||||
|
||||
vec2 imagecoord = mod(v_pos_a, 1.0);
|
||||
vec2 pos = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, imagecoord);
|
||||
vec4 color1 = texture(u_image, pos);
|
||||
|
||||
vec2 imagecoord_b = mod(v_pos_b, 1.0);
|
||||
vec2 pos2 = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, imagecoord_b);
|
||||
vec4 color2 = texture(u_image, pos2);
|
||||
|
||||
// find distance to outline for alpha interpolation
|
||||
|
||||
float dist = length(v_pos - gl_FragCoord.xy);
|
||||
float alpha = 1.0 - smoothstep(0.0, 1.0, dist);
|
||||
|
||||
|
||||
fragColor = mix(color1, color2, u_fade) * alpha * opacity;
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
fragColor = vec4(1.0);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -1,174 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillPatternShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "FillPatternShader";
|
||||
static constexpr const char* vertex = R"(layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillPatternDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp float u_tile_ratio;
|
||||
// Interpolations
|
||||
highp float u_pattern_from_t;
|
||||
highp float u_pattern_to_t;
|
||||
highp float u_opacity_t;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillPatternTilePropsUBO {
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
highp vec2 u_texsize;
|
||||
lowp float tileprops_pad1;
|
||||
lowp float tileprops_pad2;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec4 u_outline_color;
|
||||
highp float u_opacity;
|
||||
highp float u_fade;
|
||||
highp float u_from_scale;
|
||||
highp float u_to_scale;
|
||||
};
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
|
||||
out vec2 v_pos_a;
|
||||
out vec2 v_pos_b;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
layout (location = 1) in lowp vec2 a_opacity;
|
||||
out lowp float opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_from
|
||||
layout (location = 2) in lowp vec4 a_pattern_from;
|
||||
out lowp vec4 pattern_from;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_to
|
||||
layout (location = 3) in lowp vec4 a_pattern_to;
|
||||
out lowp vec4 pattern_to;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
opacity = unpack_mix_vec2(a_opacity, u_opacity_t);
|
||||
#else
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_from
|
||||
pattern_from = a_pattern_from;
|
||||
#else
|
||||
mediump vec4 pattern_from = u_pattern_from;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_to
|
||||
pattern_to = a_pattern_to;
|
||||
#else
|
||||
mediump vec4 pattern_to = u_pattern_to;
|
||||
#endif
|
||||
|
||||
vec2 pattern_tl_a = pattern_from.xy;
|
||||
vec2 pattern_br_a = pattern_from.zw;
|
||||
vec2 pattern_tl_b = pattern_to.xy;
|
||||
vec2 pattern_br_b = pattern_to.zw;
|
||||
|
||||
float pixelRatio = u_pixel_ratio;
|
||||
float tileZoomRatio = u_tile_ratio;
|
||||
float fromScale = u_from_scale;
|
||||
float toScale = u_to_scale;
|
||||
|
||||
vec2 display_size_a = vec2((pattern_br_a.x - pattern_tl_a.x) / pixelRatio, (pattern_br_a.y - pattern_tl_a.y) / pixelRatio);
|
||||
vec2 display_size_b = vec2((pattern_br_b.x - pattern_tl_b.x) / pixelRatio, (pattern_br_b.y - pattern_tl_b.y) / pixelRatio);
|
||||
gl_Position = u_matrix * vec4(a_pos, 0, 1);
|
||||
|
||||
v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, fromScale * display_size_a, tileZoomRatio, a_pos);
|
||||
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"(layout (std140) uniform FillPatternTilePropsUBO {
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
highp vec2 u_texsize;
|
||||
lowp float tileprops_pad1;
|
||||
lowp float tileprops_pad2;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec4 u_outline_color;
|
||||
highp float u_opacity;
|
||||
highp float u_fade;
|
||||
highp float u_from_scale;
|
||||
highp float u_to_scale;
|
||||
};
|
||||
|
||||
uniform sampler2D u_image;
|
||||
|
||||
in vec2 v_pos_a;
|
||||
in vec2 v_pos_b;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
in lowp float opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_from
|
||||
in lowp vec4 pattern_from;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_to
|
||||
in lowp vec4 pattern_to;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifdef HAS_UNIFORM_u_opacity
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_pattern_from
|
||||
mediump vec4 pattern_from = u_pattern_from;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_pattern_to
|
||||
mediump vec4 pattern_to = u_pattern_to;
|
||||
#endif
|
||||
|
||||
vec2 pattern_tl_a = pattern_from.xy;
|
||||
vec2 pattern_br_a = pattern_from.zw;
|
||||
vec2 pattern_tl_b = pattern_to.xy;
|
||||
vec2 pattern_br_b = pattern_to.zw;
|
||||
|
||||
if (u_texsize.x < 1.0 || u_texsize.y < 1.0) {
|
||||
discard;
|
||||
}
|
||||
|
||||
vec2 imagecoord = mod(v_pos_a, 1.0);
|
||||
vec2 pos = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, imagecoord);
|
||||
vec4 color1 = texture(u_image, pos);
|
||||
|
||||
vec2 imagecoord_b = mod(v_pos_b, 1.0);
|
||||
vec2 pos2 = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, imagecoord_b);
|
||||
vec4 color2 = texture(u_image, pos2);
|
||||
|
||||
fragColor = mix(color1, color2, u_fade) * opacity;
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
fragColor = vec4(1.0);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -1,123 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::HeatmapShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "HeatmapShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
out vec2 v_extrude;
|
||||
|
||||
layout (std140) uniform HeatmapDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp float u_extrude_scale;
|
||||
// Interpolations
|
||||
lowp float u_weight_t;
|
||||
lowp float u_radius_t;
|
||||
lowp float drawable_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform HeatmapEvaluatedPropsUBO {
|
||||
highp float u_weight;
|
||||
highp float u_radius;
|
||||
highp float u_intensity;
|
||||
lowp float props_pad1;
|
||||
};
|
||||
|
||||
#ifndef HAS_UNIFORM_u_weight
|
||||
layout (location = 1) in highp vec2 a_weight;
|
||||
out highp float weight;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_radius
|
||||
layout (location = 2) in mediump vec2 a_radius;
|
||||
#endif
|
||||
|
||||
// Effective "0" in the kernel density texture to adjust the kernel size to;
|
||||
// this empirically chosen number minimizes artifacts on overlapping kernels
|
||||
// for typical heatmap cases (assuming clustered source)
|
||||
const highp float ZERO = 1.0 / 255.0 / 16.0;
|
||||
|
||||
// Gaussian kernel coefficient: 1 / sqrt(2 * PI)
|
||||
#define GAUSS_COEF 0.3989422804014327
|
||||
|
||||
void main(void) {
|
||||
#ifndef HAS_UNIFORM_u_weight
|
||||
weight = unpack_mix_vec2(a_weight, u_weight_t);
|
||||
#else
|
||||
highp float weight = u_weight;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_radius
|
||||
mediump float radius = unpack_mix_vec2(a_radius, u_radius_t);
|
||||
#else
|
||||
mediump float radius = u_radius;
|
||||
#endif
|
||||
|
||||
// unencode the extrusion vector that we snuck into the a_pos vector
|
||||
vec2 unscaled_extrude = vec2(mod(a_pos, 2.0) * 2.0 - 1.0);
|
||||
|
||||
// This 'extrude' comes in ranging from [-1, -1], to [1, 1]. We'll use
|
||||
// it to produce the vertices of a square mesh framing the point feature
|
||||
// we're adding to the kernel density texture. We'll also pass it as
|
||||
// a varying, so that the fragment shader can determine the distance of
|
||||
// each fragment from the point feature.
|
||||
// Before we do so, we need to scale it up sufficiently so that the
|
||||
// kernel falls effectively to zero at the edge of the mesh.
|
||||
// That is, we want to know S such that
|
||||
// weight * u_intensity * GAUSS_COEF * exp(-0.5 * 3.0^2 * S^2) == ZERO
|
||||
// Which solves to:
|
||||
// S = sqrt(-2.0 * log(ZERO / (weight * u_intensity * GAUSS_COEF))) / 3.0
|
||||
float S = sqrt(-2.0 * log(ZERO / weight / u_intensity / GAUSS_COEF)) / 3.0;
|
||||
|
||||
// Pass the varying in units of radius
|
||||
v_extrude = S * unscaled_extrude;
|
||||
|
||||
// Scale by radius and the zoom-based scale factor to produce actual
|
||||
// mesh position
|
||||
vec2 extrude = v_extrude * radius * u_extrude_scale;
|
||||
|
||||
// multiply a_pos by 0.5, since we had it * 2 in order to sneak
|
||||
// in extrusion data
|
||||
vec4 pos = vec4(floor(a_pos * 0.5) + extrude, 0, 1);
|
||||
|
||||
gl_Position = u_matrix * pos;
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(in vec2 v_extrude;
|
||||
|
||||
layout (std140) uniform HeatmapEvaluatedPropsUBO {
|
||||
highp float u_weight;
|
||||
highp float u_radius;
|
||||
highp float u_intensity;
|
||||
lowp float props_pad1;
|
||||
};
|
||||
|
||||
#ifndef HAS_UNIFORM_u_weight
|
||||
in highp float weight;
|
||||
#endif
|
||||
|
||||
// Gaussian kernel coefficient: 1 / sqrt(2 * PI)
|
||||
#define GAUSS_COEF 0.3989422804014327
|
||||
|
||||
void main() {
|
||||
#ifdef HAS_UNIFORM_u_weight
|
||||
highp float weight = u_weight;
|
||||
#endif
|
||||
|
||||
// Kernel density estimation with a Gaussian kernel of size 5x5
|
||||
float d = -0.5 * 3.0 * 3.0 * dot(v_extrude, v_extrude);
|
||||
float val = weight * u_intensity * GAUSS_COEF * exp(d);
|
||||
|
||||
fragColor = vec4(val, 1.0, 1.0, 1.0);
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
fragColor = vec4(1.0);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -1,66 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::HeatmapTextureShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "HeatmapTextureShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
out vec2 v_pos;
|
||||
|
||||
layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform HeatmapTexturePropsUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp float u_opacity;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
lowp float props_pad3;
|
||||
};
|
||||
|
||||
void main() {
|
||||
gl_Position = u_matrix * vec4(a_pos * u_world_size, 0, 1);
|
||||
|
||||
v_pos.x = a_pos.x;
|
||||
v_pos.y = 1.0 - a_pos.y;
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(in vec2 v_pos;
|
||||
uniform sampler2D u_image;
|
||||
uniform sampler2D u_color_ramp;
|
||||
|
||||
layout (std140) uniform HeatmapTexturePropsUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp float u_opacity;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
lowp float props_pad3;
|
||||
};
|
||||
|
||||
void main() {
|
||||
float t = texture(u_image, v_pos).r;
|
||||
vec4 color = texture(u_color_ramp, vec2(t, 0.5));
|
||||
fragColor = color * u_opacity;
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
fragColor = vec4(0.0);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -1,86 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::HillshadeShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "HillshadeShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
layout (location = 1) in vec2 a_texture_pos;
|
||||
|
||||
layout (std140) uniform HillshadeDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
};
|
||||
|
||||
out vec2 v_pos;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_matrix * vec4(a_pos, 0, 1);
|
||||
v_pos = a_texture_pos / 8192.0;
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(in vec2 v_pos;
|
||||
uniform sampler2D u_image;
|
||||
|
||||
layout (std140) uniform HillshadeTilePropsUBO {
|
||||
highp vec2 u_latrange;
|
||||
highp vec2 u_light;
|
||||
};
|
||||
|
||||
layout (std140) uniform HillshadeEvaluatedPropsUBO {
|
||||
highp vec4 u_highlight;
|
||||
highp vec4 u_shadow;
|
||||
highp vec4 u_accent;
|
||||
};
|
||||
|
||||
#define PI 3.141592653589793
|
||||
|
||||
void main() {
|
||||
vec4 pixel = texture(u_image, v_pos);
|
||||
|
||||
vec2 deriv = ((pixel.rg * 2.0) - 1.0);
|
||||
|
||||
// We divide the slope by a scale factor based on the cosin of the pixel's approximate latitude
|
||||
// to account for mercator projection distortion. see #4807 for details
|
||||
float scaleFactor = cos(radians((u_latrange[0] - u_latrange[1]) * (1.0 - v_pos.y) + u_latrange[1]));
|
||||
// We also multiply the slope by an arbitrary z-factor of 1.25
|
||||
float slope = atan(1.25 * length(deriv) / scaleFactor);
|
||||
float aspect = deriv.x != 0.0 ? atan(deriv.y, -deriv.x) : PI / 2.0 * (deriv.y > 0.0 ? 1.0 : -1.0);
|
||||
|
||||
float intensity = u_light.x;
|
||||
// We add PI to make this property match the global light object, which adds PI/2 to the light's azimuthal
|
||||
// position property to account for 0deg corresponding to north/the top of the viewport in the style spec
|
||||
// and the original shader was written to accept (-illuminationDirection - 90) as the azimuthal.
|
||||
float azimuth = u_light.y + PI;
|
||||
|
||||
// We scale the slope exponentially based on intensity, using a calculation similar to
|
||||
// the exponential interpolation function in the style spec:
|
||||
// https://github.com/mapbox/mapbox-gl-js/blob/master/src/style-spec/expression/definitions/interpolate.js#L217-L228
|
||||
// so that higher intensity values create more opaque hillshading.
|
||||
float base = 1.875 - intensity * 1.75;
|
||||
float maxValue = 0.5 * PI;
|
||||
float scaledSlope = intensity != 0.5 ? ((pow(base, slope) - 1.0) / (pow(base, maxValue) - 1.0)) * maxValue : slope;
|
||||
|
||||
// The accent color is calculated with the cosine of the slope while the shade color is calculated with the sine
|
||||
// so that the accent color's rate of change eases in while the shade color's eases out.
|
||||
float accent = cos(scaledSlope);
|
||||
// We multiply both the accent and shade color by a clamped intensity value
|
||||
// so that intensities >= 0.5 do not additionally affect the color values
|
||||
// while intensity values < 0.5 make the overall color more transparent.
|
||||
vec4 accent_color = (1.0 - accent) * u_accent * clamp(intensity * 2.0, 0.0, 1.0);
|
||||
float shade = abs(mod((aspect + azimuth) / PI + 0.5, 2.0) - 1.0);
|
||||
vec4 shade_color = mix(u_shadow, u_highlight, shade) * sin(scaledSlope) * clamp(intensity * 2.0, 0.0, 1.0);
|
||||
fragColor = accent_color * (1.0 - shade_color.a) + shade_color;
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
fragColor = vec4(1.0);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -1,116 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::HillshadePrepareShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "HillshadePrepareShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
layout (location = 1) in vec2 a_texture_pos;
|
||||
|
||||
layout (std140) uniform HillshadePrepareDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
};
|
||||
|
||||
layout (std140) uniform HillshadePrepareTilePropsUBO {
|
||||
highp vec4 u_unpack;
|
||||
highp vec2 u_dimension;
|
||||
highp float u_zoom;
|
||||
highp float u_maxzoom;
|
||||
};
|
||||
|
||||
out vec2 v_pos;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_matrix * vec4(a_pos, 0, 1);
|
||||
|
||||
highp vec2 epsilon = 1.0 / u_dimension;
|
||||
float scale = (u_dimension.x - 2.0) / u_dimension.x;
|
||||
v_pos = (a_texture_pos / 8192.0) * scale + epsilon;
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(#ifdef GL_ES
|
||||
precision highp float;
|
||||
#endif
|
||||
|
||||
in vec2 v_pos;
|
||||
uniform sampler2D u_image;
|
||||
|
||||
layout (std140) uniform HillshadePrepareTilePropsUBO {
|
||||
highp vec4 u_unpack;
|
||||
highp vec2 u_dimension;
|
||||
highp float u_zoom;
|
||||
highp float u_maxzoom;
|
||||
};
|
||||
|
||||
float getElevation(vec2 coord, float bias) {
|
||||
// Convert encoded elevation value to meters
|
||||
vec4 data = texture(u_image, coord) * 255.0;
|
||||
data.a = -1.0;
|
||||
return dot(data, u_unpack) / 4.0;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 epsilon = 1.0 / u_dimension;
|
||||
|
||||
// queried pixels:
|
||||
// +-----------+
|
||||
// | | | |
|
||||
// | a | b | c |
|
||||
// | | | |
|
||||
// +-----------+
|
||||
// | | | |
|
||||
// | d | e | f |
|
||||
// | | | |
|
||||
// +-----------+
|
||||
// | | | |
|
||||
// | g | h | i |
|
||||
// | | | |
|
||||
// +-----------+
|
||||
|
||||
float a = getElevation(v_pos + vec2(-epsilon.x, -epsilon.y), 0.0);
|
||||
float b = getElevation(v_pos + vec2(0, -epsilon.y), 0.0);
|
||||
float c = getElevation(v_pos + vec2(epsilon.x, -epsilon.y), 0.0);
|
||||
float d = getElevation(v_pos + vec2(-epsilon.x, 0), 0.0);
|
||||
//float e = getElevation(v_pos, 0.0);
|
||||
float f = getElevation(v_pos + vec2(epsilon.x, 0), 0.0);
|
||||
float g = getElevation(v_pos + vec2(-epsilon.x, epsilon.y), 0.0);
|
||||
float h = getElevation(v_pos + vec2(0, epsilon.y), 0.0);
|
||||
float i = getElevation(v_pos + vec2(epsilon.x, epsilon.y), 0.0);
|
||||
|
||||
// here we divide the x and y slopes by 8 * pixel size
|
||||
// where pixel size (aka meters/pixel) is:
|
||||
// circumference of the world / (pixels per tile * number of tiles)
|
||||
// which is equivalent to: 8 * 40075016.6855785 / (512 * pow(2, u_zoom))
|
||||
// which can be reduced to: pow(2, 19.25619978527 - u_zoom)
|
||||
// we want to vertically exaggerate the hillshading though, because otherwise
|
||||
// it is barely noticeable at low zooms. to do this, we multiply this by some
|
||||
// scale factor pow(2, (u_zoom - u_maxzoom) * a) where a is an arbitrary value
|
||||
// Here we use a=0.3 which works out to the expression below. see
|
||||
// nickidlugash's awesome breakdown for more info
|
||||
// https://github.com/mapbox/mapbox-gl-js/pull/5286#discussion_r148419556
|
||||
float exaggeration = u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;
|
||||
|
||||
vec2 deriv = vec2(
|
||||
(c + f + f + i) - (a + d + d + g),
|
||||
(g + h + h + i) - (a + b + b + c)
|
||||
) / pow(2.0, (u_zoom - u_maxzoom) * exaggeration + 19.2562 - u_zoom);
|
||||
|
||||
fragColor = clamp(vec4(
|
||||
deriv.x / 2.0 + 0.5,
|
||||
deriv.y / 2.0 + 0.5,
|
||||
1.0,
|
||||
1.0), 0.0, 1.0);
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
fragColor = vec4(1.0);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -1,224 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::LineShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "LineShader";
|
||||
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
|
||||
// stored in a byte (-128..127). we scale regular normals up to length 63, but
|
||||
// there are also "special" normals that have a bigger length (of up to 126 in
|
||||
// this case).
|
||||
// #define scale 63.0
|
||||
#define scale 0.015873016
|
||||
|
||||
layout (location = 0) in vec2 a_pos_normal;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
|
||||
layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
mediump float u_ratio;
|
||||
// Interpolations
|
||||
lowp float u_color_t;
|
||||
lowp float u_blur_t;
|
||||
lowp float u_opacity_t;
|
||||
lowp float u_gapwidth_t;
|
||||
lowp float u_offset_t;
|
||||
lowp float u_width_t;
|
||||
lowp float drawable_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
lowp float u_blur;
|
||||
lowp float u_opacity;
|
||||
mediump float u_gapwidth;
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
lowp float u_floorwidth;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
out vec2 v_normal;
|
||||
out vec2 v_width2;
|
||||
out float v_gamma_scale;
|
||||
out highp float v_linesofar;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_color
|
||||
layout (location = 2) in highp vec4 a_color;
|
||||
out highp vec4 color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
layout (location = 3) in lowp vec2 a_blur;
|
||||
out lowp float blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
layout (location = 4) in lowp vec2 a_opacity;
|
||||
out lowp float opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_gapwidth
|
||||
layout (location = 5) in mediump vec2 a_gapwidth;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_offset
|
||||
layout (location = 6) in lowp vec2 a_offset;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_width
|
||||
layout (location = 7) in mediump vec2 a_width;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef HAS_UNIFORM_u_color
|
||||
color = unpack_mix_color(a_color, u_color_t);
|
||||
#else
|
||||
highp vec4 color = u_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
blur = unpack_mix_vec2(a_blur, u_blur_t);
|
||||
#else
|
||||
lowp float blur = u_blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
opacity = unpack_mix_vec2(a_opacity, u_opacity_t);
|
||||
#else
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_gapwidth
|
||||
mediump float gapwidth = unpack_mix_vec2(a_gapwidth, u_gapwidth_t);
|
||||
#else
|
||||
mediump float gapwidth = u_gapwidth;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_offset
|
||||
lowp float offset = unpack_mix_vec2(a_offset, u_offset_t);
|
||||
#else
|
||||
lowp float offset = u_offset;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_width
|
||||
mediump float width = unpack_mix_vec2(a_width, u_width_t);
|
||||
#else
|
||||
mediump float width = u_width;
|
||||
#endif
|
||||
|
||||
// the distance over which the line edge fades out.
|
||||
// Retina devices need a smaller distance to avoid aliasing.
|
||||
float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0;
|
||||
|
||||
vec2 a_extrude = a_data.xy - 128.0;
|
||||
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
||||
|
||||
v_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * 2.0;
|
||||
|
||||
vec2 pos = floor(a_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
|
||||
mediump vec2 normal = a_pos_normal - 2.0 * pos;
|
||||
normal.y = normal.y * 2.0 - 1.0;
|
||||
v_normal = normal;
|
||||
|
||||
// these transformations used to be applied in the JS and native code bases.
|
||||
// moved them into the shader for clarity and simplicity.
|
||||
gapwidth = gapwidth / 2.0;
|
||||
float halfwidth = width / 2.0;
|
||||
offset = -1.0 * offset;
|
||||
|
||||
float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);
|
||||
float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING);
|
||||
|
||||
// Scale the extrusion vector down to a normal and then up by the line width
|
||||
// of this vertex.
|
||||
mediump vec2 dist = outset * a_extrude * scale;
|
||||
|
||||
// Calculate the offset when drawing a line that is to the side of the actual line.
|
||||
// We do this by creating a vector that points towards the extrude, but rotate
|
||||
// it when we're drawing round end points (a_direction = -1 or 1) since their
|
||||
// extrude vector points in another direction.
|
||||
mediump float u = 0.5 * a_direction;
|
||||
mediump float t = 1.0 - abs(u);
|
||||
mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);
|
||||
|
||||
vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);
|
||||
gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;
|
||||
|
||||
// calculate how much the perspective view squishes or stretches the extrude
|
||||
float extrude_length_without_perspective = length(dist);
|
||||
float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_units_to_pixels);
|
||||
v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;
|
||||
|
||||
v_width2 = vec2(outset, inset);
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform LineEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
lowp float u_blur;
|
||||
lowp float u_opacity;
|
||||
mediump float u_gapwidth;
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
lowp float u_floorwidth;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
in vec2 v_width2;
|
||||
in vec2 v_normal;
|
||||
in float v_gamma_scale;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_color
|
||||
in highp vec4 color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
in lowp float blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
in lowp float opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifdef HAS_UNIFORM_u_color
|
||||
highp vec4 color = u_color;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_blur
|
||||
lowp float blur = u_blur;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_opacity
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
|
||||
// Calculate the distance of the pixel from the line in pixels.
|
||||
float dist = length(v_normal) * v_width2.s;
|
||||
|
||||
// Calculate the antialiasing fade factor. This is either when fading in
|
||||
// the line in case of an offset line (v_width2.t) or when fading out
|
||||
// (v_width2.s)
|
||||
float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;
|
||||
float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);
|
||||
|
||||
fragColor = color * (alpha * opacity);
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
fragColor = vec4(1.0);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -1,220 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::LineGradientShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "LineGradientShader";
|
||||
static constexpr const char* vertex = R"(
|
||||
// the attribute conveying progress along a line is scaled to [0, 2^15)
|
||||
#define MAX_LINE_DISTANCE 32767.0
|
||||
|
||||
// floor(127 / 2) == 63.0
|
||||
// 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
|
||||
// there are also "special" normals that have a bigger length (of up to 126 in
|
||||
// this case).
|
||||
// #define scale 63.0
|
||||
#define scale 0.015873016
|
||||
|
||||
layout (location = 0) in vec2 a_pos_normal;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
|
||||
layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineGradientDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
mediump float u_ratio;
|
||||
// Interpolations
|
||||
lowp float u_blur_t;
|
||||
lowp float u_opacity_t;
|
||||
lowp float u_gapwidth_t;
|
||||
lowp float u_offset_t;
|
||||
lowp float u_width_t;
|
||||
lowp float drawable_pad1;
|
||||
lowp float drawable_pad2;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
lowp float u_blur;
|
||||
lowp float u_opacity;
|
||||
mediump float u_gapwidth;
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
lowp float u_floorwidth;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
out vec2 v_normal;
|
||||
out vec2 v_width2;
|
||||
out float v_gamma_scale;
|
||||
out highp float v_lineprogress;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
layout (location = 2) in lowp vec2 a_blur;
|
||||
out lowp float blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
layout (location = 3) in lowp vec2 a_opacity;
|
||||
out lowp float opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_gapwidth
|
||||
layout (location = 4) in mediump vec2 a_gapwidth;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_offset
|
||||
layout (location = 5) in lowp vec2 a_offset;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_width
|
||||
layout (location = 6) in mediump vec2 a_width;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
blur = unpack_mix_vec2(a_blur, u_blur_t);
|
||||
#else
|
||||
lowp float blur = u_blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
opacity = unpack_mix_vec2(a_opacity, u_opacity_t);
|
||||
#else
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_gapwidth
|
||||
mediump float gapwidth = unpack_mix_vec2(a_gapwidth, u_gapwidth_t);
|
||||
#else
|
||||
mediump float gapwidth = u_gapwidth;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_offset
|
||||
lowp float offset = unpack_mix_vec2(a_offset, u_offset_t);
|
||||
#else
|
||||
lowp float offset = u_offset;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_width
|
||||
mediump float width = unpack_mix_vec2(a_width, u_width_t);
|
||||
#else
|
||||
mediump float width = u_width;
|
||||
#endif
|
||||
|
||||
// the distance over which the line edge fades out.
|
||||
// Retina devices need a smaller distance to avoid aliasing.
|
||||
float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0;
|
||||
|
||||
vec2 a_extrude = a_data.xy - 128.0;
|
||||
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
||||
|
||||
v_lineprogress = (floor(a_data.z / 4.0) + a_data.w * 64.0) * 2.0 / MAX_LINE_DISTANCE;
|
||||
|
||||
vec2 pos = floor(a_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
|
||||
mediump vec2 normal = a_pos_normal - 2.0 * pos;
|
||||
normal.y = normal.y * 2.0 - 1.0;
|
||||
v_normal = normal;
|
||||
|
||||
// these transformations used to be applied in the JS and native code bases.
|
||||
// moved them into the shader for clarity and simplicity.
|
||||
gapwidth = gapwidth / 2.0;
|
||||
float halfwidth = width / 2.0;
|
||||
offset = -1.0 * offset;
|
||||
|
||||
float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);
|
||||
float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING);
|
||||
|
||||
// Scale the extrusion vector down to a normal and then up by the line width
|
||||
// of this vertex.
|
||||
mediump vec2 dist = outset * a_extrude * scale;
|
||||
|
||||
// Calculate the offset when drawing a line that is to the side of the actual line.
|
||||
// We do this by creating a vector that points towards the extrude, but rotate
|
||||
// it when we're drawing round end points (a_direction = -1 or 1) since their
|
||||
// extrude vector points in another direction.
|
||||
mediump float u = 0.5 * a_direction;
|
||||
mediump float t = 1.0 - abs(u);
|
||||
mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);
|
||||
|
||||
vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);
|
||||
gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;
|
||||
|
||||
// calculate how much the perspective view squishes or stretches the extrude
|
||||
float extrude_length_without_perspective = length(dist);
|
||||
float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_units_to_pixels);
|
||||
v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;
|
||||
|
||||
v_width2 = vec2(outset, inset);
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform LineEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
lowp float u_blur;
|
||||
lowp float u_opacity;
|
||||
mediump float u_gapwidth;
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
lowp float u_floorwidth;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
uniform sampler2D u_image;
|
||||
|
||||
in vec2 v_width2;
|
||||
in vec2 v_normal;
|
||||
in float v_gamma_scale;
|
||||
in highp float v_lineprogress;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
in lowp float blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
in lowp float opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifdef HAS_UNIFORM_u_blur
|
||||
lowp float blur = u_blur;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_opacity
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
|
||||
// Calculate the distance of the pixel from the line in pixels.
|
||||
float dist = length(v_normal) * v_width2.s;
|
||||
|
||||
// Calculate the antialiasing fade factor. This is either when fading in
|
||||
// the line in case of an offset line (v_width2.t) or when fading out
|
||||
// (v_width2.s)
|
||||
float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;
|
||||
float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);
|
||||
|
||||
// For gradient lines, v_lineprogress is the ratio along the entire line,
|
||||
// scaled to [0, 2^15), and the gradient ramp is stored in a texture.
|
||||
vec4 color = texture(u_image, vec2(v_lineprogress, 0.5));
|
||||
|
||||
fragColor = color * (alpha * opacity);
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
fragColor = vec4(1.0);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -1,295 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::LinePatternShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "LinePatternShader";
|
||||
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
|
||||
// stored in a byte (-128..127). we scale regular normals up to length 63, but
|
||||
// there are also "special" normals that have a bigger length (of up to 126 in
|
||||
// this case).
|
||||
// #define scale 63.0
|
||||
#define scale 0.015873016
|
||||
|
||||
// We scale the distance before adding it to the buffers so that we can store
|
||||
// long distances for long segments. Use this value to unscale the distance.
|
||||
#define LINE_DISTANCE_SCALE 2.0
|
||||
|
||||
layout (location = 0) in vec2 a_pos_normal;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
|
||||
layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
layout (std140) uniform LinePatternDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
mediump float u_ratio;
|
||||
// Interpolations
|
||||
lowp float u_blur_t;
|
||||
lowp float u_opacity_t;
|
||||
lowp float u_offset_t;
|
||||
lowp float u_gapwidth_t;
|
||||
lowp float u_width_t;
|
||||
lowp float u_pattern_from_t;
|
||||
lowp float u_pattern_to_t;
|
||||
};
|
||||
|
||||
layout (std140) uniform LinePatternTilePropsUBO {
|
||||
lowp vec4 u_pattern_from;
|
||||
lowp vec4 u_pattern_to;
|
||||
mediump vec4 u_scale;
|
||||
highp vec2 u_texsize;
|
||||
highp float u_fade;
|
||||
lowp float tileprops_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
lowp float u_blur;
|
||||
lowp float u_opacity;
|
||||
mediump float u_gapwidth;
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
lowp float u_floorwidth;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
out vec2 v_normal;
|
||||
out vec2 v_width2;
|
||||
out float v_linesofar;
|
||||
out float v_gamma_scale;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
layout (location = 2) in lowp vec2 a_blur;
|
||||
out lowp float blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
layout (location = 3) in lowp vec2 a_opacity;
|
||||
out lowp float opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_offset
|
||||
layout (location = 4) in lowp vec2 a_offset;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_gapwidth
|
||||
layout (location = 5) in mediump vec2 a_gapwidth;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_width
|
||||
layout (location = 6) in mediump vec2 a_width;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_from
|
||||
layout (location = 7) in lowp vec4 a_pattern_from;
|
||||
out lowp vec4 pattern_from;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_to
|
||||
layout (location = 8) in lowp vec4 a_pattern_to;
|
||||
out lowp vec4 pattern_to;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
blur = unpack_mix_vec2(a_blur, u_blur_t);
|
||||
#else
|
||||
lowp float blur = u_blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
opacity = unpack_mix_vec2(a_opacity, u_opacity_t);
|
||||
#else
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_offset
|
||||
lowp float offset = unpack_mix_vec2(a_offset, u_offset_t);
|
||||
#else
|
||||
lowp float offset = u_offset;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_gapwidth
|
||||
mediump float gapwidth = unpack_mix_vec2(a_gapwidth, u_gapwidth_t);
|
||||
#else
|
||||
mediump float gapwidth = u_gapwidth;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_width
|
||||
mediump float width = unpack_mix_vec2(a_width, u_width_t);
|
||||
#else
|
||||
mediump float width = u_width;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_from
|
||||
pattern_from = a_pattern_from;
|
||||
#else
|
||||
mediump vec4 pattern_from = u_pattern_from;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_to
|
||||
pattern_to = a_pattern_to;
|
||||
#else
|
||||
mediump vec4 pattern_to = u_pattern_to;
|
||||
#endif
|
||||
|
||||
// the distance over which the line edge fades out.
|
||||
// Retina devices need a smaller distance to avoid aliasing.
|
||||
float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0;
|
||||
|
||||
vec2 a_extrude = a_data.xy - 128.0;
|
||||
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
||||
float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE;
|
||||
// float tileRatio = u_scale.y;
|
||||
vec2 pos = floor(a_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
|
||||
mediump vec2 normal = a_pos_normal - 2.0 * pos;
|
||||
normal.y = normal.y * 2.0 - 1.0;
|
||||
v_normal = normal;
|
||||
|
||||
// these transformations used to be applied in the JS and native code bases.
|
||||
// moved them into the shader for clarity and simplicity.
|
||||
gapwidth = gapwidth / 2.0;
|
||||
float halfwidth = width / 2.0;
|
||||
offset = -1.0 * offset;
|
||||
|
||||
float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);
|
||||
float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING);
|
||||
|
||||
// Scale the extrusion vector down to a normal and then up by the line width
|
||||
// of this vertex.
|
||||
mediump vec2 dist = outset * a_extrude * scale;
|
||||
|
||||
// Calculate the offset when drawing a line that is to the side of the actual line.
|
||||
// We do this by creating a vector that points towards the extrude, but rotate
|
||||
// it when we're drawing round end points (a_direction = -1 or 1) since their
|
||||
// extrude vector points in another direction.
|
||||
mediump float u = 0.5 * a_direction;
|
||||
mediump float t = 1.0 - abs(u);
|
||||
mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);
|
||||
|
||||
vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);
|
||||
gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;
|
||||
|
||||
// calculate how much the perspective view squishes or stretches the extrude
|
||||
float extrude_length_without_perspective = length(dist);
|
||||
float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_units_to_pixels);
|
||||
v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;
|
||||
|
||||
v_linesofar = a_linesofar;
|
||||
v_width2 = vec2(outset, inset);
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform LinePatternTilePropsUBO {
|
||||
lowp vec4 u_pattern_from;
|
||||
lowp vec4 u_pattern_to;
|
||||
mediump vec4 u_scale;
|
||||
highp vec2 u_texsize;
|
||||
highp float u_fade;
|
||||
lowp float tileprops_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
lowp float u_blur;
|
||||
lowp float u_opacity;
|
||||
mediump float u_gapwidth;
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
lowp float u_floorwidth;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
uniform sampler2D u_image;
|
||||
|
||||
in vec2 v_normal;
|
||||
in vec2 v_width2;
|
||||
in float v_linesofar;
|
||||
in float v_gamma_scale;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_pattern_from
|
||||
in lowp vec4 pattern_from;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_to
|
||||
in lowp vec4 pattern_to;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
in lowp float blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
in lowp float opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifdef HAS_UNIFORM_u_pattern_from
|
||||
mediump vec4 pattern_from = u_pattern_from;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_pattern_to
|
||||
mediump vec4 pattern_to = u_pattern_to;
|
||||
#endif
|
||||
|
||||
#ifdef HAS_UNIFORM_u_blur
|
||||
lowp float blur = u_blur;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_opacity
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
|
||||
vec2 pattern_tl_a = pattern_from.xy;
|
||||
vec2 pattern_br_a = pattern_from.zw;
|
||||
vec2 pattern_tl_b = pattern_to.xy;
|
||||
vec2 pattern_br_b = pattern_to.zw;
|
||||
|
||||
float pixelRatio = u_scale.x;
|
||||
float tileZoomRatio = u_scale.y;
|
||||
float fromScale = u_scale.z;
|
||||
float toScale = u_scale.w;
|
||||
|
||||
vec2 display_size_a = vec2((pattern_br_a.x - pattern_tl_a.x) / pixelRatio, (pattern_br_a.y - pattern_tl_a.y) / pixelRatio);
|
||||
vec2 display_size_b = vec2((pattern_br_b.x - pattern_tl_b.x) / pixelRatio, (pattern_br_b.y - pattern_tl_b.y) / pixelRatio);
|
||||
|
||||
vec2 pattern_size_a = vec2(display_size_a.x * fromScale / tileZoomRatio, display_size_a.y);
|
||||
vec2 pattern_size_b = vec2(display_size_b.x * toScale / tileZoomRatio, display_size_b.y);
|
||||
|
||||
// Calculate the distance of the pixel from the line in pixels.
|
||||
float dist = length(v_normal) * v_width2.s;
|
||||
|
||||
// Calculate the antialiasing fade factor. This is either when fading in
|
||||
// the line in case of an offset line (v_width2.t) or when fading out
|
||||
// (v_width2.s)
|
||||
float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;
|
||||
float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);
|
||||
|
||||
float x_a = mod(v_linesofar / pattern_size_a.x, 1.0);
|
||||
float x_b = mod(v_linesofar / pattern_size_b.x, 1.0);
|
||||
|
||||
// v_normal.y is 0 at the midpoint of the line, -1 at the lower edge, 1 at the upper edge
|
||||
// we clamp the line width outset to be between 0 and half the pattern height plus padding (2.0)
|
||||
// to ensure we don't sample outside the designated symbol on the sprite sheet.
|
||||
// 0.5 is added to shift the component to be bounded between 0 and 1 for interpolation of
|
||||
// the texture coordinate
|
||||
float y_a = 0.5 + (v_normal.y * clamp(v_width2.s, 0.0, (pattern_size_a.y + 2.0) / 2.0) / pattern_size_a.y);
|
||||
float y_b = 0.5 + (v_normal.y * clamp(v_width2.s, 0.0, (pattern_size_b.y + 2.0) / 2.0) / pattern_size_b.y);
|
||||
vec2 pos_a = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, vec2(x_a, y_a));
|
||||
vec2 pos_b = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, vec2(x_b, y_b));
|
||||
|
||||
vec4 color = mix(texture(u_image, pos_a), texture(u_image, pos_b), u_fade);
|
||||
|
||||
fragColor = color * alpha * opacity;
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
fragColor = vec4(1.0);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -1,275 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::LineSDFShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "LineSDFShader";
|
||||
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
|
||||
// stored in a byte (-128..127). we scale regular normals up to length 63, but
|
||||
// there are also "special" normals that have a bigger length (of up to 126 in
|
||||
// this case).
|
||||
// #define scale 63.0
|
||||
#define scale 0.015873016
|
||||
|
||||
// We scale the distance before adding it to the buffers so that we can store
|
||||
// long distances for long segments. Use this value to unscale the distance.
|
||||
#define LINE_DISTANCE_SCALE 2.0
|
||||
|
||||
layout (location = 0) in vec2 a_pos_normal;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
|
||||
layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineSDFDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_patternscale_a;
|
||||
highp vec2 u_patternscale_b;
|
||||
highp float u_tex_y_a;
|
||||
highp float u_tex_y_b;
|
||||
mediump float u_ratio;
|
||||
// Interpolations
|
||||
lowp float u_color_t;
|
||||
lowp float u_blur_t;
|
||||
lowp float u_opacity_t;
|
||||
lowp float u_gapwidth_t;
|
||||
lowp float u_offset_t;
|
||||
lowp float u_width_t;
|
||||
lowp float u_floorwidth_t;
|
||||
lowp float drawable_pad1;
|
||||
lowp float drawable_pad2;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
lowp float u_blur;
|
||||
lowp float u_opacity;
|
||||
mediump float u_gapwidth;
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
lowp float u_floorwidth;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
out vec2 v_normal;
|
||||
out vec2 v_width2;
|
||||
out vec2 v_tex_a;
|
||||
out vec2 v_tex_b;
|
||||
out float v_gamma_scale;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_color
|
||||
layout (location = 2) in highp vec4 a_color;
|
||||
out highp vec4 color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
layout (location = 3) in lowp vec2 a_blur;
|
||||
out lowp float blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
layout (location = 4) in lowp vec2 a_opacity;
|
||||
out lowp float opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_gapwidth
|
||||
layout (location = 5) in mediump vec2 a_gapwidth;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_offset
|
||||
layout (location = 6) in lowp vec2 a_offset;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_width
|
||||
layout (location = 7) in mediump vec2 a_width;
|
||||
out mediump float width;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_floorwidth
|
||||
layout (location = 8) in lowp vec2 a_floorwidth;
|
||||
out lowp float floorwidth;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef HAS_UNIFORM_u_color
|
||||
color = unpack_mix_color(a_color, u_color_t);
|
||||
#else
|
||||
highp vec4 color = u_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
blur = unpack_mix_vec2(a_blur, u_blur_t);
|
||||
#else
|
||||
lowp float blur = u_blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
opacity = unpack_mix_vec2(a_opacity, u_opacity_t);
|
||||
#else
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_gapwidth
|
||||
mediump float gapwidth = unpack_mix_vec2(a_gapwidth, u_gapwidth_t);
|
||||
#else
|
||||
mediump float gapwidth = u_gapwidth;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_offset
|
||||
lowp float offset = unpack_mix_vec2(a_offset, u_offset_t);
|
||||
#else
|
||||
lowp float offset = u_offset;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_width
|
||||
width = unpack_mix_vec2(a_width, u_width_t);
|
||||
#else
|
||||
mediump float width = u_width;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_floorwidth
|
||||
floorwidth = unpack_mix_vec2(a_floorwidth, u_floorwidth_t);
|
||||
#else
|
||||
lowp float floorwidth = u_floorwidth;
|
||||
#endif
|
||||
|
||||
// the distance over which the line edge fades out.
|
||||
// Retina devices need a smaller distance to avoid aliasing.
|
||||
float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0;
|
||||
|
||||
vec2 a_extrude = a_data.xy - 128.0;
|
||||
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
||||
float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE;
|
||||
|
||||
vec2 pos = floor(a_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
|
||||
mediump vec2 normal = a_pos_normal - 2.0 * pos;
|
||||
normal.y = normal.y * 2.0 - 1.0;
|
||||
v_normal = normal;
|
||||
|
||||
// these transformations used to be applied in the JS and native code bases.
|
||||
// moved them into the shader for clarity and simplicity.
|
||||
gapwidth = gapwidth / 2.0;
|
||||
float halfwidth = width / 2.0;
|
||||
offset = -1.0 * offset;
|
||||
|
||||
float inset = gapwidth + (gapwidth > 0.0 ? ANTIALIASING : 0.0);
|
||||
float outset = gapwidth + halfwidth * (gapwidth > 0.0 ? 2.0 : 1.0) + (halfwidth == 0.0 ? 0.0 : ANTIALIASING);
|
||||
|
||||
// Scale the extrusion vector down to a normal and then up by the line width
|
||||
// of this vertex.
|
||||
mediump vec2 dist =outset * a_extrude * scale;
|
||||
|
||||
// Calculate the offset when drawing a line that is to the side of the actual line.
|
||||
// We do this by creating a vector that points towards the extrude, but rotate
|
||||
// it when we're drawing round end points (a_direction = -1 or 1) since their
|
||||
// extrude vector points in another direction.
|
||||
mediump float u = 0.5 * a_direction;
|
||||
mediump float t = 1.0 - abs(u);
|
||||
mediump vec2 offset2 = offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);
|
||||
|
||||
vec4 projected_extrude = u_matrix * vec4(dist / u_ratio, 0.0, 0.0);
|
||||
gl_Position = u_matrix * vec4(pos + offset2 / u_ratio, 0.0, 1.0) + projected_extrude;
|
||||
|
||||
// calculate how much the perspective view squishes or stretches the extrude
|
||||
float extrude_length_without_perspective = length(dist);
|
||||
float extrude_length_with_perspective = length(projected_extrude.xy / gl_Position.w * u_units_to_pixels);
|
||||
v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective;
|
||||
|
||||
v_tex_a = vec2(a_linesofar * u_patternscale_a.x / floorwidth, normal.y * u_patternscale_a.y + u_tex_y_a);
|
||||
v_tex_b = vec2(a_linesofar * u_patternscale_b.x / floorwidth, normal.y * u_patternscale_b.y + u_tex_y_b);
|
||||
|
||||
v_width2 = vec2(outset, inset);
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform LineSDFTilePropsUBO {
|
||||
highp float u_sdfgamma;
|
||||
highp float u_mix;
|
||||
lowp float tileprops_pad1;
|
||||
lowp float tileprops_pad2;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
lowp float u_blur;
|
||||
lowp float u_opacity;
|
||||
mediump float u_gapwidth;
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
lowp float u_floorwidth;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
uniform sampler2D u_image;
|
||||
|
||||
in vec2 v_normal;
|
||||
in vec2 v_width2;
|
||||
in vec2 v_tex_a;
|
||||
in vec2 v_tex_b;
|
||||
in float v_gamma_scale;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_color
|
||||
in highp vec4 color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
in lowp float blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
in lowp float opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_width
|
||||
in mediump float width;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_floorwidth
|
||||
in lowp float floorwidth;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifdef HAS_UNIFORM_u_color
|
||||
highp vec4 color = u_color;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_blur
|
||||
lowp float blur = u_blur;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_opacity
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_width
|
||||
mediump float width = u_width;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_floorwidth
|
||||
lowp float floorwidth = u_floorwidth;
|
||||
#endif
|
||||
|
||||
// Calculate the distance of the pixel from the line in pixels.
|
||||
float dist = length(v_normal) * v_width2.s;
|
||||
|
||||
// Calculate the antialiasing fade factor. This is either when fading in
|
||||
// the line in case of an offset line (v_width2.t) or when fading out
|
||||
// (v_width2.s)
|
||||
float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;
|
||||
float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);
|
||||
|
||||
float sdfdist_a = texture(u_image, v_tex_a).a;
|
||||
float sdfdist_b = texture(u_image, v_tex_b).a;
|
||||
float sdfdist = mix(sdfdist_a, sdfdist_b, u_mix);
|
||||
alpha *= smoothstep(0.5 - u_sdfgamma / floorwidth, 0.5 + u_sdfgamma / floorwidth, sdfdist);
|
||||
|
||||
fragColor = color * (alpha * opacity);
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
fragColor = vec4(1.0);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -1,108 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::RasterShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "RasterShader";
|
||||
static constexpr const char* vertex = R"(layout (std140) uniform RasterDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
};
|
||||
layout (std140) uniform RasterEvaluatedPropsUBO {
|
||||
highp vec3 u_spin_weights;
|
||||
highp vec2 u_tl_parent;
|
||||
highp float u_scale_parent;
|
||||
highp float u_buffer_scale;
|
||||
highp float u_fade_t;
|
||||
highp float u_opacity;
|
||||
highp float u_brightness_low;
|
||||
highp float u_brightness_high;
|
||||
highp float u_saturation_factor;
|
||||
highp float u_contrast_factor;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
layout (location = 1) in vec2 a_texture_pos;
|
||||
|
||||
out vec2 v_pos0;
|
||||
out vec2 v_pos1;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_matrix * vec4(a_pos, 0, 1);
|
||||
// We are using Int16 for texture position coordinates to give us enough precision for
|
||||
// fractional coordinates. We use 8192 to scale the texture coordinates in the buffer
|
||||
// as an arbitrarily high number to preserve adequate precision when rendering.
|
||||
// This is also the same value as the EXTENT we are using for our tile buffer pos coordinates,
|
||||
// so math for modifying either is consistent.
|
||||
v_pos0 = (((a_texture_pos / 8192.0) - 0.5) / u_buffer_scale ) + 0.5;
|
||||
v_pos1 = (v_pos0 * u_scale_parent) + u_tl_parent;
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform RasterEvaluatedPropsUBO {
|
||||
highp vec3 u_spin_weights;
|
||||
highp vec2 u_tl_parent;
|
||||
highp float u_scale_parent;
|
||||
highp float u_buffer_scale;
|
||||
highp float u_fade_t;
|
||||
highp float u_opacity;
|
||||
highp float u_brightness_low;
|
||||
highp float u_brightness_high;
|
||||
highp float u_saturation_factor;
|
||||
highp float u_contrast_factor;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
uniform sampler2D u_image0;
|
||||
uniform sampler2D u_image1;
|
||||
|
||||
in vec2 v_pos0;
|
||||
in vec2 v_pos1;
|
||||
|
||||
void main() {
|
||||
|
||||
// read and cross-fade colors from the main and parent tiles
|
||||
vec4 color0 = texture(u_image0, v_pos0);
|
||||
vec4 color1 = texture(u_image1, v_pos1);
|
||||
if (color0.a > 0.0) {
|
||||
color0.rgb = color0.rgb / color0.a;
|
||||
}
|
||||
if (color1.a > 0.0) {
|
||||
color1.rgb = color1.rgb / color1.a;
|
||||
}
|
||||
vec4 color = mix(color0, color1, u_fade_t);
|
||||
color.a *= u_opacity;
|
||||
vec3 rgb = color.rgb;
|
||||
|
||||
// spin
|
||||
rgb = vec3(
|
||||
dot(rgb, u_spin_weights.xyz),
|
||||
dot(rgb, u_spin_weights.zxy),
|
||||
dot(rgb, u_spin_weights.yzx));
|
||||
|
||||
// saturation
|
||||
float average = (color.r + color.g + color.b) / 3.0;
|
||||
rgb += (average - rgb) * u_saturation_factor;
|
||||
|
||||
// contrast
|
||||
rgb = (rgb - 0.5) * u_contrast_factor + 0.5;
|
||||
|
||||
// brightness
|
||||
vec3 u_high_vec = vec3(u_brightness_low, u_brightness_low, u_brightness_low);
|
||||
vec3 u_low_vec = vec3(u_brightness_high, u_brightness_high, u_brightness_high);
|
||||
|
||||
fragColor = vec4(mix(u_high_vec, u_low_vec, rgb) * color.a, color.a);
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
fragColor = vec4(1.0);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -1,195 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::SymbolIconShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "SymbolIconShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec4 a_pos_offset;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
layout (location = 2) in vec4 a_pixeloffset;
|
||||
layout (location = 3) in vec3 a_projected_pos;
|
||||
layout (location = 4) in float a_fade_opacity;
|
||||
|
||||
layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform SymbolDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp mat4 u_label_plane_matrix;
|
||||
highp mat4 u_coord_matrix;
|
||||
|
||||
highp vec2 u_texsize;
|
||||
highp vec2 u_texsize_icon;
|
||||
|
||||
bool u_is_text_prop;
|
||||
bool u_rotate_symbol;
|
||||
bool u_pitch_with_map;
|
||||
bool u_is_size_zoom_constant;
|
||||
bool u_is_size_feature_constant;
|
||||
|
||||
highp float u_size_t; // used to interpolate between zoom stops when size is a composite function
|
||||
highp float u_size; // used when size is both zoom and feature constant
|
||||
|
||||
// Interpolations
|
||||
highp float u_fill_color_t;
|
||||
highp float u_halo_color_t;
|
||||
highp float u_opacity_t;
|
||||
highp float u_halo_width_t;
|
||||
highp float u_halo_blur_t;
|
||||
};
|
||||
|
||||
layout (std140) uniform SymbolEvaluatedPropsUBO {
|
||||
highp vec4 u_text_fill_color;
|
||||
highp vec4 u_text_halo_color;
|
||||
highp float u_text_opacity;
|
||||
highp float u_text_halo_width;
|
||||
highp float u_text_halo_blur;
|
||||
lowp float props_pad1;
|
||||
highp vec4 u_icon_fill_color;
|
||||
highp vec4 u_icon_halo_color;
|
||||
highp float u_icon_opacity;
|
||||
highp float u_icon_halo_width;
|
||||
highp float u_icon_halo_blur;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
out vec2 v_tex;
|
||||
out float v_fade_opacity;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
layout (location = 5) in lowp vec2 a_opacity;
|
||||
out lowp float opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
highp float u_opacity = u_is_text_prop ? u_text_opacity : u_icon_opacity;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
opacity = unpack_mix_vec2(a_opacity, u_opacity_t);
|
||||
#else
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
|
||||
vec2 a_pos = a_pos_offset.xy;
|
||||
vec2 a_offset = a_pos_offset.zw;
|
||||
|
||||
vec2 a_tex = a_data.xy;
|
||||
vec2 a_size = a_data.zw;
|
||||
|
||||
float a_size_min = floor(a_size[0] * 0.5);
|
||||
vec2 a_pxoffset = a_pixeloffset.xy;
|
||||
vec2 a_minFontScale = a_pixeloffset.zw / 256.0;
|
||||
|
||||
highp float segment_angle = -a_projected_pos[2];
|
||||
float size;
|
||||
|
||||
if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {
|
||||
size = mix(a_size_min, a_size[1], u_size_t) / 128.0;
|
||||
} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {
|
||||
size = a_size_min / 128.0;
|
||||
} else {
|
||||
size = u_size;
|
||||
}
|
||||
|
||||
vec4 projectedPoint = u_matrix * vec4(a_pos, 0, 1);
|
||||
highp float camera_to_anchor_distance = projectedPoint.w;
|
||||
// See comments in symbol_sdf.vertex
|
||||
highp float distance_ratio = u_pitch_with_map ?
|
||||
camera_to_anchor_distance / u_camera_to_center_distance :
|
||||
u_camera_to_center_distance / camera_to_anchor_distance;
|
||||
highp float perspective_ratio = clamp(
|
||||
0.5 + 0.5 * distance_ratio,
|
||||
0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles
|
||||
4.0);
|
||||
|
||||
size *= perspective_ratio;
|
||||
|
||||
float fontScale = u_is_text_prop ? size / 24.0 : size;
|
||||
|
||||
highp float symbol_rotation = 0.0;
|
||||
if (u_rotate_symbol) {
|
||||
// See comments in symbol_sdf.vertex
|
||||
vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), 0, 1);
|
||||
|
||||
vec2 a = projectedPoint.xy / projectedPoint.w;
|
||||
vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w;
|
||||
|
||||
symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x);
|
||||
}
|
||||
|
||||
highp float angle_sin = sin(segment_angle + symbol_rotation);
|
||||
highp float angle_cos = cos(segment_angle + symbol_rotation);
|
||||
mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);
|
||||
|
||||
vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0);
|
||||
gl_Position = u_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * max(a_minFontScale, fontScale) + a_pxoffset / 16.0), 0.0, 1.0);
|
||||
|
||||
v_tex = a_tex / u_texsize;
|
||||
vec2 fade_opacity = unpack_opacity(a_fade_opacity);
|
||||
float fade_change = fade_opacity[1] > 0.5 ? u_symbol_fade_change : -u_symbol_fade_change;
|
||||
v_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change));
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(uniform sampler2D u_texture;
|
||||
|
||||
layout (std140) uniform SymbolTilePropsUBO {
|
||||
bool u_is_text;
|
||||
bool u_is_halo;
|
||||
highp float u_gamma_scale;
|
||||
lowp float tileprops_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform SymbolEvaluatedPropsUBO {
|
||||
highp vec4 u_text_fill_color;
|
||||
highp vec4 u_text_halo_color;
|
||||
highp float u_text_opacity;
|
||||
highp float u_text_halo_width;
|
||||
highp float u_text_halo_blur;
|
||||
lowp float props_pad1;
|
||||
highp vec4 u_icon_fill_color;
|
||||
highp vec4 u_icon_halo_color;
|
||||
highp float u_icon_opacity;
|
||||
highp float u_icon_halo_width;
|
||||
highp float u_icon_halo_blur;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
in vec2 v_tex;
|
||||
in float v_fade_opacity;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
in lowp float opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
highp float u_opacity = u_is_text ? u_text_opacity : u_icon_opacity;
|
||||
|
||||
#ifdef HAS_UNIFORM_u_opacity
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
|
||||
lowp float alpha = opacity * v_fade_opacity;
|
||||
fragColor = texture(u_texture, v_tex) * alpha;
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
fragColor = vec4(1.0);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -1,320 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::SymbolTextAndIconShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "SymbolTextAndIconShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec4 a_pos_offset;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
layout (location = 2) in vec3 a_projected_pos;
|
||||
layout (location = 3) in float a_fade_opacity;
|
||||
|
||||
// contents of a_size vary based on the type of property value
|
||||
// used for {text,icon}-size.
|
||||
// For constants, a_size is disabled.
|
||||
// For source functions, we bind only one value per vertex: the value of {text,icon}-size evaluated for the current feature.
|
||||
// For composite functions:
|
||||
// [ text-size(lowerZoomStop, feature),
|
||||
// text-size(upperZoomStop, feature) ]
|
||||
|
||||
layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform SymbolDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp mat4 u_label_plane_matrix;
|
||||
highp mat4 u_coord_matrix;
|
||||
|
||||
highp vec2 u_texsize;
|
||||
highp vec2 u_texsize_icon;
|
||||
|
||||
bool u_is_text_prop;
|
||||
bool u_rotate_symbol;
|
||||
bool u_pitch_with_map;
|
||||
bool u_is_size_zoom_constant;
|
||||
bool u_is_size_feature_constant;
|
||||
|
||||
highp float u_size_t; // used to interpolate between zoom stops when size is a composite function
|
||||
highp float u_size; // used when size is both zoom and feature constant
|
||||
|
||||
// Interpolations
|
||||
highp float u_fill_color_t;
|
||||
highp float u_halo_color_t;
|
||||
highp float u_opacity_t;
|
||||
highp float u_halo_width_t;
|
||||
highp float u_halo_blur_t;
|
||||
};
|
||||
|
||||
layout (std140) uniform SymbolEvaluatedPropsUBO {
|
||||
highp vec4 u_text_fill_color;
|
||||
highp vec4 u_text_halo_color;
|
||||
highp float u_text_opacity;
|
||||
highp float u_text_halo_width;
|
||||
highp float u_text_halo_blur;
|
||||
lowp float props_pad1;
|
||||
highp vec4 u_icon_fill_color;
|
||||
highp vec4 u_icon_halo_color;
|
||||
highp float u_icon_opacity;
|
||||
highp float u_icon_halo_width;
|
||||
highp float u_icon_halo_blur;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
out vec4 v_data0;
|
||||
out vec4 v_data1;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_fill_color
|
||||
layout (location = 4) in highp vec4 a_fill_color;
|
||||
out highp vec4 fill_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_color
|
||||
layout (location = 5) in highp vec4 a_halo_color;
|
||||
out highp vec4 halo_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
layout (location = 6) in lowp vec2 a_opacity;
|
||||
out lowp float opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_width
|
||||
layout (location = 7) in lowp vec2 a_halo_width;
|
||||
out lowp float halo_width;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_blur
|
||||
layout (location = 8) in lowp vec2 a_halo_blur;
|
||||
out lowp float halo_blur;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
highp vec4 u_fill_color = u_is_text_prop ? u_text_fill_color : u_icon_fill_color;
|
||||
highp vec4 u_halo_color = u_is_text_prop ? u_text_halo_color : u_icon_halo_color;
|
||||
highp float u_opacity = u_is_text_prop ? u_text_opacity : u_icon_opacity;
|
||||
highp float u_halo_width = u_is_text_prop ? u_text_halo_width : u_icon_halo_width;
|
||||
highp float u_halo_blur = u_is_text_prop ? u_text_halo_blur : u_icon_halo_blur;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_fill_color
|
||||
fill_color = unpack_mix_color(a_fill_color, u_fill_color_t);
|
||||
#else
|
||||
highp vec4 fill_color = u_fill_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_color
|
||||
halo_color = unpack_mix_color(a_halo_color, u_halo_color_t);
|
||||
#else
|
||||
highp vec4 halo_color = u_halo_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
opacity = unpack_mix_vec2(a_opacity, u_opacity_t);
|
||||
#else
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_width
|
||||
halo_width = unpack_mix_vec2(a_halo_width, u_halo_width_t);
|
||||
#else
|
||||
lowp float halo_width = u_halo_width;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_blur
|
||||
halo_blur = unpack_mix_vec2(a_halo_blur, u_halo_blur_t);
|
||||
#else
|
||||
lowp float halo_blur = u_halo_blur;
|
||||
#endif
|
||||
|
||||
vec2 a_pos = a_pos_offset.xy;
|
||||
vec2 a_offset = a_pos_offset.zw;
|
||||
|
||||
vec2 a_tex = a_data.xy;
|
||||
vec2 a_size = a_data.zw;
|
||||
|
||||
float a_size_min = floor(a_size[0] * 0.5);
|
||||
float is_sdf = a_size[0] - 2.0 * a_size_min;
|
||||
|
||||
highp float segment_angle = -a_projected_pos[2];
|
||||
float size;
|
||||
|
||||
if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {
|
||||
size = mix(a_size_min, a_size[1], u_size_t) / 128.0;
|
||||
} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {
|
||||
size = a_size_min / 128.0;
|
||||
} else {
|
||||
size = u_size;
|
||||
}
|
||||
|
||||
vec4 projectedPoint = u_matrix * vec4(a_pos, 0, 1);
|
||||
highp float camera_to_anchor_distance = projectedPoint.w;
|
||||
// If the label is pitched with the map, layout is done in pitched space,
|
||||
// which makes labels in the distance smaller relative to viewport space.
|
||||
// We counteract part of that effect by multiplying by the perspective ratio.
|
||||
// If the label isn't pitched with the map, we do layout in viewport space,
|
||||
// which makes labels in the distance larger relative to the features around
|
||||
// them. We counteract part of that effect by dividing by the perspective ratio.
|
||||
highp float distance_ratio = u_pitch_with_map ?
|
||||
camera_to_anchor_distance / u_camera_to_center_distance :
|
||||
u_camera_to_center_distance / camera_to_anchor_distance;
|
||||
highp float perspective_ratio = clamp(
|
||||
0.5 + 0.5 * distance_ratio,
|
||||
0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles
|
||||
4.0);
|
||||
|
||||
size *= perspective_ratio;
|
||||
|
||||
float fontScale = size / 24.0;
|
||||
|
||||
highp float symbol_rotation = 0.0;
|
||||
if (u_rotate_symbol) {
|
||||
// Point labels with 'rotation-alignment: map' are horizontal with respect to tile units
|
||||
// To figure out that angle in projected space, we draw a short horizontal line in tile
|
||||
// space, project it, and measure its angle in projected space.
|
||||
vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), 0, 1);
|
||||
|
||||
vec2 a = projectedPoint.xy / projectedPoint.w;
|
||||
vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w;
|
||||
|
||||
symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x);
|
||||
}
|
||||
|
||||
highp float angle_sin = sin(segment_angle + symbol_rotation);
|
||||
highp float angle_cos = cos(segment_angle + symbol_rotation);
|
||||
mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);
|
||||
|
||||
vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0);
|
||||
gl_Position = u_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale), 0.0, 1.0);
|
||||
float gamma_scale = gl_Position.w;
|
||||
|
||||
vec2 fade_opacity = unpack_opacity(a_fade_opacity);
|
||||
float fade_change = fade_opacity[1] > 0.5 ? u_symbol_fade_change : -u_symbol_fade_change;
|
||||
float interpolated_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change));
|
||||
|
||||
v_data0.xy = a_tex / u_texsize;
|
||||
v_data0.zw = a_tex / u_texsize_icon;
|
||||
v_data1 = vec4(gamma_scale, size, interpolated_fade_opacity, is_sdf);
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(#define SDF_PX 8.0
|
||||
|
||||
#define SDF 1.0
|
||||
#define ICON 0.0
|
||||
|
||||
layout (std140) uniform SymbolTilePropsUBO {
|
||||
bool u_is_text;
|
||||
bool u_is_halo;
|
||||
highp float u_gamma_scale;
|
||||
lowp float tileprops_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform SymbolEvaluatedPropsUBO {
|
||||
highp vec4 u_text_fill_color;
|
||||
highp vec4 u_text_halo_color;
|
||||
highp float u_text_opacity;
|
||||
highp float u_text_halo_width;
|
||||
highp float u_text_halo_blur;
|
||||
lowp float props_pad1;
|
||||
highp vec4 u_icon_fill_color;
|
||||
highp vec4 u_icon_halo_color;
|
||||
highp float u_icon_opacity;
|
||||
highp float u_icon_halo_width;
|
||||
highp float u_icon_halo_blur;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
uniform sampler2D u_texture;
|
||||
uniform sampler2D u_texture_icon;
|
||||
|
||||
in vec4 v_data0;
|
||||
in vec4 v_data1;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_fill_color
|
||||
in highp vec4 fill_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_color
|
||||
in highp vec4 halo_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
in lowp float opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_width
|
||||
in lowp float halo_width;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_blur
|
||||
in lowp float halo_blur;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
highp vec4 u_fill_color = u_is_text ? u_text_fill_color : u_icon_fill_color;
|
||||
highp vec4 u_halo_color = u_is_text ? u_text_halo_color : u_icon_halo_color;
|
||||
highp float u_opacity = u_is_text ? u_text_opacity : u_icon_opacity;
|
||||
highp float u_halo_width = u_is_text ? u_text_halo_width : u_icon_halo_width;
|
||||
highp float u_halo_blur = u_is_text ? u_text_halo_blur : u_icon_halo_blur;
|
||||
|
||||
#ifdef HAS_UNIFORM_u_fill_color
|
||||
highp vec4 fill_color = u_fill_color;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_halo_color
|
||||
highp vec4 halo_color = u_halo_color;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_opacity
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_halo_width
|
||||
lowp float halo_width = u_halo_width;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_halo_blur
|
||||
lowp float halo_blur = u_halo_blur;
|
||||
#endif
|
||||
|
||||
float fade_opacity = v_data1[2];
|
||||
|
||||
if (v_data1.w == ICON) {
|
||||
vec2 tex_icon = v_data0.zw;
|
||||
lowp float alpha = opacity * fade_opacity;
|
||||
fragColor = texture(u_texture_icon, tex_icon) * alpha;
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
fragColor = vec4(1.0);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 tex = v_data0.xy;
|
||||
|
||||
float EDGE_GAMMA = 0.105 / DEVICE_PIXEL_RATIO;
|
||||
|
||||
float gamma_scale = v_data1.x;
|
||||
float size = v_data1.y;
|
||||
|
||||
float fontScale = size / 24.0;
|
||||
|
||||
lowp vec4 color = fill_color;
|
||||
highp float gamma = EDGE_GAMMA / (fontScale * u_gamma_scale);
|
||||
lowp float buff = (256.0 - 64.0) / 256.0;
|
||||
if (u_is_halo) {
|
||||
color = halo_color;
|
||||
gamma = (halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_gamma_scale);
|
||||
buff = (6.0 - halo_width / fontScale) / SDF_PX;
|
||||
}
|
||||
|
||||
lowp float dist = texture(u_texture, tex).a;
|
||||
highp float gamma_scaled = gamma * gamma_scale;
|
||||
highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);
|
||||
|
||||
fragColor = color * (alpha * opacity * fade_opacity);
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
fragColor = vec4(1.0);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -6,25 +6,35 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "FillProgram";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
struct ShaderSource<BuiltIn::FillShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "FillShader";
|
||||
static constexpr const char* vertex = R"(layout (std140) uniform FillDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
// Interpolations
|
||||
highp float u_color_t;
|
||||
highp float u_opacity_t;
|
||||
lowp float drawable_pad1;
|
||||
lowp float drawable_pad2;
|
||||
};
|
||||
|
||||
uniform mat4 u_matrix;
|
||||
layout (std140) uniform FillEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec4 u_outline_color;
|
||||
highp float u_opacity;
|
||||
highp float u_fade;
|
||||
highp float u_from_scale;
|
||||
highp float u_to_scale;
|
||||
};
|
||||
|
||||
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() {
|
||||
@@ -42,15 +52,20 @@ 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 FillEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec4 u_outline_color;
|
||||
highp float u_opacity;
|
||||
highp float u_fade;
|
||||
highp float u_from_scale;
|
||||
highp float u_to_scale;
|
||||
};
|
||||
|
||||
#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() {
|
||||
|
||||
@@ -6,36 +6,59 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillExtrusionProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "FillExtrusionProgram";
|
||||
static constexpr const char* vertex = R"(uniform mat4 u_matrix;
|
||||
uniform vec3 u_lightcolor;
|
||||
uniform lowp vec3 u_lightpos;
|
||||
uniform lowp float u_lightintensity;
|
||||
uniform float u_vertical_gradient;
|
||||
uniform lowp float u_opacity;
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
struct ShaderSource<BuiltIn::FillExtrusionShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "FillExtrusionShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
layout (location = 1) in vec4 a_normal_ed;
|
||||
out vec4 v_color;
|
||||
|
||||
layout (std140) uniform FillExtrusionDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp float u_height_factor;
|
||||
highp float u_tile_ratio;
|
||||
// Interpolations
|
||||
highp float u_base_t;
|
||||
highp float u_height_t;
|
||||
highp float u_color_t;
|
||||
highp float u_pattern_from_t;
|
||||
highp float u_pattern_to_t;
|
||||
lowp float drawable_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillExtrusionTilePropsUBO {
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
highp vec2 u_texsize;
|
||||
lowp float tileprops_pad1;
|
||||
lowp float tileprops_pad2;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillExtrusionPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec3 u_lightcolor;
|
||||
lowp float props_pad1;
|
||||
highp vec3 u_lightpos;
|
||||
highp float u_base;
|
||||
highp float u_height;
|
||||
highp float u_lightintensity;
|
||||
highp float u_vertical_gradient;
|
||||
highp float u_opacity;
|
||||
highp float u_fade;
|
||||
highp float u_from_scale;
|
||||
highp float u_to_scale;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
#ifndef HAS_UNIFORM_u_base
|
||||
uniform lowp float u_base_t;
|
||||
layout (location = 2) in highp vec2 a_base;
|
||||
#else
|
||||
uniform highp float u_base;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_height
|
||||
uniform lowp float u_height_t;
|
||||
layout (location = 3) in highp vec2 a_height;
|
||||
#else
|
||||
uniform highp float u_height;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_color
|
||||
uniform lowp float u_color_t;
|
||||
layout (location = 4) in highp vec4 a_color;
|
||||
#else
|
||||
uniform highp vec4 u_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -6,54 +6,81 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillExtrusionPatternProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "FillExtrusionPatternProgram";
|
||||
static constexpr const char* vertex = R"(uniform mat4 u_matrix;
|
||||
uniform vec2 u_pixel_coord_upper;
|
||||
uniform vec2 u_pixel_coord_lower;
|
||||
uniform float u_height_factor;
|
||||
uniform vec4 u_scale;
|
||||
uniform float u_vertical_gradient;
|
||||
uniform lowp float u_opacity;
|
||||
|
||||
uniform vec3 u_lightcolor;
|
||||
uniform lowp vec3 u_lightpos;
|
||||
uniform lowp float u_lightintensity;
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
struct ShaderSource<BuiltIn::FillExtrusionPatternShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "FillExtrusionPatternShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
layout (location = 1) in vec4 a_normal_ed;
|
||||
|
||||
out vec2 v_pos_a;
|
||||
out vec2 v_pos_b;
|
||||
out vec4 v_lighting;
|
||||
|
||||
layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillExtrusionDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp float u_height_factor;
|
||||
highp float u_tile_ratio;
|
||||
// Interpolations
|
||||
highp float u_base_t;
|
||||
highp float u_height_t;
|
||||
highp float u_color_t;
|
||||
highp float u_pattern_from_t;
|
||||
highp float u_pattern_to_t;
|
||||
lowp float drawable_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillExtrusionTilePropsUBO {
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
highp vec2 u_texsize;
|
||||
lowp float tileprops_pad1;
|
||||
lowp float tileprops_pad2;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillExtrusionPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec3 u_lightcolor;
|
||||
lowp float props_pad1;
|
||||
highp vec3 u_lightpos;
|
||||
highp float u_base;
|
||||
highp float u_height;
|
||||
highp float u_lightintensity;
|
||||
highp float u_vertical_gradient;
|
||||
highp float u_opacity;
|
||||
highp float u_fade;
|
||||
highp float u_from_scale;
|
||||
highp float u_to_scale;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
#ifndef HAS_UNIFORM_u_base
|
||||
uniform lowp float u_base_t;
|
||||
layout (location = 2) in lowp vec2 a_base;
|
||||
out lowp float base;
|
||||
#else
|
||||
uniform lowp float u_base;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_height
|
||||
uniform lowp float u_height_t;
|
||||
layout (location = 3) in lowp vec2 a_height;
|
||||
out lowp float height;
|
||||
#else
|
||||
uniform lowp float u_height;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_from
|
||||
uniform lowp float u_pattern_from_t;
|
||||
layout (location = 4) in mediump vec4 a_pattern_from;
|
||||
out mediump vec4 pattern_from;
|
||||
#else
|
||||
uniform mediump vec4 u_pattern_from;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_to
|
||||
uniform lowp float u_pattern_to_t;
|
||||
layout (location = 5) in mediump vec4 a_pattern_to;
|
||||
out mediump vec4 pattern_to;
|
||||
#else
|
||||
uniform mediump vec4 u_pattern_to;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
@@ -83,10 +110,10 @@ mediump vec4 pattern_to = u_pattern_to;
|
||||
vec2 pattern_tl_b = pattern_to.xy;
|
||||
vec2 pattern_br_b = pattern_to.zw;
|
||||
|
||||
float pixelRatio = u_scale.x;
|
||||
float tileRatio = u_scale.y;
|
||||
float fromScale = u_scale.z;
|
||||
float toScale = u_scale.w;
|
||||
float pixelRatio = u_pixel_ratio;
|
||||
float tileRatio = u_tile_ratio;
|
||||
float fromScale = u_from_scale;
|
||||
float toScale = u_to_scale;
|
||||
|
||||
vec3 normal = a_normal_ed.xyz;
|
||||
float edgedistance = a_normal_ed.w;
|
||||
@@ -125,34 +152,47 @@ mediump vec4 pattern_to = u_pattern_to;
|
||||
v_lighting *= u_opacity;
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(uniform vec2 u_texsize;
|
||||
uniform float u_fade;
|
||||
|
||||
uniform sampler2D u_image;
|
||||
|
||||
in vec2 v_pos_a;
|
||||
static constexpr const char* fragment = R"(in vec2 v_pos_a;
|
||||
in vec2 v_pos_b;
|
||||
in vec4 v_lighting;
|
||||
|
||||
layout (std140) uniform FillExtrusionTilePropsUBO {
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
highp vec2 u_texsize;
|
||||
lowp float tileprops_pad1;
|
||||
lowp float tileprops_pad2;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillExtrusionPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec3 u_lightcolor;
|
||||
lowp float props_pad1;
|
||||
highp vec3 u_lightpos;
|
||||
highp float u_base;
|
||||
highp float u_height;
|
||||
highp float u_lightintensity;
|
||||
highp float u_vertical_gradient;
|
||||
highp float u_opacity;
|
||||
highp float u_fade;
|
||||
highp float u_from_scale;
|
||||
highp float u_to_scale;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
uniform sampler2D u_image;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_base
|
||||
in lowp float base;
|
||||
#else
|
||||
uniform lowp float u_base;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_height
|
||||
in lowp float height;
|
||||
#else
|
||||
uniform lowp float u_height;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_from
|
||||
in mediump vec4 pattern_from;
|
||||
#else
|
||||
uniform mediump vec4 u_pattern_from;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_to
|
||||
in mediump vec4 pattern_to;
|
||||
#else
|
||||
uniform mediump vec4 u_pattern_to;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -6,28 +6,49 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillOutlineProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "FillOutlineProgram";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
struct ShaderSource<BuiltIn::FillOutlineShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "FillOutlineShader";
|
||||
static constexpr const char* vertex = R"(layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
uniform mat4 u_matrix;
|
||||
uniform vec2 u_world;
|
||||
layout (std140) uniform FillOutlineDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
// Interpolations
|
||||
highp float u_outline_color_t;
|
||||
highp float u_opacity_t;
|
||||
lowp float drawable_pad1;
|
||||
lowp float drawable_pad2;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec4 u_outline_color;
|
||||
highp float u_opacity;
|
||||
highp float u_fade;
|
||||
highp float u_from_scale;
|
||||
highp float u_to_scale;
|
||||
};
|
||||
|
||||
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() {
|
||||
@@ -43,20 +64,25 @@ lowp float opacity = u_opacity;
|
||||
#endif
|
||||
|
||||
gl_Position = u_matrix * vec4(a_pos, 0, 1);
|
||||
v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world;
|
||||
v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world_size;
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(in vec2 v_pos;
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform FillEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec4 u_outline_color;
|
||||
highp float u_opacity;
|
||||
highp float u_fade;
|
||||
highp float u_from_scale;
|
||||
highp float u_to_scale;
|
||||
};
|
||||
|
||||
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() {
|
||||
|
||||
@@ -6,13 +6,47 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillOutlinePatternProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "FillOutlinePatternProgram";
|
||||
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;
|
||||
struct ShaderSource<BuiltIn::FillOutlinePatternShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "FillOutlinePatternShader";
|
||||
static constexpr const char* vertex = R"(layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillOutlinePatternDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp float u_tile_ratio;
|
||||
// Interpolations
|
||||
highp float u_pattern_from_t;
|
||||
highp float u_pattern_to_t;
|
||||
highp float u_opacity_t;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillOutlinePatternTilePropsUBO {
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
highp vec2 u_texsize;
|
||||
lowp float tileprops_pad1;
|
||||
lowp float tileprops_pad2;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec4 u_outline_color;
|
||||
highp float u_opacity;
|
||||
highp float u_fade;
|
||||
highp float u_from_scale;
|
||||
highp float u_to_scale;
|
||||
};
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
|
||||
@@ -21,25 +55,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 mediump vec4 a_pattern_from;
|
||||
out mediump vec4 pattern_from;
|
||||
#else
|
||||
uniform mediump vec4 u_pattern_from;
|
||||
layout (location = 2) in lowp vec4 a_pattern_from;
|
||||
out lowp vec4 pattern_from;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_to
|
||||
uniform lowp float u_pattern_to_t;
|
||||
layout (location = 3) in mediump vec4 a_pattern_to;
|
||||
out mediump vec4 pattern_to;
|
||||
#else
|
||||
uniform mediump vec4 u_pattern_to;
|
||||
layout (location = 3) in lowp vec4 a_pattern_to;
|
||||
out lowp vec4 pattern_to;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
@@ -64,10 +89,10 @@ mediump vec4 pattern_to = u_pattern_to;
|
||||
vec2 pattern_tl_b = pattern_to.xy;
|
||||
vec2 pattern_br_b = pattern_to.zw;
|
||||
|
||||
float pixelRatio = u_scale.x;
|
||||
float tileRatio = u_scale.y;
|
||||
float fromScale = u_scale.z;
|
||||
float toScale = u_scale.w;
|
||||
float pixelRatio = u_pixel_ratio;
|
||||
float tileRatio = u_tile_ratio;
|
||||
float fromScale = u_from_scale;
|
||||
float toScale = u_to_scale;
|
||||
|
||||
gl_Position = u_matrix * vec4(a_pos, 0, 1);
|
||||
|
||||
@@ -77,13 +102,27 @@ mediump vec4 pattern_to = u_pattern_to;
|
||||
v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, fromScale * display_size_a, tileRatio, a_pos);
|
||||
v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, toScale * display_size_b, tileRatio, a_pos);
|
||||
|
||||
v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world;
|
||||
v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world_size;
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(
|
||||
uniform vec2 u_texsize;
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform FillOutlinePatternTilePropsUBO {
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
highp vec2 u_texsize;
|
||||
lowp float tileprops_pad1;
|
||||
lowp float tileprops_pad2;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec4 u_outline_color;
|
||||
highp float u_opacity;
|
||||
highp float u_fade;
|
||||
highp float u_from_scale;
|
||||
highp float u_to_scale;
|
||||
};
|
||||
|
||||
uniform sampler2D u_image;
|
||||
uniform float u_fade;
|
||||
|
||||
in vec2 v_pos_a;
|
||||
in vec2 v_pos_b;
|
||||
@@ -91,18 +130,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 mediump vec4 pattern_from;
|
||||
#else
|
||||
uniform mediump vec4 u_pattern_from;
|
||||
in lowp vec4 pattern_from;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_to
|
||||
in mediump vec4 pattern_to;
|
||||
#else
|
||||
uniform mediump vec4 u_pattern_to;
|
||||
in lowp vec4 pattern_to;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -6,12 +6,47 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::FillPatternProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "FillPatternProgram";
|
||||
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;
|
||||
struct ShaderSource<BuiltIn::FillPatternShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "FillPatternShader";
|
||||
static constexpr const char* vertex = R"(layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillPatternDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_pixel_coord_upper;
|
||||
highp vec2 u_pixel_coord_lower;
|
||||
highp float u_tile_ratio;
|
||||
// Interpolations
|
||||
highp float u_pattern_from_t;
|
||||
highp float u_pattern_to_t;
|
||||
highp float u_opacity_t;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillPatternTilePropsUBO {
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
highp vec2 u_texsize;
|
||||
lowp float tileprops_pad1;
|
||||
lowp float tileprops_pad2;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec4 u_outline_color;
|
||||
highp float u_opacity;
|
||||
highp float u_fade;
|
||||
highp float u_from_scale;
|
||||
highp float u_to_scale;
|
||||
};
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
|
||||
@@ -19,25 +54,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 mediump vec4 a_pattern_from;
|
||||
out mediump vec4 pattern_from;
|
||||
#else
|
||||
uniform mediump vec4 u_pattern_from;
|
||||
layout (location = 2) in lowp vec4 a_pattern_from;
|
||||
out lowp vec4 pattern_from;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_to
|
||||
uniform lowp float u_pattern_to_t;
|
||||
layout (location = 3) in mediump vec4 a_pattern_to;
|
||||
out mediump vec4 pattern_to;
|
||||
#else
|
||||
uniform mediump vec4 u_pattern_to;
|
||||
layout (location = 3) in lowp vec4 a_pattern_to;
|
||||
out lowp vec4 pattern_to;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
@@ -62,10 +88,10 @@ mediump vec4 pattern_to = u_pattern_to;
|
||||
vec2 pattern_tl_b = pattern_to.xy;
|
||||
vec2 pattern_br_b = pattern_to.zw;
|
||||
|
||||
float pixelRatio = u_scale.x;
|
||||
float tileZoomRatio = u_scale.y;
|
||||
float fromScale = u_scale.z;
|
||||
float toScale = u_scale.w;
|
||||
float pixelRatio = u_pixel_ratio;
|
||||
float tileZoomRatio = u_tile_ratio;
|
||||
float fromScale = u_from_scale;
|
||||
float toScale = u_to_scale;
|
||||
|
||||
vec2 display_size_a = vec2((pattern_br_a.x - pattern_tl_a.x) / pixelRatio, (pattern_br_a.y - pattern_tl_a.y) / pixelRatio);
|
||||
vec2 display_size_b = vec2((pattern_br_b.x - pattern_tl_b.x) / pixelRatio, (pattern_br_b.y - pattern_tl_b.y) / pixelRatio);
|
||||
@@ -75,8 +101,22 @@ 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 FillPatternTilePropsUBO {
|
||||
highp vec4 u_pattern_from;
|
||||
highp vec4 u_pattern_to;
|
||||
highp vec2 u_texsize;
|
||||
lowp float tileprops_pad1;
|
||||
lowp float tileprops_pad2;
|
||||
};
|
||||
|
||||
layout (std140) uniform FillEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
highp vec4 u_outline_color;
|
||||
highp float u_opacity;
|
||||
highp float u_fade;
|
||||
highp float u_from_scale;
|
||||
highp float u_to_scale;
|
||||
};
|
||||
|
||||
uniform sampler2D u_image;
|
||||
|
||||
@@ -85,18 +125,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 mediump vec4 pattern_from;
|
||||
#else
|
||||
uniform mediump vec4 u_pattern_from;
|
||||
in lowp vec4 pattern_from;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_to
|
||||
in mediump vec4 pattern_to;
|
||||
#else
|
||||
uniform mediump vec4 u_pattern_to;
|
||||
in lowp vec4 pattern_to;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
@@ -115,6 +149,10 @@ mediump vec4 pattern_to = u_pattern_to;
|
||||
vec2 pattern_tl_b = pattern_to.xy;
|
||||
vec2 pattern_br_b = pattern_to.zw;
|
||||
|
||||
if (u_texsize.x < 1.0 || u_texsize.y < 1.0) {
|
||||
discard;
|
||||
}
|
||||
|
||||
vec2 imagecoord = mod(v_pos_a, 1.0);
|
||||
vec2 pos = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, imagecoord);
|
||||
vec4 color1 = texture(u_image, pos);
|
||||
|
||||
@@ -6,28 +6,33 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::HeatmapProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "HeatmapProgram";
|
||||
static constexpr const char* vertex = R"(uniform mat4 u_matrix;
|
||||
uniform float u_extrude_scale;
|
||||
uniform float u_opacity;
|
||||
uniform float u_intensity;
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
struct ShaderSource<BuiltIn::HeatmapShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "HeatmapShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
out vec2 v_extrude;
|
||||
|
||||
layout (std140) uniform HeatmapDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp float u_extrude_scale;
|
||||
// Interpolations
|
||||
lowp float u_weight_t;
|
||||
lowp float u_radius_t;
|
||||
lowp float drawable_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform HeatmapEvaluatedPropsUBO {
|
||||
highp float u_weight;
|
||||
highp float u_radius;
|
||||
highp float u_intensity;
|
||||
lowp float props_pad1;
|
||||
};
|
||||
|
||||
#ifndef HAS_UNIFORM_u_weight
|
||||
uniform lowp float u_weight_t;
|
||||
layout (location = 1) in highp vec2 a_weight;
|
||||
out highp float weight;
|
||||
#else
|
||||
uniform highp float u_weight;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_radius
|
||||
uniform lowp float u_radius_t;
|
||||
layout (location = 2) in mediump vec2 a_radius;
|
||||
#else
|
||||
uniform mediump float u_radius;
|
||||
#endif
|
||||
|
||||
// Effective "0" in the kernel density texture to adjust the kernel size to;
|
||||
@@ -80,14 +85,17 @@ mediump float radius = u_radius;
|
||||
gl_Position = u_matrix * pos;
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(uniform highp float u_intensity;
|
||||
static constexpr const char* fragment = R"(in vec2 v_extrude;
|
||||
|
||||
in vec2 v_extrude;
|
||||
layout (std140) uniform HeatmapEvaluatedPropsUBO {
|
||||
highp float u_weight;
|
||||
highp float u_radius;
|
||||
highp float u_intensity;
|
||||
lowp float props_pad1;
|
||||
};
|
||||
|
||||
#ifndef HAS_UNIFORM_u_weight
|
||||
in highp float weight;
|
||||
#else
|
||||
uniform highp float u_weight;
|
||||
#endif
|
||||
|
||||
// Gaussian kernel coefficient: 1 / sqrt(2 * PI)
|
||||
|
||||
@@ -6,24 +6,49 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::HeatmapTextureProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "HeatmapTextureProgram";
|
||||
static constexpr const char* vertex = R"(uniform mat4 u_matrix;
|
||||
uniform vec2 u_world;
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
struct ShaderSource<BuiltIn::HeatmapTextureShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "HeatmapTextureShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
out vec2 v_pos;
|
||||
|
||||
layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform HeatmapTexturePropsUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp float u_opacity;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
lowp float props_pad3;
|
||||
};
|
||||
|
||||
void main() {
|
||||
gl_Position = u_matrix * vec4(a_pos * u_world, 0, 1);
|
||||
gl_Position = u_matrix * vec4(a_pos * u_world_size, 0, 1);
|
||||
|
||||
v_pos.x = a_pos.x;
|
||||
v_pos.y = 1.0 - a_pos.y;
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(uniform sampler2D u_image;
|
||||
static constexpr const char* fragment = R"(in vec2 v_pos;
|
||||
uniform sampler2D u_image;
|
||||
uniform sampler2D u_color_ramp;
|
||||
uniform float u_opacity;
|
||||
in vec2 v_pos;
|
||||
|
||||
layout (std140) uniform HeatmapTexturePropsUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp float u_opacity;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
lowp float props_pad3;
|
||||
};
|
||||
|
||||
void main() {
|
||||
float t = texture(u_image, v_pos).r;
|
||||
|
||||
@@ -6,13 +6,15 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::HillshadeProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "HillshadeProgram";
|
||||
static constexpr const char* vertex = R"(uniform mat4 u_matrix;
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
struct ShaderSource<BuiltIn::HillshadeShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "HillshadeShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
layout (location = 1) in vec2 a_texture_pos;
|
||||
|
||||
layout (std140) uniform HillshadeDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
};
|
||||
|
||||
out vec2 v_pos;
|
||||
|
||||
void main() {
|
||||
@@ -20,14 +22,19 @@ void main() {
|
||||
v_pos = a_texture_pos / 8192.0;
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(uniform sampler2D u_image;
|
||||
in vec2 v_pos;
|
||||
static constexpr const char* fragment = R"(in vec2 v_pos;
|
||||
uniform sampler2D u_image;
|
||||
|
||||
uniform vec2 u_latrange;
|
||||
uniform vec2 u_light;
|
||||
uniform vec4 u_shadow;
|
||||
uniform vec4 u_highlight;
|
||||
uniform vec4 u_accent;
|
||||
layout (std140) uniform HillshadeTilePropsUBO {
|
||||
highp vec2 u_latrange;
|
||||
highp vec2 u_light;
|
||||
};
|
||||
|
||||
layout (std140) uniform HillshadeEvaluatedPropsUBO {
|
||||
highp vec4 u_highlight;
|
||||
highp vec4 u_shadow;
|
||||
highp vec4 u_accent;
|
||||
};
|
||||
|
||||
#define PI 3.141592653589793
|
||||
|
||||
|
||||
@@ -6,14 +6,22 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::HillshadePrepareProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "HillshadePrepareProgram";
|
||||
static constexpr const char* vertex = R"(uniform mat4 u_matrix;
|
||||
uniform vec2 u_dimension;
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
struct ShaderSource<BuiltIn::HillshadePrepareShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "HillshadePrepareShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
|
||||
layout (location = 1) in vec2 a_texture_pos;
|
||||
|
||||
layout (std140) uniform HillshadePrepareDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
};
|
||||
|
||||
layout (std140) uniform HillshadePrepareTilePropsUBO {
|
||||
highp vec4 u_unpack;
|
||||
highp vec2 u_dimension;
|
||||
highp float u_zoom;
|
||||
highp float u_maxzoom;
|
||||
};
|
||||
|
||||
out vec2 v_pos;
|
||||
|
||||
void main() {
|
||||
@@ -28,12 +36,15 @@ void main() {
|
||||
precision highp float;
|
||||
#endif
|
||||
|
||||
uniform sampler2D u_image;
|
||||
in vec2 v_pos;
|
||||
uniform vec2 u_dimension;
|
||||
uniform float u_zoom;
|
||||
uniform float u_maxzoom;
|
||||
uniform vec4 u_unpack;
|
||||
uniform sampler2D u_image;
|
||||
|
||||
layout (std140) uniform HillshadePrepareTilePropsUBO {
|
||||
highp vec4 u_unpack;
|
||||
highp vec2 u_dimension;
|
||||
highp float u_zoom;
|
||||
highp float u_maxzoom;
|
||||
};
|
||||
|
||||
float getElevation(vec2 coord, float bias) {
|
||||
// Convert encoded elevation value to meters
|
||||
|
||||
@@ -6,8 +6,8 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::LineProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "LineProgram";
|
||||
struct ShaderSource<BuiltIn::LineShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "LineShader";
|
||||
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
|
||||
// stored in a byte (-128..127). we scale regular normals up to length 63, but
|
||||
@@ -19,10 +19,42 @@ struct ShaderSource<BuiltIn::LineProgram, gfx::Backend::Type::OpenGL> {
|
||||
layout (location = 0) in vec2 a_pos_normal;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
|
||||
uniform mat4 u_matrix;
|
||||
uniform mediump float u_ratio;
|
||||
uniform vec2 u_units_to_pixels;
|
||||
uniform lowp float u_device_pixel_ratio;
|
||||
layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
mediump float u_ratio;
|
||||
// Interpolations
|
||||
lowp float u_color_t;
|
||||
lowp float u_blur_t;
|
||||
lowp float u_opacity_t;
|
||||
lowp float u_gapwidth_t;
|
||||
lowp float u_offset_t;
|
||||
lowp float u_width_t;
|
||||
lowp float drawable_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
lowp float u_blur;
|
||||
lowp float u_opacity;
|
||||
mediump float u_gapwidth;
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
lowp float u_floorwidth;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
out vec2 v_normal;
|
||||
out vec2 v_width2;
|
||||
@@ -30,43 +62,25 @@ out float v_gamma_scale;
|
||||
out highp float v_linesofar;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_color
|
||||
uniform lowp float u_color_t;
|
||||
layout (location = 2) in highp vec4 a_color;
|
||||
out highp vec4 color;
|
||||
#else
|
||||
uniform highp vec4 u_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
uniform lowp float u_blur_t;
|
||||
layout (location = 3) in lowp vec2 a_blur;
|
||||
out lowp float blur;
|
||||
#else
|
||||
uniform lowp float u_blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
uniform lowp float u_opacity_t;
|
||||
layout (location = 4) in lowp vec2 a_opacity;
|
||||
out lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_gapwidth
|
||||
uniform lowp float u_gapwidth_t;
|
||||
layout (location = 5) in mediump vec2 a_gapwidth;
|
||||
#else
|
||||
uniform mediump float u_gapwidth;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_offset
|
||||
uniform lowp float u_offset_t;
|
||||
layout (location = 6) in lowp vec2 a_offset;
|
||||
#else
|
||||
uniform lowp float u_offset;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_width
|
||||
uniform lowp float u_width_t;
|
||||
layout (location = 7) in mediump vec2 a_width;
|
||||
#else
|
||||
uniform mediump float u_width;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
@@ -103,7 +117,7 @@ mediump float width = u_width;
|
||||
|
||||
// the distance over which the line edge fades out.
|
||||
// Retina devices need a smaller distance to avoid aliasing.
|
||||
float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0;
|
||||
float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0;
|
||||
|
||||
vec2 a_extrude = a_data.xy - 128.0;
|
||||
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
||||
@@ -151,7 +165,17 @@ mediump float width = u_width;
|
||||
v_width2 = vec2(outset, inset);
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(uniform lowp float u_device_pixel_ratio;
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform LineEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
lowp float u_blur;
|
||||
lowp float u_opacity;
|
||||
mediump float u_gapwidth;
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
lowp float u_floorwidth;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
in vec2 v_width2;
|
||||
in vec2 v_normal;
|
||||
@@ -159,18 +183,12 @@ in float v_gamma_scale;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_color
|
||||
in highp vec4 color;
|
||||
#else
|
||||
uniform highp vec4 u_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
in lowp float blur;
|
||||
#else
|
||||
uniform lowp float u_blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
in lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
@@ -190,7 +208,7 @@ lowp float opacity = u_opacity;
|
||||
// Calculate the antialiasing fade factor. This is either when fading in
|
||||
// the line in case of an offset line (v_width2.t) or when fading out
|
||||
// (v_width2.s)
|
||||
float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale;
|
||||
float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;
|
||||
float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);
|
||||
|
||||
fragColor = color * (alpha * opacity);
|
||||
|
||||
@@ -6,8 +6,8 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::LineGradientProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "LineGradientProgram";
|
||||
struct ShaderSource<BuiltIn::LineGradientShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "LineGradientShader";
|
||||
static constexpr const char* vertex = R"(
|
||||
// the attribute conveying progress along a line is scaled to [0, 2^15)
|
||||
#define MAX_LINE_DISTANCE 32767.0
|
||||
@@ -23,10 +23,42 @@ struct ShaderSource<BuiltIn::LineGradientProgram, gfx::Backend::Type::OpenGL> {
|
||||
layout (location = 0) in vec2 a_pos_normal;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
|
||||
uniform mat4 u_matrix;
|
||||
uniform mediump float u_ratio;
|
||||
uniform lowp float u_device_pixel_ratio;
|
||||
uniform vec2 u_units_to_pixels;
|
||||
layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineGradientDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
mediump float u_ratio;
|
||||
// Interpolations
|
||||
lowp float u_blur_t;
|
||||
lowp float u_opacity_t;
|
||||
lowp float u_gapwidth_t;
|
||||
lowp float u_offset_t;
|
||||
lowp float u_width_t;
|
||||
lowp float drawable_pad1;
|
||||
lowp float drawable_pad2;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
lowp float u_blur;
|
||||
lowp float u_opacity;
|
||||
mediump float u_gapwidth;
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
lowp float u_floorwidth;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
out vec2 v_normal;
|
||||
out vec2 v_width2;
|
||||
@@ -34,36 +66,21 @@ out float v_gamma_scale;
|
||||
out highp float v_lineprogress;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
uniform lowp float u_blur_t;
|
||||
layout (location = 2) in lowp vec2 a_blur;
|
||||
out lowp float blur;
|
||||
#else
|
||||
uniform lowp float u_blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
uniform lowp float u_opacity_t;
|
||||
layout (location = 3) in lowp vec2 a_opacity;
|
||||
out lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_gapwidth
|
||||
uniform lowp float u_gapwidth_t;
|
||||
layout (location = 4) in mediump vec2 a_gapwidth;
|
||||
#else
|
||||
uniform mediump float u_gapwidth;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_offset
|
||||
uniform lowp float u_offset_t;
|
||||
layout (location = 5) in lowp vec2 a_offset;
|
||||
#else
|
||||
uniform lowp float u_offset;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_width
|
||||
uniform lowp float u_width_t;
|
||||
layout (location = 6) in mediump vec2 a_width;
|
||||
#else
|
||||
uniform mediump float u_width;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
@@ -95,7 +112,7 @@ mediump float width = u_width;
|
||||
|
||||
// the distance over which the line edge fades out.
|
||||
// Retina devices need a smaller distance to avoid aliasing.
|
||||
float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0;
|
||||
float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0;
|
||||
|
||||
vec2 a_extrude = a_data.xy - 128.0;
|
||||
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
||||
@@ -143,7 +160,18 @@ mediump float width = u_width;
|
||||
v_width2 = vec2(outset, inset);
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(uniform lowp float u_device_pixel_ratio;
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform LineEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
lowp float u_blur;
|
||||
lowp float u_opacity;
|
||||
mediump float u_gapwidth;
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
lowp float u_floorwidth;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
uniform sampler2D u_image;
|
||||
|
||||
in vec2 v_width2;
|
||||
@@ -153,13 +181,9 @@ in highp float v_lineprogress;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
in lowp float blur;
|
||||
#else
|
||||
uniform lowp float u_blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
in lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
@@ -176,7 +200,7 @@ lowp float opacity = u_opacity;
|
||||
// Calculate the antialiasing fade factor. This is either when fading in
|
||||
// the line in case of an offset line (v_width2.t) or when fading out
|
||||
// (v_width2.s)
|
||||
float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale;
|
||||
float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;
|
||||
float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);
|
||||
|
||||
// For gradient lines, v_lineprogress is the ratio along the entire line,
|
||||
|
||||
@@ -6,8 +6,8 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::LinePatternProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "LinePatternProgram";
|
||||
struct ShaderSource<BuiltIn::LinePatternShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "LinePatternShader";
|
||||
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
|
||||
// stored in a byte (-128..127). we scale regular normals up to length 63, but
|
||||
@@ -23,10 +23,50 @@ struct ShaderSource<BuiltIn::LinePatternProgram, gfx::Backend::Type::OpenGL> {
|
||||
layout (location = 0) in vec2 a_pos_normal;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
|
||||
uniform mat4 u_matrix;
|
||||
uniform vec2 u_units_to_pixels;
|
||||
uniform mediump float u_ratio;
|
||||
uniform lowp float u_device_pixel_ratio;
|
||||
layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
layout (std140) uniform LinePatternDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
mediump float u_ratio;
|
||||
// Interpolations
|
||||
lowp float u_blur_t;
|
||||
lowp float u_opacity_t;
|
||||
lowp float u_offset_t;
|
||||
lowp float u_gapwidth_t;
|
||||
lowp float u_width_t;
|
||||
lowp float u_pattern_from_t;
|
||||
lowp float u_pattern_to_t;
|
||||
};
|
||||
|
||||
layout (std140) uniform LinePatternTilePropsUBO {
|
||||
lowp vec4 u_pattern_from;
|
||||
lowp vec4 u_pattern_to;
|
||||
mediump vec4 u_scale;
|
||||
highp vec2 u_texsize;
|
||||
highp float u_fade;
|
||||
lowp float tileprops_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
lowp float u_blur;
|
||||
lowp float u_opacity;
|
||||
mediump float u_gapwidth;
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
lowp float u_floorwidth;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
out vec2 v_normal;
|
||||
out vec2 v_width2;
|
||||
@@ -34,50 +74,29 @@ out float v_linesofar;
|
||||
out float v_gamma_scale;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
uniform lowp float u_blur_t;
|
||||
layout (location = 2) in lowp vec2 a_blur;
|
||||
out lowp float blur;
|
||||
#else
|
||||
uniform lowp float u_blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
uniform lowp float u_opacity_t;
|
||||
layout (location = 3) in lowp vec2 a_opacity;
|
||||
out lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_offset
|
||||
uniform lowp float u_offset_t;
|
||||
layout (location = 4) in lowp vec2 a_offset;
|
||||
#else
|
||||
uniform lowp float u_offset;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_gapwidth
|
||||
uniform lowp float u_gapwidth_t;
|
||||
layout (location = 5) in mediump vec2 a_gapwidth;
|
||||
#else
|
||||
uniform mediump float u_gapwidth;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_width
|
||||
uniform lowp float u_width_t;
|
||||
layout (location = 6) in mediump vec2 a_width;
|
||||
#else
|
||||
uniform mediump float u_width;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_from
|
||||
uniform lowp float u_pattern_from_t;
|
||||
layout (location = 7) in mediump vec4 a_pattern_from;
|
||||
out mediump vec4 pattern_from;
|
||||
#else
|
||||
uniform mediump vec4 u_pattern_from;
|
||||
layout (location = 7) in lowp vec4 a_pattern_from;
|
||||
out lowp vec4 pattern_from;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_to
|
||||
uniform lowp float u_pattern_to_t;
|
||||
layout (location = 8) in mediump vec4 a_pattern_to;
|
||||
out mediump vec4 pattern_to;
|
||||
#else
|
||||
uniform mediump vec4 u_pattern_to;
|
||||
layout (location = 8) in lowp vec4 a_pattern_to;
|
||||
out lowp vec4 pattern_to;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
@@ -119,7 +138,7 @@ mediump vec4 pattern_to = u_pattern_to;
|
||||
|
||||
// the distance over which the line edge fades out.
|
||||
// Retina devices need a smaller distance to avoid aliasing.
|
||||
float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0;
|
||||
float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0;
|
||||
|
||||
vec2 a_extrude = a_data.xy - 128.0;
|
||||
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
||||
@@ -167,10 +186,26 @@ mediump vec4 pattern_to = u_pattern_to;
|
||||
v_width2 = vec2(outset, inset);
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(uniform lowp float u_device_pixel_ratio;
|
||||
uniform vec2 u_texsize;
|
||||
uniform float u_fade;
|
||||
uniform mediump vec4 u_scale;
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform LinePatternTilePropsUBO {
|
||||
lowp vec4 u_pattern_from;
|
||||
lowp vec4 u_pattern_to;
|
||||
mediump vec4 u_scale;
|
||||
highp vec2 u_texsize;
|
||||
highp float u_fade;
|
||||
lowp float tileprops_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
lowp float u_blur;
|
||||
lowp float u_opacity;
|
||||
mediump float u_gapwidth;
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
lowp float u_floorwidth;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
uniform sampler2D u_image;
|
||||
|
||||
@@ -180,24 +215,16 @@ in float v_linesofar;
|
||||
in float v_gamma_scale;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_pattern_from
|
||||
in mediump vec4 pattern_from;
|
||||
#else
|
||||
uniform mediump vec4 u_pattern_from;
|
||||
in lowp vec4 pattern_from;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_pattern_to
|
||||
in mediump vec4 pattern_to;
|
||||
#else
|
||||
uniform mediump vec4 u_pattern_to;
|
||||
in lowp vec4 pattern_to;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
in lowp float blur;
|
||||
#else
|
||||
uniform lowp float u_blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
in lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
@@ -207,6 +234,7 @@ mediump vec4 pattern_from = u_pattern_from;
|
||||
#ifdef HAS_UNIFORM_u_pattern_to
|
||||
mediump vec4 pattern_to = u_pattern_to;
|
||||
#endif
|
||||
|
||||
#ifdef HAS_UNIFORM_u_blur
|
||||
lowp float blur = u_blur;
|
||||
#endif
|
||||
@@ -236,7 +264,7 @@ lowp float opacity = u_opacity;
|
||||
// Calculate the antialiasing fade factor. This is either when fading in
|
||||
// the line in case of an offset line (v_width2.t) or when fading out
|
||||
// (v_width2.s)
|
||||
float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale;
|
||||
float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;
|
||||
float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);
|
||||
|
||||
float x_a = mod(v_linesofar / pattern_size_a.x, 1.0);
|
||||
|
||||
@@ -6,8 +6,8 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::LineSDFProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "LineSDFProgram";
|
||||
struct ShaderSource<BuiltIn::LineSDFShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "LineSDFShader";
|
||||
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
|
||||
// stored in a byte (-128..127). we scale regular normals up to length 63, but
|
||||
@@ -23,14 +23,48 @@ struct ShaderSource<BuiltIn::LineSDFProgram, gfx::Backend::Type::OpenGL> {
|
||||
layout (location = 0) in vec2 a_pos_normal;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
|
||||
uniform mat4 u_matrix;
|
||||
uniform mediump float u_ratio;
|
||||
uniform lowp float u_device_pixel_ratio;
|
||||
uniform vec2 u_patternscale_a;
|
||||
uniform float u_tex_y_a;
|
||||
uniform vec2 u_patternscale_b;
|
||||
uniform float u_tex_y_b;
|
||||
uniform vec2 u_units_to_pixels;
|
||||
layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineSDFDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp vec2 u_patternscale_a;
|
||||
highp vec2 u_patternscale_b;
|
||||
highp float u_tex_y_a;
|
||||
highp float u_tex_y_b;
|
||||
mediump float u_ratio;
|
||||
// Interpolations
|
||||
lowp float u_color_t;
|
||||
lowp float u_blur_t;
|
||||
lowp float u_opacity_t;
|
||||
lowp float u_gapwidth_t;
|
||||
lowp float u_offset_t;
|
||||
lowp float u_width_t;
|
||||
lowp float u_floorwidth_t;
|
||||
lowp float drawable_pad1;
|
||||
lowp float drawable_pad2;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
lowp float u_blur;
|
||||
lowp float u_opacity;
|
||||
mediump float u_gapwidth;
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
lowp float u_floorwidth;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
out vec2 v_normal;
|
||||
out vec2 v_width2;
|
||||
@@ -39,51 +73,30 @@ out vec2 v_tex_b;
|
||||
out float v_gamma_scale;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_color
|
||||
uniform lowp float u_color_t;
|
||||
layout (location = 2) in highp vec4 a_color;
|
||||
out highp vec4 color;
|
||||
#else
|
||||
uniform highp vec4 u_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
uniform lowp float u_blur_t;
|
||||
layout (location = 3) in lowp vec2 a_blur;
|
||||
out lowp float blur;
|
||||
#else
|
||||
uniform lowp float u_blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
uniform lowp float u_opacity_t;
|
||||
layout (location = 4) in lowp vec2 a_opacity;
|
||||
out lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_gapwidth
|
||||
uniform lowp float u_gapwidth_t;
|
||||
layout (location = 5) in mediump vec2 a_gapwidth;
|
||||
#else
|
||||
uniform mediump float u_gapwidth;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_offset
|
||||
uniform lowp float u_offset_t;
|
||||
layout (location = 6) in lowp vec2 a_offset;
|
||||
#else
|
||||
uniform lowp float u_offset;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_width
|
||||
uniform lowp float u_width_t;
|
||||
layout (location = 7) in mediump vec2 a_width;
|
||||
out mediump float width;
|
||||
#else
|
||||
uniform mediump float u_width;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_floorwidth
|
||||
uniform lowp float u_floorwidth_t;
|
||||
layout (location = 8) in lowp vec2 a_floorwidth;
|
||||
out lowp float floorwidth;
|
||||
#else
|
||||
uniform lowp float u_floorwidth;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
@@ -125,7 +138,7 @@ lowp float floorwidth = u_floorwidth;
|
||||
|
||||
// the distance over which the line edge fades out.
|
||||
// Retina devices need a smaller distance to avoid aliasing.
|
||||
float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0;
|
||||
float ANTIALIASING = 1.0 / DEVICE_PIXEL_RATIO / 2.0;
|
||||
|
||||
vec2 a_extrude = a_data.xy - 128.0;
|
||||
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
||||
@@ -175,11 +188,26 @@ lowp float floorwidth = u_floorwidth;
|
||||
v_width2 = vec2(outset, inset);
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(
|
||||
uniform lowp float u_device_pixel_ratio;
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform LineSDFTilePropsUBO {
|
||||
highp float u_sdfgamma;
|
||||
highp float u_mix;
|
||||
lowp float tileprops_pad1;
|
||||
lowp float tileprops_pad2;
|
||||
};
|
||||
|
||||
layout (std140) uniform LineEvaluatedPropsUBO {
|
||||
highp vec4 u_color;
|
||||
lowp float u_blur;
|
||||
lowp float u_opacity;
|
||||
mediump float u_gapwidth;
|
||||
lowp float u_offset;
|
||||
mediump float u_width;
|
||||
lowp float u_floorwidth;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
uniform sampler2D u_image;
|
||||
uniform float u_sdfgamma;
|
||||
uniform float u_mix;
|
||||
|
||||
in vec2 v_normal;
|
||||
in vec2 v_width2;
|
||||
@@ -189,28 +217,18 @@ in float v_gamma_scale;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_color
|
||||
in highp vec4 color;
|
||||
#else
|
||||
uniform highp vec4 u_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
in lowp float blur;
|
||||
#else
|
||||
uniform lowp float u_blur;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
in lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_width
|
||||
in mediump float width;
|
||||
#else
|
||||
uniform mediump float u_width;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_floorwidth
|
||||
in lowp float floorwidth;
|
||||
#else
|
||||
uniform lowp float u_floorwidth;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
@@ -236,7 +254,7 @@ lowp float floorwidth = u_floorwidth;
|
||||
// Calculate the antialiasing fade factor. This is either when fading in
|
||||
// the line in case of an offset line (v_width2.t) or when fading out
|
||||
// (v_width2.s)
|
||||
float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale;
|
||||
float blur2 = (blur + 1.0 / DEVICE_PIXEL_RATIO) * v_gamma_scale;
|
||||
float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0);
|
||||
|
||||
float sdfdist_a = texture(u_image, v_tex_a).a;
|
||||
|
||||
@@ -17,7 +17,8 @@ layout(location = 0) in vec2 a_pos;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);
|
||||
})";
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform LocationIndicatorDrawableUBO {
|
||||
mat4 u_matrix;
|
||||
vec4 u_color;
|
||||
@@ -25,7 +26,8 @@ void main() {
|
||||
|
||||
void main() {
|
||||
fragColor = u_color;
|
||||
})";
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
@@ -21,7 +21,8 @@ out vec2 frag_uv;
|
||||
void main() {
|
||||
frag_uv = a_uv;
|
||||
gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);
|
||||
})";
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform LocationIndicatorDrawableUBO {
|
||||
mat4 u_matrix;
|
||||
vec4 u_color;
|
||||
@@ -32,7 +33,8 @@ uniform sampler2D u_image;
|
||||
|
||||
void main() {
|
||||
fragColor = texture(u_image, frag_uv);
|
||||
})";
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
@@ -6,12 +6,25 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::RasterProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "RasterProgram";
|
||||
static constexpr const char* vertex = R"(uniform mat4 u_matrix;
|
||||
uniform vec2 u_tl_parent;
|
||||
uniform float u_scale_parent;
|
||||
uniform float u_buffer_scale;
|
||||
struct ShaderSource<BuiltIn::RasterShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "RasterShader";
|
||||
static constexpr const char* vertex = R"(layout (std140) uniform RasterDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
};
|
||||
layout (std140) uniform RasterEvaluatedPropsUBO {
|
||||
highp vec3 u_spin_weights;
|
||||
highp vec2 u_tl_parent;
|
||||
highp float u_scale_parent;
|
||||
highp float u_buffer_scale;
|
||||
highp float u_fade_t;
|
||||
highp float u_opacity;
|
||||
highp float u_brightness_low;
|
||||
highp float u_brightness_high;
|
||||
highp float u_saturation_factor;
|
||||
highp float u_contrast_factor;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
layout (location = 0) in vec2 a_pos;
|
||||
layout (location = 1) in vec2 a_texture_pos;
|
||||
@@ -30,20 +43,26 @@ void main() {
|
||||
v_pos1 = (v_pos0 * u_scale_parent) + u_tl_parent;
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(uniform float u_fade_t;
|
||||
uniform float u_opacity;
|
||||
static constexpr const char* fragment = R"(layout (std140) uniform RasterEvaluatedPropsUBO {
|
||||
highp vec3 u_spin_weights;
|
||||
highp vec2 u_tl_parent;
|
||||
highp float u_scale_parent;
|
||||
highp float u_buffer_scale;
|
||||
highp float u_fade_t;
|
||||
highp float u_opacity;
|
||||
highp float u_brightness_low;
|
||||
highp float u_brightness_high;
|
||||
highp float u_saturation_factor;
|
||||
highp float u_contrast_factor;
|
||||
lowp float props_pad1;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
uniform sampler2D u_image0;
|
||||
uniform sampler2D u_image1;
|
||||
|
||||
in vec2 v_pos0;
|
||||
in vec2 v_pos1;
|
||||
|
||||
uniform float u_brightness_low;
|
||||
uniform float u_brightness_high;
|
||||
|
||||
uniform float u_saturation_factor;
|
||||
uniform float u_contrast_factor;
|
||||
uniform vec3 u_spin_weights;
|
||||
|
||||
void main() {
|
||||
|
||||
// read and cross-fade colors from the main and parent tiles
|
||||
|
||||
@@ -6,45 +6,77 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::SymbolIconProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "SymbolIconProgram";
|
||||
struct ShaderSource<BuiltIn::SymbolIconShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "SymbolIconShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec4 a_pos_offset;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
layout (location = 2) in vec4 a_pixeloffset;
|
||||
layout (location = 3) in vec3 a_projected_pos;
|
||||
layout (location = 4) in float a_fade_opacity;
|
||||
|
||||
uniform bool u_is_size_zoom_constant;
|
||||
uniform bool u_is_size_feature_constant;
|
||||
uniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function
|
||||
uniform highp float u_size; // used when size is both zoom and feature constant
|
||||
uniform highp float u_camera_to_center_distance;
|
||||
uniform highp float u_pitch;
|
||||
uniform bool u_rotate_symbol;
|
||||
uniform highp float u_aspect_ratio;
|
||||
uniform float u_fade_change;
|
||||
layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
uniform mat4 u_matrix;
|
||||
uniform mat4 u_label_plane_matrix;
|
||||
uniform mat4 u_coord_matrix;
|
||||
layout (std140) uniform SymbolDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp mat4 u_label_plane_matrix;
|
||||
highp mat4 u_coord_matrix;
|
||||
|
||||
uniform bool u_is_text;
|
||||
uniform bool u_pitch_with_map;
|
||||
highp vec2 u_texsize;
|
||||
highp vec2 u_texsize_icon;
|
||||
|
||||
uniform vec2 u_texsize;
|
||||
bool u_is_text_prop;
|
||||
bool u_rotate_symbol;
|
||||
bool u_pitch_with_map;
|
||||
bool u_is_size_zoom_constant;
|
||||
bool u_is_size_feature_constant;
|
||||
|
||||
highp float u_size_t; // used to interpolate between zoom stops when size is a composite function
|
||||
highp float u_size; // used when size is both zoom and feature constant
|
||||
|
||||
// Interpolations
|
||||
highp float u_fill_color_t;
|
||||
highp float u_halo_color_t;
|
||||
highp float u_opacity_t;
|
||||
highp float u_halo_width_t;
|
||||
highp float u_halo_blur_t;
|
||||
};
|
||||
|
||||
layout (std140) uniform SymbolEvaluatedPropsUBO {
|
||||
highp vec4 u_text_fill_color;
|
||||
highp vec4 u_text_halo_color;
|
||||
highp float u_text_opacity;
|
||||
highp float u_text_halo_width;
|
||||
highp float u_text_halo_blur;
|
||||
lowp float props_pad1;
|
||||
highp vec4 u_icon_fill_color;
|
||||
highp vec4 u_icon_halo_color;
|
||||
highp float u_icon_opacity;
|
||||
highp float u_icon_halo_width;
|
||||
highp float u_icon_halo_blur;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
out vec2 v_tex;
|
||||
out float v_fade_opacity;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
uniform lowp float u_opacity_t;
|
||||
layout (location = 5) in lowp vec2 a_opacity;
|
||||
out lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
highp float u_opacity = u_is_text_prop ? u_text_opacity : u_icon_opacity;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
opacity = unpack_mix_vec2(a_opacity, u_opacity_t);
|
||||
#else
|
||||
@@ -85,7 +117,7 @@ lowp float opacity = u_opacity;
|
||||
|
||||
size *= perspective_ratio;
|
||||
|
||||
float fontScale = u_is_text ? size / 24.0 : size;
|
||||
float fontScale = u_is_text_prop ? size / 24.0 : size;
|
||||
|
||||
highp float symbol_rotation = 0.0;
|
||||
if (u_rotate_symbol) {
|
||||
@@ -107,22 +139,44 @@ lowp float opacity = u_opacity;
|
||||
|
||||
v_tex = a_tex / u_texsize;
|
||||
vec2 fade_opacity = unpack_opacity(a_fade_opacity);
|
||||
float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change;
|
||||
float fade_change = fade_opacity[1] > 0.5 ? u_symbol_fade_change : -u_symbol_fade_change;
|
||||
v_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change));
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(uniform sampler2D u_texture;
|
||||
|
||||
layout (std140) uniform SymbolTilePropsUBO {
|
||||
bool u_is_text;
|
||||
bool u_is_halo;
|
||||
highp float u_gamma_scale;
|
||||
lowp float tileprops_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform SymbolEvaluatedPropsUBO {
|
||||
highp vec4 u_text_fill_color;
|
||||
highp vec4 u_text_halo_color;
|
||||
highp float u_text_opacity;
|
||||
highp float u_text_halo_width;
|
||||
highp float u_text_halo_blur;
|
||||
lowp float props_pad1;
|
||||
highp vec4 u_icon_fill_color;
|
||||
highp vec4 u_icon_halo_color;
|
||||
highp float u_icon_opacity;
|
||||
highp float u_icon_halo_width;
|
||||
highp float u_icon_halo_blur;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
in vec2 v_tex;
|
||||
in float v_fade_opacity;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
in lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
highp float u_opacity = u_is_text ? u_text_opacity : u_icon_opacity;
|
||||
|
||||
#ifdef HAS_UNIFORM_u_opacity
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
|
||||
@@ -1,261 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::SymbolSDFIconProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "SymbolSDFIconProgram";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec4 a_pos_offset;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
layout (location = 2) in vec4 a_pixeloffset;
|
||||
layout (location = 3) in vec3 a_projected_pos;
|
||||
layout (location = 4) in float a_fade_opacity;
|
||||
|
||||
// contents of a_size vary based on the type of property value
|
||||
// used for {text,icon}-size.
|
||||
// For constants, a_size is disabled.
|
||||
// For source functions, we bind only one value per vertex: the value of {text,icon}-size evaluated for the current feature.
|
||||
// For composite functions:
|
||||
// [ text-size(lowerZoomStop, feature),
|
||||
// text-size(upperZoomStop, feature) ]
|
||||
uniform bool u_is_size_zoom_constant;
|
||||
uniform bool u_is_size_feature_constant;
|
||||
uniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function
|
||||
uniform highp float u_size; // used when size is both zoom and feature constant
|
||||
uniform mat4 u_matrix;
|
||||
uniform mat4 u_label_plane_matrix;
|
||||
uniform mat4 u_coord_matrix;
|
||||
uniform bool u_is_text;
|
||||
uniform bool u_pitch_with_map;
|
||||
uniform highp float u_pitch;
|
||||
uniform bool u_rotate_symbol;
|
||||
uniform highp float u_aspect_ratio;
|
||||
uniform highp float u_camera_to_center_distance;
|
||||
uniform float u_fade_change;
|
||||
uniform vec2 u_texsize;
|
||||
|
||||
out vec2 v_data0;
|
||||
out vec3 v_data1;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_fill_color
|
||||
uniform lowp float u_fill_color_t;
|
||||
layout (location = 5) in highp vec4 a_fill_color;
|
||||
out highp vec4 fill_color;
|
||||
#else
|
||||
uniform highp vec4 u_fill_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_color
|
||||
uniform lowp float u_halo_color_t;
|
||||
layout (location = 6) in highp vec4 a_halo_color;
|
||||
out highp vec4 halo_color;
|
||||
#else
|
||||
uniform highp vec4 u_halo_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
uniform lowp float u_opacity_t;
|
||||
layout (location = 7) in lowp vec2 a_opacity;
|
||||
out lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_width
|
||||
uniform lowp float u_halo_width_t;
|
||||
layout (location = 8) in lowp vec2 a_halo_width;
|
||||
out lowp float halo_width;
|
||||
#else
|
||||
uniform lowp float u_halo_width;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_blur
|
||||
uniform lowp float u_halo_blur_t;
|
||||
layout (location = 9) in lowp vec2 a_halo_blur;
|
||||
out lowp float halo_blur;
|
||||
#else
|
||||
uniform lowp float u_halo_blur;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef HAS_UNIFORM_u_fill_color
|
||||
fill_color = unpack_mix_color(a_fill_color, u_fill_color_t);
|
||||
#else
|
||||
highp vec4 fill_color = u_fill_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_color
|
||||
halo_color = unpack_mix_color(a_halo_color, u_halo_color_t);
|
||||
#else
|
||||
highp vec4 halo_color = u_halo_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
opacity = unpack_mix_vec2(a_opacity, u_opacity_t);
|
||||
#else
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_width
|
||||
halo_width = unpack_mix_vec2(a_halo_width, u_halo_width_t);
|
||||
#else
|
||||
lowp float halo_width = u_halo_width;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_blur
|
||||
halo_blur = unpack_mix_vec2(a_halo_blur, u_halo_blur_t);
|
||||
#else
|
||||
lowp float halo_blur = u_halo_blur;
|
||||
#endif
|
||||
|
||||
vec2 a_pos = a_pos_offset.xy;
|
||||
vec2 a_offset = a_pos_offset.zw;
|
||||
|
||||
vec2 a_tex = a_data.xy;
|
||||
vec2 a_size = a_data.zw;
|
||||
|
||||
float a_size_min = floor(a_size[0] * 0.5);
|
||||
vec2 a_pxoffset = a_pixeloffset.xy;
|
||||
|
||||
highp float segment_angle = -a_projected_pos[2];
|
||||
float size;
|
||||
|
||||
if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {
|
||||
size = mix(a_size_min, a_size[1], u_size_t) / 128.0;
|
||||
} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {
|
||||
size = a_size_min / 128.0;
|
||||
} else {
|
||||
size = u_size;
|
||||
}
|
||||
|
||||
vec4 projectedPoint = u_matrix * vec4(a_pos, 0, 1);
|
||||
highp float camera_to_anchor_distance = projectedPoint.w;
|
||||
// If the label is pitched with the map, layout is done in pitched space,
|
||||
// which makes labels in the distance smaller relative to viewport space.
|
||||
// We counteract part of that effect by multiplying by the perspective ratio.
|
||||
// If the label isn't pitched with the map, we do layout in viewport space,
|
||||
// which makes labels in the distance larger relative to the features around
|
||||
// them. We counteract part of that effect by dividing by the perspective ratio.
|
||||
highp float distance_ratio = u_pitch_with_map ?
|
||||
camera_to_anchor_distance / u_camera_to_center_distance :
|
||||
u_camera_to_center_distance / camera_to_anchor_distance;
|
||||
highp float perspective_ratio = clamp(
|
||||
0.5 + 0.5 * distance_ratio,
|
||||
0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles
|
||||
4.0);
|
||||
|
||||
size *= perspective_ratio;
|
||||
|
||||
float fontScale = u_is_text ? size / 24.0 : size;
|
||||
|
||||
highp float symbol_rotation = 0.0;
|
||||
if (u_rotate_symbol) {
|
||||
// Point labels with 'rotation-alignment: map' are horizontal with respect to tile units
|
||||
// To figure out that angle in projected space, we draw a short horizontal line in tile
|
||||
// space, project it, and measure its angle in projected space.
|
||||
vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), 0, 1);
|
||||
|
||||
vec2 a = projectedPoint.xy / projectedPoint.w;
|
||||
vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w;
|
||||
|
||||
symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x);
|
||||
}
|
||||
|
||||
highp float angle_sin = sin(segment_angle + symbol_rotation);
|
||||
highp float angle_cos = cos(segment_angle + symbol_rotation);
|
||||
mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);
|
||||
|
||||
vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0);
|
||||
gl_Position = u_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale + a_pxoffset), 0.0, 1.0);
|
||||
float gamma_scale = gl_Position.w;
|
||||
|
||||
vec2 fade_opacity = unpack_opacity(a_fade_opacity);
|
||||
float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change;
|
||||
float interpolated_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change));
|
||||
|
||||
v_data0 = a_tex / u_texsize;
|
||||
v_data1 = vec3(gamma_scale, size, interpolated_fade_opacity);
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(#define SDF_PX 8.0
|
||||
|
||||
uniform bool u_is_halo;
|
||||
uniform sampler2D u_texture;
|
||||
uniform highp float u_gamma_scale;
|
||||
uniform lowp float u_device_pixel_ratio;
|
||||
uniform bool u_is_text;
|
||||
|
||||
in vec2 v_data0;
|
||||
in vec3 v_data1;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_fill_color
|
||||
in highp vec4 fill_color;
|
||||
#else
|
||||
uniform highp vec4 u_fill_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_color
|
||||
in highp vec4 halo_color;
|
||||
#else
|
||||
uniform highp vec4 u_halo_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
in lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_width
|
||||
in lowp float halo_width;
|
||||
#else
|
||||
uniform lowp float u_halo_width;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_blur
|
||||
in lowp float halo_blur;
|
||||
#else
|
||||
uniform lowp float u_halo_blur;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifdef HAS_UNIFORM_u_fill_color
|
||||
highp vec4 fill_color = u_fill_color;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_halo_color
|
||||
highp vec4 halo_color = u_halo_color;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_opacity
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_halo_width
|
||||
lowp float halo_width = u_halo_width;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_halo_blur
|
||||
lowp float halo_blur = u_halo_blur;
|
||||
#endif
|
||||
|
||||
float EDGE_GAMMA = 0.105 / u_device_pixel_ratio;
|
||||
|
||||
vec2 tex = v_data0.xy;
|
||||
float gamma_scale = v_data1.x;
|
||||
float size = v_data1.y;
|
||||
float fade_opacity = v_data1[2];
|
||||
|
||||
float fontScale = u_is_text ? size / 24.0 : size;
|
||||
|
||||
lowp vec4 color = fill_color;
|
||||
highp float gamma = EDGE_GAMMA / (fontScale * u_gamma_scale);
|
||||
lowp float buff = (256.0 - 64.0) / 256.0;
|
||||
if (u_is_halo) {
|
||||
color = halo_color;
|
||||
gamma = (halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_gamma_scale);
|
||||
buff = (6.0 - halo_width / fontScale) / SDF_PX;
|
||||
}
|
||||
|
||||
lowp float dist = texture(u_texture, tex).a;
|
||||
highp float gamma_scaled = gamma * gamma_scale;
|
||||
highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);
|
||||
|
||||
fragColor = color * (alpha * opacity * fade_opacity);
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
fragColor = vec4(1.0);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -1,261 +0,0 @@
|
||||
// Generated code, do not modify this file!
|
||||
#pragma once
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::SymbolSDFTextProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "SymbolSDFTextProgram";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec4 a_pos_offset;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
layout (location = 2) in vec4 a_pixeloffset;
|
||||
layout (location = 3) in vec3 a_projected_pos;
|
||||
layout (location = 4) in float a_fade_opacity;
|
||||
|
||||
// contents of a_size vary based on the type of property value
|
||||
// used for {text,icon}-size.
|
||||
// For constants, a_size is disabled.
|
||||
// For source functions, we bind only one value per vertex: the value of {text,icon}-size evaluated for the current feature.
|
||||
// For composite functions:
|
||||
// [ text-size(lowerZoomStop, feature),
|
||||
// text-size(upperZoomStop, feature) ]
|
||||
uniform bool u_is_size_zoom_constant;
|
||||
uniform bool u_is_size_feature_constant;
|
||||
uniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function
|
||||
uniform highp float u_size; // used when size is both zoom and feature constant
|
||||
uniform mat4 u_matrix;
|
||||
uniform mat4 u_label_plane_matrix;
|
||||
uniform mat4 u_coord_matrix;
|
||||
uniform bool u_is_text;
|
||||
uniform bool u_pitch_with_map;
|
||||
uniform highp float u_pitch;
|
||||
uniform bool u_rotate_symbol;
|
||||
uniform highp float u_aspect_ratio;
|
||||
uniform highp float u_camera_to_center_distance;
|
||||
uniform float u_fade_change;
|
||||
uniform vec2 u_texsize;
|
||||
|
||||
out vec2 v_data0;
|
||||
out vec3 v_data1;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_fill_color
|
||||
uniform lowp float u_fill_color_t;
|
||||
layout (location = 5) in highp vec4 a_fill_color;
|
||||
out highp vec4 fill_color;
|
||||
#else
|
||||
uniform highp vec4 u_fill_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_color
|
||||
uniform lowp float u_halo_color_t;
|
||||
layout (location = 6) in highp vec4 a_halo_color;
|
||||
out highp vec4 halo_color;
|
||||
#else
|
||||
uniform highp vec4 u_halo_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
uniform lowp float u_opacity_t;
|
||||
layout (location = 7) in lowp vec2 a_opacity;
|
||||
out lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_width
|
||||
uniform lowp float u_halo_width_t;
|
||||
layout (location = 8) in lowp vec2 a_halo_width;
|
||||
out lowp float halo_width;
|
||||
#else
|
||||
uniform lowp float u_halo_width;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_blur
|
||||
uniform lowp float u_halo_blur_t;
|
||||
layout (location = 9) in lowp vec2 a_halo_blur;
|
||||
out lowp float halo_blur;
|
||||
#else
|
||||
uniform lowp float u_halo_blur;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifndef HAS_UNIFORM_u_fill_color
|
||||
fill_color = unpack_mix_color(a_fill_color, u_fill_color_t);
|
||||
#else
|
||||
highp vec4 fill_color = u_fill_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_color
|
||||
halo_color = unpack_mix_color(a_halo_color, u_halo_color_t);
|
||||
#else
|
||||
highp vec4 halo_color = u_halo_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
opacity = unpack_mix_vec2(a_opacity, u_opacity_t);
|
||||
#else
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_width
|
||||
halo_width = unpack_mix_vec2(a_halo_width, u_halo_width_t);
|
||||
#else
|
||||
lowp float halo_width = u_halo_width;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_blur
|
||||
halo_blur = unpack_mix_vec2(a_halo_blur, u_halo_blur_t);
|
||||
#else
|
||||
lowp float halo_blur = u_halo_blur;
|
||||
#endif
|
||||
|
||||
vec2 a_pos = a_pos_offset.xy;
|
||||
vec2 a_offset = a_pos_offset.zw;
|
||||
|
||||
vec2 a_tex = a_data.xy;
|
||||
vec2 a_size = a_data.zw;
|
||||
|
||||
float a_size_min = floor(a_size[0] * 0.5);
|
||||
vec2 a_pxoffset = a_pixeloffset.xy;
|
||||
|
||||
highp float segment_angle = -a_projected_pos[2];
|
||||
float size;
|
||||
|
||||
if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {
|
||||
size = mix(a_size_min, a_size[1], u_size_t) / 128.0;
|
||||
} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {
|
||||
size = a_size_min / 128.0;
|
||||
} else {
|
||||
size = u_size;
|
||||
}
|
||||
|
||||
vec4 projectedPoint = u_matrix * vec4(a_pos, 0, 1);
|
||||
highp float camera_to_anchor_distance = projectedPoint.w;
|
||||
// If the label is pitched with the map, layout is done in pitched space,
|
||||
// which makes labels in the distance smaller relative to viewport space.
|
||||
// We counteract part of that effect by multiplying by the perspective ratio.
|
||||
// If the label isn't pitched with the map, we do layout in viewport space,
|
||||
// which makes labels in the distance larger relative to the features around
|
||||
// them. We counteract part of that effect by dividing by the perspective ratio.
|
||||
highp float distance_ratio = u_pitch_with_map ?
|
||||
camera_to_anchor_distance / u_camera_to_center_distance :
|
||||
u_camera_to_center_distance / camera_to_anchor_distance;
|
||||
highp float perspective_ratio = clamp(
|
||||
0.5 + 0.5 * distance_ratio,
|
||||
0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles
|
||||
4.0);
|
||||
|
||||
size *= perspective_ratio;
|
||||
|
||||
float fontScale = u_is_text ? size / 24.0 : size;
|
||||
|
||||
highp float symbol_rotation = 0.0;
|
||||
if (u_rotate_symbol) {
|
||||
// Point labels with 'rotation-alignment: map' are horizontal with respect to tile units
|
||||
// To figure out that angle in projected space, we draw a short horizontal line in tile
|
||||
// space, project it, and measure its angle in projected space.
|
||||
vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), 0, 1);
|
||||
|
||||
vec2 a = projectedPoint.xy / projectedPoint.w;
|
||||
vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w;
|
||||
|
||||
symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x);
|
||||
}
|
||||
|
||||
highp float angle_sin = sin(segment_angle + symbol_rotation);
|
||||
highp float angle_cos = cos(segment_angle + symbol_rotation);
|
||||
mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);
|
||||
|
||||
vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0);
|
||||
gl_Position = u_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale + a_pxoffset), 0.0, 1.0);
|
||||
float gamma_scale = gl_Position.w;
|
||||
|
||||
vec2 fade_opacity = unpack_opacity(a_fade_opacity);
|
||||
float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change;
|
||||
float interpolated_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change));
|
||||
|
||||
v_data0 = a_tex / u_texsize;
|
||||
v_data1 = vec3(gamma_scale, size, interpolated_fade_opacity);
|
||||
}
|
||||
)";
|
||||
static constexpr const char* fragment = R"(#define SDF_PX 8.0
|
||||
|
||||
uniform bool u_is_halo;
|
||||
uniform sampler2D u_texture;
|
||||
uniform highp float u_gamma_scale;
|
||||
uniform lowp float u_device_pixel_ratio;
|
||||
uniform bool u_is_text;
|
||||
|
||||
in vec2 v_data0;
|
||||
in vec3 v_data1;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_fill_color
|
||||
in highp vec4 fill_color;
|
||||
#else
|
||||
uniform highp vec4 u_fill_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_color
|
||||
in highp vec4 halo_color;
|
||||
#else
|
||||
uniform highp vec4 u_halo_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
in lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_width
|
||||
in lowp float halo_width;
|
||||
#else
|
||||
uniform lowp float u_halo_width;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_blur
|
||||
in lowp float halo_blur;
|
||||
#else
|
||||
uniform lowp float u_halo_blur;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifdef HAS_UNIFORM_u_fill_color
|
||||
highp vec4 fill_color = u_fill_color;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_halo_color
|
||||
highp vec4 halo_color = u_halo_color;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_opacity
|
||||
lowp float opacity = u_opacity;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_halo_width
|
||||
lowp float halo_width = u_halo_width;
|
||||
#endif
|
||||
#ifdef HAS_UNIFORM_u_halo_blur
|
||||
lowp float halo_blur = u_halo_blur;
|
||||
#endif
|
||||
|
||||
float EDGE_GAMMA = 0.105 / u_device_pixel_ratio;
|
||||
|
||||
vec2 tex = v_data0.xy;
|
||||
float gamma_scale = v_data1.x;
|
||||
float size = v_data1.y;
|
||||
float fade_opacity = v_data1[2];
|
||||
|
||||
float fontScale = u_is_text ? size / 24.0 : size;
|
||||
|
||||
lowp vec4 color = fill_color;
|
||||
highp float gamma = EDGE_GAMMA / (fontScale * u_gamma_scale);
|
||||
lowp float buff = (256.0 - 64.0) / 256.0;
|
||||
if (u_is_halo) {
|
||||
color = halo_color;
|
||||
gamma = (halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_gamma_scale);
|
||||
buff = (6.0 - halo_width / fontScale) / SDF_PX;
|
||||
}
|
||||
|
||||
lowp float dist = texture(u_texture, tex).a;
|
||||
highp float gamma_scaled = gamma * gamma_scale;
|
||||
highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);
|
||||
|
||||
fragColor = color * (alpha * opacity * fade_opacity);
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
fragColor = vec4(1.0);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -6,8 +6,8 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::SymbolTextAndIconProgram, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "SymbolTextAndIconProgram";
|
||||
struct ShaderSource<BuiltIn::SymbolTextAndIconShader, gfx::Backend::Type::OpenGL> {
|
||||
static constexpr const char* name = "SymbolTextAndIconShader";
|
||||
static constexpr const char* vertex = R"(layout (location = 0) in vec4 a_pos_offset;
|
||||
layout (location = 1) in vec4 a_data;
|
||||
layout (location = 2) in vec3 a_projected_pos;
|
||||
@@ -20,63 +20,90 @@ layout (location = 3) in float a_fade_opacity;
|
||||
// For composite functions:
|
||||
// [ text-size(lowerZoomStop, feature),
|
||||
// text-size(upperZoomStop, feature) ]
|
||||
uniform bool u_is_size_zoom_constant;
|
||||
uniform bool u_is_size_feature_constant;
|
||||
uniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function
|
||||
uniform highp float u_size; // used when size is both zoom and feature constant
|
||||
uniform mat4 u_matrix;
|
||||
uniform mat4 u_label_plane_matrix;
|
||||
uniform mat4 u_coord_matrix;
|
||||
uniform bool u_is_text;
|
||||
uniform bool u_pitch_with_map;
|
||||
uniform highp float u_pitch;
|
||||
uniform bool u_rotate_symbol;
|
||||
uniform highp float u_aspect_ratio;
|
||||
uniform highp float u_camera_to_center_distance;
|
||||
uniform float u_fade_change;
|
||||
uniform vec2 u_texsize;
|
||||
uniform vec2 u_texsize_icon;
|
||||
|
||||
layout (std140) uniform GlobalPaintParamsUBO {
|
||||
highp vec2 u_pattern_atlas_texsize;
|
||||
highp vec2 u_units_to_pixels;
|
||||
highp vec2 u_world_size;
|
||||
highp float u_camera_to_center_distance;
|
||||
highp float u_symbol_fade_change;
|
||||
highp float u_aspect_ratio;
|
||||
highp float u_pixel_ratio;
|
||||
highp float u_map_zoom;
|
||||
lowp float global_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform SymbolDrawableUBO {
|
||||
highp mat4 u_matrix;
|
||||
highp mat4 u_label_plane_matrix;
|
||||
highp mat4 u_coord_matrix;
|
||||
|
||||
highp vec2 u_texsize;
|
||||
highp vec2 u_texsize_icon;
|
||||
|
||||
bool u_is_text_prop;
|
||||
bool u_rotate_symbol;
|
||||
bool u_pitch_with_map;
|
||||
bool u_is_size_zoom_constant;
|
||||
bool u_is_size_feature_constant;
|
||||
|
||||
highp float u_size_t; // used to interpolate between zoom stops when size is a composite function
|
||||
highp float u_size; // used when size is both zoom and feature constant
|
||||
|
||||
// Interpolations
|
||||
highp float u_fill_color_t;
|
||||
highp float u_halo_color_t;
|
||||
highp float u_opacity_t;
|
||||
highp float u_halo_width_t;
|
||||
highp float u_halo_blur_t;
|
||||
};
|
||||
|
||||
layout (std140) uniform SymbolEvaluatedPropsUBO {
|
||||
highp vec4 u_text_fill_color;
|
||||
highp vec4 u_text_halo_color;
|
||||
highp float u_text_opacity;
|
||||
highp float u_text_halo_width;
|
||||
highp float u_text_halo_blur;
|
||||
lowp float props_pad1;
|
||||
highp vec4 u_icon_fill_color;
|
||||
highp vec4 u_icon_halo_color;
|
||||
highp float u_icon_opacity;
|
||||
highp float u_icon_halo_width;
|
||||
highp float u_icon_halo_blur;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
out vec4 v_data0;
|
||||
out vec4 v_data1;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_fill_color
|
||||
uniform lowp float u_fill_color_t;
|
||||
layout (location = 4) in highp vec4 a_fill_color;
|
||||
out highp vec4 fill_color;
|
||||
#else
|
||||
uniform highp vec4 u_fill_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_color
|
||||
uniform lowp float u_halo_color_t;
|
||||
layout (location = 5) in highp vec4 a_halo_color;
|
||||
out highp vec4 halo_color;
|
||||
#else
|
||||
uniform highp vec4 u_halo_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
uniform lowp float u_opacity_t;
|
||||
layout (location = 6) in lowp vec2 a_opacity;
|
||||
out lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_width
|
||||
uniform lowp float u_halo_width_t;
|
||||
layout (location = 7) in lowp vec2 a_halo_width;
|
||||
out lowp float halo_width;
|
||||
#else
|
||||
uniform lowp float u_halo_width;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_blur
|
||||
uniform lowp float u_halo_blur_t;
|
||||
layout (location = 8) in lowp vec2 a_halo_blur;
|
||||
out lowp float halo_blur;
|
||||
#else
|
||||
uniform lowp float u_halo_blur;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
highp vec4 u_fill_color = u_is_text_prop ? u_text_fill_color : u_icon_fill_color;
|
||||
highp vec4 u_halo_color = u_is_text_prop ? u_text_halo_color : u_icon_halo_color;
|
||||
highp float u_opacity = u_is_text_prop ? u_text_opacity : u_icon_opacity;
|
||||
highp float u_halo_width = u_is_text_prop ? u_text_halo_width : u_icon_halo_width;
|
||||
highp float u_halo_blur = u_is_text_prop ? u_text_halo_blur : u_icon_halo_blur;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_fill_color
|
||||
fill_color = unpack_mix_color(a_fill_color, u_fill_color_t);
|
||||
#else
|
||||
@@ -165,7 +192,7 @@ lowp float halo_blur = u_halo_blur;
|
||||
float gamma_scale = gl_Position.w;
|
||||
|
||||
vec2 fade_opacity = unpack_opacity(a_fade_opacity);
|
||||
float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change;
|
||||
float fade_change = fade_opacity[1] > 0.5 ? u_symbol_fade_change : -u_symbol_fade_change;
|
||||
float interpolated_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change));
|
||||
|
||||
v_data0.xy = a_tex / u_texsize;
|
||||
@@ -178,42 +205,57 @@ lowp float halo_blur = u_halo_blur;
|
||||
#define SDF 1.0
|
||||
#define ICON 0.0
|
||||
|
||||
uniform bool u_is_halo;
|
||||
layout (std140) uniform SymbolTilePropsUBO {
|
||||
bool u_is_text;
|
||||
bool u_is_halo;
|
||||
highp float u_gamma_scale;
|
||||
lowp float tileprops_pad1;
|
||||
};
|
||||
|
||||
layout (std140) uniform SymbolEvaluatedPropsUBO {
|
||||
highp vec4 u_text_fill_color;
|
||||
highp vec4 u_text_halo_color;
|
||||
highp float u_text_opacity;
|
||||
highp float u_text_halo_width;
|
||||
highp float u_text_halo_blur;
|
||||
lowp float props_pad1;
|
||||
highp vec4 u_icon_fill_color;
|
||||
highp vec4 u_icon_halo_color;
|
||||
highp float u_icon_opacity;
|
||||
highp float u_icon_halo_width;
|
||||
highp float u_icon_halo_blur;
|
||||
lowp float props_pad2;
|
||||
};
|
||||
|
||||
uniform sampler2D u_texture;
|
||||
uniform sampler2D u_texture_icon;
|
||||
uniform highp float u_gamma_scale;
|
||||
uniform lowp float u_device_pixel_ratio;
|
||||
|
||||
in vec4 v_data0;
|
||||
in vec4 v_data1;
|
||||
|
||||
#ifndef HAS_UNIFORM_u_fill_color
|
||||
in highp vec4 fill_color;
|
||||
#else
|
||||
uniform highp vec4 u_fill_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_color
|
||||
in highp vec4 halo_color;
|
||||
#else
|
||||
uniform highp vec4 u_halo_color;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
in lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_width
|
||||
in lowp float halo_width;
|
||||
#else
|
||||
uniform lowp float u_halo_width;
|
||||
#endif
|
||||
#ifndef HAS_UNIFORM_u_halo_blur
|
||||
in lowp float halo_blur;
|
||||
#else
|
||||
uniform lowp float u_halo_blur;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
highp vec4 u_fill_color = u_is_text ? u_text_fill_color : u_icon_fill_color;
|
||||
highp vec4 u_halo_color = u_is_text ? u_text_halo_color : u_icon_halo_color;
|
||||
highp float u_opacity = u_is_text ? u_text_opacity : u_icon_opacity;
|
||||
highp float u_halo_width = u_is_text ? u_text_halo_width : u_icon_halo_width;
|
||||
highp float u_halo_blur = u_is_text ? u_text_halo_blur : u_icon_halo_blur;
|
||||
|
||||
#ifdef HAS_UNIFORM_u_fill_color
|
||||
highp vec4 fill_color = u_fill_color;
|
||||
#endif
|
||||
@@ -245,7 +287,7 @@ lowp float halo_blur = u_halo_blur;
|
||||
|
||||
vec2 tex = v_data0.xy;
|
||||
|
||||
float EDGE_GAMMA = 0.105 / u_device_pixel_ratio;
|
||||
float EDGE_GAMMA = 0.105 / DEVICE_PIXEL_RATIO;
|
||||
|
||||
float gamma_scale = v_data1.x;
|
||||
float size = v_data1.y;
|
||||
|
||||
@@ -3,61 +3,36 @@
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
#if MLN_RENDER_BACKEND_OPENGL
|
||||
#include <mbgl/shaders/gl/drawable_background.hpp>
|
||||
#include <mbgl/shaders/gl/drawable_background_pattern.hpp>
|
||||
#include <mbgl/shaders/gl/drawable_circle.hpp>
|
||||
#include <mbgl/shaders/gl/drawable_collision_box.hpp>
|
||||
#include <mbgl/shaders/gl/drawable_collision_circle.hpp>
|
||||
#include <mbgl/shaders/gl/drawable_custom_geometry.hpp>
|
||||
#include <mbgl/shaders/gl/drawable_custom_symbol_icon.hpp>
|
||||
#include <mbgl/shaders/gl/drawable_debug.hpp>
|
||||
#include <mbgl/shaders/gl/drawable_fill.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_triangulated.hpp>
|
||||
#include <mbgl/shaders/gl/drawable_fill_extrusion.hpp>
|
||||
#include <mbgl/shaders/gl/drawable_fill_extrusion_pattern.hpp>
|
||||
#include <mbgl/shaders/gl/drawable_heatmap.hpp>
|
||||
#include <mbgl/shaders/gl/drawable_heatmap_texture.hpp>
|
||||
#include <mbgl/shaders/gl/drawable_hillshade_prepare.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_location_indicator.hpp>
|
||||
#include <mbgl/shaders/gl/drawable_location_indicator_textured.hpp>
|
||||
#include <mbgl/shaders/gl/drawable_line_sdf.hpp>
|
||||
#include <mbgl/shaders/gl/drawable_raster.hpp>
|
||||
#include <mbgl/shaders/gl/drawable_symbol_icon.hpp>
|
||||
#include <mbgl/shaders/gl/drawable_symbol_sdf.hpp>
|
||||
#include <mbgl/shaders/gl/drawable_symbol_text_and_icon.hpp>
|
||||
#include <mbgl/shaders/gl/drawable_wide_vector.hpp>
|
||||
#include <mbgl/shaders/gl/prelude.hpp>
|
||||
#include <mbgl/shaders/gl/clipping_mask.hpp>
|
||||
#include <mbgl/shaders/gl/background.hpp>
|
||||
#include <mbgl/shaders/gl/background_pattern.hpp>
|
||||
#include <mbgl/shaders/gl/circle.hpp>
|
||||
#include <mbgl/shaders/gl/clipping_mask.hpp>
|
||||
#include <mbgl/shaders/gl/collision_box.hpp>
|
||||
#include <mbgl/shaders/gl/collision_circle.hpp>
|
||||
#include <mbgl/shaders/gl/custom_geometry.hpp>
|
||||
#include <mbgl/shaders/gl/custom_symbol_icon.hpp>
|
||||
#include <mbgl/shaders/gl/debug.hpp>
|
||||
#include <mbgl/shaders/gl/fill_extrusion_pattern.hpp>
|
||||
#include <mbgl/shaders/gl/fill_extrusion.hpp>
|
||||
#include <mbgl/shaders/gl/fill_outline_pattern.hpp>
|
||||
#include <mbgl/shaders/gl/fill.hpp>
|
||||
#include <mbgl/shaders/gl/fill_outline.hpp>
|
||||
#include <mbgl/shaders/gl/fill_pattern.hpp>
|
||||
#include <mbgl/shaders/gl/fill.hpp>
|
||||
#include <mbgl/shaders/gl/heatmap_texture.hpp>
|
||||
#include <mbgl/shaders/gl/fill_outline_pattern.hpp>
|
||||
#include <mbgl/shaders/gl/fill_outline_triangulated.hpp>
|
||||
#include <mbgl/shaders/gl/fill_extrusion.hpp>
|
||||
#include <mbgl/shaders/gl/fill_extrusion_pattern.hpp>
|
||||
#include <mbgl/shaders/gl/heatmap.hpp>
|
||||
#include <mbgl/shaders/gl/heatmap_texture.hpp>
|
||||
#include <mbgl/shaders/gl/hillshade_prepare.hpp>
|
||||
#include <mbgl/shaders/gl/hillshade.hpp>
|
||||
#include <mbgl/shaders/gl/line.hpp>
|
||||
#include <mbgl/shaders/gl/line_gradient.hpp>
|
||||
#include <mbgl/shaders/gl/line_pattern.hpp>
|
||||
#include <mbgl/shaders/gl/location_indicator.hpp>
|
||||
#include <mbgl/shaders/gl/location_indicator_textured.hpp>
|
||||
#include <mbgl/shaders/gl/line_sdf.hpp>
|
||||
#include <mbgl/shaders/gl/line.hpp>
|
||||
#include <mbgl/shaders/gl/raster.hpp>
|
||||
#include <mbgl/shaders/gl/symbol_icon.hpp>
|
||||
#include <mbgl/shaders/gl/symbol_sdf_text.hpp>
|
||||
#include <mbgl/shaders/gl/symbol_sdf_icon.hpp>
|
||||
#include <mbgl/shaders/gl/symbol_sdf.hpp>
|
||||
#include <mbgl/shaders/gl/symbol_text_and_icon.hpp>
|
||||
#include <mbgl/shaders/gl/wide_vector.hpp>
|
||||
#endif
|
||||
|
||||
@@ -9,6 +9,8 @@ namespace shaders {
|
||||
/// source code for the desired program and graphics back-end.
|
||||
enum class BuiltIn {
|
||||
None,
|
||||
Prelude,
|
||||
ClippingMaskProgram,
|
||||
BackgroundShader,
|
||||
BackgroundPatternShader,
|
||||
CircleShader,
|
||||
@@ -38,34 +40,7 @@ enum class BuiltIn {
|
||||
SymbolIconShader,
|
||||
SymbolSDFIconShader,
|
||||
SymbolTextAndIconShader,
|
||||
WideVectorShader,
|
||||
Prelude,
|
||||
BackgroundProgram,
|
||||
BackgroundPatternProgram,
|
||||
CircleProgram,
|
||||
ClippingMaskProgram,
|
||||
CollisionBoxProgram,
|
||||
CollisionCircleProgram,
|
||||
DebugProgram,
|
||||
FillExtrusionPatternProgram,
|
||||
FillExtrusionProgram,
|
||||
FillOutlinePatternProgram,
|
||||
FillOutlineProgram,
|
||||
FillPatternProgram,
|
||||
FillProgram,
|
||||
HeatmapTextureProgram,
|
||||
HeatmapProgram,
|
||||
HillshadePrepareProgram,
|
||||
HillshadeProgram,
|
||||
LineGradientProgram,
|
||||
LinePatternProgram,
|
||||
LineSDFProgram,
|
||||
LineProgram,
|
||||
RasterProgram,
|
||||
SymbolIconProgram,
|
||||
SymbolSDFTextProgram,
|
||||
SymbolSDFIconProgram,
|
||||
SymbolTextAndIconProgram
|
||||
WideVectorShader
|
||||
};
|
||||
|
||||
/// @brief Select shader source based on a program type and a desired
|
||||
|
||||
Reference in New Issue
Block a user