@openglobus/og 0.11.7 → 0.11.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/og.css +3 -2
- package/package.json +1 -1
- package/src/og/control/Lighting.js +52 -73
- package/src/og/control/MouseNavigation.js +21 -18
- package/src/og/control/MouseWheelZoomControl.js +257 -0
- package/src/og/control/index.js +2 -0
- package/src/og/control/visibleExtent/Segment.js +1862 -0
- package/src/og/control/visibleExtent/VisibleExtent.js +80 -0
- package/src/og/control/visibleExtent/drawnode.js +751 -0
- package/src/og/entity/BaseBillboard.js +9 -9
- package/src/og/entity/Label.js +7 -7
- package/src/og/layer/CanvasTiles.js +0 -1
- package/src/og/layer/GeoImage.js +2 -10
- package/src/og/layer/GeoTexture2d.js +2 -10
- package/src/og/layer/GeoVideo.js +2 -10
- package/src/og/layer/Layer.js +0 -22
- package/src/og/layer/WMS.js +0 -2
- package/src/og/layer/XYZ.js +4 -5
- package/src/og/renderer/Renderer.js +69 -94
- package/src/og/renderer/RendererEvents.js +3 -1
- package/src/og/scene/Planet.js +39 -61
- package/src/og/segment/Segment.js +60 -156
- package/src/og/segment/Slice.js +45 -0
- package/src/og/shaders/drawnode.js +197 -287
- package/src/og/utils/GeoImageCreator.js +5 -1
- package/src/og/webgl/Handler.js +1 -1
|
@@ -11,11 +11,34 @@ import { Program } from "../webgl/Program.js";
|
|
|
11
11
|
// glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
|
12
12
|
// src*(src.alpha)+dest*(1-src.alpha)
|
|
13
13
|
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
14
|
-
|
|
15
|
-
const CORNERS = `const vec2 BOTTOMLEFT = vec2(-0.01);
|
|
16
|
-
const vec2 TOPRIGHT = vec2(1.01);`;
|
|
17
14
|
|
|
18
|
-
|
|
15
|
+
|
|
16
|
+
const NIGHT = `const vec3 nightStep = 10.0 * vec3(0.58, 0.48, 0.25);`;
|
|
17
|
+
|
|
18
|
+
const BLEND = `
|
|
19
|
+
void blend(
|
|
20
|
+
out vec4 dest,
|
|
21
|
+
in sampler2D sampler,
|
|
22
|
+
in vec4 tileOffset,
|
|
23
|
+
in float opacity)
|
|
24
|
+
{
|
|
25
|
+
vec4 src = texture( sampler, tileOffset.xy + vTextureCoord.xy * tileOffset.zw );
|
|
26
|
+
//dest = dest * (1.0 - src.a * opacity) + src * opacity;
|
|
27
|
+
dest = vec4(mix(dest.rgb, src.rgb, src.a * opacity), 1.0);
|
|
28
|
+
}`;
|
|
29
|
+
|
|
30
|
+
const BLEND1 =
|
|
31
|
+
`void blend(
|
|
32
|
+
out vec4 dest,
|
|
33
|
+
in sampler2D sampler,
|
|
34
|
+
in vec4 tileOffset,
|
|
35
|
+
in float opacity)
|
|
36
|
+
{
|
|
37
|
+
vec4 src = texture2D(sampler, tileOffset.xy + vTextureCoord.xy * tileOffset.zw);
|
|
38
|
+
dest = vec4(mix(dest.rgb, src.rgb, src.a * opacity), 1.0);
|
|
39
|
+
}`
|
|
40
|
+
|
|
41
|
+
const SLICE_SIZE = 4;
|
|
19
42
|
|
|
20
43
|
export function drawnode_screen_nl() {
|
|
21
44
|
return new Program("drawnode_screen_nl", {
|
|
@@ -25,10 +48,9 @@ export function drawnode_screen_nl() {
|
|
|
25
48
|
eyePositionHigh: "vec3",
|
|
26
49
|
eyePositionLow: "vec3",
|
|
27
50
|
samplerCount: "int",
|
|
28
|
-
tileOffsetArr: "vec4",
|
|
29
|
-
|
|
51
|
+
tileOffsetArr: "vec4",
|
|
52
|
+
layerOpacityArr: "float",
|
|
30
53
|
samplerArr: "sampler2darray",
|
|
31
|
-
transparentColorArr: "vec4",
|
|
32
54
|
defaultTexture: "sampler2d",
|
|
33
55
|
height: "float"
|
|
34
56
|
},
|
|
@@ -61,61 +83,36 @@ export function drawnode_screen_nl() {
|
|
|
61
83
|
viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
|
|
62
84
|
|
|
63
85
|
gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
|
|
64
|
-
|
|
65
|
-
/*vec3 cameraPosition = eyePositionHigh + eyePositionLow;*/
|
|
66
|
-
/*vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow * (cameraPosition / cameraPosition);*/
|
|
67
|
-
/*gl_Position = projectionViewMatrix * vec4(aVertexPosition + normalize(aVertexPosition) * height, 1.0);*/
|
|
68
86
|
}`,
|
|
69
87
|
|
|
70
|
-
fragmentShader: `precision highp float;
|
|
71
|
-
|
|
72
|
-
uniform vec4
|
|
73
|
-
uniform
|
|
88
|
+
fragmentShader: `precision highp float;
|
|
89
|
+
#define SLICE_SIZE ${SLICE_SIZE + 1}
|
|
90
|
+
uniform vec4 tileOffsetArr[SLICE_SIZE];
|
|
91
|
+
uniform float layerOpacityArr[SLICE_SIZE];
|
|
74
92
|
uniform sampler2D defaultTexture;
|
|
75
|
-
uniform sampler2D samplerArr[
|
|
93
|
+
uniform sampler2D samplerArr[SLICE_SIZE];
|
|
76
94
|
uniform int samplerCount;
|
|
77
95
|
varying vec2 vTextureCoord;
|
|
78
|
-
|
|
79
|
-
/* return 1 if v inside the box, return 0 otherwise */
|
|
80
|
-
float insideBox(vec2 v, vec2 bottomLeft, vec2 topRight) {
|
|
81
|
-
vec2 s = step(bottomLeft, v) - step(topRight, v);
|
|
82
|
-
return s.x * s.y;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
${CORNERS}
|
|
86
96
|
|
|
87
|
-
|
|
88
|
-
out vec4 prevColor,
|
|
89
|
-
in sampler2D sampler,
|
|
90
|
-
in vec4 tileOffset,
|
|
91
|
-
in vec4 visibleExtentOffset,
|
|
92
|
-
in vec4 transparentColor)
|
|
93
|
-
{
|
|
94
|
-
vec4 t = texture2D( sampler, tileOffset.xy + vTextureCoord.xy * tileOffset.zw );
|
|
95
|
-
|
|
96
|
-
float emptiness = smoothstep(0.35, 0.5, distance( t.rgb, transparentColor.rgb )) *
|
|
97
|
-
insideBox(visibleExtentOffset.xy + vTextureCoord.xy * visibleExtentOffset.zw, BOTTOMLEFT, TOPRIGHT);
|
|
98
|
-
|
|
99
|
-
prevColor = prevColor * (1.0 - t.a * transparentColor.a * emptiness) + vec4(t.rgb, t.a) * transparentColor.a * emptiness;
|
|
100
|
-
}
|
|
97
|
+
${BLEND1}
|
|
101
98
|
|
|
102
99
|
void main(void) {
|
|
103
100
|
gl_FragColor = texture2D( defaultTexture, vTextureCoord );
|
|
104
101
|
if( samplerCount == 0 ) return;
|
|
105
102
|
|
|
106
|
-
blend(gl_FragColor, samplerArr[0], tileOffsetArr[0],
|
|
103
|
+
blend(gl_FragColor, samplerArr[0], tileOffsetArr[0], layerOpacityArr[0]);
|
|
107
104
|
if( samplerCount == 1 ) return;
|
|
108
105
|
|
|
109
|
-
blend(gl_FragColor, samplerArr[1], tileOffsetArr[1],
|
|
106
|
+
blend(gl_FragColor, samplerArr[1], tileOffsetArr[1], layerOpacityArr[1]);
|
|
110
107
|
if( samplerCount == 2 ) return;
|
|
111
108
|
|
|
112
|
-
blend(gl_FragColor, samplerArr[2], tileOffsetArr[2],
|
|
109
|
+
blend(gl_FragColor, samplerArr[2], tileOffsetArr[2], layerOpacityArr[2]);
|
|
113
110
|
if( samplerCount == 3 ) return;
|
|
114
111
|
|
|
115
|
-
blend(gl_FragColor, samplerArr[3], tileOffsetArr[3],
|
|
112
|
+
blend(gl_FragColor, samplerArr[3], tileOffsetArr[3], layerOpacityArr[3]);
|
|
116
113
|
if( samplerCount == 4 ) return;
|
|
117
114
|
|
|
118
|
-
blend(gl_FragColor, samplerArr[4], tileOffsetArr[4],
|
|
115
|
+
blend(gl_FragColor, samplerArr[4], tileOffsetArr[4], layerOpacityArr[4]);
|
|
119
116
|
}`
|
|
120
117
|
});
|
|
121
118
|
}
|
|
@@ -133,19 +130,18 @@ export function drawnode_screen_wl() {
|
|
|
133
130
|
uNormalMapBias: "vec3",
|
|
134
131
|
|
|
135
132
|
samplerCount: "int",
|
|
136
|
-
tileOffsetArr: "vec4",
|
|
137
|
-
|
|
133
|
+
tileOffsetArr: "vec4",
|
|
134
|
+
layerOpacityArr: "float",
|
|
138
135
|
samplerArr: "sampler2darray",
|
|
139
|
-
transparentColorArr: "vec4",
|
|
140
136
|
defaultTexture: "sampler2d",
|
|
141
137
|
normalMatrix: "mat3",
|
|
142
138
|
uNormalMap: "sampler2d",
|
|
143
139
|
nightTexture: "sampler2d",
|
|
144
140
|
specularTexture: "sampler2d",
|
|
145
141
|
lightsPositions: "vec4",
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
142
|
+
diffuse: "vec3",
|
|
143
|
+
ambient: "vec3",
|
|
144
|
+
specular: "vec4"
|
|
149
145
|
},
|
|
150
146
|
attributes: {
|
|
151
147
|
aVertexPositionHigh: "vec3",
|
|
@@ -191,12 +187,11 @@ export function drawnode_screen_wl() {
|
|
|
191
187
|
fragmentShader: `precision highp float;
|
|
192
188
|
|
|
193
189
|
#define MAX_POINT_LIGHTS 1
|
|
194
|
-
#define
|
|
195
|
-
#define MAX_OVERLAYS_PLUS_ONE 6
|
|
190
|
+
#define SLICE_SIZE ${SLICE_SIZE + 1}
|
|
196
191
|
|
|
197
|
-
uniform vec3
|
|
198
|
-
uniform vec3
|
|
199
|
-
uniform vec4
|
|
192
|
+
uniform vec3 diffuse;
|
|
193
|
+
uniform vec3 ambient;
|
|
194
|
+
uniform vec4 specular;
|
|
200
195
|
|
|
201
196
|
uniform sampler2D uNormalMap;
|
|
202
197
|
uniform vec4 lightsPositions[MAX_POINT_LIGHTS];
|
|
@@ -204,43 +199,22 @@ export function drawnode_screen_wl() {
|
|
|
204
199
|
uniform sampler2D nightTexture;
|
|
205
200
|
uniform sampler2D specularTexture;
|
|
206
201
|
|
|
207
|
-
uniform vec4 tileOffsetArr[
|
|
208
|
-
uniform
|
|
209
|
-
uniform vec4 transparentColorArr[MAX_OVERLAYS];
|
|
202
|
+
uniform vec4 tileOffsetArr[SLICE_SIZE];
|
|
203
|
+
uniform float layerOpacityArr[SLICE_SIZE];
|
|
210
204
|
|
|
211
205
|
uniform sampler2D defaultTexture;
|
|
212
|
-
uniform sampler2D samplerArr[
|
|
206
|
+
uniform sampler2D samplerArr[SLICE_SIZE];
|
|
213
207
|
uniform int samplerCount;
|
|
214
208
|
|
|
215
209
|
varying vec4 vTextureCoord;
|
|
216
210
|
varying vec2 vGlobalTextureCoord;
|
|
217
211
|
varying vec4 v_vertex;
|
|
218
212
|
varying float v_height;
|
|
219
|
-
|
|
220
|
-
/* return 1 if v inside the box, return 0 otherwise */
|
|
221
|
-
float insideBox(vec2 v, vec2 bottomLeft, vec2 topRight) {
|
|
222
|
-
vec2 s = step(bottomLeft, v) - step(topRight, v);
|
|
223
|
-
return s.x * s.y;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
${CORNERS}
|
|
227
213
|
|
|
228
214
|
${NIGHT}
|
|
229
215
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
in sampler2D sampler,
|
|
233
|
-
in vec4 tileOffset,
|
|
234
|
-
in vec4 visibleExtentOffset,
|
|
235
|
-
in vec4 transparentColor)
|
|
236
|
-
{
|
|
237
|
-
vec4 t = texture2D( sampler, tileOffset.xy + vTextureCoord.xy * tileOffset.zw );
|
|
238
|
-
|
|
239
|
-
float emptiness = smoothstep(0.35, 0.5, distance( t.rgb, transparentColor.rgb )) *
|
|
240
|
-
insideBox(visibleExtentOffset.xy + vTextureCoord.xy * visibleExtentOffset.zw, BOTTOMLEFT, TOPRIGHT);
|
|
241
|
-
|
|
242
|
-
prevColor = prevColor * (1.0 - t.a * transparentColor.a * emptiness) + vec4(t.rgb, t.a) * transparentColor.a * emptiness;
|
|
243
|
-
}
|
|
216
|
+
${BLEND}
|
|
217
|
+
|
|
244
218
|
|
|
245
219
|
void main(void) {
|
|
246
220
|
|
|
@@ -256,33 +230,41 @@ export function drawnode_screen_wl() {
|
|
|
256
230
|
vec3 night = nightStep * (0.3 - diffuseLightWeighting) * nightImageColor.rgb;
|
|
257
231
|
night *= overGround * step(0.0, night);
|
|
258
232
|
|
|
233
|
+
vec3 spec = specular.rgb * pow( reflection, specular.w) * shininess;
|
|
234
|
+
vec3 lightWeighting = ambient + diffuse * diffuseLightWeighting + spec + night;
|
|
259
235
|
|
|
236
|
+
gl_FragColor = texture2D( defaultTexture, vTextureCoord.xy );
|
|
237
|
+
if( samplerCount == 0 ) {
|
|
238
|
+
gl_FragColor *= lightWeighting;
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
260
241
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
if( samplerCount == 0 ) return;
|
|
267
|
-
|
|
268
|
-
blend(gl_FragColor, samplerArr[0], tileOffsetArr[0], visibleExtentOffsetArr[0], transparentColorArr[0],
|
|
269
|
-
specularMaterial[1], ambientMaterial[1], diffuseMaterial[1]);
|
|
270
|
-
if( samplerCount == 1 ) return;
|
|
242
|
+
blend(gl_FragColor, samplerArr[0], tileOffsetArr[0], layerOpacityArr[0]);
|
|
243
|
+
if( samplerCount == 1 ) {
|
|
244
|
+
gl_FragColor *= lightWeighting;
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
271
247
|
|
|
272
|
-
blend(gl_FragColor, samplerArr[1], tileOffsetArr[1],
|
|
273
|
-
|
|
274
|
-
|
|
248
|
+
blend(gl_FragColor, samplerArr[1], tileOffsetArr[1], layerOpacityArr[1]);
|
|
249
|
+
if( samplerCount == 2 ) {
|
|
250
|
+
gl_FragColor *= lightWeighting;
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
275
253
|
|
|
276
|
-
blend(gl_FragColor, samplerArr[2], tileOffsetArr[2],
|
|
277
|
-
|
|
278
|
-
|
|
254
|
+
blend(gl_FragColor, samplerArr[2], tileOffsetArr[2], layerOpacityArr[2]);
|
|
255
|
+
if( samplerCount == 3 ) {
|
|
256
|
+
gl_FragColor *= lightWeighting;
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
279
259
|
|
|
280
|
-
blend(gl_FragColor, samplerArr[3], tileOffsetArr[3],
|
|
281
|
-
|
|
282
|
-
|
|
260
|
+
blend(gl_FragColor, samplerArr[3], tileOffsetArr[3], layerOpacityArr[3]);
|
|
261
|
+
if( samplerCount == 4 ) {
|
|
262
|
+
gl_FragColor *= lightWeighting;
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
283
265
|
|
|
284
|
-
blend(gl_FragColor, samplerArr[4], tileOffsetArr[4],
|
|
285
|
-
|
|
266
|
+
blend(gl_FragColor, samplerArr[4], tileOffsetArr[4], layerOpacityArr[4]);
|
|
267
|
+
gl_FragColor *= lightWeighting;
|
|
286
268
|
}`
|
|
287
269
|
});
|
|
288
270
|
}
|
|
@@ -300,19 +282,18 @@ export function drawnode_screen_wl_webgl2() {
|
|
|
300
282
|
uNormalMapBias: "vec3",
|
|
301
283
|
|
|
302
284
|
samplerCount: "int",
|
|
303
|
-
tileOffsetArr: "vec4",
|
|
304
|
-
|
|
285
|
+
tileOffsetArr: "vec4",
|
|
286
|
+
layerOpacityArr: "float",
|
|
305
287
|
samplerArr: "sampler2darray",
|
|
306
|
-
transparentColorArr: "vec4",
|
|
307
288
|
defaultTexture: "sampler2d",
|
|
308
289
|
normalMatrix: "mat3",
|
|
309
290
|
uNormalMap: "sampler2d",
|
|
310
291
|
nightTexture: "sampler2d",
|
|
311
292
|
specularTexture: "sampler2d",
|
|
312
293
|
lightsPositions: "vec4",
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
294
|
+
diffuse: "vec3",
|
|
295
|
+
ambient: "vec3",
|
|
296
|
+
specular: "vec4"
|
|
316
297
|
},
|
|
317
298
|
attributes: {
|
|
318
299
|
aVertexPositionHigh: "vec3",
|
|
@@ -362,12 +343,11 @@ export function drawnode_screen_wl_webgl2() {
|
|
|
362
343
|
precision highp float;
|
|
363
344
|
|
|
364
345
|
#define MAX_POINT_LIGHTS 1
|
|
365
|
-
#define
|
|
366
|
-
#define MAX_OVERLAYS_PLUS_ONE 6
|
|
346
|
+
#define SLICE_SIZE ${SLICE_SIZE + 1}
|
|
367
347
|
|
|
368
|
-
uniform vec3
|
|
369
|
-
uniform vec3
|
|
370
|
-
uniform vec4
|
|
348
|
+
uniform vec3 diffuse;
|
|
349
|
+
uniform vec3 ambient;
|
|
350
|
+
uniform vec4 specular;
|
|
371
351
|
|
|
372
352
|
uniform sampler2D uNormalMap;
|
|
373
353
|
uniform vec4 lightsPositions[MAX_POINT_LIGHTS];
|
|
@@ -375,12 +355,11 @@ export function drawnode_screen_wl_webgl2() {
|
|
|
375
355
|
uniform sampler2D nightTexture;
|
|
376
356
|
uniform sampler2D specularTexture;
|
|
377
357
|
|
|
378
|
-
uniform vec4 tileOffsetArr[
|
|
379
|
-
uniform
|
|
380
|
-
uniform vec4 transparentColorArr[MAX_OVERLAYS];
|
|
358
|
+
uniform vec4 tileOffsetArr[SLICE_SIZE];
|
|
359
|
+
uniform float layerOpacityArr[SLICE_SIZE];
|
|
381
360
|
|
|
382
361
|
uniform sampler2D defaultTexture;
|
|
383
|
-
uniform sampler2D samplerArr[
|
|
362
|
+
uniform sampler2D samplerArr[SLICE_SIZE];
|
|
384
363
|
uniform int samplerCount;
|
|
385
364
|
|
|
386
365
|
in vec4 vTextureCoord;
|
|
@@ -395,36 +374,9 @@ export function drawnode_screen_wl_webgl2() {
|
|
|
395
374
|
|
|
396
375
|
layout(location = 0) out vec4 fragColor;
|
|
397
376
|
|
|
398
|
-
/* return 1 if v inside the box, return 0 otherwise */
|
|
399
|
-
float insideBox(vec2 v, vec2 bottomLeft, vec2 topRight) {
|
|
400
|
-
vec2 s = step(bottomLeft, v) - step(topRight, v);
|
|
401
|
-
return s.x * s.y;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
${CORNERS}
|
|
405
|
-
|
|
406
377
|
${NIGHT}
|
|
407
378
|
|
|
408
|
-
|
|
409
|
-
out vec4 dest,
|
|
410
|
-
in sampler2D sampler,
|
|
411
|
-
in vec4 tileOffset,
|
|
412
|
-
in vec4 visibleExtentOffset,
|
|
413
|
-
in vec4 transparentColor,
|
|
414
|
-
in vec4 specular,
|
|
415
|
-
in vec3 ambient,
|
|
416
|
-
in vec3 diffuse)
|
|
417
|
-
{
|
|
418
|
-
vec3 spec = specular.rgb * pow(reflection, specular.w) * (1.0 + shininess);
|
|
419
|
-
vec3 lightWeighting = ambient + diffuse * diffuseLightWeighting + spec;
|
|
420
|
-
|
|
421
|
-
vec4 src = texture( sampler, tileOffset.xy + vTextureCoord.xy * tileOffset.zw );
|
|
422
|
-
|
|
423
|
-
float emptiness = smoothstep(0.35, 0.5, distance( src.rgb, transparentColor.rgb )) *
|
|
424
|
-
insideBox(visibleExtentOffset.xy + vTextureCoord.xy * visibleExtentOffset.zw, BOTTOMLEFT, TOPRIGHT);
|
|
425
|
-
|
|
426
|
-
dest = dest * (1.0 - src.a * transparentColor.a * emptiness) + vec4(src.rgb * lightWeighting + night + spec * src.a, src.a) * transparentColor.a * emptiness;
|
|
427
|
-
}
|
|
379
|
+
${BLEND}
|
|
428
380
|
|
|
429
381
|
void main(void) {
|
|
430
382
|
|
|
@@ -441,30 +393,41 @@ export function drawnode_screen_wl_webgl2() {
|
|
|
441
393
|
night = nightStep * (.18 - diffuseLightWeighting * 3.0) * nightImageColor.rgb;
|
|
442
394
|
night *= overGround * step(0.0, night);
|
|
443
395
|
|
|
444
|
-
vec3 spec =
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
fragColor =
|
|
448
|
-
if( samplerCount == 0 )
|
|
396
|
+
vec3 spec = specular.rgb * pow( reflection, specular.w) * shininess;
|
|
397
|
+
vec4 lightWeighting = vec4(ambient + diffuse * diffuseLightWeighting + spec + night, 1.0);
|
|
398
|
+
|
|
399
|
+
fragColor = texture( defaultTexture, vTextureCoord.xy );
|
|
400
|
+
if( samplerCount == 0 ) {
|
|
401
|
+
fragColor *= lightWeighting;
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
449
404
|
|
|
450
|
-
blend(fragColor, samplerArr[0], tileOffsetArr[0],
|
|
451
|
-
|
|
452
|
-
|
|
405
|
+
blend(fragColor, samplerArr[0], tileOffsetArr[0], layerOpacityArr[0]);
|
|
406
|
+
if( samplerCount == 1 ) {
|
|
407
|
+
fragColor *= lightWeighting;
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
453
410
|
|
|
454
|
-
blend(fragColor, samplerArr[1], tileOffsetArr[1],
|
|
455
|
-
|
|
456
|
-
|
|
411
|
+
blend(fragColor, samplerArr[1], tileOffsetArr[1], layerOpacityArr[1]);
|
|
412
|
+
if( samplerCount == 2 ) {
|
|
413
|
+
fragColor *= lightWeighting;
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
457
416
|
|
|
458
|
-
blend(fragColor, samplerArr[2], tileOffsetArr[2],
|
|
459
|
-
|
|
460
|
-
|
|
417
|
+
blend(fragColor, samplerArr[2], tileOffsetArr[2], layerOpacityArr[2]);
|
|
418
|
+
if( samplerCount == 3 ) {
|
|
419
|
+
fragColor *= lightWeighting;
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
461
422
|
|
|
462
|
-
blend(fragColor, samplerArr[3], tileOffsetArr[3],
|
|
463
|
-
|
|
464
|
-
|
|
423
|
+
blend(fragColor, samplerArr[3], tileOffsetArr[3], layerOpacityArr[3]);
|
|
424
|
+
if( samplerCount == 4 ) {
|
|
425
|
+
fragColor *= lightWeighting;
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
465
428
|
|
|
466
|
-
blend(fragColor, samplerArr[4], tileOffsetArr[4],
|
|
467
|
-
|
|
429
|
+
blend(fragColor, samplerArr[4], tileOffsetArr[4], layerOpacityArr[4]);
|
|
430
|
+
fragColor *= lightWeighting;
|
|
468
431
|
}`
|
|
469
432
|
});
|
|
470
433
|
}
|
|
@@ -478,10 +441,8 @@ export function drawnode_colorPicking() {
|
|
|
478
441
|
eyePositionLow: "vec3",
|
|
479
442
|
samplerCount: "int",
|
|
480
443
|
tileOffsetArr: "vec4",
|
|
481
|
-
visibleExtentOffsetArr: "vec4",
|
|
482
444
|
samplerArr: "sampler2darray",
|
|
483
445
|
pickingMaskArr: "sampler2darray",
|
|
484
|
-
transparentColorArr: "vec4",
|
|
485
446
|
pickingColorArr: "vec4",
|
|
486
447
|
height: "float"
|
|
487
448
|
},
|
|
@@ -516,70 +477,46 @@ export function drawnode_colorPicking() {
|
|
|
516
477
|
gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
|
|
517
478
|
}`,
|
|
518
479
|
|
|
519
|
-
fragmentShader: `precision highp float;
|
|
520
|
-
|
|
521
|
-
uniform vec4
|
|
522
|
-
uniform vec4
|
|
523
|
-
uniform
|
|
524
|
-
uniform sampler2D
|
|
525
|
-
uniform sampler2D pickingMaskArr[5];
|
|
480
|
+
fragmentShader: `precision highp float;
|
|
481
|
+
#define SLICE_SIZE ${SLICE_SIZE + 1}
|
|
482
|
+
uniform vec4 tileOffsetArr[SLICE_SIZE];
|
|
483
|
+
uniform vec4 pickingColorArr[SLICE_SIZE];
|
|
484
|
+
uniform sampler2D samplerArr[SLICE_SIZE];
|
|
485
|
+
uniform sampler2D pickingMaskArr[SLICE_SIZE];
|
|
526
486
|
uniform int samplerCount;
|
|
527
|
-
varying vec2 vTextureCoord;
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
487
|
+
varying vec2 vTextureCoord;
|
|
488
|
+
|
|
489
|
+
void blendPicking(
|
|
490
|
+
out vec4 dest,
|
|
491
|
+
in vec4 tileOffset,
|
|
492
|
+
in sampler2D sampler,
|
|
493
|
+
in sampler2D pickingMask,
|
|
494
|
+
in vec4 pickingColor,
|
|
495
|
+
in float opacity)
|
|
496
|
+
{
|
|
497
|
+
vec2 tc = tileOffset.xy + vTextureCoord.xy * tileOffset.zw;
|
|
498
|
+
vec4 t = texture2D( sampler, tc );
|
|
499
|
+
vec4 p = texture2D( pickingMask, tc );
|
|
500
|
+
dest = mix( dest, vec4(max(pickingColor.rgb, p.rgb), opacity), (t.a == 0.0 ? 0.0 : 1.0) * pickingColor.a);
|
|
532
501
|
}
|
|
533
502
|
|
|
534
|
-
${CORNERS}
|
|
535
|
-
|
|
536
503
|
void main(void) {
|
|
537
504
|
gl_FragColor = vec4(0.0);
|
|
538
505
|
if( samplerCount == 0 ) return;
|
|
539
506
|
|
|
540
|
-
|
|
541
|
-
float ins = insideBox(visibleExtentOffsetArr[0].xy + vTextureCoord.xy * visibleExtentOffsetArr[0].zw, BOTTOMLEFT, TOPRIGHT);
|
|
542
|
-
vec4 t = texture2D( samplerArr[0], tc ) * ins;
|
|
543
|
-
vec4 p = texture2D( pickingMaskArr[0], tc ) * ins;
|
|
544
|
-
float emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[0].rgb ));
|
|
545
|
-
emptiness = 1.0 - step(0.0, -emptiness);
|
|
546
|
-
gl_FragColor = mix( gl_FragColor, vec4(max(pickingColorArr[0].rgb, p.rgb), 1.0), emptiness * pickingColorArr[0].a);
|
|
507
|
+
blendPicking(gl_FragColor, tileOffsetArr[0], samplerArr[0], pickingMaskArr[0], pickingColorArr[0], 1.0);
|
|
547
508
|
if( samplerCount == 1 ) return;
|
|
548
509
|
|
|
549
|
-
|
|
550
|
-
ins = insideBox(visibleExtentOffsetArr[1].xy + vTextureCoord.xy * visibleExtentOffsetArr[1].zw, BOTTOMLEFT, TOPRIGHT);
|
|
551
|
-
t = texture2D( samplerArr[1], tc ) * ins;
|
|
552
|
-
p = texture2D( pickingMaskArr[1], tc ) * ins;
|
|
553
|
-
emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[1].rgb ));
|
|
554
|
-
emptiness = 1.0 - step(0.0, -emptiness);
|
|
555
|
-
gl_FragColor = mix( gl_FragColor, vec4(max(pickingColorArr[1].rgb, p.rgb), 1.0), emptiness * pickingColorArr[1].a);
|
|
510
|
+
blendPicking(gl_FragColor, tileOffsetArr[1], samplerArr[1], pickingMaskArr[1], pickingColorArr[1], 1.0);
|
|
556
511
|
if( samplerCount == 2 ) return;
|
|
557
512
|
|
|
558
|
-
|
|
559
|
-
ins = insideBox(visibleExtentOffsetArr[2].xy + vTextureCoord.xy * visibleExtentOffsetArr[2].zw, BOTTOMLEFT, TOPRIGHT);
|
|
560
|
-
t = texture2D( samplerArr[2], tc ) * ins;
|
|
561
|
-
p = texture2D( pickingMaskArr[2], tc ) * ins;
|
|
562
|
-
emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[2].rgb ));
|
|
563
|
-
emptiness = 1.0 - step(0.0, -emptiness);
|
|
564
|
-
gl_FragColor = mix( gl_FragColor, vec4(max(pickingColorArr[2].rgb, p.rgb), 1.0), emptiness * pickingColorArr[2].a);
|
|
513
|
+
blendPicking(gl_FragColor, tileOffsetArr[2], samplerArr[2], pickingMaskArr[2], pickingColorArr[2], 1.0);
|
|
565
514
|
if( samplerCount == 3 ) return;
|
|
566
515
|
|
|
567
|
-
|
|
568
|
-
ins = insideBox(visibleExtentOffsetArr[3].xy + vTextureCoord.xy * visibleExtentOffsetArr[3].zw, BOTTOMLEFT, TOPRIGHT);
|
|
569
|
-
t = texture2D( samplerArr[3], tc ) * ins;
|
|
570
|
-
p = texture2D( pickingMaskArr[3], tc ) * ins;
|
|
571
|
-
emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[3].rgb ));
|
|
572
|
-
emptiness = 1.0 - step(0.0, -emptiness);
|
|
573
|
-
gl_FragColor = mix( gl_FragColor, vec4(max(pickingColorArr[3].rgb, p.rgb), 1.0), emptiness * pickingColorArr[3].a);
|
|
516
|
+
blendPicking(gl_FragColor, tileOffsetArr[3], samplerArr[3], pickingMaskArr[3], pickingColorArr[3], 1.0);
|
|
574
517
|
if( samplerCount == 4 ) return;
|
|
575
518
|
|
|
576
|
-
|
|
577
|
-
ins = insideBox(visibleExtentOffsetArr[4].xy + vTextureCoord.xy * visibleExtentOffsetArr[4].zw, BOTTOMLEFT, TOPRIGHT);
|
|
578
|
-
t = texture2D( samplerArr[4], tc ) * ins;
|
|
579
|
-
p = texture2D( pickingMaskArr[4], tc ) * ins;
|
|
580
|
-
emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[4].rgb ));
|
|
581
|
-
emptiness = 1.0 - step(0.0, -emptiness);
|
|
582
|
-
gl_FragColor = mix( gl_FragColor, vec4(max(pickingColorArr[4].rgb, p.rgb), 1.0), emptiness * pickingColorArr[4].a);
|
|
519
|
+
blendPicking(gl_FragColor, tileOffsetArr[4], samplerArr[4], pickingMaskArr[4], pickingColorArr[4], 1.0);
|
|
583
520
|
}`
|
|
584
521
|
});
|
|
585
522
|
}
|
|
@@ -591,9 +528,7 @@ export function drawnode_heightPicking() {
|
|
|
591
528
|
viewMatrix: "mat4",
|
|
592
529
|
samplerCount: "int",
|
|
593
530
|
tileOffsetArr: "vec4",
|
|
594
|
-
visibleExtentOffsetArr: "vec4",
|
|
595
531
|
samplerArr: "sampler2darray",
|
|
596
|
-
transparentColorArr: "vec4",
|
|
597
532
|
defaultTexture: "sampler2d",
|
|
598
533
|
height: "float",
|
|
599
534
|
eyePositionHigh: "vec3",
|
|
@@ -634,22 +569,15 @@ export function drawnode_heightPicking() {
|
|
|
634
569
|
gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
|
|
635
570
|
}`,
|
|
636
571
|
|
|
637
|
-
fragmentShader: `precision highp float;
|
|
572
|
+
fragmentShader: `precision highp float;
|
|
573
|
+
#define SLICE_SIZE ${SLICE_SIZE + 1}
|
|
638
574
|
uniform sampler2D defaultTexture;
|
|
639
|
-
uniform vec4 tileOffsetArr[
|
|
640
|
-
uniform
|
|
641
|
-
uniform vec4 transparentColorArr[5];
|
|
642
|
-
uniform sampler2D samplerArr[5];
|
|
575
|
+
uniform vec4 tileOffsetArr[SLICE_SIZE];
|
|
576
|
+
uniform sampler2D samplerArr[SLICE_SIZE];
|
|
643
577
|
uniform int samplerCount;
|
|
644
578
|
varying vec2 vTextureCoord;
|
|
645
579
|
varying float range;
|
|
646
580
|
|
|
647
|
-
/* return 1 if v inside the box, return 0 otherwise */
|
|
648
|
-
float insideBox(vec2 v, vec2 bottomLeft, vec2 topRight) {
|
|
649
|
-
vec2 s = step(bottomLeft, v) - step(topRight, v);
|
|
650
|
-
return s.x * s.y;
|
|
651
|
-
}
|
|
652
|
-
|
|
653
581
|
vec3 encode24(highp float f) {
|
|
654
582
|
float F = abs(f);
|
|
655
583
|
float s = step( 0.0, -f );
|
|
@@ -662,35 +590,30 @@ export function drawnode_heightPicking() {
|
|
|
662
590
|
floor( mod( floor( m * exp2( 23.0 - 8.0) ), exp2(8.0) ) ) / 255.0);
|
|
663
591
|
}
|
|
664
592
|
|
|
665
|
-
${CORNERS}
|
|
666
|
-
|
|
667
593
|
void main(void) {
|
|
668
594
|
gl_FragColor = vec4(encode24(range), texture2D( defaultTexture, vTextureCoord ).a);
|
|
669
595
|
if( samplerCount == 0 ) return;
|
|
670
596
|
|
|
671
|
-
vec4 t = texture2D( samplerArr[0], tileOffsetArr[0].xy + vTextureCoord * tileOffsetArr[0].zw )
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
597
|
+
vec4 t = texture2D( samplerArr[0], tileOffsetArr[0].xy + vTextureCoord * tileOffsetArr[0].zw );
|
|
598
|
+
gl_FragColor = mix( gl_FragColor, vec4(encode24(range), 1.0), 1.0);
|
|
599
|
+
//
|
|
600
|
+
// TODO: Seems to be it is not necessary
|
|
601
|
+
//if( samplerCount == 1 ) return;
|
|
675
602
|
|
|
676
|
-
t = texture2D( samplerArr[1], tileOffsetArr[1].xy + vTextureCoord * tileOffsetArr[1].zw )
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
if( samplerCount == 2 ) return;
|
|
603
|
+
//t = texture2D( samplerArr[1], tileOffsetArr[1].xy + vTextureCoord * tileOffsetArr[1].zw );
|
|
604
|
+
//gl_FragColor = mix( gl_FragColor, vec4(encode24(range), 1.0), 1.0);
|
|
605
|
+
//if( samplerCount == 2 ) return;
|
|
680
606
|
|
|
681
|
-
t = texture2D( samplerArr[2], tileOffsetArr[2].xy + vTextureCoord * tileOffsetArr[2].zw )
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
if( samplerCount == 3 ) return;
|
|
607
|
+
//t = texture2D( samplerArr[2], tileOffsetArr[2].xy + vTextureCoord * tileOffsetArr[2].zw );
|
|
608
|
+
//gl_FragColor = mix( gl_FragColor, vec4(encode24(range), 1.0), 1.0);
|
|
609
|
+
//if( samplerCount == 3 ) return;
|
|
685
610
|
|
|
686
|
-
t = texture2D( samplerArr[3], tileOffsetArr[3].xy + vTextureCoord * tileOffsetArr[3].zw )
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
if( samplerCount == 4 ) return;
|
|
611
|
+
//t = texture2D( samplerArr[3], tileOffsetArr[3].xy + vTextureCoord * tileOffsetArr[3].zw );
|
|
612
|
+
//gl_FragColor = mix( gl_FragColor, vec4(encode24(range), 1.0), 1.0);
|
|
613
|
+
//if( samplerCount == 4 ) return;
|
|
690
614
|
|
|
691
|
-
t = texture2D( samplerArr[4], tileOffsetArr[4].xy + vTextureCoord * tileOffsetArr[4].zw )
|
|
692
|
-
|
|
693
|
-
gl_FragColor = mix( gl_FragColor, vec4(encode24(range), 1.0), 1.0 - step(0.0, -emptiness));
|
|
615
|
+
//t = texture2D( samplerArr[4], tileOffsetArr[4].xy + vTextureCoord * tileOffsetArr[4].zw );
|
|
616
|
+
//gl_FragColor = mix( gl_FragColor, vec4(encode24(range), 1.0), 1.0);
|
|
694
617
|
}`
|
|
695
618
|
});
|
|
696
619
|
}
|
|
@@ -702,9 +625,7 @@ export function drawnode_depth() {
|
|
|
702
625
|
viewMatrix: "mat4",
|
|
703
626
|
samplerCount: "int",
|
|
704
627
|
tileOffsetArr: "vec4",
|
|
705
|
-
visibleExtentOffsetArr: "vec4",
|
|
706
628
|
samplerArr: "sampler2darray",
|
|
707
|
-
transparentColorArr: "vec4",
|
|
708
629
|
defaultTexture: "sampler2d",
|
|
709
630
|
height: "float",
|
|
710
631
|
eyePositionHigh: "vec3",
|
|
@@ -745,13 +666,12 @@ export function drawnode_depth() {
|
|
|
745
666
|
gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
|
|
746
667
|
}`,
|
|
747
668
|
|
|
748
|
-
fragmentShader: `#version 300 es
|
|
669
|
+
fragmentShader: `#version 300 es
|
|
670
|
+
#define SLICE_SIZE ${SLICE_SIZE + 1}
|
|
749
671
|
precision highp float;
|
|
750
672
|
uniform sampler2D defaultTexture;
|
|
751
|
-
uniform vec4 tileOffsetArr[
|
|
752
|
-
uniform
|
|
753
|
-
uniform vec4 transparentColorArr[5];
|
|
754
|
-
uniform sampler2D samplerArr[5];
|
|
673
|
+
uniform vec4 tileOffsetArr[SLICE_SIZE];
|
|
674
|
+
uniform sampler2D samplerArr[SLICE_SIZE];
|
|
755
675
|
uniform int samplerCount;
|
|
756
676
|
uniform vec3 frustumPickingColor;
|
|
757
677
|
|
|
@@ -759,42 +679,32 @@ export function drawnode_depth() {
|
|
|
759
679
|
|
|
760
680
|
layout(location = 0) out vec4 frustumColor;
|
|
761
681
|
|
|
762
|
-
/* return 1 if v inside the box, return 0 otherwise */
|
|
763
|
-
float insideBox(vec2 v, vec2 bottomLeft, vec2 topRight) {
|
|
764
|
-
vec2 s = step(bottomLeft, v) - step(topRight, v);
|
|
765
|
-
return s.x * s.y;
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
${CORNERS}
|
|
769
|
-
|
|
770
682
|
void main(void) {
|
|
771
683
|
|
|
772
684
|
frustumColor = vec4(frustumPickingColor, texture(defaultTexture, vTextureCoord).a);
|
|
773
685
|
if(samplerCount == 0) return;
|
|
774
686
|
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
frustumColor = mix(frustumColor, vec4(frustumPickingColor, 1.0), 1.0 - step(0.0, -emptiness));
|
|
798
|
-
} `
|
|
687
|
+
vec4 t = texture(samplerArr[0], tileOffsetArr[0].xy + vTextureCoord * tileOffsetArr[0].zw);
|
|
688
|
+
frustumColor = mix(frustumColor, vec4(frustumPickingColor, 1.0), 1.0);
|
|
689
|
+
|
|
690
|
+
//
|
|
691
|
+
// TODO: Seems to be it is not necessary
|
|
692
|
+
//if (samplerCount == 1) return;
|
|
693
|
+
|
|
694
|
+
//t = texture(samplerArr[1], tileOffsetArr[1].xy + vTextureCoord * tileOffsetArr[1].zw);
|
|
695
|
+
//frustumColor = mix(frustumColor, vec4(frustumPickingColor, 1.0), 1.0);
|
|
696
|
+
//if (samplerCount == 2) return;
|
|
697
|
+
|
|
698
|
+
//t = texture(samplerArr[2], tileOffsetArr[2].xy + vTextureCoord * tileOffsetArr[2].zw);
|
|
699
|
+
//frustumColor = mix(frustumColor, vec4(frustumPickingColor, 1.0), 1.0);
|
|
700
|
+
//if (samplerCount == 3) return;
|
|
701
|
+
|
|
702
|
+
//t = texture(samplerArr[3], tileOffsetArr[3].xy + vTextureCoord * tileOffsetArr[3].zw);
|
|
703
|
+
//frustumColor = mix(frustumColor, vec4(frustumPickingColor, 1.0), 1.0);
|
|
704
|
+
//if (samplerCount == 4) return;
|
|
705
|
+
|
|
706
|
+
//t = texture(samplerArr[4], tileOffsetArr[4].xy + vTextureCoord * tileOffsetArr[4].zw);
|
|
707
|
+
//frustumColor = mix(frustumColor, vec4(frustumPickingColor, 1.0), 1.0);
|
|
708
|
+
} `
|
|
799
709
|
});
|
|
800
710
|
}
|