Skip to content

Commit

Permalink
[MAPS3D-1081] Evaluate base at bucket creation time and remove the ne…
Browse files Browse the repository at this point in the history
…ed for including it as a vertex buffer (internal-809)
  • Loading branch information
akoylasar authored and mourner committed Oct 5, 2023
1 parent 62dcff0 commit 70e5370
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/data/bucket/fill_extrusion_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,8 @@ class FillExtrusionBucket implements Bucket {
const borderCentroidData = new BorderCentroidData();
borderCentroidData.centroidDataIndex = this.centroidData.length;
const centroid = new PartData();
const base = this.layers[0].paint.get('fill-extrusion-base').evaluate(feature, {}, canonical);
const onGround = base <= 0;
const height = this.layers[0].paint.get('fill-extrusion-height').evaluate(feature, {}, canonical);
centroid.height = height;
centroid.vertexArrayOffset = this.layoutVertexArray.length;
Expand Down Expand Up @@ -859,7 +861,7 @@ class FillExtrusionBucket implements Bucket {
na = nb;
}

if ((edgeRadius === 0 || optimiseGround) && !isDuplicate(groundPolyline, q)) {
if (onGround && (edgeRadius === 0 || optimiseGround) && !isDuplicate(groundPolyline, q)) {
groundPolyline.push(q);
}

Expand All @@ -879,7 +881,7 @@ class FillExtrusionBucket implements Bucket {
}
}

if (edgeRadius === 0 || optimiseGround) {
if (onGround && (edgeRadius === 0 || optimiseGround)) {
if (groundPolyline.length !== 0 && isDuplicate(groundPolyline, groundPolyline[0])) {
groundPolyline.pop();
}
Expand Down Expand Up @@ -982,7 +984,7 @@ class FillExtrusionBucket implements Bucket {

na = nb;

if (this.zoom >= 17) {
if (onGround && this.zoom >= 17) {
if (!isDuplicate(groundPolyline, p0)) groundPolyline.push(p0);
if (!isDuplicate(groundPolyline, p1)) groundPolyline.push(p1);
}
Expand Down Expand Up @@ -1060,7 +1062,7 @@ class FillExtrusionBucket implements Bucket {
}
}
if (isPolygon) topIndex += (ring.length - 1);
if (edgeRadius && this.zoom >= 17) {
if (onGround && edgeRadius && this.zoom >= 17) {
if (groundPolyline.length !== 0 && isDuplicate(groundPolyline, groundPolyline[0])) {
groundPolyline.pop();
}
Expand Down
3 changes: 0 additions & 3 deletions src/shaders/fill_extrusion_ground_effect.vertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ uniform highp float u_edge_radius; // in tile coords
uniform highp vec2 u_ao;

#pragma mapbox: define highp float flood_light_ground_radius
#pragma mapbox: define highp float base

const float TANGENT_CUTOFF = 4.0;

void main() {
#pragma mapbox: initialize highp float flood_light_ground_radius
#pragma mapbox: initialize highp float base

vec2 p = a_pos_end.xy;
vec2 q = floor(a_pos_end.zw * 0.5);
Expand Down Expand Up @@ -74,7 +72,6 @@ void main() {

float isFloodlit = float(flood_light_ground_radius > 0.0 && u_flood_light_intensity > 0.0);
float hidden = mix(1.0 - isFloodlit, isFloodlit, u_ao_pass);
hidden += float(base > 0.0); // vertex base is above ground.
hidden += hidden_by_landmark;

gl_Position = mix(u_matrix * vec4(pos, 1.0), AWAY, float(hidden > 0.0));
Expand Down

0 comments on commit 70e5370

Please sign in to comment.