@openglobus/og 0.11.6 → 0.12.1

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 (213) hide show
  1. package/css/og.css +5 -2
  2. package/package.json +12 -12
  3. package/src/og/Globe.js +25 -10
  4. package/src/og/Popup.js +3 -2
  5. package/src/og/camera/Camera.js +70 -79
  6. package/src/og/camera/PlanetCamera.js +33 -33
  7. package/src/og/control/DebugInfo.js +2 -2
  8. package/src/og/control/EarthNavigation.js +26 -17
  9. package/src/og/control/Lighting.js +74 -64
  10. package/src/og/control/MouseNavigation.js +30 -29
  11. package/src/og/control/MouseWheelZoomControl.js +257 -0
  12. package/src/og/control/Sun.js +3 -3
  13. package/src/og/control/index.js +2 -0
  14. package/src/og/control/visibleExtent/Segment.js +1862 -0
  15. package/src/og/control/visibleExtent/VisibleExtent.js +80 -0
  16. package/src/og/control/visibleExtent/drawnode.js +751 -0
  17. package/src/og/ellipsoid/Ellipsoid.js +1 -1
  18. package/src/og/entity/BaseBillboard.js +67 -76
  19. package/src/og/entity/BillboardHandler.js +15 -8
  20. package/src/og/entity/Entity.js +742 -742
  21. package/src/og/entity/GeoObjectHandler.js +102 -117
  22. package/src/og/entity/Label.js +45 -48
  23. package/src/og/entity/LabelHandler.js +24 -23
  24. package/src/og/entity/LabelWorker.js +21 -16
  25. package/src/og/layer/CanvasTiles.js +8 -12
  26. package/src/og/layer/GeoImage.js +2 -10
  27. package/src/og/layer/GeoTexture2d.js +2 -10
  28. package/src/og/layer/GeoVideo.js +2 -10
  29. package/src/og/layer/Layer.js +23 -32
  30. package/src/og/layer/Material.js +1 -1
  31. package/src/og/layer/WMS.js +0 -2
  32. package/src/og/layer/XYZ.js +31 -33
  33. package/src/og/math/Vec3.js +18 -2
  34. package/src/og/quadTree/Node.js +52 -111
  35. package/src/og/quadTree/quadTree.js +1 -1
  36. package/src/og/renderer/Renderer.js +85 -122
  37. package/src/og/renderer/RendererEvents.js +44 -22
  38. package/src/og/scene/Planet.js +179 -198
  39. package/src/og/segment/Segment.js +99 -268
  40. package/src/og/segment/Slice.js +45 -0
  41. package/src/og/shaders/drawnode.js +174 -360
  42. package/src/og/shaders/toneMapping.js +1 -0
  43. package/src/og/shapes/BaseShape.js +1 -1
  44. package/src/og/terrain/EmptyTerrain.js +3 -2
  45. package/src/og/terrain/GlobusTerrain.js +2 -0
  46. package/src/og/utils/FontAtlas.js +6 -2
  47. package/src/og/utils/GeoImageCreator.js +5 -1
  48. package/src/og/utils/Loader.js +1 -1
  49. package/src/og/utils/PlainSegmentWorker.js +0 -13
  50. package/src/og/utils/TextureAtlas.js +2 -2
  51. package/src/og/utils/VectorTileCreator.js +1 -3
  52. package/src/og/utils/shared.js +1 -1
  53. package/src/og/webgl/Handler.js +156 -118
  54. package/types/Clock.d.ts +0 -94
  55. package/types/Deferred.d.ts +0 -6
  56. package/types/Events.d.ts +0 -77
  57. package/types/Extent.d.ts +0 -166
  58. package/types/Globe.d.ts +0 -82
  59. package/types/ImageCanvas.d.ts +0 -123
  60. package/types/Lock.d.ts +0 -12
  61. package/types/LonLat.d.ts +0 -108
  62. package/types/Popup.d.ts +0 -42
  63. package/types/QueueArray.d.ts +0 -19
  64. package/types/Rectangle.d.ts +0 -80
  65. package/types/Stack.d.ts +0 -19
  66. package/types/ajax.d.ts +0 -24
  67. package/types/arial.d.ts +0 -48
  68. package/types/astro/astro.d.ts +0 -38
  69. package/types/astro/earth.d.ts +0 -7
  70. package/types/astro/jd.d.ts +0 -254
  71. package/types/bv/Box.d.ts +0 -30
  72. package/types/bv/Sphere.d.ts +0 -38
  73. package/types/bv/index.d.ts +0 -3
  74. package/types/camera/Camera.d.ts +0 -312
  75. package/types/camera/Frustum.d.ts +0 -133
  76. package/types/camera/PlanetCamera.d.ts +0 -218
  77. package/types/camera/index.d.ts +0 -3
  78. package/types/cons.d.ts +0 -40
  79. package/types/control/CompassButton.d.ts +0 -17
  80. package/types/control/Control.d.ts +0 -104
  81. package/types/control/DebugInfo.d.ts +0 -15
  82. package/types/control/EarthCoordinates.d.ts +0 -47
  83. package/types/control/EarthNavigation.d.ts +0 -42
  84. package/types/control/GeoImageDragControl.d.ts +0 -6
  85. package/types/control/KeyboardNavigation.d.ts +0 -21
  86. package/types/control/LayerSwitcher.d.ts +0 -21
  87. package/types/control/Lighting.d.ts +0 -16
  88. package/types/control/MouseNavigation.d.ts +0 -47
  89. package/types/control/ScaleControl.d.ts +0 -22
  90. package/types/control/ShowFps.d.ts +0 -11
  91. package/types/control/SimpleNavigation.d.ts +0 -25
  92. package/types/control/Sun.d.ts +0 -50
  93. package/types/control/ToggleWireframe.d.ts +0 -12
  94. package/types/control/TouchNavigation.d.ts +0 -48
  95. package/types/control/ZoomControl.d.ts +0 -27
  96. package/types/control/index.d.ts +0 -17
  97. package/types/ellipsoid/Ellipsoid.d.ts +0 -146
  98. package/types/ellipsoid/index.d.ts +0 -3
  99. package/types/ellipsoid/wgs84.d.ts +0 -6
  100. package/types/entity/BaseBillboard.d.ts +0 -215
  101. package/types/entity/Billboard.d.ts +0 -94
  102. package/types/entity/BillboardHandler.d.ts +0 -78
  103. package/types/entity/Entity.d.ts +0 -348
  104. package/types/entity/EntityCollection.d.ts +0 -317
  105. package/types/entity/GeoObject.d.ts +0 -111
  106. package/types/entity/GeoObjectHandler.d.ts +0 -77
  107. package/types/entity/Geometry.d.ts +0 -74
  108. package/types/entity/GeometryHandler.d.ts +0 -76
  109. package/types/entity/Label.d.ts +0 -189
  110. package/types/entity/LabelHandler.d.ts +0 -31
  111. package/types/entity/LabelWorker.d.ts +0 -9
  112. package/types/entity/PointCloud.d.ts +0 -174
  113. package/types/entity/PointCloudHandler.d.ts +0 -38
  114. package/types/entity/Polyline.d.ts +0 -306
  115. package/types/entity/PolylineHandler.d.ts +0 -18
  116. package/types/entity/Ray.d.ts +0 -124
  117. package/types/entity/RayHandler.d.ts +0 -67
  118. package/types/entity/ShapeHandler.d.ts +0 -22
  119. package/types/entity/Strip.d.ts +0 -119
  120. package/types/entity/StripHandler.d.ts +0 -38
  121. package/types/entity/index.d.ts +0 -8
  122. package/types/index.core.d.ts +0 -65
  123. package/types/index.d.ts +0 -45
  124. package/types/index.webgl.d.ts +0 -7
  125. package/types/input/KeyboardHandler.d.ts +0 -10
  126. package/types/input/MouseHandler.d.ts +0 -5
  127. package/types/input/TouchHandler.d.ts +0 -5
  128. package/types/input/input.d.ts +0 -34
  129. package/types/layer/BaseGeoImage.d.ts +0 -94
  130. package/types/layer/CanvasTiles.d.ts +0 -68
  131. package/types/layer/GeoImage.d.ts +0 -52
  132. package/types/layer/GeoTexture2d.d.ts +0 -8
  133. package/types/layer/GeoVideo.d.ts +0 -55
  134. package/types/layer/KML.d.ts +0 -63
  135. package/types/layer/Layer.d.ts +0 -326
  136. package/types/layer/Material.d.ts +0 -45
  137. package/types/layer/Vector.d.ts +0 -208
  138. package/types/layer/WMS.d.ts +0 -63
  139. package/types/layer/XYZ.d.ts +0 -120
  140. package/types/layer/index.d.ts +0 -10
  141. package/types/light/LightSource.d.ts +0 -178
  142. package/types/math/Line2.d.ts +0 -11
  143. package/types/math/Line3.d.ts +0 -10
  144. package/types/math/Mat3.d.ts +0 -65
  145. package/types/math/Mat4.d.ts +0 -176
  146. package/types/math/Plane.d.ts +0 -18
  147. package/types/math/Quat.d.ts +0 -379
  148. package/types/math/Ray.d.ts +0 -82
  149. package/types/math/Vec2.d.ts +0 -309
  150. package/types/math/Vec3.d.ts +0 -460
  151. package/types/math/Vec4.d.ts +0 -162
  152. package/types/math/coder.d.ts +0 -43
  153. package/types/math/index.d.ts +0 -11
  154. package/types/math.d.ts +0 -261
  155. package/types/mercator.d.ts +0 -92
  156. package/types/proj/EPSG3857.d.ts +0 -6
  157. package/types/proj/EPSG4326.d.ts +0 -6
  158. package/types/proj/Proj.d.ts +0 -42
  159. package/types/quadTree/EntityCollectionNode.d.ts +0 -34
  160. package/types/quadTree/Node.d.ts +0 -61
  161. package/types/quadTree/quadTree.d.ts +0 -40
  162. package/types/renderer/Renderer.d.ts +0 -300
  163. package/types/renderer/RendererEvents.d.ts +0 -233
  164. package/types/res/images.d.ts +0 -3
  165. package/types/scene/Axes.d.ts +0 -11
  166. package/types/scene/BaseNode.d.ts +0 -60
  167. package/types/scene/Planet.d.ts +0 -577
  168. package/types/scene/RenderNode.d.ts +0 -142
  169. package/types/scene/SkyBox.d.ts +0 -10
  170. package/types/scene/index.d.ts +0 -4
  171. package/types/segment/Segment.d.ts +0 -279
  172. package/types/segment/SegmentLonLat.d.ts +0 -16
  173. package/types/segment/segmentHelper.d.ts +0 -13
  174. package/types/shaders/billboard.d.ts +0 -3
  175. package/types/shaders/depth.d.ts +0 -2
  176. package/types/shaders/drawnode.d.ts +0 -7
  177. package/types/shaders/geoObject.d.ts +0 -3
  178. package/types/shaders/label.d.ts +0 -4
  179. package/types/shaders/pointCloud.d.ts +0 -2
  180. package/types/shaders/polyline.d.ts +0 -3
  181. package/types/shaders/ray.d.ts +0 -2
  182. package/types/shaders/screenFrame.d.ts +0 -2
  183. package/types/shaders/shape.d.ts +0 -4
  184. package/types/shaders/skybox.d.ts +0 -2
  185. package/types/shaders/toneMapping.d.ts +0 -2
  186. package/types/shapes/BaseShape.d.ts +0 -250
  187. package/types/shapes/Sphere.d.ts +0 -41
  188. package/types/terrain/BilTerrain.d.ts +0 -7
  189. package/types/terrain/EmptyTerrain.d.ts +0 -72
  190. package/types/terrain/Geoid.d.ts +0 -26
  191. package/types/terrain/GlobusTerrain.d.ts +0 -116
  192. package/types/terrain/MapboxTerrain.d.ts +0 -7
  193. package/types/terrain/index.d.ts +0 -5
  194. package/types/utils/FontAtlas.d.ts +0 -14
  195. package/types/utils/GeoImageCreator.d.ts +0 -30
  196. package/types/utils/ImagesCacheManager.d.ts +0 -10
  197. package/types/utils/Loader.d.ts +0 -25
  198. package/types/utils/NormalMapCreator.d.ts +0 -39
  199. package/types/utils/PlainSegmentWorker.d.ts +0 -10
  200. package/types/utils/TerrainWorker.d.ts +0 -9
  201. package/types/utils/TextureAtlas.d.ts +0 -111
  202. package/types/utils/VectorTileCreator.d.ts +0 -16
  203. package/types/utils/colorTable.d.ts +0 -143
  204. package/types/utils/earcut.d.ts +0 -6
  205. package/types/utils/shared.d.ts +0 -231
  206. package/types/webgl/Framebuffer.d.ts +0 -135
  207. package/types/webgl/Handler.d.ts +0 -397
  208. package/types/webgl/Multisample.d.ts +0 -89
  209. package/types/webgl/Program.d.ts +0 -161
  210. package/types/webgl/ProgramController.d.ts +0 -89
  211. package/types/webgl/callbacks.d.ts +0 -1
  212. package/types/webgl/index.d.ts +0 -6
  213. package/types/webgl/types.d.ts +0 -2
@@ -6,8 +6,31 @@
6
6
 
7
7
  import { Program } from "../webgl/Program.js";
8
8
 
9
- const CORNERS = `const vec2 BOTTOMLEFT = vec2(-0.01);
10
- const vec2 TOPRIGHT = vec2(1.01);`;
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
+
18
+ const DEF_BLEND = `#define blend(DEST, SAMPLER, OFFSET, OPACITY) \
19
+ src = texture( SAMPLER, OFFSET.xy + vTextureCoord.xy * OFFSET.zw ); \
20
+ DEST = DEST * (1.0 - src.a * OPACITY) + src * OPACITY;`;
21
+
22
+ const DEF_BLEND_WEBGL1 = `#define blend(DEST, SAMPLER, OFFSET, OPACITY) \
23
+ src = texture2D( SAMPLER, OFFSET.xy + vTextureCoord.xy * OFFSET.zw ); \
24
+ DEST = DEST * (1.0 - src.a * OPACITY) + src * OPACITY;`;
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); \
30
+ DEST = mix(DEST, vec4(max(COLOR.rgb, p.rgb), OPACITY), (t.a == 0.0 ? 0.0 : 1.0) * COLOR.a);`
31
+
32
+
33
+ const SLICE_SIZE = 4;
11
34
 
12
35
  export function drawnode_screen_nl() {
13
36
  return new Program("drawnode_screen_nl", {
@@ -18,9 +41,8 @@ export function drawnode_screen_nl() {
18
41
  eyePositionLow: "vec3",
19
42
  samplerCount: "int",
20
43
  tileOffsetArr: "vec4",
21
- visibleExtentOffsetArr: "vec4",
44
+ layerOpacityArr: "float",
22
45
  samplerArr: "sampler2darray",
23
- transparentColorArr: "vec4",
24
46
  defaultTexture: "sampler2d",
25
47
  height: "float"
26
48
  },
@@ -53,55 +75,38 @@ export function drawnode_screen_nl() {
53
75
  viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
54
76
 
55
77
  gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
56
-
57
- /*vec3 cameraPosition = eyePositionHigh + eyePositionLow;*/
58
- /*vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow * (cameraPosition / cameraPosition);*/
59
- /*gl_Position = projectionViewMatrix * vec4(aVertexPosition + normalize(aVertexPosition) * height, 1.0);*/
60
78
  }`,
61
79
 
62
80
  fragmentShader: `precision highp float;
63
- uniform vec4 tileOffsetArr[5];
64
- uniform vec4 visibleExtentOffsetArr[5];
65
- uniform vec4 transparentColorArr[5];
81
+ #define SLICE_SIZE ${SLICE_SIZE + 1}
82
+ uniform vec4 tileOffsetArr[SLICE_SIZE];
83
+ uniform float layerOpacityArr[SLICE_SIZE];
66
84
  uniform sampler2D defaultTexture;
67
- uniform sampler2D samplerArr[5];
85
+ uniform sampler2D samplerArr[SLICE_SIZE];
68
86
  uniform int samplerCount;
69
87
  varying vec2 vTextureCoord;
70
- /* return 1 if v inside the box, return 0 otherwise */
71
- float insideBox(vec2 v, vec2 bottomLeft, vec2 topRight) {
72
- vec2 s = step(bottomLeft, v) - step(topRight, v);
73
- return s.x * s.y;
74
- }
75
88
 
76
- ${CORNERS}
89
+ ${DEF_BLEND_WEBGL1}
77
90
 
78
91
  void main(void) {
79
92
  gl_FragColor = texture2D( defaultTexture, vTextureCoord );
80
- if( samplerCount == 0 ) return;
93
+ if( samplerCount == 0 ) return;
94
+
95
+ vec4 src;
81
96
 
82
- vec4 t = texture2D( samplerArr[0], tileOffsetArr[0].xy + vTextureCoord * tileOffsetArr[0].zw ) * insideBox(visibleExtentOffsetArr[0].xy + vTextureCoord * visibleExtentOffsetArr[0].zw, BOTTOMLEFT, TOPRIGHT);
83
- float emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[0].rgb ));
84
- gl_FragColor = mix( gl_FragColor, vec4(t.rgb, 1.0), transparentColorArr[0].a * t.a * emptiness);
97
+ blend(gl_FragColor, samplerArr[0], tileOffsetArr[0], layerOpacityArr[0]);
85
98
  if( samplerCount == 1 ) return;
86
99
 
87
- t = texture2D( samplerArr[1], tileOffsetArr[1].xy + vTextureCoord * tileOffsetArr[1].zw ) * insideBox(visibleExtentOffsetArr[1].xy + vTextureCoord * visibleExtentOffsetArr[1].zw, BOTTOMLEFT, TOPRIGHT);
88
- emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[1].rgb ));
89
- gl_FragColor = mix( gl_FragColor, vec4(t.rgb, 1.0), transparentColorArr[1].a * t.a * emptiness);
100
+ blend(gl_FragColor, samplerArr[1], tileOffsetArr[1], layerOpacityArr[1]);
90
101
  if( samplerCount == 2 ) return;
91
102
 
92
- t = texture2D( samplerArr[2], tileOffsetArr[2].xy + vTextureCoord * tileOffsetArr[2].zw ) * insideBox(visibleExtentOffsetArr[2].xy + vTextureCoord * visibleExtentOffsetArr[2].zw, BOTTOMLEFT, TOPRIGHT);
93
- emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[2].rgb ));
94
- gl_FragColor = mix( gl_FragColor, vec4(t.rgb, 1.0), transparentColorArr[2].a * t.a * emptiness);
103
+ blend(gl_FragColor, samplerArr[2], tileOffsetArr[2], layerOpacityArr[2]);
95
104
  if( samplerCount == 3 ) return;
96
105
 
97
- t = texture2D( samplerArr[3], tileOffsetArr[3].xy + vTextureCoord * tileOffsetArr[3].zw ) * insideBox(visibleExtentOffsetArr[3].xy + vTextureCoord * visibleExtentOffsetArr[3].zw, BOTTOMLEFT, TOPRIGHT);
98
- emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[3].rgb ));
99
- gl_FragColor = mix( gl_FragColor, vec4(t.rgb, 1.0), transparentColorArr[3].a * t.a * emptiness);
106
+ blend(gl_FragColor, samplerArr[3], tileOffsetArr[3], layerOpacityArr[3]);
100
107
  if( samplerCount == 4 ) return;
101
108
 
102
- t = texture2D( samplerArr[4], tileOffsetArr[4].xy + vTextureCoord * tileOffsetArr[4].zw ) * insideBox(visibleExtentOffsetArr[4].xy + vTextureCoord * visibleExtentOffsetArr[4].zw, BOTTOMLEFT, TOPRIGHT);
103
- emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[4].rgb ));
104
- gl_FragColor = mix( gl_FragColor, vec4(t.rgb, 1.0), transparentColorArr[4].a * t.a * emptiness);
109
+ blend(gl_FragColor, samplerArr[4], tileOffsetArr[4], layerOpacityArr[4]);
105
110
  }`
106
111
  });
107
112
  }
@@ -120,18 +125,17 @@ export function drawnode_screen_wl() {
120
125
 
121
126
  samplerCount: "int",
122
127
  tileOffsetArr: "vec4",
123
- visibleExtentOffsetArr: "vec4",
128
+ layerOpacityArr: "float",
124
129
  samplerArr: "sampler2darray",
125
- transparentColorArr: "vec4",
126
130
  defaultTexture: "sampler2d",
127
131
  normalMatrix: "mat3",
128
132
  uNormalMap: "sampler2d",
129
133
  nightTexture: "sampler2d",
130
134
  specularTexture: "sampler2d",
131
135
  lightsPositions: "vec4",
132
- diffuseMaterial: "vec3",
133
- ambientMaterial: "vec3",
134
- specularMaterial: "vec4"
136
+ diffuse: "vec3",
137
+ ambient: "vec3",
138
+ specular: "vec4"
135
139
  },
136
140
  attributes: {
137
141
  aVertexPositionHigh: "vec3",
@@ -177,12 +181,11 @@ export function drawnode_screen_wl() {
177
181
  fragmentShader: `precision highp float;
178
182
 
179
183
  #define MAX_POINT_LIGHTS 1
180
- #define MAX_OVERLAYS 5
181
- #define MAX_OVERLAYS_PLUS_ONE 6
184
+ #define SLICE_SIZE ${SLICE_SIZE + 1}
182
185
 
183
- uniform vec3 diffuseMaterial[MAX_OVERLAYS_PLUS_ONE];
184
- uniform vec3 ambientMaterial[MAX_OVERLAYS_PLUS_ONE];
185
- uniform vec4 specularMaterial[MAX_OVERLAYS_PLUS_ONE];
186
+ uniform vec3 diffuse;
187
+ uniform vec3 ambient;
188
+ uniform vec4 specular;
186
189
 
187
190
  uniform sampler2D uNormalMap;
188
191
  uniform vec4 lightsPositions[MAX_POINT_LIGHTS];
@@ -190,12 +193,11 @@ export function drawnode_screen_wl() {
190
193
  uniform sampler2D nightTexture;
191
194
  uniform sampler2D specularTexture;
192
195
 
193
- uniform vec4 tileOffsetArr[MAX_OVERLAYS];
194
- uniform vec4 visibleExtentOffsetArr[MAX_OVERLAYS];
195
- uniform vec4 transparentColorArr[MAX_OVERLAYS];
196
+ uniform vec4 tileOffsetArr[SLICE_SIZE];
197
+ uniform float layerOpacityArr[SLICE_SIZE];
196
198
 
197
199
  uniform sampler2D defaultTexture;
198
- uniform sampler2D samplerArr[MAX_OVERLAYS];
200
+ uniform sampler2D samplerArr[SLICE_SIZE];
199
201
  uniform int samplerCount;
200
202
 
201
203
  varying vec4 vTextureCoord;
@@ -203,15 +205,10 @@ export function drawnode_screen_wl() {
203
205
  varying vec4 v_vertex;
204
206
  varying float v_height;
205
207
 
206
- /* return 1 if v inside the box, return 0 otherwise */
207
- float insideBox(vec2 v, vec2 bottomLeft, vec2 topRight) {
208
- vec2 s = step(bottomLeft, v) - step(topRight, v);
209
- return s.x * s.y;
210
- }
208
+ ${NIGHT}
211
209
 
212
- ${CORNERS}
210
+ ${DEF_BLEND}
213
211
 
214
- const vec3 nightStep = 10.0 * vec3(0.58, 0.48, 0.25);
215
212
 
216
213
  void main(void) {
217
214
 
@@ -227,63 +224,43 @@ export function drawnode_screen_wl() {
227
224
  vec3 night = nightStep * (0.3 - diffuseLightWeighting) * nightImageColor.rgb;
228
225
  night *= overGround * step(0.0, night);
229
226
 
230
-
231
-
232
- vec3 spec = specularMaterial[0].rgb * pow( reflection, specularMaterial[0].w) * shininess;
233
- vec3 lightWeighting = ambientMaterial[0] + diffuseMaterial[0] * diffuseLightWeighting + spec;
234
-
235
- vec4 t = texture2D( defaultTexture, vTextureCoord.xy );
236
- gl_FragColor = vec4(t.rgb * lightWeighting + night + spec, t.a);
237
- if( samplerCount == 0 ) return;
238
-
239
-
240
-
241
- spec = specularMaterial[1].rgb * pow( reflection, specularMaterial[1].w) * (1.0 + shininess);
242
- lightWeighting = ambientMaterial[1] + diffuseMaterial[1] * diffuseLightWeighting + spec;
243
-
244
- t = texture2D( samplerArr[0], tileOffsetArr[0].xy + vTextureCoord.xy * tileOffsetArr[0].zw ) * insideBox(visibleExtentOffsetArr[0].xy + vTextureCoord.xy * visibleExtentOffsetArr[0].zw, BOTTOMLEFT, TOPRIGHT);
245
- float emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[0].rgb ));
246
- gl_FragColor = mix( gl_FragColor, vec4(t.rgb * lightWeighting + night + spec, 1.0), transparentColorArr[0].a * t.a * emptiness);
247
- if( samplerCount == 1 ) return;
248
-
249
-
250
-
251
- spec = specularMaterial[2].rgb * pow( reflection, specularMaterial[2].w);
252
- lightWeighting = ambientMaterial[2] + diffuseMaterial[2] * diffuseLightWeighting + spec;
253
-
254
- t = texture2D( samplerArr[1], tileOffsetArr[1].xy + vTextureCoord.xy * tileOffsetArr[1].zw ) * insideBox(visibleExtentOffsetArr[1].xy + vTextureCoord.xy * visibleExtentOffsetArr[1].zw, BOTTOMLEFT, TOPRIGHT);
255
- emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[1].rgb ));
256
- gl_FragColor = mix( gl_FragColor, vec4(t.rgb * lightWeighting + night + spec, 1.0), transparentColorArr[1].a * t.a * emptiness);
257
- if( samplerCount == 2 ) return;
258
-
259
-
260
-
261
- spec = specularMaterial[3].rgb * pow( reflection, specularMaterial[3].w);
262
- lightWeighting = ambientMaterial[3] + diffuseMaterial[3] * diffuseLightWeighting + spec;
263
-
264
- t = texture2D( samplerArr[2], tileOffsetArr[2].xy + vTextureCoord.xy * tileOffsetArr[2].zw ) * insideBox(visibleExtentOffsetArr[2].xy + vTextureCoord.xy * visibleExtentOffsetArr[2].zw, BOTTOMLEFT, TOPRIGHT);
265
- emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[2].rgb ));
266
- gl_FragColor = mix( gl_FragColor, vec4(t.rgb * lightWeighting + night + spec, 1.0), transparentColorArr[2].a * t.a * emptiness);
267
- if( samplerCount == 3 ) return;
268
-
269
-
270
-
271
- spec = specularMaterial[4].rgb * pow( reflection, specularMaterial[4].w);
272
- lightWeighting = ambientMaterial[4] + diffuseMaterial[4] * diffuseLightWeighting + spec;
273
-
274
- t = texture2D( samplerArr[3], tileOffsetArr[3].xy + vTextureCoord.xy * tileOffsetArr[3].zw ) * insideBox(visibleExtentOffsetArr[3].xy + vTextureCoord.xy * visibleExtentOffsetArr[3].zw, BOTTOMLEFT, TOPRIGHT);
275
- emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[3].rgb ));
276
- gl_FragColor = mix( gl_FragColor, vec4(t.rgb * lightWeighting + night + spec, 1.0), transparentColorArr[3].a * t.a * emptiness);
277
- if( samplerCount == 4 ) return;
278
-
279
-
280
-
281
- spec = specularMaterial[5].rgb * pow( reflection, specularMaterial[5].w);
282
- lightWeighting = ambientMaterial[5] + diffuseMaterial[5] * diffuseLightWeighting + spec;
283
-
284
- t = texture2D( samplerArr[4], tileOffsetArr[4].xy + vTextureCoord.xy * tileOffsetArr[4].zw ) * insideBox(visibleExtentOffsetArr[4].xy + vTextureCoord.xy * visibleExtentOffsetArr[4].zw, BOTTOMLEFT, TOPRIGHT);
285
- emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[4].rgb ));
286
- gl_FragColor = mix( gl_FragColor, vec4(t.rgb * lightWeighting + night + spec, 1.0), transparentColorArr[4].a * t.a * emptiness);
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;
234
+ }
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;
287
264
  }`
288
265
  });
289
266
  }
@@ -302,18 +279,17 @@ export function drawnode_screen_wl_webgl2() {
302
279
 
303
280
  samplerCount: "int",
304
281
  tileOffsetArr: "vec4",
305
- visibleExtentOffsetArr: "vec4",
282
+ layerOpacityArr: "float",
306
283
  samplerArr: "sampler2darray",
307
- transparentColorArr: "vec4",
308
284
  defaultTexture: "sampler2d",
309
285
  normalMatrix: "mat3",
310
286
  uNormalMap: "sampler2d",
311
287
  nightTexture: "sampler2d",
312
288
  specularTexture: "sampler2d",
313
289
  lightsPositions: "vec4",
314
- diffuseMaterial: "vec3",
315
- ambientMaterial: "vec3",
316
- specularMaterial: "vec4"
290
+ diffuse: "vec3",
291
+ ambient: "vec3",
292
+ specular: "vec4"
317
293
  },
318
294
  attributes: {
319
295
  aVertexPositionHigh: "vec3",
@@ -363,12 +339,11 @@ export function drawnode_screen_wl_webgl2() {
363
339
  precision highp float;
364
340
 
365
341
  #define MAX_POINT_LIGHTS 1
366
- #define MAX_OVERLAYS 5
367
- #define MAX_OVERLAYS_PLUS_ONE 6
342
+ #define SLICE_SIZE ${SLICE_SIZE + 1}
368
343
 
369
- uniform vec3 diffuseMaterial[MAX_OVERLAYS_PLUS_ONE];
370
- uniform vec3 ambientMaterial[MAX_OVERLAYS_PLUS_ONE];
371
- uniform vec4 specularMaterial[MAX_OVERLAYS_PLUS_ONE];
344
+ uniform vec3 diffuse;
345
+ uniform vec3 ambient;
346
+ uniform vec4 specular;
372
347
 
373
348
  uniform sampler2D uNormalMap;
374
349
  uniform vec4 lightsPositions[MAX_POINT_LIGHTS];
@@ -376,12 +351,11 @@ export function drawnode_screen_wl_webgl2() {
376
351
  uniform sampler2D nightTexture;
377
352
  uniform sampler2D specularTexture;
378
353
 
379
- uniform vec4 tileOffsetArr[MAX_OVERLAYS];
380
- uniform vec4 visibleExtentOffsetArr[MAX_OVERLAYS];
381
- uniform vec4 transparentColorArr[MAX_OVERLAYS];
354
+ uniform vec4 tileOffsetArr[SLICE_SIZE];
355
+ uniform float layerOpacityArr[SLICE_SIZE];
382
356
 
383
357
  uniform sampler2D defaultTexture;
384
- uniform sampler2D samplerArr[MAX_OVERLAYS];
358
+ uniform sampler2D samplerArr[SLICE_SIZE];
385
359
  uniform int samplerCount;
386
360
 
387
361
  in vec4 vTextureCoord;
@@ -389,19 +363,18 @@ export function drawnode_screen_wl_webgl2() {
389
363
  in vec4 v_vertex;
390
364
  in float v_height;
391
365
 
392
- layout(location = 0) out vec4 fragColor;
366
+ float shininess;
367
+ float reflection;
368
+ float diffuseLightWeighting;
369
+ vec3 night;
393
370
 
394
- /* return 1 if v inside the box, return 0 otherwise */
395
- float insideBox(vec2 v, vec2 bottomLeft, vec2 topRight) {
396
- vec2 s = step(bottomLeft, v) - step(topRight, v);
397
- return s.x * s.y;
398
- }
371
+ layout(location = 0) out vec4 fragColor;
399
372
 
400
- ${CORNERS}
373
+ ${NIGHT}
401
374
 
402
- const vec3 nightStep = 10.0 * vec3(0.58, 0.48, 0.25);
375
+ ${DEF_BLEND}
403
376
 
404
- void main(void) {
377
+ void main(void) {
405
378
 
406
379
  float overGround = 1.0 - step(0.1, v_height);
407
380
  vec3 normal = normalize(normalMatrix * ((texture(uNormalMap, vTextureCoord.zw).rgb - 0.5) * 2.0));
@@ -409,69 +382,50 @@ export function drawnode_screen_wl_webgl2() {
409
382
  vec3 eyeDirection = normalize(-v_vertex.xyz);
410
383
  vec3 reflectionDirection = reflect(-lightDirection, normal);
411
384
  vec4 nightImageColor = texture( nightTexture, vGlobalTextureCoord.st );
412
- float shininess = texture( specularTexture, vGlobalTextureCoord.st ).r * 255.0 * overGround;
413
- float reflection = max( dot(reflectionDirection, eyeDirection), 0.0);
414
- float diffuseLightWeighting = max(dot(normal, lightDirection), 0.0);
415
- vec3 night = nightStep * (0.3 - diffuseLightWeighting) * nightImageColor.rgb;
416
- night *= overGround * step(0.0, night);
417
-
418
-
419
-
420
- vec3 spec = specularMaterial[0].rgb * pow( reflection, specularMaterial[0].w) * shininess;
421
- vec3 lightWeighting = ambientMaterial[0] + diffuseMaterial[0] * diffuseLightWeighting + spec;
422
-
423
- vec4 t = texture( defaultTexture, vTextureCoord.xy );
424
- fragColor = vec4(t.rgb * lightWeighting + night + spec, t.a);
425
- if( samplerCount == 0 ) return;
426
-
427
-
428
-
429
- spec = specularMaterial[1].rgb * pow( reflection, specularMaterial[1].w) * (1.0 + shininess);
430
- lightWeighting = ambientMaterial[1] + diffuseMaterial[1] * diffuseLightWeighting + spec;
431
-
432
- t = texture( samplerArr[0], tileOffsetArr[0].xy + vTextureCoord.xy * tileOffsetArr[0].zw ) * insideBox(visibleExtentOffsetArr[0].xy + vTextureCoord.xy * visibleExtentOffsetArr[0].zw, BOTTOMLEFT, TOPRIGHT);
433
- float emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[0].rgb ));
434
- fragColor = mix( fragColor, vec4(t.rgb * lightWeighting + night + spec, 1.0), transparentColorArr[0].a * t.a * emptiness);
435
- if( samplerCount == 1 ) return;
436
-
437
-
438
-
439
- spec = specularMaterial[2].rgb * pow( reflection, specularMaterial[2].w);
440
- lightWeighting = ambientMaterial[2] + diffuseMaterial[2] * diffuseLightWeighting + spec;
441
-
442
- t = texture( samplerArr[1], tileOffsetArr[1].xy + vTextureCoord.xy * tileOffsetArr[1].zw ) * insideBox(visibleExtentOffsetArr[1].xy + vTextureCoord.xy * visibleExtentOffsetArr[1].zw, BOTTOMLEFT, TOPRIGHT);
443
- emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[1].rgb ));
444
- fragColor = mix( fragColor, vec4(t.rgb * lightWeighting + night + spec, 1.0), transparentColorArr[1].a * t.a * emptiness);
445
- if( samplerCount == 2 ) return;
446
-
447
-
448
-
449
- spec = specularMaterial[3].rgb * pow( reflection, specularMaterial[3].w);
450
- lightWeighting = ambientMaterial[3] + diffuseMaterial[3] * diffuseLightWeighting + spec;
451
-
452
- t = texture( samplerArr[2], tileOffsetArr[2].xy + vTextureCoord.xy * tileOffsetArr[2].zw ) * insideBox(visibleExtentOffsetArr[2].xy + vTextureCoord.xy * visibleExtentOffsetArr[2].zw, BOTTOMLEFT, TOPRIGHT);
453
- emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[2].rgb ));
454
- fragColor = mix( fragColor, vec4(t.rgb * lightWeighting + night + spec, 1.0), transparentColorArr[2].a * t.a * emptiness);
455
- if( samplerCount == 3 ) return;
456
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);
457
391
 
458
-
459
- spec = specularMaterial[4].rgb * pow( reflection, specularMaterial[4].w);
460
- lightWeighting = ambientMaterial[4] + diffuseMaterial[4] * diffuseLightWeighting + spec;
461
-
462
- t = texture( samplerArr[3], tileOffsetArr[3].xy + vTextureCoord.xy * tileOffsetArr[3].zw ) * insideBox(visibleExtentOffsetArr[3].xy + vTextureCoord.xy * visibleExtentOffsetArr[3].zw, BOTTOMLEFT, TOPRIGHT);
463
- emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[3].rgb ));
464
- fragColor = mix( fragColor, vec4(t.rgb * lightWeighting + night + spec, 1.0), transparentColorArr[3].a * t.a * emptiness);
465
- if( samplerCount == 4 ) return;
466
-
467
-
468
-
469
- spec = specularMaterial[5].rgb * pow( reflection, specularMaterial[5].w);
470
- lightWeighting = ambientMaterial[5] + diffuseMaterial[5] * diffuseLightWeighting + spec;
471
-
472
- t = texture( samplerArr[4], tileOffsetArr[4].xy + vTextureCoord.xy * tileOffsetArr[4].zw ) * insideBox(visibleExtentOffsetArr[4].xy + vTextureCoord.xy * visibleExtentOffsetArr[4].zw, BOTTOMLEFT, TOPRIGHT);
473
- emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[4].rgb ));
474
- fragColor = mix( fragColor, vec4(t.rgb * lightWeighting + night + spec, 1.0), transparentColorArr[4].a * t.a * emptiness);
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;
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;
475
429
  }`
476
430
  });
477
431
  }
@@ -485,10 +439,8 @@ export function drawnode_colorPicking() {
485
439
  eyePositionLow: "vec3",
486
440
  samplerCount: "int",
487
441
  tileOffsetArr: "vec4",
488
- visibleExtentOffsetArr: "vec4",
489
442
  samplerArr: "sampler2darray",
490
443
  pickingMaskArr: "sampler2darray",
491
- transparentColorArr: "vec4",
492
444
  pickingColorArr: "vec4",
493
445
  height: "float"
494
446
  },
@@ -524,69 +476,37 @@ export function drawnode_colorPicking() {
524
476
  }`,
525
477
 
526
478
  fragmentShader: `precision highp float;
527
- uniform vec4 tileOffsetArr[5];
528
- uniform vec4 visibleExtentOffsetArr[5];
529
- uniform vec4 transparentColorArr[5];
530
- uniform vec4 pickingColorArr[5];
531
- uniform sampler2D samplerArr[5];
532
- uniform sampler2D pickingMaskArr[5];
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];
533
484
  uniform int samplerCount;
534
485
  varying vec2 vTextureCoord;
535
- /* return 1 if v inside the box, return 0 otherwise */
536
- float insideBox(vec2 v, vec2 bottomLeft, vec2 topRight) {
537
- vec2 s = step(bottomLeft, v) - step(topRight, v);
538
- return s.x * s.y;
539
- }
540
486
 
541
- ${CORNERS}
487
+ ${DEF_BLEND_PICKING}
542
488
 
543
489
  void main(void) {
544
490
  gl_FragColor = vec4(0.0);
545
491
  if( samplerCount == 0 ) return;
492
+
493
+ vec2 tc;
494
+ vec4 t;
495
+ vec4 p;
546
496
 
547
- vec2 tc = tileOffsetArr[0].xy + vTextureCoord.xy * tileOffsetArr[0].zw;
548
- float ins = insideBox(visibleExtentOffsetArr[0].xy + vTextureCoord.xy * visibleExtentOffsetArr[0].zw, BOTTOMLEFT, TOPRIGHT);
549
- vec4 t = texture2D( samplerArr[0], tc ) * ins;
550
- vec4 p = texture2D( pickingMaskArr[0], tc ) * ins;
551
- float emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[0].rgb ));
552
- emptiness = 1.0 - step(0.0, -emptiness);
553
- gl_FragColor = mix( gl_FragColor, vec4(max(pickingColorArr[0].rgb, p.rgb), 1.0), emptiness * pickingColorArr[0].a);
497
+ blendPicking(gl_FragColor, tileOffsetArr[0], samplerArr[0], pickingMaskArr[0], pickingColorArr[0], 1.0);
554
498
  if( samplerCount == 1 ) return;
555
499
 
556
- tc = tileOffsetArr[1].xy + vTextureCoord.xy * tileOffsetArr[1].zw;
557
- ins = insideBox(visibleExtentOffsetArr[1].xy + vTextureCoord.xy * visibleExtentOffsetArr[1].zw, BOTTOMLEFT, TOPRIGHT);
558
- t = texture2D( samplerArr[1], tc ) * ins;
559
- p = texture2D( pickingMaskArr[1], tc ) * ins;
560
- emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[1].rgb ));
561
- emptiness = 1.0 - step(0.0, -emptiness);
562
- gl_FragColor = mix( gl_FragColor, vec4(max(pickingColorArr[1].rgb, p.rgb), 1.0), emptiness * pickingColorArr[1].a);
500
+ blendPicking(gl_FragColor, tileOffsetArr[1], samplerArr[1], pickingMaskArr[1], pickingColorArr[1], 1.0);
563
501
  if( samplerCount == 2 ) return;
564
502
 
565
- tc = tileOffsetArr[2].xy + vTextureCoord.xy * tileOffsetArr[2].zw;
566
- ins = insideBox(visibleExtentOffsetArr[2].xy + vTextureCoord.xy * visibleExtentOffsetArr[2].zw, BOTTOMLEFT, TOPRIGHT);
567
- t = texture2D( samplerArr[2], tc ) * ins;
568
- p = texture2D( pickingMaskArr[2], tc ) * ins;
569
- emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[2].rgb ));
570
- emptiness = 1.0 - step(0.0, -emptiness);
571
- gl_FragColor = mix( gl_FragColor, vec4(max(pickingColorArr[2].rgb, p.rgb), 1.0), emptiness * pickingColorArr[2].a);
503
+ blendPicking(gl_FragColor, tileOffsetArr[2], samplerArr[2], pickingMaskArr[2], pickingColorArr[2], 1.0);
572
504
  if( samplerCount == 3 ) return;
573
505
 
574
- tc = tileOffsetArr[3].xy + vTextureCoord.xy * tileOffsetArr[3].zw;
575
- ins = insideBox(visibleExtentOffsetArr[3].xy + vTextureCoord.xy * visibleExtentOffsetArr[3].zw, BOTTOMLEFT, TOPRIGHT);
576
- t = texture2D( samplerArr[3], tc ) * ins;
577
- p = texture2D( pickingMaskArr[3], tc ) * ins;
578
- emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[3].rgb ));
579
- emptiness = 1.0 - step(0.0, -emptiness);
580
- gl_FragColor = mix( gl_FragColor, vec4(max(pickingColorArr[3].rgb, p.rgb), 1.0), emptiness * pickingColorArr[3].a);
506
+ blendPicking(gl_FragColor, tileOffsetArr[3], samplerArr[3], pickingMaskArr[3], pickingColorArr[3], 1.0);
581
507
  if( samplerCount == 4 ) return;
582
508
 
583
- tc = tileOffsetArr[4].xy + vTextureCoord.xy * tileOffsetArr[4].zw;
584
- ins = insideBox(visibleExtentOffsetArr[4].xy + vTextureCoord.xy * visibleExtentOffsetArr[4].zw, BOTTOMLEFT, TOPRIGHT);
585
- t = texture2D( samplerArr[4], tc ) * ins;
586
- p = texture2D( pickingMaskArr[4], tc ) * ins;
587
- emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[4].rgb ));
588
- emptiness = 1.0 - step(0.0, -emptiness);
589
- gl_FragColor = mix( gl_FragColor, vec4(max(pickingColorArr[4].rgb, p.rgb), 1.0), emptiness * pickingColorArr[4].a);
509
+ blendPicking(gl_FragColor, tileOffsetArr[4], samplerArr[4], pickingMaskArr[4], pickingColorArr[4], 1.0);
590
510
  }`
591
511
  });
592
512
  }
@@ -596,25 +516,17 @@ export function drawnode_heightPicking() {
596
516
  uniforms: {
597
517
  projectionMatrix: "mat4",
598
518
  viewMatrix: "mat4",
599
- samplerCount: "int",
600
- tileOffsetArr: "vec4",
601
- visibleExtentOffsetArr: "vec4",
602
- samplerArr: "sampler2darray",
603
- transparentColorArr: "vec4",
604
- defaultTexture: "sampler2d",
605
519
  height: "float",
606
520
  eyePositionHigh: "vec3",
607
521
  eyePositionLow: "vec3"
608
522
  },
609
523
  attributes: {
610
524
  aVertexPositionHigh: "vec3",
611
- aVertexPositionLow: "vec3",
612
- aTextureCoord: "vec2"
525
+ aVertexPositionLow: "vec3"
613
526
  },
614
527
 
615
528
  vertexShader: `attribute vec3 aVertexPositionHigh;
616
529
  attribute vec3 aVertexPositionLow;
617
- attribute vec2 aTextureCoord;
618
530
 
619
531
  uniform mat4 projectionMatrix;
620
532
  uniform mat4 viewMatrix;
@@ -622,7 +534,6 @@ export function drawnode_heightPicking() {
622
534
  uniform vec3 eyePositionHigh;
623
535
  uniform vec3 eyePositionLow;
624
536
 
625
- varying vec2 vTextureCoord;
626
537
  varying float range;
627
538
 
628
539
  void main(void) {
@@ -637,25 +548,12 @@ export function drawnode_heightPicking() {
637
548
  viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
638
549
 
639
550
  range = distance(cameraPosition, aVertexPosition + normalize(aVertexPosition) * height);
640
- vTextureCoord = aTextureCoord;
641
551
  gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
642
552
  }`,
643
553
 
644
554
  fragmentShader: `precision highp float;
645
- uniform sampler2D defaultTexture;
646
- uniform vec4 tileOffsetArr[5];
647
- uniform vec4 visibleExtentOffsetArr[5];
648
- uniform vec4 transparentColorArr[5];
649
- uniform sampler2D samplerArr[5];
650
- uniform int samplerCount;
651
- varying vec2 vTextureCoord;
652
- varying float range;
653
555
 
654
- /* return 1 if v inside the box, return 0 otherwise */
655
- float insideBox(vec2 v, vec2 bottomLeft, vec2 topRight) {
656
- vec2 s = step(bottomLeft, v) - step(topRight, v);
657
- return s.x * s.y;
658
- }
556
+ varying float range;
659
557
 
660
558
  vec3 encode24(highp float f) {
661
559
  float F = abs(f);
@@ -669,35 +567,8 @@ export function drawnode_heightPicking() {
669
567
  floor( mod( floor( m * exp2( 23.0 - 8.0) ), exp2(8.0) ) ) / 255.0);
670
568
  }
671
569
 
672
- ${CORNERS}
673
-
674
570
  void main(void) {
675
- gl_FragColor = vec4(encode24(range), texture2D( defaultTexture, vTextureCoord ).a);
676
- if( samplerCount == 0 ) return;
677
-
678
- vec4 t = texture2D( samplerArr[0], tileOffsetArr[0].xy + vTextureCoord * tileOffsetArr[0].zw ) * insideBox(visibleExtentOffsetArr[0].xy + vTextureCoord * visibleExtentOffsetArr[0].zw, BOTTOMLEFT, TOPRIGHT);
679
- float emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[0].rgb ));
680
- gl_FragColor = mix( gl_FragColor, vec4(encode24(range), 1.0), 1.0 - step(0.0, -emptiness));
681
- if( samplerCount == 1 ) return;
682
-
683
- t = texture2D( samplerArr[1], tileOffsetArr[1].xy + vTextureCoord * tileOffsetArr[1].zw ) * insideBox(visibleExtentOffsetArr[1].xy + vTextureCoord * visibleExtentOffsetArr[1].zw, BOTTOMLEFT, TOPRIGHT);
684
- emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[1].rgb ));
685
- gl_FragColor = mix( gl_FragColor, vec4(encode24(range), 1.0), 1.0 - step(0.0, -emptiness));
686
- if( samplerCount == 2 ) return;
687
-
688
- t = texture2D( samplerArr[2], tileOffsetArr[2].xy + vTextureCoord * tileOffsetArr[2].zw ) * insideBox(visibleExtentOffsetArr[2].xy + vTextureCoord * visibleExtentOffsetArr[2].zw, BOTTOMLEFT, TOPRIGHT);
689
- emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[2].rgb ));
690
- gl_FragColor = mix( gl_FragColor, vec4(encode24(range), 1.0), 1.0 - step(0.0, -emptiness));
691
- if( samplerCount == 3 ) return;
692
-
693
- t = texture2D( samplerArr[3], tileOffsetArr[3].xy + vTextureCoord * tileOffsetArr[3].zw ) * insideBox(visibleExtentOffsetArr[3].xy + vTextureCoord * visibleExtentOffsetArr[3].zw, BOTTOMLEFT, TOPRIGHT);
694
- emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[3].rgb ));
695
- gl_FragColor = mix( gl_FragColor, vec4(encode24(range), 1.0), 1.0 - step(0.0, -emptiness));
696
- if( samplerCount == 4 ) return;
697
-
698
- t = texture2D( samplerArr[4], tileOffsetArr[4].xy + vTextureCoord * tileOffsetArr[4].zw ) * insideBox(visibleExtentOffsetArr[4].xy + vTextureCoord * visibleExtentOffsetArr[4].zw, BOTTOMLEFT, TOPRIGHT);
699
- emptiness = t.a * smoothstep(0.35, 0.5, distance( t.rgb, transparentColorArr[4].rgb ));
700
- gl_FragColor = mix( gl_FragColor, vec4(encode24(range), 1.0), 1.0 - step(0.0, -emptiness));
571
+ gl_FragColor = vec4(encode24(range), 1.0);
701
572
  }`
702
573
  });
703
574
  }
@@ -707,12 +578,6 @@ export function drawnode_depth() {
707
578
  uniforms: {
708
579
  projectionMatrix: "mat4",
709
580
  viewMatrix: "mat4",
710
- samplerCount: "int",
711
- tileOffsetArr: "vec4",
712
- visibleExtentOffsetArr: "vec4",
713
- samplerArr: "sampler2darray",
714
- transparentColorArr: "vec4",
715
- defaultTexture: "sampler2d",
716
581
  height: "float",
717
582
  eyePositionHigh: "vec3",
718
583
  eyePositionLow: "vec3",
@@ -720,14 +585,11 @@ export function drawnode_depth() {
720
585
  },
721
586
  attributes: {
722
587
  aVertexPositionHigh: "vec3",
723
- aVertexPositionLow: "vec3",
724
- aTextureCoord: "vec2"
588
+ aVertexPositionLow: "vec3"
725
589
  },
726
590
 
727
- vertexShader: `#version 300 es
728
- in vec3 aVertexPositionHigh;
729
- in vec3 aVertexPositionLow;
730
- in vec2 aTextureCoord;
591
+ vertexShader: `attribute vec3 aVertexPositionHigh;
592
+ attribute vec3 aVertexPositionLow;
731
593
 
732
594
  uniform mat4 projectionMatrix;
733
595
  uniform mat4 viewMatrix;
@@ -735,8 +597,6 @@ export function drawnode_depth() {
735
597
  uniform vec3 eyePositionHigh;
736
598
  uniform vec3 eyePositionLow;
737
599
 
738
- out vec2 vTextureCoord;
739
-
740
600
  void main(void) {
741
601
 
742
602
  vec3 cameraPosition = eyePositionHigh + eyePositionLow;
@@ -748,60 +608,14 @@ export function drawnode_depth() {
748
608
  mat4 viewMatrixRTE = viewMatrix;
749
609
  viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
750
610
 
751
- vTextureCoord = aTextureCoord;
752
611
  gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
753
612
  }`,
754
613
 
755
- fragmentShader: `#version 300 es
756
- precision highp float;
757
- uniform sampler2D defaultTexture;
758
- uniform vec4 tileOffsetArr[5];
759
- uniform vec4 visibleExtentOffsetArr[5];
760
- uniform vec4 transparentColorArr[5];
761
- uniform sampler2D samplerArr[5];
762
- uniform int samplerCount;
614
+ fragmentShader: `precision highp float;
763
615
  uniform vec3 frustumPickingColor;
764
616
 
765
- in vec2 vTextureCoord;
766
-
767
- layout(location = 0) out vec4 frustumColor;
768
-
769
- /* return 1 if v inside the box, return 0 otherwise */
770
- float insideBox(vec2 v, vec2 bottomLeft, vec2 topRight) {
771
- vec2 s = step(bottomLeft, v) - step(topRight, v);
772
- return s.x * s.y;
773
- }
774
-
775
- ${CORNERS}
776
-
777
617
  void main(void) {
778
-
779
- frustumColor = vec4(frustumPickingColor, texture(defaultTexture, vTextureCoord).a);
780
- if(samplerCount == 0) return;
781
-
782
- vec4 t = texture(samplerArr[0], tileOffsetArr[0].xy + vTextureCoord * tileOffsetArr[0].zw) * insideBox(visibleExtentOffsetArr[0].xy + vTextureCoord * visibleExtentOffsetArr[0].zw, BOTTOMLEFT, TOPRIGHT);
783
- float emptiness = t.a * smoothstep(0.35, 0.5, distance(t.rgb, transparentColorArr[0].rgb));
784
- frustumColor = mix(frustumColor, vec4(frustumPickingColor, 1.0), 1.0 - step(0.0, -emptiness));
785
- if (samplerCount == 1) return;
786
-
787
- t = texture(samplerArr[1], tileOffsetArr[1].xy + vTextureCoord * tileOffsetArr[1].zw) * insideBox(visibleExtentOffsetArr[1].xy + vTextureCoord * visibleExtentOffsetArr[1].zw, BOTTOMLEFT, TOPRIGHT);
788
- emptiness = t.a * smoothstep(0.35, 0.5, distance(t.rgb, transparentColorArr[1].rgb));
789
- frustumColor = mix(frustumColor, vec4(frustumPickingColor, 1.0), 1.0 - step(0.0, -emptiness));
790
- if (samplerCount == 2) return;
791
-
792
- t = texture(samplerArr[2], tileOffsetArr[2].xy + vTextureCoord * tileOffsetArr[2].zw) * insideBox(visibleExtentOffsetArr[2].xy + vTextureCoord * visibleExtentOffsetArr[2].zw, BOTTOMLEFT, TOPRIGHT);
793
- emptiness = t.a * smoothstep(0.35, 0.5, distance(t.rgb, transparentColorArr[2].rgb));
794
- frustumColor = mix(frustumColor, vec4(frustumPickingColor, 1.0), 1.0 - step(0.0, -emptiness));
795
- if (samplerCount == 3) return;
796
-
797
- t = texture(samplerArr[3], tileOffsetArr[3].xy + vTextureCoord * tileOffsetArr[3].zw) * insideBox(visibleExtentOffsetArr[3].xy + vTextureCoord * visibleExtentOffsetArr[3].zw, BOTTOMLEFT, TOPRIGHT);
798
- emptiness = t.a * smoothstep(0.35, 0.5, distance(t.rgb, transparentColorArr[3].rgb));
799
- frustumColor = mix(frustumColor, vec4(frustumPickingColor, 1.0), 1.0 - step(0.0, -emptiness));
800
- if (samplerCount == 4) return;
801
-
802
- t = texture(samplerArr[4], tileOffsetArr[4].xy + vTextureCoord * tileOffsetArr[4].zw) * insideBox(visibleExtentOffsetArr[4].xy + vTextureCoord * visibleExtentOffsetArr[4].zw, BOTTOMLEFT, TOPRIGHT);
803
- emptiness = t.a * smoothstep(0.35, 0.5, distance(t.rgb, transparentColorArr[4].rgb));
804
- frustumColor = mix(frustumColor, vec4(frustumPickingColor, 1.0), 1.0 - step(0.0, -emptiness));
805
- } `
618
+ gl_FragColor = vec4(frustumPickingColor, 1.0);
619
+ } `
806
620
  });
807
621
  }