Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion include/mbgl/shaders/gl/symbol_icon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ layout (std140) uniform SymbolDrawableUBO {
bool u_pitch_with_map;
bool u_is_size_zoom_constant;
bool u_is_size_feature_constant;
bool u_is_offset;

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
Expand Down Expand Up @@ -115,7 +116,9 @@ lowp float opacity = u_opacity;
0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles
4.0);

size *= perspective_ratio;
if (!u_is_offset) {
size *= perspective_ratio;
}

float fontScale = u_is_text_prop ? size / 24.0 : size;

Expand Down
5 changes: 4 additions & 1 deletion include/mbgl/shaders/gl/symbol_sdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ layout (std140) uniform SymbolDrawableUBO {
bool u_pitch_with_map;
bool u_is_size_zoom_constant;
bool u_is_size_feature_constant;
bool u_is_offset;

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
Expand Down Expand Up @@ -167,7 +168,9 @@ lowp float halo_blur = u_halo_blur;
0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles
4.0);

size *= perspective_ratio;
if (!u_is_offset) {
size *= perspective_ratio;
}

float fontScale = u_is_text_prop ? size / 24.0 : size;

Expand Down
5 changes: 4 additions & 1 deletion include/mbgl/shaders/gl/symbol_text_and_icon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ layout (std140) uniform SymbolDrawableUBO {
bool u_pitch_with_map;
bool u_is_size_zoom_constant;
bool u_is_size_feature_constant;
bool u_is_offset;

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
Expand Down Expand Up @@ -166,7 +167,9 @@ lowp float halo_blur = u_halo_blur;
0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles
4.0);

size *= perspective_ratio;
if (!u_is_offset) {
size *= perspective_ratio;
}

float fontScale = size / 24.0;

Expand Down
31 changes: 19 additions & 12 deletions include/mbgl/shaders/mtl/symbol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,20 @@ struct alignas(16) SymbolDrawableUBO {
/* 216 */ /*bool*/ int pitch_with_map;
/* 220 */ /*bool*/ int is_size_zoom_constant;
/* 224 */ /*bool*/ int is_size_feature_constant;
/* 228 */ /*bool*/ int is_offset;

/* 228 */ float size_t;
/* 232 */ float size;
/* 232 */ float size_t;
/* 236 */ float size;

// Interpolations
/* 236 */ float fill_color_t;
/* 240 */ float halo_color_t;
/* 244 */ float opacity_t;
/* 248 */ float halo_width_t;
/* 252 */ float halo_blur_t;
/* 256 */
/* 240 */ float fill_color_t;
/* 244 */ float halo_color_t;
/* 248 */ float opacity_t;
/* 252 */ float halo_width_t;
/* 256 */ float halo_blur_t;
/* 260 */
};
static_assert(sizeof(SymbolDrawableUBO) == 16 * 16, "wrong size");
static_assert(sizeof(SymbolDrawableUBO) == 17 * 16, "wrong size");

struct alignas(16) SymbolTilePropsUBO {
/* 0 */ /*bool*/ int is_text;
Expand Down Expand Up @@ -171,7 +172,9 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles
4.0);

size *= perspective_ratio;
if (!drawable.is_offset) {
size *= perspective_ratio;
}

const float fontScale = drawable.is_text_prop ? size / 24.0 : size;

Expand Down Expand Up @@ -348,7 +351,9 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles
4.0);

size *= perspective_ratio;
if (!drawable.is_offset) {
size *= perspective_ratio;
}

const float fontScale = drawable.is_text_prop ? size / 24.0 : size;

Expand Down Expand Up @@ -583,7 +588,9 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles
4.0);

size *= perspective_ratio;
if (!drawable.is_offset) {
size *= perspective_ratio;
}

const float fontScale = size / 24.0;

Expand Down
19 changes: 10 additions & 9 deletions include/mbgl/shaders/symbol_layer_ubo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@ struct alignas(16) SymbolDrawableUBO {
/* 216 */ /*bool*/ int pitch_with_map;
/* 220 */ /*bool*/ int is_size_zoom_constant;
/* 224 */ /*bool*/ int is_size_feature_constant;
/* 228 */ /*bool*/ int is_offset;

/* 228 */ float size_t;
/* 232 */ float size;
/* 232 */ float size_t;
/* 236 */ float size;

// Interpolations
/* 236 */ float fill_color_t;
/* 240 */ float halo_color_t;
/* 244 */ float opacity_t;
/* 248 */ float halo_width_t;
/* 252 */ float halo_blur_t;
/* 256 */
/* 240 */ float fill_color_t;
/* 244 */ float halo_color_t;
/* 248 */ float opacity_t;
/* 252 */ float halo_width_t;
/* 256 */ float halo_blur_t;
/* 260 */
};
static_assert(sizeof(SymbolDrawableUBO) == 16 * 16);
static_assert(sizeof(SymbolDrawableUBO) == 17 * 16);

struct alignas(16) SymbolTilePropsUBO {
/* 0 */ /*bool*/ int is_text;
Expand Down
15 changes: 12 additions & 3 deletions include/mbgl/shaders/vulkan/symbol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ struct SymbolDrawableUBO {
bool pitch_with_map;
bool is_size_zoom_constant;
bool is_size_feature_constant;
bool is_offset;

float size_t;
float size;
Expand Down Expand Up @@ -106,7 +107,9 @@ void main() {
0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles
4.0);

size *= perspective_ratio;
if (!drawable.is_offset) {
size *= perspective_ratio;
}

const float fontScale = drawable.is_text_prop ? size / 24.0 : size;

Expand Down Expand Up @@ -256,6 +259,7 @@ struct SymbolDrawableUBO {
bool pitch_with_map;
bool is_size_zoom_constant;
bool is_size_feature_constant;
bool is_offset;

float size_t;
float size;
Expand Down Expand Up @@ -335,7 +339,9 @@ void main() {
0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles
4.0);

size *= perspective_ratio;
if (!drawable.is_offset) {
size *= perspective_ratio;
}

const float fontScale = drawable.is_text_prop ? size / 24.0 : size;

Expand Down Expand Up @@ -563,6 +569,7 @@ struct SymbolDrawableUBO {
bool pitch_with_map;
bool is_size_zoom_constant;
bool is_size_feature_constant;
bool is_offset;

float size_t;
float size;
Expand Down Expand Up @@ -644,7 +651,9 @@ void main() {
0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles
4.0);

size *= perspective_ratio;
if (!drawable.is_offset) {
size *= perspective_ratio;
}

const float fontScale = size / 24.0;

Expand Down
13 changes: 10 additions & 3 deletions include/mbgl/shaders/webgpu/symbol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ struct SymbolDrawableUBO {
pitch_with_map: u32,
is_size_zoom_constant: u32,
is_size_feature_constant: u32,
is_offset: u32,

size_t: f32,
size: f32,
Expand Down Expand Up @@ -175,7 +176,9 @@ fn main(in: VertexInput) -> VertexOutput {
);
let perspective_ratio = clamp(0.5 + 0.5 * distance_ratio, 0.0, 4.0);

size *= perspective_ratio;
if (drawable.is_offset == 0u) {
size *= perspective_ratio;
}

let is_text = drawable.is_text_prop != 0u;
let fontScale = select(size, size / 24.0, is_text);
Expand Down Expand Up @@ -348,7 +351,9 @@ fn main(in: VertexInput) -> VertexOutput {
);
let perspective_ratio = clamp(0.5 + 0.5 * distance_ratio, 0.0, 4.0);

size *= perspective_ratio;
if (drawable.is_offset == 0u) {
size *= perspective_ratio;
}

let is_text = drawable.is_text_prop != 0u;
let fontScale = select(size, size / 24.0, is_text);
Expand Down Expand Up @@ -597,7 +602,9 @@ fn main(in: VertexInput) -> VertexOutput {
);
let perspective_ratio = clamp(0.5 + 0.5 * distance_ratio, 0.0, 4.0);

size *= perspective_ratio;
if (drawable.is_offset == 0u) {
size *= perspective_ratio;
}

let fontScale = size / 24.0;

Expand Down
Binary file modified metrics/cache-style.db
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
125 changes: 125 additions & 0 deletions metrics/integration/render-tests/icon-offset/pitched-offset/style.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
{
"version": 8,
"metadata": {
"test": {
"height": 1048
}
},
"pitch": 60,
"center": [-118.78224, 39.32157],
"zoom": 14,
"sources": {
"geojson": {
"type": "geojson",
"data": {
"type": "LineString",
"coordinates": [
[
-118.78156097142148,
39.47488496583114
],
[
-118.7823961479745,
39.28832054802072
]
]
}
}
},
"sprite": "local://sprites/almccon",
"layers": [
{
"id": "background",
"type": "background",
"layout": {"visibility": "visible"},
"paint": {"background-color": "rgba(204, 204, 204, 1)"}
},
{
"id": "streets",
"type": "line",
"source": "geojson",
"layout": {
"visibility": "visible",
"line-cap": "round",
"line-join": "round"
},
"paint": {
"line-color": "rgba(32, 32, 32, 1)",
"line-width": 150
}
},
{
"id": "road-lane-dashes-right",
"type": "line",
"source": "geojson",
"layout": {"line-cap": "round", "line-join": "round"},
"paint": {
"line-color": "hsl(0, 0%, 100%)",
"line-dasharray": [4, 12],
"line-offset": 7
}
},
{
"id": "road-lane-dashes-left",
"type": "line",
"source": "geojson",
"layout": {"line-cap": "round", "line-join": "round"},
"paint": {
"line-color": "hsl(0, 0%, 100%)",
"line-dasharray": [4, 12],
"line-offset": -7
}
},
{
"id": "road-arrows-center",
"type": "symbol",
"source": "geojson",
"layout": {
"icon-allow-overlap": true,
"icon-image": "through",
"icon-offset": [0, 0],
"icon-rotate": 90,
"icon-rotation-alignment": "map",
"icon-pitch-alignment": "map",
"icon-size": 1,
"symbol-placement": "line",
"symbol-spacing": 300
},
"paint": {"icon-opacity": 0.8}
},
{
"id": "road-arrows-right",
"type": "symbol",
"source": "geojson",
"layout": {
"icon-allow-overlap": true,
"icon-image": "through",
"icon-offset": [50.339999999999996, 0],
"icon-rotate": 90,
"icon-rotation-alignment": "map",
"icon-pitch-alignment": "map",
"icon-size": 1,
"symbol-placement": "line",
"symbol-spacing": 300
},
"paint": {"icon-opacity": 0.8}
},
{
"id": "road-arrows-left",
"type": "symbol",
"source": "geojson",
"layout": {
"icon-allow-overlap": true,
"icon-image": "through",
"icon-offset": [-53.339999999999996, 0],
"icon-rotate": 90,
"icon-rotation-alignment": "map",
"icon-pitch-alignment": "map",
"icon-size": 1,
"symbol-placement": "line",
"symbol-spacing": 300
},
"paint": {"icon-opacity": 0.8}
}
]
}
23 changes: 23 additions & 0 deletions metrics/integration/sprites/almccon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"through": {
"width": 48,
"height": 64,
"x": 531,
"y": 64,
"pixelRatio": 1
},
"through;right": {
"width": 48,
"height": 64,
"x": 579,
"y": 64,
"pixelRatio": 1
},
"through;slight_right": {
"width": 48,
"height": 64,
"x": 627,
"y": 64,
"pixelRatio": 1
}
}
Binary file added metrics/integration/sprites/almccon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading