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