@openglobus/og 0.12.4 → 0.13.0

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.
Files changed (93) hide show
  1. package/README.md +0 -2
  2. package/dist/@openglobus/og.esm.js +2 -2
  3. package/dist/@openglobus/og.esm.js.map +1 -1
  4. package/dist/@openglobus/og.umd.js +2 -2
  5. package/dist/@openglobus/og.umd.js.map +1 -1
  6. package/package.json +7 -7
  7. package/src/og/Extent.js +3 -3
  8. package/src/og/Globe.js +277 -275
  9. package/src/og/ImageCanvas.js +3 -3
  10. package/src/og/LonLat.js +9 -9
  11. package/src/og/QueueArray.js +2 -2
  12. package/src/og/Rectangle.js +5 -5
  13. package/src/og/bv/Box.js +1 -1
  14. package/src/og/bv/Sphere.js +2 -2
  15. package/src/og/camera/Camera.js +1 -1
  16. package/src/og/camera/PlanetCamera.js +649 -646
  17. package/src/og/control/LayerSwitcher.js +1 -1
  18. package/src/og/control/MouseNavigation.js +22 -13
  19. package/src/og/control/MouseWheelZoomControl.js +2 -2
  20. package/src/og/control/ScaleControl.js +1 -1
  21. package/src/og/control/TouchNavigation.js +319 -319
  22. package/src/og/control/ZoomControl.js +132 -132
  23. package/src/og/control/visibleExtent/Segment.js +12 -12
  24. package/src/og/ellipsoid/Ellipsoid.js +577 -567
  25. package/src/og/entity/BillboardHandler.js +878 -1051
  26. package/src/og/entity/Entity.js +1 -1
  27. package/src/og/entity/EntityCollection.js +847 -857
  28. package/src/og/entity/GeoObjectHandler.js +2 -2
  29. package/src/og/entity/LabelHandler.js +888 -1040
  30. package/src/og/entity/LabelWorker.js +0 -6
  31. package/src/og/entity/PointCloud.js +495 -495
  32. package/src/og/entity/Polyline.js +2218 -2222
  33. package/src/og/entity/RayHandler.js +1 -1
  34. package/src/og/layer/CanvasTiles.js +6 -3
  35. package/src/og/layer/GeoImage.js +1 -1
  36. package/src/og/layer/KML.js +5 -5
  37. package/src/og/layer/Layer.js +800 -752
  38. package/src/og/layer/Vector.js +997 -1010
  39. package/src/og/layer/XYZ.js +359 -357
  40. package/src/og/math/Line2.js +4 -4
  41. package/src/og/math/Quat.js +2 -2
  42. package/src/og/math/Ray.js +2 -2
  43. package/src/og/math/Vec2.js +524 -524
  44. package/src/og/math/Vec3.js +900 -900
  45. package/src/og/math/Vec4.js +261 -261
  46. package/src/og/math.js +397 -398
  47. package/src/og/quadTree/EntityCollectionNode.js +389 -387
  48. package/src/og/renderer/Renderer.js +14 -20
  49. package/src/og/renderer/RendererEvents.js +1034 -1045
  50. package/src/og/scene/Planet.js +12 -9
  51. package/src/og/scene/RenderNode.js +347 -354
  52. package/src/og/segment/Segment.js +3 -1
  53. package/src/og/segment/SegmentLonLat.js +1 -4
  54. package/src/og/shaders/billboard.js +220 -204
  55. package/src/og/shaders/drawnode.js +603 -603
  56. package/src/og/shaders/label.js +596 -456
  57. package/src/og/shaders/polyline.js +365 -361
  58. package/src/og/terrain/MapboxTerrain.js +1 -1
  59. package/src/og/utils/FontAtlas.js +209 -200
  60. package/src/og/utils/GeoImageCreator.js +4 -5
  61. package/src/og/utils/TextureAtlas.js +4 -4
  62. package/src/og/utils/VectorTileCreator.js +414 -414
  63. package/src/og/utils/shared.js +1 -1
  64. package/src/og/webgl/Handler.js +28 -60
  65. package/src/og/webgl/Multisample.js +260 -260
  66. package/src/og/webgl/Program.js +411 -396
  67. package/types/bv/Box.d.ts +1 -1
  68. package/types/bv/Sphere.d.ts +1 -1
  69. package/types/camera/PlanetCamera.d.ts +3 -3
  70. package/types/control/LayerSwitcher.d.ts +1 -1
  71. package/types/ellipsoid/Ellipsoid.d.ts +9 -2
  72. package/types/entity/BillboardHandler.d.ts +0 -4
  73. package/types/entity/EntityCollection.d.ts +0 -8
  74. package/types/entity/LabelHandler.d.ts +0 -2
  75. package/types/entity/Polyline.d.ts +1 -1
  76. package/types/layer/KML.d.ts +11 -11
  77. package/types/layer/Layer.d.ts +4 -0
  78. package/types/layer/Vector.d.ts +1 -8
  79. package/types/math/Line2.d.ts +4 -4
  80. package/types/math/Ray.d.ts +2 -2
  81. package/types/math/Vec2.d.ts +1 -1
  82. package/types/math/Vec3.d.ts +1 -1
  83. package/types/math/Vec4.d.ts +2 -2
  84. package/types/math.d.ts +1 -1
  85. package/types/renderer/Renderer.d.ts +1 -1
  86. package/types/renderer/RendererEvents.d.ts +1 -1
  87. package/types/shaders/label.d.ts +1 -1
  88. package/types/utils/FontAtlas.d.ts +3 -2
  89. package/types/utils/TextureAtlas.d.ts +3 -3
  90. package/types/utils/VectorTileCreator.d.ts +4 -4
  91. package/types/utils/shared.d.ts +1 -1
  92. package/types/webgl/Handler.d.ts +6 -31
  93. package/types/webgl/Program.d.ts +2 -0
@@ -1,19 +1,19 @@
1
- /**
2
- * @module og/shaders/drawnode
3
- */
4
-
5
- "use strict";
6
-
7
- import { Program } from "../webgl/Program.js";
8
-
9
- // REMEMBER!
10
- // src*(1)+dest*(1-src.alpha)
11
- // glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
12
- // src*(src.alpha)+dest*(1-src.alpha)
13
- // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
14
-
15
-
16
- const NIGHT = `const vec3 nightStep = 10.0 * vec3(0.58, 0.48, 0.25);`;
1
+ /**
2
+ * @module og/shaders/drawnode
3
+ */
4
+
5
+ "use strict";
6
+
7
+ import { Program } from "../webgl/Program.js";
8
+
9
+ // REMEMBER!
10
+ // src*(1)+dest*(1-src.alpha)
11
+ // glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
12
+ // src*(src.alpha)+dest*(1-src.alpha)
13
+ // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
14
+
15
+
16
+ const NIGHT = `const vec3 nightStep = 10.0 * vec3(0.58, 0.48, 0.25);`;
17
17
 
18
18
  const DEF_BLEND = `#define blend(DEST, SAMPLER, OFFSET, OPACITY) \
19
19
  src = texture( SAMPLER, OFFSET.xy + vTextureCoord.xy * OFFSET.zw ); \
@@ -21,601 +21,601 @@ const DEF_BLEND = `#define blend(DEST, SAMPLER, OFFSET, OPACITY) \
21
21
 
22
22
  const DEF_BLEND_WEBGL1 = `#define blend(DEST, SAMPLER, OFFSET, OPACITY) \
23
23
  src = texture2D( SAMPLER, OFFSET.xy + vTextureCoord.xy * OFFSET.zw ); \
24
- DEST = DEST * (1.0 - src.a * OPACITY) + src * OPACITY;`;
24
+ DEST = DEST * (1.0 - src.a * OPACITY) + src * OPACITY;`;
25
25
 
26
- const DEF_BLEND_PICKING = `#define blendPicking(DEST, OFFSET, SAMPLER, MASK, COLOR, OPACITY) \
27
- tc = OFFSET.xy + vTextureCoord.xy * OFFSET.zw; \
28
- t = texture2D(SAMPLER, tc); \
29
- p = texture2D(MASK, tc); \
26
+ const DEF_BLEND_PICKING = `#define blendPicking(DEST, OFFSET, SAMPLER, MASK, COLOR, OPACITY) \
27
+ tc = OFFSET.xy + vTextureCoord.xy * OFFSET.zw; \
28
+ t = texture2D(SAMPLER, tc); \
29
+ p = texture2D(MASK, tc); \
30
30
  DEST = mix(DEST, vec4(max(COLOR.rgb, p.rgb), OPACITY), (t.a == 0.0 ? 0.0 : 1.0) * COLOR.a);`
31
31
 
32
-
33
- const SLICE_SIZE = 4;
34
-
35
- export function drawnode_screen_nl() {
36
- return new Program("drawnode_screen_nl", {
37
- uniforms: {
38
- projectionMatrix: "mat4",
39
- viewMatrix: "mat4",
40
- eyePositionHigh: "vec3",
41
- eyePositionLow: "vec3",
42
- samplerCount: "int",
43
- tileOffsetArr: "vec4",
44
- layerOpacityArr: "float",
45
- samplerArr: "sampler2darray",
46
- defaultTexture: "sampler2d",
47
- height: "float"
48
- },
49
- attributes: {
50
- aVertexPositionHigh: "vec3",
51
- aVertexPositionLow: "vec3",
52
- aTextureCoord: "vec2"
53
- },
54
-
55
- vertexShader: `attribute vec3 aVertexPositionHigh;
56
- attribute vec3 aVertexPositionLow;
57
- attribute vec2 aTextureCoord;
58
-
59
- uniform mat4 projectionMatrix;
60
- uniform mat4 viewMatrix;
61
- uniform vec3 eyePositionHigh;
62
- uniform vec3 eyePositionLow;
63
- uniform float height;
64
-
65
- varying vec2 vTextureCoord;
66
-
67
- void main(void) {
68
- vTextureCoord = aTextureCoord;
69
-
70
- vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
71
- vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
72
- vec3 lowDiff = aVertexPositionLow + normalize(aVertexPosition) * height - eyePositionLow;
73
-
74
- mat4 viewMatrixRTE = viewMatrix;
75
- viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
76
-
77
- gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
78
- }`,
79
-
80
- fragmentShader: `precision highp float;
81
- #define SLICE_SIZE ${SLICE_SIZE + 1}
82
- uniform vec4 tileOffsetArr[SLICE_SIZE];
83
- uniform float layerOpacityArr[SLICE_SIZE];
84
- uniform sampler2D defaultTexture;
85
- uniform sampler2D samplerArr[SLICE_SIZE];
86
- uniform int samplerCount;
87
- varying vec2 vTextureCoord;
88
-
89
- ${DEF_BLEND_WEBGL1}
90
-
91
- void main(void) {
92
- gl_FragColor = texture2D( defaultTexture, vTextureCoord );
32
+
33
+ const SLICE_SIZE = 4;
34
+
35
+ export function drawnode_screen_nl() {
36
+ return new Program("drawnode_screen_nl", {
37
+ uniforms: {
38
+ projectionMatrix: "mat4",
39
+ viewMatrix: "mat4",
40
+ eyePositionHigh: "vec3",
41
+ eyePositionLow: "vec3",
42
+ samplerCount: "int",
43
+ tileOffsetArr: "vec4",
44
+ layerOpacityArr: "float",
45
+ samplerArr: "sampler2darray",
46
+ defaultTexture: "sampler2d",
47
+ height: "float"
48
+ },
49
+ attributes: {
50
+ aVertexPositionHigh: "vec3",
51
+ aVertexPositionLow: "vec3",
52
+ aTextureCoord: "vec2"
53
+ },
54
+
55
+ vertexShader: `attribute vec3 aVertexPositionHigh;
56
+ attribute vec3 aVertexPositionLow;
57
+ attribute vec2 aTextureCoord;
58
+
59
+ uniform mat4 projectionMatrix;
60
+ uniform mat4 viewMatrix;
61
+ uniform vec3 eyePositionHigh;
62
+ uniform vec3 eyePositionLow;
63
+ uniform float height;
64
+
65
+ varying vec2 vTextureCoord;
66
+
67
+ void main(void) {
68
+ vTextureCoord = aTextureCoord;
69
+
70
+ vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
71
+ vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
72
+ vec3 lowDiff = aVertexPositionLow + normalize(aVertexPosition) * height - eyePositionLow;
73
+
74
+ mat4 viewMatrixRTE = viewMatrix;
75
+ viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
76
+
77
+ gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
78
+ }`,
79
+
80
+ fragmentShader: `precision highp float;
81
+ #define SLICE_SIZE ${SLICE_SIZE + 1}
82
+ uniform vec4 tileOffsetArr[SLICE_SIZE];
83
+ uniform float layerOpacityArr[SLICE_SIZE];
84
+ uniform sampler2D defaultTexture;
85
+ uniform sampler2D samplerArr[SLICE_SIZE];
86
+ uniform int samplerCount;
87
+ varying vec2 vTextureCoord;
88
+
89
+ ${DEF_BLEND_WEBGL1}
90
+
91
+ void main(void) {
92
+ gl_FragColor = texture2D( defaultTexture, vTextureCoord );
93
93
  if( samplerCount == 0 ) return;
94
94
 
95
- vec4 src;
96
-
97
- blend(gl_FragColor, samplerArr[0], tileOffsetArr[0], layerOpacityArr[0]);
98
- if( samplerCount == 1 ) return;
99
-
100
- blend(gl_FragColor, samplerArr[1], tileOffsetArr[1], layerOpacityArr[1]);
101
- if( samplerCount == 2 ) return;
102
-
103
- blend(gl_FragColor, samplerArr[2], tileOffsetArr[2], layerOpacityArr[2]);
104
- if( samplerCount == 3 ) return;
105
-
106
- blend(gl_FragColor, samplerArr[3], tileOffsetArr[3], layerOpacityArr[3]);
107
- if( samplerCount == 4 ) return;
108
-
109
- blend(gl_FragColor, samplerArr[4], tileOffsetArr[4], layerOpacityArr[4]);
110
- }`
111
- });
112
- }
113
-
114
- export function drawnode_screen_wl() {
115
- return new Program("drawnode_screen_wl", {
116
- uniforms: {
117
- projectionMatrix: "mat4",
118
- viewMatrix: "mat4",
119
- eyePositionHigh: "vec3",
120
- eyePositionLow: "vec3",
121
- height: "float",
122
-
123
- uGlobalTextureCoord: "vec4",
124
- uNormalMapBias: "vec3",
125
-
126
- samplerCount: "int",
127
- tileOffsetArr: "vec4",
128
- layerOpacityArr: "float",
129
- samplerArr: "sampler2darray",
130
- defaultTexture: "sampler2d",
131
- normalMatrix: "mat3",
132
- uNormalMap: "sampler2d",
133
- nightTexture: "sampler2d",
134
- specularTexture: "sampler2d",
135
- lightsPositions: "vec4",
136
- diffuse: "vec3",
137
- ambient: "vec3",
138
- specular: "vec4"
139
- },
140
- attributes: {
141
- aVertexPositionHigh: "vec3",
142
- aVertexPositionLow: "vec3",
143
- aTextureCoord: "vec2"
144
- },
145
-
146
- vertexShader: `attribute vec3 aVertexPositionHigh;
147
- attribute vec3 aVertexPositionLow;
148
- attribute vec2 aTextureCoord;
149
-
150
- uniform mat4 projectionMatrix;
151
- uniform mat4 viewMatrix;
152
- uniform float height;
153
- uniform vec4 uGlobalTextureCoord;
154
- uniform vec3 uNormalMapBias;
155
- uniform vec3 eyePositionHigh;
156
- uniform vec3 eyePositionLow;
157
-
158
- varying vec4 vTextureCoord;
159
- varying vec2 vGlobalTextureCoord;
160
- varying vec4 v_vertex;
161
- varying float v_height;
162
-
163
- void main(void) {
164
-
165
- vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
166
- vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
167
- vec3 lowDiff = aVertexPositionLow + normalize(aVertexPosition) * height - eyePositionLow;
168
-
169
- mat4 viewMatrixRTE = viewMatrix;
170
- viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
171
-
172
- v_height = height;
173
- vec3 heightVertex = aVertexPosition + normalize(aVertexPosition) * height;
174
- v_vertex = viewMatrix * vec4(heightVertex, 1.0);
175
- vTextureCoord.xy = aTextureCoord;
176
- vGlobalTextureCoord = uGlobalTextureCoord.xy + (uGlobalTextureCoord.zw - uGlobalTextureCoord.xy) * aTextureCoord;
177
- vTextureCoord.zw = uNormalMapBias.z * ( aTextureCoord + uNormalMapBias.xy );
178
- gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
179
- }`,
180
-
181
- fragmentShader: `precision highp float;
182
-
183
- #define MAX_POINT_LIGHTS 1
184
- #define SLICE_SIZE ${SLICE_SIZE + 1}
185
-
186
- uniform vec3 diffuse;
187
- uniform vec3 ambient;
188
- uniform vec4 specular;
189
-
190
- uniform sampler2D uNormalMap;
191
- uniform vec4 lightsPositions[MAX_POINT_LIGHTS];
192
- uniform mat3 normalMatrix;
193
- uniform sampler2D nightTexture;
194
- uniform sampler2D specularTexture;
195
-
196
- uniform vec4 tileOffsetArr[SLICE_SIZE];
197
- uniform float layerOpacityArr[SLICE_SIZE];
198
-
199
- uniform sampler2D defaultTexture;
200
- uniform sampler2D samplerArr[SLICE_SIZE];
201
- uniform int samplerCount;
202
-
203
- varying vec4 vTextureCoord;
204
- varying vec2 vGlobalTextureCoord;
205
- varying vec4 v_vertex;
206
- varying float v_height;
207
-
208
- ${NIGHT}
209
-
210
- ${DEF_BLEND}
211
-
212
-
213
- void main(void) {
214
-
215
- float overGround = 1.0 - step(0.1, v_height);
216
- vec3 normal = normalize(normalMatrix * ((texture2D(uNormalMap, vTextureCoord.zw).rgb - 0.5) * 2.0));
217
- vec3 lightDirection = normalize(lightsPositions[0].xyz - v_vertex.xyz * lightsPositions[0].w);
218
- vec3 eyeDirection = normalize(-v_vertex.xyz);
219
- vec3 reflectionDirection = reflect(-lightDirection, normal);
220
- vec4 nightImageColor = texture2D( nightTexture, vGlobalTextureCoord.st );
221
- float shininess = texture2D( specularTexture, vGlobalTextureCoord.st ).r * 255.0 * overGround;
222
- float reflection = max( dot(reflectionDirection, eyeDirection), 0.0);
223
- float diffuseLightWeighting = max(dot(normal, lightDirection), 0.0);
224
- vec3 night = nightStep * (0.3 - diffuseLightWeighting) * nightImageColor.rgb;
225
- night *= overGround * step(0.0, night);
226
-
227
- vec3 spec = specular.rgb * pow( reflection, specular.w) * shininess;
228
- vec3 lightWeighting = ambient + diffuse * diffuseLightWeighting + spec + night;
229
-
230
- gl_FragColor = texture2D( defaultTexture, vTextureCoord.xy );
231
- if( samplerCount == 0 ) {
232
- gl_FragColor *= lightWeighting;
233
- return;
95
+ vec4 src;
96
+
97
+ blend(gl_FragColor, samplerArr[0], tileOffsetArr[0], layerOpacityArr[0]);
98
+ if( samplerCount == 1 ) return;
99
+
100
+ blend(gl_FragColor, samplerArr[1], tileOffsetArr[1], layerOpacityArr[1]);
101
+ if( samplerCount == 2 ) return;
102
+
103
+ blend(gl_FragColor, samplerArr[2], tileOffsetArr[2], layerOpacityArr[2]);
104
+ if( samplerCount == 3 ) return;
105
+
106
+ blend(gl_FragColor, samplerArr[3], tileOffsetArr[3], layerOpacityArr[3]);
107
+ if( samplerCount == 4 ) return;
108
+
109
+ blend(gl_FragColor, samplerArr[4], tileOffsetArr[4], layerOpacityArr[4]);
110
+ }`
111
+ });
112
+ }
113
+
114
+ export function drawnode_screen_wl() {
115
+ return new Program("drawnode_screen_wl", {
116
+ uniforms: {
117
+ projectionMatrix: "mat4",
118
+ viewMatrix: "mat4",
119
+ eyePositionHigh: "vec3",
120
+ eyePositionLow: "vec3",
121
+ height: "float",
122
+
123
+ uGlobalTextureCoord: "vec4",
124
+ uNormalMapBias: "vec3",
125
+
126
+ samplerCount: "int",
127
+ tileOffsetArr: "vec4",
128
+ layerOpacityArr: "float",
129
+ samplerArr: "sampler2darray",
130
+ defaultTexture: "sampler2d",
131
+ normalMatrix: "mat3",
132
+ uNormalMap: "sampler2d",
133
+ nightTexture: "sampler2d",
134
+ specularTexture: "sampler2d",
135
+ lightsPositions: "vec4",
136
+ diffuse: "vec3",
137
+ ambient: "vec3",
138
+ specular: "vec4"
139
+ },
140
+ attributes: {
141
+ aVertexPositionHigh: "vec3",
142
+ aVertexPositionLow: "vec3",
143
+ aTextureCoord: "vec2"
144
+ },
145
+
146
+ vertexShader: `attribute vec3 aVertexPositionHigh;
147
+ attribute vec3 aVertexPositionLow;
148
+ attribute vec2 aTextureCoord;
149
+
150
+ uniform mat4 projectionMatrix;
151
+ uniform mat4 viewMatrix;
152
+ uniform float height;
153
+ uniform vec4 uGlobalTextureCoord;
154
+ uniform vec3 uNormalMapBias;
155
+ uniform vec3 eyePositionHigh;
156
+ uniform vec3 eyePositionLow;
157
+
158
+ varying vec4 vTextureCoord;
159
+ varying vec2 vGlobalTextureCoord;
160
+ varying vec4 v_vertex;
161
+ varying float v_height;
162
+
163
+ void main(void) {
164
+
165
+ vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
166
+ vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
167
+ vec3 lowDiff = aVertexPositionLow + normalize(aVertexPosition) * height - eyePositionLow;
168
+
169
+ mat4 viewMatrixRTE = viewMatrix;
170
+ viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
171
+
172
+ v_height = height;
173
+ vec3 heightVertex = aVertexPosition + normalize(aVertexPosition) * height;
174
+ v_vertex = viewMatrix * vec4(heightVertex, 1.0);
175
+ vTextureCoord.xy = aTextureCoord;
176
+ vGlobalTextureCoord = uGlobalTextureCoord.xy + (uGlobalTextureCoord.zw - uGlobalTextureCoord.xy) * aTextureCoord;
177
+ vTextureCoord.zw = uNormalMapBias.z * ( aTextureCoord + uNormalMapBias.xy );
178
+ gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
179
+ }`,
180
+
181
+ fragmentShader: `precision highp float;
182
+
183
+ #define MAX_POINT_LIGHTS 1
184
+ #define SLICE_SIZE ${SLICE_SIZE + 1}
185
+
186
+ uniform vec3 diffuse;
187
+ uniform vec3 ambient;
188
+ uniform vec4 specular;
189
+
190
+ uniform sampler2D uNormalMap;
191
+ uniform vec4 lightsPositions[MAX_POINT_LIGHTS];
192
+ uniform mat3 normalMatrix;
193
+ uniform sampler2D nightTexture;
194
+ uniform sampler2D specularTexture;
195
+
196
+ uniform vec4 tileOffsetArr[SLICE_SIZE];
197
+ uniform float layerOpacityArr[SLICE_SIZE];
198
+
199
+ uniform sampler2D defaultTexture;
200
+ uniform sampler2D samplerArr[SLICE_SIZE];
201
+ uniform int samplerCount;
202
+
203
+ varying vec4 vTextureCoord;
204
+ varying vec2 vGlobalTextureCoord;
205
+ varying vec4 v_vertex;
206
+ varying float v_height;
207
+
208
+ ${NIGHT}
209
+
210
+ ${DEF_BLEND_WEBGL1}
211
+
212
+
213
+ void main(void) {
214
+
215
+ float overGround = 1.0 - step(0.1, v_height);
216
+ vec3 normal = normalize(normalMatrix * ((texture2D(uNormalMap, vTextureCoord.zw).rgb - 0.5) * 2.0));
217
+ vec3 lightDirection = normalize(lightsPositions[0].xyz - v_vertex.xyz * lightsPositions[0].w);
218
+ vec3 eyeDirection = normalize(-v_vertex.xyz);
219
+ vec3 reflectionDirection = reflect(-lightDirection, normal);
220
+ vec4 nightImageColor = texture2D( nightTexture, vGlobalTextureCoord.st );
221
+ float shininess = texture2D( specularTexture, vGlobalTextureCoord.st ).r * 255.0 * overGround;
222
+ float reflection = max( dot(reflectionDirection, eyeDirection), 0.0);
223
+ float diffuseLightWeighting = max(dot(normal, lightDirection), 0.0);
224
+ vec3 night = nightStep * (0.3 - diffuseLightWeighting) * nightImageColor.rgb;
225
+ night *= overGround * step(0.0, night);
226
+
227
+ vec3 spec = specular.rgb * pow( reflection, specular.w) * shininess;
228
+ vec3 lightWeighting = ambient + diffuse * diffuseLightWeighting + spec + night;
229
+
230
+ gl_FragColor = texture2D( defaultTexture, vTextureCoord.xy );
231
+ if( samplerCount == 0 ) {
232
+ gl_FragColor *= vec4(lightWeighting, 1);
233
+ return;
234
234
  }
235
235
 
236
- vec4 src;
237
-
238
- blend(gl_FragColor, samplerArr[0], tileOffsetArr[0], layerOpacityArr[0]);
239
- if( samplerCount == 1 ) {
240
- gl_FragColor *= lightWeighting;
241
- return;
242
- }
243
-
244
- blend(gl_FragColor, samplerArr[1], tileOffsetArr[1], layerOpacityArr[1]);
245
- if( samplerCount == 2 ) {
246
- gl_FragColor *= lightWeighting;
247
- return;
248
- }
249
-
250
- blend(gl_FragColor, samplerArr[2], tileOffsetArr[2], layerOpacityArr[2]);
251
- if( samplerCount == 3 ) {
252
- gl_FragColor *= lightWeighting;
253
- return;
254
- }
255
-
256
- blend(gl_FragColor, samplerArr[3], tileOffsetArr[3], layerOpacityArr[3]);
257
- if( samplerCount == 4 ) {
258
- gl_FragColor *= lightWeighting;
259
- return;
260
- }
261
-
262
- blend(gl_FragColor, samplerArr[4], tileOffsetArr[4], layerOpacityArr[4]);
263
- gl_FragColor *= lightWeighting;
264
- }`
265
- });
266
- }
267
-
268
- export function drawnode_screen_wl_webgl2() {
269
- return new Program("drawnode_screen_wl", {
270
- uniforms: {
271
- projectionMatrix: "mat4",
272
- viewMatrix: "mat4",
273
- eyePositionHigh: "vec3",
274
- eyePositionLow: "vec3",
275
- height: "float",
276
-
277
- uGlobalTextureCoord: "vec4",
278
- uNormalMapBias: "vec3",
279
-
280
- samplerCount: "int",
281
- tileOffsetArr: "vec4",
282
- layerOpacityArr: "float",
283
- samplerArr: "sampler2darray",
284
- defaultTexture: "sampler2d",
285
- normalMatrix: "mat3",
286
- uNormalMap: "sampler2d",
287
- nightTexture: "sampler2d",
288
- specularTexture: "sampler2d",
289
- lightsPositions: "vec4",
290
- diffuse: "vec3",
291
- ambient: "vec3",
292
- specular: "vec4"
293
- },
294
- attributes: {
295
- aVertexPositionHigh: "vec3",
296
- aVertexPositionLow: "vec3",
297
- aTextureCoord: "vec2"
298
- },
299
-
300
- vertexShader: `#version 300 es
301
-
302
- in vec3 aVertexPositionHigh;
303
- in vec3 aVertexPositionLow;
304
- in vec2 aTextureCoord;
305
-
306
- uniform mat4 projectionMatrix;
307
- uniform mat4 viewMatrix;
308
- uniform float height;
309
- uniform vec4 uGlobalTextureCoord;
310
- uniform vec3 uNormalMapBias;
311
- uniform vec3 eyePositionHigh;
312
- uniform vec3 eyePositionLow;
313
-
314
- out vec4 vTextureCoord;
315
- out vec2 vGlobalTextureCoord;
316
- out vec4 v_vertex;
317
- out float v_height;
318
-
319
- void main(void) {
320
-
321
- vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
322
- vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
323
- vec3 lowDiff = aVertexPositionLow + normalize(aVertexPosition) * height - eyePositionLow;
324
-
325
- mat4 viewMatrixRTE = viewMatrix;
326
- viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
327
-
328
- v_height = height;
329
- vec3 heightVertex = aVertexPosition + normalize(aVertexPosition) * height;
330
- v_vertex = viewMatrix * vec4(heightVertex, 1.0);
331
- vTextureCoord.xy = aTextureCoord;
332
- vGlobalTextureCoord = uGlobalTextureCoord.xy + (uGlobalTextureCoord.zw - uGlobalTextureCoord.xy) * aTextureCoord;
333
- vTextureCoord.zw = uNormalMapBias.z * ( aTextureCoord + uNormalMapBias.xy );
334
- gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
335
- }`,
336
-
337
- fragmentShader: `#version 300 es
338
-
339
- precision highp float;
340
-
341
- #define MAX_POINT_LIGHTS 1
342
- #define SLICE_SIZE ${SLICE_SIZE + 1}
343
-
344
- uniform vec3 diffuse;
345
- uniform vec3 ambient;
346
- uniform vec4 specular;
347
-
348
- uniform sampler2D uNormalMap;
349
- uniform vec4 lightsPositions[MAX_POINT_LIGHTS];
350
- uniform mat3 normalMatrix;
351
- uniform sampler2D nightTexture;
352
- uniform sampler2D specularTexture;
353
-
354
- uniform vec4 tileOffsetArr[SLICE_SIZE];
355
- uniform float layerOpacityArr[SLICE_SIZE];
356
-
357
- uniform sampler2D defaultTexture;
358
- uniform sampler2D samplerArr[SLICE_SIZE];
359
- uniform int samplerCount;
360
-
361
- in vec4 vTextureCoord;
362
- in vec2 vGlobalTextureCoord;
363
- in vec4 v_vertex;
364
- in float v_height;
365
-
366
- float shininess;
367
- float reflection;
368
- float diffuseLightWeighting;
369
- vec3 night;
370
-
371
- layout(location = 0) out vec4 fragColor;
372
-
373
- ${NIGHT}
374
-
375
- ${DEF_BLEND}
376
-
236
+ vec4 src;
237
+
238
+ blend(gl_FragColor, samplerArr[0], tileOffsetArr[0], layerOpacityArr[0]);
239
+ if( samplerCount == 1 ) {
240
+ gl_FragColor *= vec4(lightWeighting, 1);
241
+ return;
242
+ }
243
+
244
+ blend(gl_FragColor, samplerArr[1], tileOffsetArr[1], layerOpacityArr[1]);
245
+ if( samplerCount == 2 ) {
246
+ gl_FragColor *= vec4(lightWeighting, 1);
247
+ return;
248
+ }
249
+
250
+ blend(gl_FragColor, samplerArr[2], tileOffsetArr[2], layerOpacityArr[2]);
251
+ if( samplerCount == 3 ) {
252
+ gl_FragColor *= vec4(lightWeighting, 1);
253
+ return;
254
+ }
255
+
256
+ blend(gl_FragColor, samplerArr[3], tileOffsetArr[3], layerOpacityArr[3]);
257
+ if( samplerCount == 4 ) {
258
+ gl_FragColor *= vec4(lightWeighting, 1);
259
+ return;
260
+ }
261
+
262
+ blend(gl_FragColor, samplerArr[4], tileOffsetArr[4], layerOpacityArr[4]);
263
+ gl_FragColor *= vec4(lightWeighting, 1);
264
+ }`
265
+ });
266
+ }
267
+
268
+ export function drawnode_screen_wl_webgl2() {
269
+ return new Program("drawnode_screen_wl", {
270
+ uniforms: {
271
+ projectionMatrix: "mat4",
272
+ viewMatrix: "mat4",
273
+ eyePositionHigh: "vec3",
274
+ eyePositionLow: "vec3",
275
+ height: "float",
276
+
277
+ uGlobalTextureCoord: "vec4",
278
+ uNormalMapBias: "vec3",
279
+
280
+ samplerCount: "int",
281
+ tileOffsetArr: "vec4",
282
+ layerOpacityArr: "float",
283
+ samplerArr: "sampler2darray",
284
+ defaultTexture: "sampler2d",
285
+ normalMatrix: "mat3",
286
+ uNormalMap: "sampler2d",
287
+ nightTexture: "sampler2d",
288
+ specularTexture: "sampler2d",
289
+ lightsPositions: "vec4",
290
+ diffuse: "vec3",
291
+ ambient: "vec3",
292
+ specular: "vec4"
293
+ },
294
+ attributes: {
295
+ aVertexPositionHigh: "vec3",
296
+ aVertexPositionLow: "vec3",
297
+ aTextureCoord: "vec2"
298
+ },
299
+
300
+ vertexShader: `#version 300 es
301
+
302
+ in vec3 aVertexPositionHigh;
303
+ in vec3 aVertexPositionLow;
304
+ in vec2 aTextureCoord;
305
+
306
+ uniform mat4 projectionMatrix;
307
+ uniform mat4 viewMatrix;
308
+ uniform float height;
309
+ uniform vec4 uGlobalTextureCoord;
310
+ uniform vec3 uNormalMapBias;
311
+ uniform vec3 eyePositionHigh;
312
+ uniform vec3 eyePositionLow;
313
+
314
+ out vec4 vTextureCoord;
315
+ out vec2 vGlobalTextureCoord;
316
+ out vec4 v_vertex;
317
+ out float v_height;
318
+
319
+ void main(void) {
320
+
321
+ vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
322
+ vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
323
+ vec3 lowDiff = aVertexPositionLow + normalize(aVertexPosition) * height - eyePositionLow;
324
+
325
+ mat4 viewMatrixRTE = viewMatrix;
326
+ viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
327
+
328
+ v_height = height;
329
+ vec3 heightVertex = aVertexPosition + normalize(aVertexPosition) * height;
330
+ v_vertex = viewMatrix * vec4(heightVertex, 1.0);
331
+ vTextureCoord.xy = aTextureCoord;
332
+ vGlobalTextureCoord = uGlobalTextureCoord.xy + (uGlobalTextureCoord.zw - uGlobalTextureCoord.xy) * aTextureCoord;
333
+ vTextureCoord.zw = uNormalMapBias.z * ( aTextureCoord + uNormalMapBias.xy );
334
+ gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
335
+ }`,
336
+
337
+ fragmentShader: `#version 300 es
338
+
339
+ precision highp float;
340
+
341
+ #define MAX_POINT_LIGHTS 1
342
+ #define SLICE_SIZE ${SLICE_SIZE + 1}
343
+
344
+ uniform vec3 diffuse;
345
+ uniform vec3 ambient;
346
+ uniform vec4 specular;
347
+
348
+ uniform sampler2D uNormalMap;
349
+ uniform vec4 lightsPositions[MAX_POINT_LIGHTS];
350
+ uniform mat3 normalMatrix;
351
+ uniform sampler2D nightTexture;
352
+ uniform sampler2D specularTexture;
353
+
354
+ uniform vec4 tileOffsetArr[SLICE_SIZE];
355
+ uniform float layerOpacityArr[SLICE_SIZE];
356
+
357
+ uniform sampler2D defaultTexture;
358
+ uniform sampler2D samplerArr[SLICE_SIZE];
359
+ uniform int samplerCount;
360
+
361
+ in vec4 vTextureCoord;
362
+ in vec2 vGlobalTextureCoord;
363
+ in vec4 v_vertex;
364
+ in float v_height;
365
+
366
+ float shininess;
367
+ float reflection;
368
+ float diffuseLightWeighting;
369
+ vec3 night;
370
+
371
+ layout(location = 0) out vec4 fragColor;
372
+
373
+ ${NIGHT}
374
+
375
+ ${DEF_BLEND}
376
+
377
377
  void main(void) {
378
-
379
- float overGround = 1.0 - step(0.1, v_height);
380
- vec3 normal = normalize(normalMatrix * ((texture(uNormalMap, vTextureCoord.zw).rgb - 0.5) * 2.0));
381
- vec3 lightDirection = normalize(lightsPositions[0].xyz - v_vertex.xyz * lightsPositions[0].w);
382
- vec3 eyeDirection = normalize(-v_vertex.xyz);
383
- vec3 reflectionDirection = reflect(-lightDirection, normal);
384
- vec4 nightImageColor = texture( nightTexture, vGlobalTextureCoord.st );
385
-
386
- shininess = texture( specularTexture, vGlobalTextureCoord.st ).r * 255.0 * overGround;
387
- reflection = max( dot(reflectionDirection, eyeDirection), 0.0);
388
- diffuseLightWeighting = max(dot(normal, lightDirection), 0.0);
389
- night = nightStep * (.18 - diffuseLightWeighting * 3.0) * nightImageColor.rgb;
390
- night *= overGround * step(0.0, night);
391
-
392
- vec3 spec = specular.rgb * pow( reflection, specular.w) * shininess;
393
- vec4 lightWeighting = vec4(ambient + diffuse * diffuseLightWeighting + spec + night, 1.0);
394
-
395
- fragColor = texture( defaultTexture, vTextureCoord.xy );
396
- if( samplerCount == 0 ) {
397
- fragColor *= lightWeighting;
398
- return;
378
+
379
+ float overGround = 1.0 - step(0.1, v_height);
380
+ vec3 normal = normalize(normalMatrix * ((texture(uNormalMap, vTextureCoord.zw).rgb - 0.5) * 2.0));
381
+ vec3 lightDirection = normalize(lightsPositions[0].xyz - v_vertex.xyz * lightsPositions[0].w);
382
+ vec3 eyeDirection = normalize(-v_vertex.xyz);
383
+ vec3 reflectionDirection = reflect(-lightDirection, normal);
384
+ vec4 nightImageColor = texture( nightTexture, vGlobalTextureCoord.st );
385
+
386
+ shininess = texture( specularTexture, vGlobalTextureCoord.st ).r * 255.0 * overGround;
387
+ reflection = max( dot(reflectionDirection, eyeDirection), 0.0);
388
+ diffuseLightWeighting = max(dot(normal, lightDirection), 0.0);
389
+ night = nightStep * (.18 - diffuseLightWeighting * 3.0) * nightImageColor.rgb;
390
+ night *= overGround * step(0.0, night);
391
+
392
+ vec3 spec = specular.rgb * pow( reflection, specular.w) * shininess;
393
+ vec4 lightWeighting = vec4(ambient + diffuse * diffuseLightWeighting + spec + night, 1.0);
394
+
395
+ fragColor = texture( defaultTexture, vTextureCoord.xy );
396
+ if( samplerCount == 0 ) {
397
+ fragColor *= lightWeighting;
398
+ return;
399
+ }
400
+
401
+ vec4 src;
402
+
403
+ blend(fragColor, samplerArr[0], tileOffsetArr[0], layerOpacityArr[0]);
404
+ if( samplerCount == 1 ) {
405
+ fragColor *= lightWeighting;
406
+ return;
407
+ }
408
+
409
+ blend(fragColor, samplerArr[1], tileOffsetArr[1], layerOpacityArr[1]);
410
+ if( samplerCount == 2 ) {
411
+ fragColor *= lightWeighting;
412
+ return;
413
+ }
414
+
415
+ blend(fragColor, samplerArr[2], tileOffsetArr[2], layerOpacityArr[2]);
416
+ if( samplerCount == 3 ) {
417
+ fragColor *= lightWeighting;
418
+ return;
399
419
  }
400
420
 
401
- vec4 src;
402
-
403
- blend(fragColor, samplerArr[0], tileOffsetArr[0], layerOpacityArr[0]);
404
- if( samplerCount == 1 ) {
405
- fragColor *= lightWeighting;
406
- return;
407
- }
408
-
409
- blend(fragColor, samplerArr[1], tileOffsetArr[1], layerOpacityArr[1]);
410
- if( samplerCount == 2 ) {
411
- fragColor *= lightWeighting;
412
- return;
413
- }
414
-
415
- blend(fragColor, samplerArr[2], tileOffsetArr[2], layerOpacityArr[2]);
416
- if( samplerCount == 3 ) {
417
- fragColor *= lightWeighting;
418
- return;
419
- }
420
-
421
- blend(fragColor, samplerArr[3], tileOffsetArr[3], layerOpacityArr[3]);
422
- if( samplerCount == 4 ) {
423
- fragColor *= lightWeighting;
424
- return;
425
- }
426
-
427
- blend(fragColor, samplerArr[4], tileOffsetArr[4], layerOpacityArr[4]);
428
- fragColor *= lightWeighting;
429
- }`
430
- });
431
- }
432
-
433
- export function drawnode_colorPicking() {
434
- return new Program("drawnode_colorPicking", {
435
- uniforms: {
436
- projectionMatrix: "mat4",
437
- viewMatrix: "mat4",
438
- eyePositionHigh: "vec3",
439
- eyePositionLow: "vec3",
440
- samplerCount: "int",
441
- tileOffsetArr: "vec4",
442
- samplerArr: "sampler2darray",
443
- pickingMaskArr: "sampler2darray",
444
- pickingColorArr: "vec4",
445
- height: "float"
446
- },
447
- attributes: {
448
- aVertexPositionHigh: "vec3",
449
- aVertexPositionLow: "vec3",
450
- aTextureCoord: "vec2"
451
- },
452
-
453
- vertexShader: `attribute vec3 aVertexPositionHigh;
454
- attribute vec3 aVertexPositionLow;
455
- attribute vec2 aTextureCoord;
456
-
457
- uniform mat4 projectionMatrix;
458
- uniform mat4 viewMatrix;
459
- uniform vec3 eyePositionHigh;
460
- uniform vec3 eyePositionLow;
461
- uniform float height;
462
-
463
- varying vec2 vTextureCoord;
464
-
465
- void main(void) {
466
-
467
- vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
468
- vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
469
- vec3 lowDiff = aVertexPositionLow + normalize(aVertexPosition) * height - eyePositionLow;
470
-
471
- mat4 viewMatrixRTE = viewMatrix;
472
- viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
473
-
474
- vTextureCoord = aTextureCoord;
475
- gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
476
- }`,
477
-
478
- fragmentShader: `precision highp float;
479
- #define SLICE_SIZE ${SLICE_SIZE + 1}
480
- uniform vec4 tileOffsetArr[SLICE_SIZE];
481
- uniform vec4 pickingColorArr[SLICE_SIZE];
482
- uniform sampler2D samplerArr[SLICE_SIZE];
483
- uniform sampler2D pickingMaskArr[SLICE_SIZE];
484
- uniform int samplerCount;
485
- varying vec2 vTextureCoord;
486
-
487
- ${DEF_BLEND_PICKING}
488
-
489
- void main(void) {
490
- gl_FragColor = vec4(0.0);
491
- if( samplerCount == 0 ) return;
492
-
493
- vec2 tc;
494
- vec4 t;
421
+ blend(fragColor, samplerArr[3], tileOffsetArr[3], layerOpacityArr[3]);
422
+ if( samplerCount == 4 ) {
423
+ fragColor *= lightWeighting;
424
+ return;
425
+ }
426
+
427
+ blend(fragColor, samplerArr[4], tileOffsetArr[4], layerOpacityArr[4]);
428
+ fragColor *= lightWeighting;
429
+ }`
430
+ });
431
+ }
432
+
433
+ export function drawnode_colorPicking() {
434
+ return new Program("drawnode_colorPicking", {
435
+ uniforms: {
436
+ projectionMatrix: "mat4",
437
+ viewMatrix: "mat4",
438
+ eyePositionHigh: "vec3",
439
+ eyePositionLow: "vec3",
440
+ samplerCount: "int",
441
+ tileOffsetArr: "vec4",
442
+ samplerArr: "sampler2darray",
443
+ pickingMaskArr: "sampler2darray",
444
+ pickingColorArr: "vec4",
445
+ height: "float"
446
+ },
447
+ attributes: {
448
+ aVertexPositionHigh: "vec3",
449
+ aVertexPositionLow: "vec3",
450
+ aTextureCoord: "vec2"
451
+ },
452
+
453
+ vertexShader: `attribute vec3 aVertexPositionHigh;
454
+ attribute vec3 aVertexPositionLow;
455
+ attribute vec2 aTextureCoord;
456
+
457
+ uniform mat4 projectionMatrix;
458
+ uniform mat4 viewMatrix;
459
+ uniform vec3 eyePositionHigh;
460
+ uniform vec3 eyePositionLow;
461
+ uniform float height;
462
+
463
+ varying vec2 vTextureCoord;
464
+
465
+ void main(void) {
466
+
467
+ vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
468
+ vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
469
+ vec3 lowDiff = aVertexPositionLow + normalize(aVertexPosition) * height - eyePositionLow;
470
+
471
+ mat4 viewMatrixRTE = viewMatrix;
472
+ viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
473
+
474
+ vTextureCoord = aTextureCoord;
475
+ gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
476
+ }`,
477
+
478
+ fragmentShader: `precision highp float;
479
+ #define SLICE_SIZE ${SLICE_SIZE + 1}
480
+ uniform vec4 tileOffsetArr[SLICE_SIZE];
481
+ uniform vec4 pickingColorArr[SLICE_SIZE];
482
+ uniform sampler2D samplerArr[SLICE_SIZE];
483
+ uniform sampler2D pickingMaskArr[SLICE_SIZE];
484
+ uniform int samplerCount;
485
+ varying vec2 vTextureCoord;
486
+
487
+ ${DEF_BLEND_PICKING}
488
+
489
+ void main(void) {
490
+ gl_FragColor = vec4(0.0);
491
+ if( samplerCount == 0 ) return;
492
+
493
+ vec2 tc;
494
+ vec4 t;
495
495
  vec4 p;
496
-
497
- blendPicking(gl_FragColor, tileOffsetArr[0], samplerArr[0], pickingMaskArr[0], pickingColorArr[0], 1.0);
498
- if( samplerCount == 1 ) return;
499
-
500
- blendPicking(gl_FragColor, tileOffsetArr[1], samplerArr[1], pickingMaskArr[1], pickingColorArr[1], 1.0);
501
- if( samplerCount == 2 ) return;
502
-
503
- blendPicking(gl_FragColor, tileOffsetArr[2], samplerArr[2], pickingMaskArr[2], pickingColorArr[2], 1.0);
504
- if( samplerCount == 3 ) return;
505
-
506
- blendPicking(gl_FragColor, tileOffsetArr[3], samplerArr[3], pickingMaskArr[3], pickingColorArr[3], 1.0);
507
- if( samplerCount == 4 ) return;
508
-
509
- blendPicking(gl_FragColor, tileOffsetArr[4], samplerArr[4], pickingMaskArr[4], pickingColorArr[4], 1.0);
510
- }`
511
- });
512
- }
513
-
514
- export function drawnode_heightPicking() {
515
- return new Program("drawnode_heightPicking", {
516
- uniforms: {
517
- projectionMatrix: "mat4",
518
- viewMatrix: "mat4",
519
- height: "float",
520
- eyePositionHigh: "vec3",
521
- eyePositionLow: "vec3"
522
- },
523
- attributes: {
524
- aVertexPositionHigh: "vec3",
525
- aVertexPositionLow: "vec3"
526
- },
527
-
528
- vertexShader: `attribute vec3 aVertexPositionHigh;
529
- attribute vec3 aVertexPositionLow;
530
-
531
- uniform mat4 projectionMatrix;
532
- uniform mat4 viewMatrix;
533
- uniform float height;
534
- uniform vec3 eyePositionHigh;
535
- uniform vec3 eyePositionLow;
536
-
537
- varying float range;
538
-
539
- void main(void) {
540
-
541
- vec3 cameraPosition = eyePositionHigh + eyePositionLow;
542
- vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
543
-
544
- vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
545
- vec3 lowDiff = aVertexPositionLow + normalize(aVertexPosition) * height - eyePositionLow;
546
-
547
- mat4 viewMatrixRTE = viewMatrix;
548
- viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
549
-
550
- range = distance(cameraPosition, aVertexPosition + normalize(aVertexPosition) * height);
551
- gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
552
- }`,
553
-
554
- fragmentShader: `precision highp float;
555
-
556
- varying float range;
557
-
558
- vec3 encode24(highp float f) {
559
- float F = abs(f);
560
- float s = step( 0.0, -f );
561
- float e = floor( log2(F) );
562
- float m = exp2(- e) * F;
563
- e = floor( log2(F) + 127.0 ) + floor( log2(m) );
564
- return vec3(
565
- ( 128.0 * s + floor( e * exp2(-1.0) ) ) / 255.0,
566
- ( 128.0 * mod( e, 2.0 ) + mod( floor( m * 128.0 ), 128.0 ) ) / 255.0,
567
- floor( mod( floor( m * exp2( 23.0 - 8.0) ), exp2(8.0) ) ) / 255.0);
568
- }
569
-
570
- void main(void) {
571
- gl_FragColor = vec4(encode24(range), 1.0);
572
- }`
573
- });
574
- }
575
-
576
- export function drawnode_depth() {
577
- return new Program("drawnode_depth", {
578
- uniforms: {
579
- projectionMatrix: "mat4",
580
- viewMatrix: "mat4",
581
- height: "float",
582
- eyePositionHigh: "vec3",
583
- eyePositionLow: "vec3",
584
- frustumPickingColor: "vec3"
585
- },
586
- attributes: {
587
- aVertexPositionHigh: "vec3",
588
- aVertexPositionLow: "vec3"
589
- },
590
-
591
- vertexShader: `attribute vec3 aVertexPositionHigh;
592
- attribute vec3 aVertexPositionLow;
593
-
594
- uniform mat4 projectionMatrix;
595
- uniform mat4 viewMatrix;
596
- uniform float height;
597
- uniform vec3 eyePositionHigh;
598
- uniform vec3 eyePositionLow;
599
-
600
- void main(void) {
601
-
602
- vec3 cameraPosition = eyePositionHigh + eyePositionLow;
603
- vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
604
-
605
- vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
606
- vec3 lowDiff = aVertexPositionLow + normalize(aVertexPosition) * height - eyePositionLow;
607
-
608
- mat4 viewMatrixRTE = viewMatrix;
609
- viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
610
-
611
- gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
612
- }`,
613
-
614
- fragmentShader: `precision highp float;
615
- uniform vec3 frustumPickingColor;
616
-
617
- void main(void) {
618
- gl_FragColor = vec4(frustumPickingColor, 1.0);
619
- } `
620
- });
621
- }
496
+
497
+ blendPicking(gl_FragColor, tileOffsetArr[0], samplerArr[0], pickingMaskArr[0], pickingColorArr[0], 1.0);
498
+ if( samplerCount == 1 ) return;
499
+
500
+ blendPicking(gl_FragColor, tileOffsetArr[1], samplerArr[1], pickingMaskArr[1], pickingColorArr[1], 1.0);
501
+ if( samplerCount == 2 ) return;
502
+
503
+ blendPicking(gl_FragColor, tileOffsetArr[2], samplerArr[2], pickingMaskArr[2], pickingColorArr[2], 1.0);
504
+ if( samplerCount == 3 ) return;
505
+
506
+ blendPicking(gl_FragColor, tileOffsetArr[3], samplerArr[3], pickingMaskArr[3], pickingColorArr[3], 1.0);
507
+ if( samplerCount == 4 ) return;
508
+
509
+ blendPicking(gl_FragColor, tileOffsetArr[4], samplerArr[4], pickingMaskArr[4], pickingColorArr[4], 1.0);
510
+ }`
511
+ });
512
+ }
513
+
514
+ export function drawnode_heightPicking() {
515
+ return new Program("drawnode_heightPicking", {
516
+ uniforms: {
517
+ projectionMatrix: "mat4",
518
+ viewMatrix: "mat4",
519
+ height: "float",
520
+ eyePositionHigh: "vec3",
521
+ eyePositionLow: "vec3"
522
+ },
523
+ attributes: {
524
+ aVertexPositionHigh: "vec3",
525
+ aVertexPositionLow: "vec3"
526
+ },
527
+
528
+ vertexShader: `attribute vec3 aVertexPositionHigh;
529
+ attribute vec3 aVertexPositionLow;
530
+
531
+ uniform mat4 projectionMatrix;
532
+ uniform mat4 viewMatrix;
533
+ uniform float height;
534
+ uniform vec3 eyePositionHigh;
535
+ uniform vec3 eyePositionLow;
536
+
537
+ varying float range;
538
+
539
+ void main(void) {
540
+
541
+ vec3 cameraPosition = eyePositionHigh + eyePositionLow;
542
+ vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
543
+
544
+ vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
545
+ vec3 lowDiff = aVertexPositionLow + normalize(aVertexPosition) * height - eyePositionLow;
546
+
547
+ mat4 viewMatrixRTE = viewMatrix;
548
+ viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
549
+
550
+ range = distance(cameraPosition, aVertexPosition + normalize(aVertexPosition) * height);
551
+ gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
552
+ }`,
553
+
554
+ fragmentShader: `precision highp float;
555
+
556
+ varying float range;
557
+
558
+ vec3 encode24(highp float f) {
559
+ float F = abs(f);
560
+ float s = step( 0.0, -f );
561
+ float e = floor( log2(F) );
562
+ float m = exp2(- e) * F;
563
+ e = floor( log2(F) + 127.0 ) + floor( log2(m) );
564
+ return vec3(
565
+ ( 128.0 * s + floor( e * exp2(-1.0) ) ) / 255.0,
566
+ ( 128.0 * mod( e, 2.0 ) + mod( floor( m * 128.0 ), 128.0 ) ) / 255.0,
567
+ floor( mod( floor( m * exp2( 23.0 - 8.0) ), exp2(8.0) ) ) / 255.0);
568
+ }
569
+
570
+ void main(void) {
571
+ gl_FragColor = vec4(encode24(range), 1.0);
572
+ }`
573
+ });
574
+ }
575
+
576
+ export function drawnode_depth() {
577
+ return new Program("drawnode_depth", {
578
+ uniforms: {
579
+ projectionMatrix: "mat4",
580
+ viewMatrix: "mat4",
581
+ height: "float",
582
+ eyePositionHigh: "vec3",
583
+ eyePositionLow: "vec3",
584
+ frustumPickingColor: "vec3"
585
+ },
586
+ attributes: {
587
+ aVertexPositionHigh: "vec3",
588
+ aVertexPositionLow: "vec3"
589
+ },
590
+
591
+ vertexShader: `attribute vec3 aVertexPositionHigh;
592
+ attribute vec3 aVertexPositionLow;
593
+
594
+ uniform mat4 projectionMatrix;
595
+ uniform mat4 viewMatrix;
596
+ uniform float height;
597
+ uniform vec3 eyePositionHigh;
598
+ uniform vec3 eyePositionLow;
599
+
600
+ void main(void) {
601
+
602
+ vec3 cameraPosition = eyePositionHigh + eyePositionLow;
603
+ vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
604
+
605
+ vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
606
+ vec3 lowDiff = aVertexPositionLow + normalize(aVertexPosition) * height - eyePositionLow;
607
+
608
+ mat4 viewMatrixRTE = viewMatrix;
609
+ viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
610
+
611
+ gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
612
+ }`,
613
+
614
+ fragmentShader: `precision highp float;
615
+ uniform vec3 frustumPickingColor;
616
+
617
+ void main(void) {
618
+ gl_FragColor = vec4(frustumPickingColor, 1.0);
619
+ } `
620
+ });
621
+ }