Skip to content

Commit 8d4637b

Browse files
akoylasargithub-actions[bot]
authored andcommitted
Procedural building improvements and optimisations (internal-8406)
GitOrigin-RevId: b0c1b0e05b660918d4d75fee04467a657eab2842
1 parent d8c8424 commit 8d4637b

File tree

4 files changed

+216
-1
lines changed

4 files changed

+216
-1
lines changed

3d-style/shaders/building.vertex.glsl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void main() {
7878
v_normal = vec3(u_normal_matrix * vec4(a_normal_3f, 0.0));
7979

8080
float hidden = 0.0;
81-
81+
float depth_offset = 0.0;
8282
#ifdef BUILDING_FAUX_FACADE
8383
v_faux_facade = a_faux_facade_data.x;
8484
if (v_faux_facade > 0.0) {
@@ -102,6 +102,9 @@ void main() {
102102

103103
v_faux_color_emissive = decode_color(faux_facade_color_emissive);
104104
v_faux_color_emissive.rgb = sRGBToLinear(v_faux_color_emissive.rgb);
105+
106+
float height = a_centroid_3.z;
107+
depth_offset = min(1000.0, height) * 0.0000002;
105108
}
106109
#endif
107110
v_pos = a_pos_3f;
@@ -128,4 +131,5 @@ void main() {
128131
#endif
129132

130133
gl_Position = mix(u_matrix * vec4(v_pos, 1), AWAY, hidden);
134+
gl_Position.z -= depth_offset * gl_Position.w;
131135
}

test/ignores/windows-chrome.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const todo = [
5757
"render-tests/building/faux-facade/feature-state",
5858
"render-tests/building/faux-facade/shadows-supported",
5959
"render-tests/building/faux-facade/window-ao",
60+
"render-tests/building/faux-facade/overlapping-walls"
6061
];
6162

6263
const skip = [
59.7 KB
Loading
Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
{
2+
"version": 8,
3+
"metadata": {
4+
"test": {
5+
"allowed": 0.0015,
6+
"height": 512,
7+
"width": 512,
8+
"operations": [
9+
]
10+
}
11+
},
12+
"lights": [
13+
{
14+
"type": "ambient",
15+
"id": "environment",
16+
"properties": {
17+
"intensity": 0.4
18+
}
19+
},
20+
{
21+
"type": "directional",
22+
"id": "sun_light",
23+
"properties": {
24+
"intensity": 0.6,
25+
"cast-shadows": true
26+
}
27+
}
28+
],
29+
"sources": {
30+
"geojson": {
31+
"type": "geojson",
32+
"data": {
33+
"type": "FeatureCollection",
34+
"features": [
35+
{
36+
"type": "Feature",
37+
"properties": {
38+
"extrude": "true",
39+
"underground": "false",
40+
"source_id": 127046656,
41+
"height": 12
42+
},
43+
"id": 127046656,
44+
"geometry": {
45+
"coordinates": [
46+
[
47+
[
48+
11.568937291974436,
49+
48.13246952281412
50+
],
51+
[
52+
11.568937291974436,
53+
48.132286810394845
54+
],
55+
[
56+
11.56931009612731,
57+
48.132286810394845
58+
],
59+
[
60+
11.56931009612731,
61+
48.13246952281412
62+
],
63+
[
64+
11.568937291974436,
65+
48.13246952281412
66+
]
67+
]
68+
],
69+
"type": "Polygon"
70+
}
71+
},
72+
{
73+
"type": "Feature",
74+
"properties": {
75+
"extrude": "true",
76+
"underground": "false",
77+
"source_id": 127046657,
78+
"height": 16
79+
},
80+
"id": 127046657,
81+
"geometry": {
82+
"coordinates": [
83+
[
84+
[
85+
11.568937291974436,
86+
48.13246952281412
87+
],
88+
[
89+
11.568937291974436,
90+
48.132286810394845
91+
],
92+
[
93+
11.56931009612731,
94+
48.132286810394845
95+
],
96+
[
97+
11.56931009612731,
98+
48.13246952281412
99+
],
100+
[
101+
11.568937291974436,
102+
48.13246952281412
103+
]
104+
]
105+
],
106+
"type": "Polygon"
107+
}
108+
},
109+
{
110+
"type": "Feature",
111+
"properties": {
112+
"min_height": 0,
113+
"cross_perc": 0,
114+
"source_id": 127046656,
115+
"distance_to_road": 33.34
116+
},
117+
"id": 127046656,
118+
"geometry": {
119+
"type": "LineString",
120+
"coordinates":
121+
[
122+
[
123+
11.568937291974436,
124+
48.132286810394845
125+
],
126+
[
127+
11.56931009612731,
128+
48.132286810394845
129+
]
130+
]
131+
}
132+
},
133+
{
134+
"type": "Feature",
135+
"properties": {
136+
"min_height": 0,
137+
"cross_perc": 0,
138+
"source_id": 127046657,
139+
"distance_to_road": 33.34
140+
},
141+
"id": 127046657,
142+
"geometry": {
143+
"type": "LineString",
144+
"coordinates":
145+
[
146+
[
147+
11.568937291974436,
148+
48.132286810394845
149+
],
150+
[
151+
11.56931009612731,
152+
48.132286810394845
153+
]
154+
]
155+
}
156+
}
157+
]
158+
}
159+
}
160+
},
161+
"bearing": 25,
162+
"pitch": 65,
163+
"zoom": 19.45,
164+
"center": [11.5691398, 48.1323676],
165+
"layers": [
166+
{
167+
"id": "background",
168+
"type": "background",
169+
"paint": {
170+
"background-color": "grey"
171+
}
172+
},
173+
{
174+
"id": "building",
175+
"type": "building",
176+
"source": "geojson",
177+
"minzoom": 16,
178+
"layout": {
179+
"building-facade": true,
180+
"building-facade-floors": ["ceil", ["/", ["get", "height"], 4]],
181+
"building-roof-shape": "parapet",
182+
"building-base": 0,
183+
"building-height": ["get", "height"]
184+
},
185+
"paint": {
186+
"building-color": [
187+
"match",
188+
["get", "building-part"],
189+
"wall",
190+
["hsl", 41, 90, 90],
191+
"roof",
192+
["hsl", 25, 43, 80],
193+
"window",
194+
["hsl", 198, 22.4, 64.1],
195+
"door",
196+
["hsl", 0, 100, 100],
197+
["hsl", 41, 90, 90]
198+
],
199+
"building-emissive-strength": [
200+
"match",
201+
["get", "building-part"],
202+
"door",
203+
2.5,
204+
0
205+
],
206+
"building-ambient-occlusion-intensity": 1
207+
}
208+
}
209+
]
210+
}

0 commit comments

Comments
 (0)