Skip to content

Commit 3cf1f61

Browse files
jtorresfabramourner
authored andcommitted
[MAPS3D-1348] Fix landmarks highlights v2 (internal-1383)
* Use tileModelMatrix for normals * Add render test
1 parent acc665f commit 3cf1f61

File tree

4 files changed

+278
-1
lines changed

4 files changed

+278
-1
lines changed

3d-style/render/draw_model.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,12 +788,15 @@ function drawBatchedModels(painter: Painter, source: SourceCache, layer: ModelSt
788788
// keep model and nodemodel matrices separate for rendering door lights
789789
const nodeModelMatrix = mat4.multiply([], tileModelMatrix, node.matrix);
790790

791-
const lightingMatrix = mat4.multiply([], zScaleMatrix, tileModelMatrix);
791+
let lightingMatrix = mat4.multiply([], zScaleMatrix, tileModelMatrix);
792792
mat4.multiply(lightingMatrix, negCameraPosMatrix, lightingMatrix);
793793
const normalMatrix = mat4.invert([], lightingMatrix);
794794
mat4.transpose(normalMatrix, normalMatrix);
795795
mat4.scale(normalMatrix, normalMatrix, normalScale);
796796

797+
// lighting matrix should take node.matrix into account
798+
lightingMatrix = mat4.multiply(lightingMatrix, lightingMatrix, node.matrix);
799+
797800
const isLightBeamPass = painter.renderPass === 'light-beam';
798801
const wpvForNode = mat4.multiply([], tr.expandedFarZProjMatrix, nodeModelMatrix);
799802
// Lights come in tilespace so wvp should not include node.matrix when rendering door ligths
Binary file not shown.
Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
1+
{
2+
"version": 8,
3+
"metadata": {
4+
"test": {
5+
"allowed": 0.00025,
6+
"width": 1024,
7+
"height": 1024
8+
}
9+
},
10+
"lights": [
11+
{
12+
"type": "ambient",
13+
"id": "test_ambient",
14+
"properties": {
15+
"color": "rgba(255, 255, 255, 1)",
16+
"intensity": 0.5
17+
}
18+
},
19+
{
20+
"type": "directional",
21+
"id": "test_directional",
22+
"properties": {
23+
"color": "rgba(255, 255, 255, 1)",
24+
"intensity": 0.5
25+
}
26+
}
27+
],
28+
"sources": {
29+
"file-system-tiles": {
30+
"type": "batched-model",
31+
"maxzoom": 14,
32+
"tiles": [
33+
"local://models/landmark/mbx-meshopt/{x}-{y}-{z}.glb"
34+
]
35+
}
36+
},
37+
"pitch": 49,
38+
"zoom": 17.89,
39+
"bearing": -14.4,
40+
"center": [
41+
21.002212,
42+
52.230135
43+
],
44+
45+
"layers": [
46+
{
47+
"type": "background",
48+
"paint": {
49+
"background-color": "lightgray"
50+
},
51+
"id": "land"
52+
},
53+
{
54+
"id": "building-models",
55+
"minzoom": 14.0,
56+
"paint": {
57+
"model-ambient-occlusion-intensity": 0.75,
58+
"model-color": [
59+
"match",
60+
[
61+
"get",
62+
"part"
63+
],
64+
"roof",
65+
[
66+
"hsl",
67+
22,
68+
82,
69+
90
70+
],
71+
"wall",
72+
[
73+
"hsl",
74+
0,
75+
0,
76+
100
77+
],
78+
"window",
79+
[
80+
"interpolate",
81+
[ "linear" ],
82+
[ "measure-light", "brightness" ],
83+
0,
84+
[
85+
"hsl",
86+
[
87+
"random",
88+
0.0,
89+
90.0,
90+
[
91+
"id"
92+
]
93+
],
94+
[
95+
"random",
96+
20.0,
97+
100.0,
98+
[
99+
"id"
100+
]
101+
],
102+
87
103+
],
104+
0.15,
105+
[
106+
"hsl",
107+
[
108+
"random",
109+
200.0,
110+
215.0,
111+
[
112+
"id"
113+
]
114+
],
115+
100,
116+
[
117+
"random",
118+
70.0,
119+
80.0,
120+
[
121+
"id"
122+
]
123+
]
124+
]
125+
],
126+
[
127+
"interpolate",
128+
[ "linear" ],
129+
[ "measure-light", "brightness" ],
130+
0.16,
131+
[
132+
"hsla",
133+
[
134+
"random",
135+
10.0,
136+
70.0,
137+
[
138+
"id"
139+
]
140+
],
141+
55
142+
,
143+
[
144+
"random",
145+
80.0,
146+
90.0,
147+
[
148+
"id"
149+
]
150+
],
151+
1.0
152+
],
153+
0.4,
154+
"hsl(0, 100%, 100%)"
155+
]
156+
],
157+
"model-color-mix-intensity": [
158+
"match",
159+
[
160+
"get",
161+
"part"
162+
],
163+
"logo",
164+
[
165+
"interpolate",
166+
[ "linear" ],
167+
[ "measure-light", "brightness" ],
168+
0.2,
169+
0,
170+
0.4,
171+
0.3
172+
],
173+
1.0
174+
],
175+
"model-emissive-strength": [
176+
"match",
177+
[
178+
"get",
179+
"part"
180+
],
181+
"door",
182+
[
183+
"interpolate",
184+
[ "linear" ],
185+
[ "measure-light", "brightness" ],
186+
0.2,
187+
1.5,
188+
0.4,
189+
2.5
190+
],
191+
"logo",
192+
0.6,
193+
"window",
194+
[
195+
"random",
196+
0.5,
197+
0.8,
198+
[
199+
"id"
200+
]
201+
],
202+
0.0
203+
],
204+
"model-height-based-emissive-strength-multiplier": [
205+
"match",
206+
[
207+
"get",
208+
"part"
209+
],
210+
"window",
211+
[
212+
"literal",
213+
[
214+
0.0,
215+
0.9,
216+
0,
217+
1,
218+
0.5
219+
]
220+
],
221+
[
222+
"literal",
223+
[
224+
1.0,
225+
1.0,
226+
1.0,
227+
1.0,
228+
1.0
229+
]
230+
]
231+
],
232+
"model-opacity": [
233+
"interpolate",
234+
[ "linear" ],
235+
[ "zoom" ],
236+
14.2,
237+
0.0,
238+
14.5,
239+
1.0
240+
],
241+
"model-roughness": [
242+
"match",
243+
[
244+
"get",
245+
"part"
246+
],
247+
"window",
248+
0.0,
249+
1.0
250+
],
251+
"model-scale": [
252+
"interpolate",
253+
[ "linear" ],
254+
[ "zoom" ],
255+
14.2,
256+
[
257+
1.0,
258+
1.0,
259+
0.0
260+
],
261+
14.5,
262+
[
263+
1.0,
264+
1.0,
265+
1.0
266+
]
267+
],
268+
"model-type": "common-3d"
269+
},
270+
"source": "file-system-tiles",
271+
"type": "model"
272+
}
273+
]
274+
}

0 commit comments

Comments
 (0)