Skip to content

Commit

Permalink
Elevated circles features shader modifications. (for mapbox/mapbox-sd…
Browse files Browse the repository at this point in the history
…k#2062) (internal-2161)

* circle vertex shader z-offset

* more clear guard

* fix metal shader generator that does not support the ifdef and/or

* circle vertex shader z-offset

* merge

* add new property

* update generated code

* use the correct version number

* remove the corner case consideration for now
  • Loading branch information
longpractice authored and underoot committed Feb 13, 2025
1 parent 19ceb05 commit f75aa8d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/shaders/circle.vertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ uniform float u_zoom_transition;
uniform vec3 u_up_dir;
#endif

#ifdef ELEVATED_ROADS
in float a_circle_z_offset;
#endif

out vec3 v_data;
out float v_visibility;

Expand Down Expand Up @@ -122,6 +126,10 @@ void main(void) {
world_center = vec4(circle_center, height, 1);
#endif

#ifdef ELEVATED_ROADS
world_center.z += a_circle_z_offset + ELEVATION_BIAS;
#endif

vec4 projected_center = u_matrix * world_center;

float view_scale = 0.0;
Expand Down
25 changes: 25 additions & 0 deletions src/style-spec/reference/v8.json
Original file line number Diff line number Diff line change
Expand Up @@ -1733,6 +1733,31 @@
},
"property-type": "data-driven"
},
"circle-elevation-reference": {
"type": "enum",
"doc": "Selects the base of circle-elevation. Some modes might require precomputed elevation data in the tileset.",
"values": {
"none": {
"doc": "Elevated rendering is disabled."
},
"hd-road-markup": {
"doc": "Elevated rendering is enabled. Use this mode to describe additive and stackable features that should exist only on top of road polygons."
}
},
"default": "none",
"experimental": true,
"transition": false,
"sdk-support": {
"basic functionality": {
"android": "11.11.0",
"ios": "11.11.0"
}
},
"expression": {
"interpolated": false
},
"property-type": "data-constant"
},
"visibility": {
"type": "enum",
"values": {
Expand Down
4 changes: 4 additions & 0 deletions src/style-spec/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,10 @@ export type CircleLayerSpecification = {
"filter"?: FilterSpecification,
"layout"?: {
"circle-sort-key"?: DataDrivenPropertyValueSpecification<number>,
/**
* @experimental This property is experimental and subject to change in future versions.
*/
"circle-elevation-reference"?: "none" | "hd-road-markup" | ExpressionSpecification,
"visibility"?: "visible" | "none" | ExpressionSpecification
},
"paint"?: {
Expand Down
2 changes: 2 additions & 0 deletions src/style/style_layer/circle_style_layer_properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ import type {StylePropertySpecification} from '../../style-spec/style-spec';

export type LayoutProps = {
"circle-sort-key": DataDrivenProperty<number>;
"circle-elevation-reference": DataConstantProperty<"none" | "hd-road-markup">;
"visibility": DataConstantProperty<"visible" | "none">;
};
let layout: Properties<LayoutProps>;
export const getLayoutProperties = (): Properties<LayoutProps> => layout || (layout = new Properties({
"circle-sort-key": new DataDrivenProperty(styleSpec["layout_circle"]["circle-sort-key"]),
"circle-elevation-reference": new DataConstantProperty(styleSpec["layout_circle"]["circle-elevation-reference"]),
"visibility": new DataConstantProperty(styleSpec["layout_circle"]["visibility"]),
}));

Expand Down

0 comments on commit f75aa8d

Please sign in to comment.