@openglobus/og 0.14.10 → 0.15.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.
- package/css/og.css +378 -275
- package/dist/@openglobus/og.css +1 -1
- package/dist/@openglobus/og.esm.js +2 -2
- package/dist/@openglobus/og.esm.js.map +1 -1
- package/dist/@openglobus/og.umd.js +2 -2
- package/dist/@openglobus/og.umd.js.map +1 -1
- package/package.json +18 -17
- package/src/og/Clock.js +218 -194
- package/src/og/Globe.js +5 -5
- package/src/og/Object3d.js +104 -145
- package/src/og/camera/Camera.js +31 -27
- package/src/og/camera/PlanetCamera.js +22 -14
- package/src/og/cons.js +107 -107
- package/src/og/control/Atmosphere.js +396 -0
- package/src/og/control/CompassButton.js +11 -18
- package/src/og/control/Control.js +187 -188
- package/src/og/control/GeoImageDragControl.js +84 -66
- package/src/og/control/LayerSwitcher.js +56 -138
- package/src/og/control/Lighting.js +314 -186
- package/src/og/control/MouseNavigation.js +2 -2
- package/src/og/control/RulerSwitcher.js +24 -19
- package/src/og/control/ScaleControl.js +30 -10
- package/src/og/control/SimpleSkyBackground.js +210 -0
- package/src/og/control/Sun.js +2 -0
- package/src/og/control/ZoomControl.js +30 -42
- package/src/og/control/index.js +6 -0
- package/src/og/control/ruler/RulerScene.js +5 -23
- package/src/og/control/selection/Selection.js +99 -0
- package/src/og/control/selection/SelectionScene.js +350 -0
- package/src/og/control/timeline/TimelineControl.js +99 -0
- package/src/og/control/timeline/TimelineModel.js +133 -0
- package/src/og/control/timeline/TimelineView.js +449 -0
- package/src/og/control/timeline/timelineUtils.js +132 -0
- package/src/og/ellipsoid/Ellipsoid.js +120 -93
- package/src/og/ellipsoid/wgs84.js +13 -13
- package/src/og/entity/Entity.js +36 -9
- package/src/og/entity/EntityCollection.js +0 -2
- package/src/og/entity/GeoObject.js +72 -56
- package/src/og/entity/GeoObjectHandler.js +487 -656
- package/src/og/entity/GeometryHandler.js +1341 -1337
- package/src/og/entity/Polyline.js +0 -16
- package/src/og/entity/Ray.js +0 -10
- package/src/og/entity/RayHandler.js +3 -44
- package/src/og/entity/Strip.js +1 -6
- package/src/og/index.js +10 -6
- package/src/og/input/input.js +3 -1
- package/src/og/layer/CanvasTiles.js +39 -34
- package/src/og/layer/Layer.js +69 -9
- package/src/og/layer/Material.js +1 -8
- package/src/og/layer/WMS.js +16 -5
- package/src/og/light/LightSource.js +2 -0
- package/src/og/math/Line3.js +140 -139
- package/src/og/math/Plane.js +118 -117
- package/src/og/math/Ray.js +242 -239
- package/src/og/math/Vec3.js +56 -37
- package/src/og/math/Vec4.js +3 -4
- package/src/og/math.js +21 -21
- package/src/og/quadTree/Node.js +5 -4
- package/src/og/quadTree/index.js +12 -0
- package/src/og/renderer/Renderer.js +64 -37
- package/src/og/renderer/RendererEvents.js +1071 -1065
- package/src/og/scene/Planet.js +352 -172
- package/src/og/scene/RenderNode.js +27 -12
- package/src/og/segment/Segment.js +0 -5
- package/src/og/shaders/atmos.js +332 -0
- package/src/og/shaders/drawnode.js +475 -109
- package/src/og/shaders/geoObject.js +96 -51
- package/src/og/shaders/polyline.js +212 -17
- package/src/og/shaders/ray.js +13 -6
- package/src/og/shaders/toneMapping.js +5 -5
- package/src/og/shaders/utils.js +88 -0
- package/src/og/terrain/GlobusTerrain.js +5 -4
- package/src/og/terrain/MapboxTerrain.js +231 -52
- package/src/og/ui/Button.js +106 -0
- package/src/og/ui/ButtonGroup.js +57 -0
- package/src/og/ui/Dialog.js +242 -0
- package/src/og/ui/Slider.js +144 -0
- package/src/og/ui/ToggleButton.js +51 -0
- package/src/og/{control → ui}/UIhelpers.js +11 -2
- package/src/og/ui/View.js +190 -0
- package/src/og/utils/shared.js +960 -942
- package/src/og/webgl/Framebuffer.js +308 -387
- package/src/og/webgl/Handler.js +90 -30
- package/src/og/webgl/Multisample.js +8 -0
- package/types/Clock.d.ts +7 -2
- package/types/Object3d.d.ts +14 -3
- package/types/camera/Camera.d.ts +18 -17
- package/types/camera/PlanetCamera.d.ts +3 -1
- package/types/control/Atmosphere.d.ts +15 -0
- package/types/control/CompassButton.d.ts +1 -2
- package/types/control/GeoImageDragControl.d.ts +7 -1
- package/types/control/LayerSwitcher.d.ts +5 -6
- package/types/control/Lighting.d.ts +32 -7
- package/types/control/ScaleControl.d.ts +2 -1
- package/types/control/SimpleSkyBackground.d.ts +15 -0
- package/types/control/ZoomControl.d.ts +0 -1
- package/types/control/index.d.ts +4 -1
- package/types/control/ruler/RulerScene.d.ts +0 -1
- package/types/control/selection/Selection.d.ts +49 -0
- package/types/control/selection/SelectionScene.d.ts +34 -0
- package/types/ellipsoid/Ellipsoid.d.ts +3 -2
- package/types/entity/Entity.d.ts +8 -0
- package/types/entity/GeoObject.d.ts +28 -22
- package/types/entity/GeoObjectHandler.d.ts +16 -56
- package/types/entity/Ray.d.ts +0 -3
- package/types/entity/RayHandler.d.ts +0 -4
- package/types/index.d.ts +7 -5
- package/types/input/input.d.ts +2 -0
- package/types/layer/CanvasTiles.d.ts +1 -0
- package/types/layer/Layer.d.ts +9 -0
- package/types/layer/WMS.d.ts +7 -3
- package/types/math/Plane.d.ts +1 -1
- package/types/math/Vec3.d.ts +19 -16
- package/types/math/Vec4.d.ts +2 -3
- package/types/math.d.ts +20 -20
- package/types/quadTree/index.d.ts +10 -0
- package/types/renderer/Renderer.d.ts +11 -37
- package/types/scene/Planet.d.ts +27 -1
- package/types/scene/RenderNode.d.ts +2 -1
- package/types/segment/Segment.d.ts +1 -1
- package/types/shaders/atmos.d.ts +4 -0
- package/types/shaders/drawnode.d.ts +3 -2
- package/types/shaders/utils.d.ts +1 -0
- package/types/terrain/GlobusTerrain.d.ts +1 -1
- package/types/terrain/MapboxTerrain.d.ts +2 -1
- package/types/ui/Button.d.ts +21 -0
- package/types/ui/Dialog.d.ts +41 -0
- package/types/ui/Slider.d.ts +30 -0
- package/types/ui/ToggleButton.d.ts +10 -0
- package/types/{control → ui}/UIhelpers.d.ts +1 -1
- package/types/ui/View.d.ts +32 -0
- package/types/utils/shared.d.ts +16 -14
- package/types/webgl/Framebuffer.d.ts +2 -5
- package/types/webgl/Handler.d.ts +15 -10
- package/types/webgl/Multisample.d.ts +2 -0
- package/src/og/ajax.js +0 -204
- package/src/og/entity/Object3d.js +0 -504
- package/src/og/utils/quadTreeType.js +0 -11
- package/types/ajax.d.ts +0 -24
- package/types/utils/quadTreeType.d.ts +0 -8
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
"use strict";
|
|
6
6
|
|
|
7
7
|
import { Program } from "../webgl/Program.js";
|
|
8
|
+
import * as atmos from "./atmos.js";
|
|
9
|
+
import { UTILS } from './utils.js';
|
|
8
10
|
|
|
9
11
|
// REMEMBER!
|
|
10
12
|
// src*(1)+dest*(1-src.alpha)
|
|
@@ -45,11 +47,8 @@ export function drawnode_screen_nl() {
|
|
|
45
47
|
samplerArr: "sampler2darray",
|
|
46
48
|
defaultTexture: "sampler2d",
|
|
47
49
|
height: "float"
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
aVertexPositionHigh: "vec3",
|
|
51
|
-
aVertexPositionLow: "vec3",
|
|
52
|
-
aTextureCoord: "vec2"
|
|
50
|
+
}, attributes: {
|
|
51
|
+
aVertexPositionHigh: "vec3", aVertexPositionLow: "vec3", aTextureCoord: "vec2"
|
|
53
52
|
},
|
|
54
53
|
|
|
55
54
|
vertexShader: `attribute vec3 aVertexPositionHigh;
|
|
@@ -111,7 +110,7 @@ export function drawnode_screen_nl() {
|
|
|
111
110
|
});
|
|
112
111
|
}
|
|
113
112
|
|
|
114
|
-
export function
|
|
113
|
+
export function drawnode_screen_wl_webgl1NoAtmos() {
|
|
115
114
|
return new Program("drawnode_screen_wl", {
|
|
116
115
|
uniforms: {
|
|
117
116
|
projectionMatrix: "mat4",
|
|
@@ -128,22 +127,25 @@ export function drawnode_screen_wl() {
|
|
|
128
127
|
layerOpacityArr: "float",
|
|
129
128
|
samplerArr: "sampler2darray",
|
|
130
129
|
defaultTexture: "sampler2d",
|
|
131
|
-
normalMatrix: "mat3",
|
|
132
130
|
uNormalMap: "sampler2d",
|
|
133
131
|
nightTexture: "sampler2d",
|
|
134
132
|
specularTexture: "sampler2d",
|
|
135
|
-
lightsPositions: "
|
|
133
|
+
lightsPositions: "vec3",
|
|
136
134
|
diffuse: "vec3",
|
|
137
135
|
ambient: "vec3",
|
|
138
|
-
specular: "vec4"
|
|
139
|
-
|
|
140
|
-
|
|
136
|
+
specular: "vec4",
|
|
137
|
+
|
|
138
|
+
camHeight: "float",
|
|
139
|
+
nightTextureCoefficient: "float"
|
|
140
|
+
}, attributes: {
|
|
141
141
|
aVertexPositionHigh: "vec3",
|
|
142
142
|
aVertexPositionLow: "vec3",
|
|
143
143
|
aTextureCoord: "vec2"
|
|
144
144
|
},
|
|
145
145
|
|
|
146
|
-
vertexShader:
|
|
146
|
+
vertexShader:
|
|
147
|
+
`
|
|
148
|
+
attribute vec3 aVertexPositionHigh;
|
|
147
149
|
attribute vec3 aVertexPositionLow;
|
|
148
150
|
attribute vec2 aTextureCoord;
|
|
149
151
|
|
|
@@ -157,12 +159,16 @@ export function drawnode_screen_wl() {
|
|
|
157
159
|
|
|
158
160
|
varying vec4 vTextureCoord;
|
|
159
161
|
varying vec2 vGlobalTextureCoord;
|
|
160
|
-
varying
|
|
161
|
-
varying float v_height;
|
|
162
|
+
varying vec3 v_vertex;
|
|
163
|
+
varying float v_height;
|
|
164
|
+
varying vec3 cameraPosition;
|
|
162
165
|
|
|
163
166
|
void main(void) {
|
|
164
167
|
|
|
165
168
|
vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
|
|
169
|
+
|
|
170
|
+
cameraPosition = eyePositionHigh + eyePositionLow;
|
|
171
|
+
|
|
166
172
|
vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
|
|
167
173
|
vec3 lowDiff = aVertexPositionLow + normalize(aVertexPosition) * height - eyePositionLow;
|
|
168
174
|
|
|
@@ -170,26 +176,28 @@ export function drawnode_screen_wl() {
|
|
|
170
176
|
viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
|
|
171
177
|
|
|
172
178
|
v_height = height;
|
|
173
|
-
|
|
174
|
-
|
|
179
|
+
v_vertex = aVertexPosition + normalize(aVertexPosition) * height;
|
|
180
|
+
|
|
175
181
|
vTextureCoord.xy = aTextureCoord;
|
|
176
182
|
vGlobalTextureCoord = uGlobalTextureCoord.xy + (uGlobalTextureCoord.zw - uGlobalTextureCoord.xy) * aTextureCoord;
|
|
177
183
|
vTextureCoord.zw = uNormalMapBias.z * ( aTextureCoord + uNormalMapBias.xy );
|
|
184
|
+
|
|
178
185
|
gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
|
|
179
186
|
}`,
|
|
180
187
|
|
|
181
|
-
fragmentShader:
|
|
182
|
-
|
|
188
|
+
fragmentShader:
|
|
189
|
+
`
|
|
190
|
+
precision highp float;
|
|
191
|
+
|
|
183
192
|
#define MAX_POINT_LIGHTS 1
|
|
184
193
|
#define SLICE_SIZE ${SLICE_SIZE + 1}
|
|
185
194
|
|
|
186
195
|
uniform vec3 diffuse;
|
|
187
196
|
uniform vec3 ambient;
|
|
188
|
-
uniform vec4 specular;
|
|
197
|
+
uniform vec4 specular;
|
|
189
198
|
|
|
190
199
|
uniform sampler2D uNormalMap;
|
|
191
|
-
uniform
|
|
192
|
-
uniform mat3 normalMatrix;
|
|
200
|
+
uniform vec3 lightsPositions[MAX_POINT_LIGHTS];
|
|
193
201
|
uniform sampler2D nightTexture;
|
|
194
202
|
uniform sampler2D specularTexture;
|
|
195
203
|
|
|
@@ -199,77 +207,94 @@ export function drawnode_screen_wl() {
|
|
|
199
207
|
uniform sampler2D defaultTexture;
|
|
200
208
|
uniform sampler2D samplerArr[SLICE_SIZE];
|
|
201
209
|
uniform int samplerCount;
|
|
210
|
+
uniform float nightTextureCoefficient;
|
|
211
|
+
|
|
212
|
+
uniform float camHeight;
|
|
202
213
|
|
|
203
214
|
varying vec4 vTextureCoord;
|
|
215
|
+
varying vec3 v_vertex;
|
|
216
|
+
varying vec3 cameraPosition;
|
|
204
217
|
varying vec2 vGlobalTextureCoord;
|
|
205
|
-
varying vec4 v_vertex;
|
|
206
218
|
varying float v_height;
|
|
207
219
|
|
|
220
|
+
vec3 sunPos;
|
|
221
|
+
|
|
208
222
|
${NIGHT}
|
|
209
223
|
|
|
210
224
|
${DEF_BLEND_WEBGL1}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
float diffuseLightWeighting;
|
|
215
|
-
vec3 night;
|
|
216
|
-
|
|
225
|
+
|
|
226
|
+
${UTILS}
|
|
227
|
+
|
|
217
228
|
void main(void) {
|
|
218
229
|
|
|
230
|
+
sunPos = lightsPositions[0];
|
|
231
|
+
|
|
232
|
+
vec3 texNormal = texture2D(uNormalMap, vTextureCoord.zw).rgb;
|
|
233
|
+
vec3 normal = normalize((texNormal - 0.5) * 2.0);
|
|
234
|
+
|
|
235
|
+
float minH = 1200000.0;
|
|
236
|
+
float maxH = minH * 3.0;
|
|
237
|
+
float nightCoef = getLerpValue(minH, maxH, camHeight) * nightTextureCoefficient;
|
|
238
|
+
|
|
239
|
+
if(camHeight > 6000000.0)
|
|
240
|
+
{
|
|
241
|
+
normal = normalize(v_vertex);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
vec3 lightDir = normalize(sunPos);
|
|
245
|
+
vec3 viewDir = normalize(cameraPosition - v_vertex);
|
|
246
|
+
|
|
219
247
|
float overGround = 1.0 - step(0.1, v_height);
|
|
220
|
-
vec3 normal = normalize(normalMatrix * ((texture2D(uNormalMap, vTextureCoord.zw).rgb - 0.5) * 2.0));
|
|
221
|
-
vec3 lightDirection = normalize(lightsPositions[0].xyz - v_vertex.xyz * lightsPositions[0].w);
|
|
222
|
-
vec3 eyeDirection = normalize(-v_vertex.xyz);
|
|
223
|
-
vec3 reflectionDirection = reflect(-lightDirection, normal);
|
|
224
|
-
vec4 nightImageColor = texture2D( nightTexture, vGlobalTextureCoord.st );
|
|
225
|
-
shininess = texture2D( specularTexture, vGlobalTextureCoord.st ).r * 255.0 * overGround;
|
|
226
|
-
reflection = max( dot(reflectionDirection, eyeDirection), 0.0);
|
|
227
|
-
diffuseLightWeighting = max(dot(normal, lightDirection), 0.0);
|
|
228
|
-
night = nightStep * (.18 - diffuseLightWeighting * 3.0) * nightImageColor.rgb;
|
|
229
|
-
night *= overGround * step(0.0, night);
|
|
230
|
-
|
|
231
|
-
vec3 spec = specular.rgb * pow( reflection, specular.w) * shininess;
|
|
232
|
-
vec4 lightWeighting = vec4(ambient + diffuse * diffuseLightWeighting + spec + night, 1.0);
|
|
233
248
|
|
|
249
|
+
float shininess = texture2D( specularTexture, vGlobalTextureCoord.st ).r * 255.0 * overGround;
|
|
250
|
+
vec3 reflectionDirection = reflect(-lightDir, normal);
|
|
251
|
+
float reflection = max( dot(reflectionDirection, viewDir), 0.0);
|
|
252
|
+
vec3 spec = specular.rgb * pow( reflection, specular.w) * shininess;
|
|
253
|
+
float diffuseLightWeighting = max(dot(normal, lightDir), 0.0);
|
|
254
|
+
vec4 nightImageColor = texture2D( nightTexture, vGlobalTextureCoord.st );
|
|
255
|
+
vec3 night = nightStep * (.18 - diffuseLightWeighting * 3.0) * nightImageColor.rgb * nightCoef;
|
|
256
|
+
night *= overGround * step(0.0, night);
|
|
257
|
+
vec4 lightWeighting = vec4(ambient + diffuse * diffuseLightWeighting + night, 1.0);
|
|
258
|
+
|
|
234
259
|
gl_FragColor = texture2D( defaultTexture, vTextureCoord.xy );
|
|
235
260
|
if( samplerCount == 0 ) {
|
|
236
|
-
gl_FragColor
|
|
261
|
+
gl_FragColor = gl_FragColor * lightWeighting + vec4(spec, 0.0);
|
|
237
262
|
return;
|
|
238
263
|
}
|
|
239
|
-
|
|
264
|
+
|
|
240
265
|
vec4 src;
|
|
241
266
|
|
|
242
267
|
blend(gl_FragColor, samplerArr[0], tileOffsetArr[0], layerOpacityArr[0]);
|
|
243
|
-
if( samplerCount == 1 ) {
|
|
244
|
-
gl_FragColor
|
|
268
|
+
if( samplerCount == 1 ) {
|
|
269
|
+
gl_FragColor = gl_FragColor * lightWeighting + vec4(spec, 0.0);
|
|
245
270
|
return;
|
|
246
271
|
}
|
|
247
272
|
|
|
248
273
|
blend(gl_FragColor, samplerArr[1], tileOffsetArr[1], layerOpacityArr[1]);
|
|
249
274
|
if( samplerCount == 2 ) {
|
|
250
|
-
gl_FragColor
|
|
275
|
+
gl_FragColor = gl_FragColor * lightWeighting + vec4(spec, 0.0);
|
|
251
276
|
return;
|
|
252
277
|
}
|
|
253
278
|
|
|
254
279
|
blend(gl_FragColor, samplerArr[2], tileOffsetArr[2], layerOpacityArr[2]);
|
|
255
280
|
if( samplerCount == 3 ) {
|
|
256
|
-
gl_FragColor
|
|
281
|
+
gl_FragColor = gl_FragColor * lightWeighting + vec4(spec, 0.0);
|
|
257
282
|
return;
|
|
258
283
|
}
|
|
259
284
|
|
|
260
285
|
blend(gl_FragColor, samplerArr[3], tileOffsetArr[3], layerOpacityArr[3]);
|
|
261
286
|
if( samplerCount == 4 ) {
|
|
262
|
-
gl_FragColor
|
|
287
|
+
gl_FragColor = gl_FragColor * lightWeighting + vec4(spec, 0.0);
|
|
263
288
|
return;
|
|
264
289
|
}
|
|
265
290
|
|
|
266
291
|
blend(gl_FragColor, samplerArr[4], tileOffsetArr[4], layerOpacityArr[4]);
|
|
267
|
-
gl_FragColor
|
|
292
|
+
gl_FragColor = gl_FragColor * lightWeighting + vec4(spec, 0.0);
|
|
268
293
|
}`
|
|
269
294
|
});
|
|
270
295
|
}
|
|
271
296
|
|
|
272
|
-
export function
|
|
297
|
+
export function drawnode_screen_wl_webgl2NoAtmos() {
|
|
273
298
|
return new Program("drawnode_screen_wl", {
|
|
274
299
|
uniforms: {
|
|
275
300
|
projectionMatrix: "mat4",
|
|
@@ -286,22 +311,24 @@ export function drawnode_screen_wl_webgl2() {
|
|
|
286
311
|
layerOpacityArr: "float",
|
|
287
312
|
samplerArr: "sampler2darray",
|
|
288
313
|
defaultTexture: "sampler2d",
|
|
289
|
-
normalMatrix: "mat3",
|
|
290
314
|
uNormalMap: "sampler2d",
|
|
291
315
|
nightTexture: "sampler2d",
|
|
292
316
|
specularTexture: "sampler2d",
|
|
293
|
-
lightsPositions: "
|
|
317
|
+
lightsPositions: "vec3",
|
|
294
318
|
diffuse: "vec3",
|
|
295
319
|
ambient: "vec3",
|
|
296
|
-
specular: "vec4"
|
|
297
|
-
|
|
298
|
-
|
|
320
|
+
specular: "vec4",
|
|
321
|
+
|
|
322
|
+
camHeight: "float",
|
|
323
|
+
nightTextureCoefficient: "float"
|
|
324
|
+
}, attributes: {
|
|
299
325
|
aVertexPositionHigh: "vec3",
|
|
300
326
|
aVertexPositionLow: "vec3",
|
|
301
327
|
aTextureCoord: "vec2"
|
|
302
328
|
},
|
|
303
329
|
|
|
304
|
-
vertexShader:
|
|
330
|
+
vertexShader:
|
|
331
|
+
`#version 300 es
|
|
305
332
|
|
|
306
333
|
in vec3 aVertexPositionHigh;
|
|
307
334
|
in vec3 aVertexPositionLow;
|
|
@@ -317,12 +344,16 @@ export function drawnode_screen_wl_webgl2() {
|
|
|
317
344
|
|
|
318
345
|
out vec4 vTextureCoord;
|
|
319
346
|
out vec2 vGlobalTextureCoord;
|
|
320
|
-
out
|
|
347
|
+
out vec3 v_vertex;
|
|
321
348
|
out float v_height;
|
|
349
|
+
out vec3 cameraPosition;
|
|
322
350
|
|
|
323
351
|
void main(void) {
|
|
324
352
|
|
|
325
353
|
vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
|
|
354
|
+
|
|
355
|
+
cameraPosition = eyePositionHigh + eyePositionLow;
|
|
356
|
+
|
|
326
357
|
vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
|
|
327
358
|
vec3 lowDiff = aVertexPositionLow + normalize(aVertexPosition) * height - eyePositionLow;
|
|
328
359
|
|
|
@@ -330,28 +361,29 @@ export function drawnode_screen_wl_webgl2() {
|
|
|
330
361
|
viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
|
|
331
362
|
|
|
332
363
|
v_height = height;
|
|
333
|
-
|
|
334
|
-
|
|
364
|
+
v_vertex = aVertexPosition + normalize(aVertexPosition) * height;
|
|
365
|
+
|
|
335
366
|
vTextureCoord.xy = aTextureCoord;
|
|
336
367
|
vGlobalTextureCoord = uGlobalTextureCoord.xy + (uGlobalTextureCoord.zw - uGlobalTextureCoord.xy) * aTextureCoord;
|
|
337
368
|
vTextureCoord.zw = uNormalMapBias.z * ( aTextureCoord + uNormalMapBias.xy );
|
|
369
|
+
|
|
338
370
|
gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
|
|
339
371
|
}`,
|
|
340
372
|
|
|
341
|
-
fragmentShader:
|
|
373
|
+
fragmentShader:
|
|
374
|
+
`#version 300 es
|
|
342
375
|
|
|
343
376
|
precision highp float;
|
|
344
|
-
|
|
377
|
+
|
|
345
378
|
#define MAX_POINT_LIGHTS 1
|
|
346
379
|
#define SLICE_SIZE ${SLICE_SIZE + 1}
|
|
347
380
|
|
|
348
381
|
uniform vec3 diffuse;
|
|
349
382
|
uniform vec3 ambient;
|
|
350
|
-
uniform vec4 specular;
|
|
383
|
+
uniform vec4 specular;
|
|
351
384
|
|
|
352
385
|
uniform sampler2D uNormalMap;
|
|
353
|
-
uniform
|
|
354
|
-
uniform mat3 normalMatrix;
|
|
386
|
+
uniform vec3 lightsPositions[MAX_POINT_LIGHTS];
|
|
355
387
|
uniform sampler2D nightTexture;
|
|
356
388
|
uniform sampler2D specularTexture;
|
|
357
389
|
|
|
@@ -361,75 +393,416 @@ export function drawnode_screen_wl_webgl2() {
|
|
|
361
393
|
uniform sampler2D defaultTexture;
|
|
362
394
|
uniform sampler2D samplerArr[SLICE_SIZE];
|
|
363
395
|
uniform int samplerCount;
|
|
396
|
+
uniform float nightTextureCoefficient;
|
|
397
|
+
|
|
398
|
+
uniform float camHeight;
|
|
364
399
|
|
|
365
400
|
in vec4 vTextureCoord;
|
|
401
|
+
in vec3 v_vertex;
|
|
402
|
+
in vec3 cameraPosition;
|
|
366
403
|
in vec2 vGlobalTextureCoord;
|
|
367
|
-
in vec4 v_vertex;
|
|
368
404
|
in float v_height;
|
|
369
405
|
|
|
370
|
-
|
|
371
|
-
float reflection;
|
|
372
|
-
float diffuseLightWeighting;
|
|
373
|
-
vec3 night;
|
|
406
|
+
vec3 sunPos;
|
|
374
407
|
|
|
375
|
-
layout(location = 0) out vec4
|
|
408
|
+
layout(location = 0) out vec4 diffuseColor;
|
|
376
409
|
|
|
377
410
|
${NIGHT}
|
|
378
411
|
|
|
379
412
|
${DEF_BLEND}
|
|
380
|
-
|
|
413
|
+
|
|
414
|
+
${UTILS}
|
|
415
|
+
|
|
381
416
|
void main(void) {
|
|
382
|
-
|
|
417
|
+
|
|
418
|
+
sunPos = lightsPositions[0];
|
|
419
|
+
|
|
420
|
+
vec3 texNormal = texture(uNormalMap, vTextureCoord.zw).rgb;
|
|
421
|
+
vec3 normal = normalize((texNormal - 0.5) * 2.0);
|
|
422
|
+
|
|
423
|
+
float minH = 1200000.0;
|
|
424
|
+
float maxH = minH * 3.0;
|
|
425
|
+
float nightCoef = getLerpValue(minH, maxH, camHeight) * nightTextureCoefficient;
|
|
426
|
+
|
|
427
|
+
if(camHeight > 6000000.0)
|
|
428
|
+
{
|
|
429
|
+
normal = normalize(v_vertex);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
vec3 lightDir = normalize(sunPos);
|
|
433
|
+
vec3 viewDir = normalize(cameraPosition - v_vertex);
|
|
434
|
+
|
|
383
435
|
float overGround = 1.0 - step(0.1, v_height);
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
vec3
|
|
387
|
-
|
|
436
|
+
|
|
437
|
+
float shininess = texture( specularTexture, vGlobalTextureCoord.st ).r * 255.0 * overGround;
|
|
438
|
+
vec3 reflectionDirection = reflect(-lightDir, normal);
|
|
439
|
+
float reflection = max( dot(reflectionDirection, viewDir), 0.0);
|
|
440
|
+
vec3 spec = specular.rgb * pow( reflection, specular.w) * shininess;
|
|
441
|
+
float diffuseLightWeighting = max(dot(normal, lightDir), 0.0);
|
|
388
442
|
vec4 nightImageColor = texture( nightTexture, vGlobalTextureCoord.st );
|
|
443
|
+
vec3 night = nightStep * (.18 - diffuseLightWeighting * 3.0) * nightImageColor.rgb * nightCoef;
|
|
444
|
+
night *= overGround * step(0.0, night);
|
|
445
|
+
vec4 lightWeighting = vec4(ambient + diffuse * diffuseLightWeighting + night, 1.0);
|
|
446
|
+
|
|
447
|
+
diffuseColor = texture( defaultTexture, vTextureCoord.xy );
|
|
448
|
+
if( samplerCount == 0 ) {
|
|
449
|
+
diffuseColor = diffuseColor * lightWeighting + vec4(spec, 0.0);
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
389
452
|
|
|
390
|
-
|
|
391
|
-
reflection = max( dot(reflectionDirection, eyeDirection), 0.0);
|
|
392
|
-
diffuseLightWeighting = max(dot(normal, lightDirection), 0.0);
|
|
393
|
-
night = nightStep * (.18 - diffuseLightWeighting * 3.0) * nightImageColor.rgb;
|
|
394
|
-
night *= overGround * step(0.0, night);
|
|
453
|
+
vec4 src;
|
|
395
454
|
|
|
396
|
-
|
|
397
|
-
|
|
455
|
+
blend(diffuseColor, samplerArr[0], tileOffsetArr[0], layerOpacityArr[0]);
|
|
456
|
+
if( samplerCount == 1 ) {
|
|
457
|
+
diffuseColor = diffuseColor * lightWeighting + vec4(spec, 0.0);
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
398
460
|
|
|
399
|
-
|
|
461
|
+
blend(diffuseColor, samplerArr[1], tileOffsetArr[1], layerOpacityArr[1]);
|
|
462
|
+
if( samplerCount == 2 ) {
|
|
463
|
+
diffuseColor = diffuseColor * lightWeighting + vec4(spec, 0.0);
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
blend(diffuseColor, samplerArr[2], tileOffsetArr[2], layerOpacityArr[2]);
|
|
468
|
+
if( samplerCount == 3 ) {
|
|
469
|
+
diffuseColor = diffuseColor * lightWeighting + vec4(spec, 0.0);
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
blend(diffuseColor, samplerArr[3], tileOffsetArr[3], layerOpacityArr[3]);
|
|
474
|
+
if( samplerCount == 4 ) {
|
|
475
|
+
diffuseColor = diffuseColor * lightWeighting + vec4(spec, 0.0);
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
blend(diffuseColor, samplerArr[4], tileOffsetArr[4], layerOpacityArr[4]);
|
|
480
|
+
diffuseColor = diffuseColor * lightWeighting + vec4(spec, 0.0);
|
|
481
|
+
}`
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
export function drawnode_screen_wl_webgl2Atmos() {
|
|
487
|
+
return new Program("drawnode_screen_wl", {
|
|
488
|
+
uniforms: {
|
|
489
|
+
projectionMatrix: "mat4",
|
|
490
|
+
viewMatrix: "mat4",
|
|
491
|
+
eyePositionHigh: "vec3",
|
|
492
|
+
eyePositionLow: "vec3",
|
|
493
|
+
height: "float",
|
|
494
|
+
|
|
495
|
+
uGlobalTextureCoord: "vec4",
|
|
496
|
+
uNormalMapBias: "vec3",
|
|
497
|
+
|
|
498
|
+
samplerCount: "int",
|
|
499
|
+
tileOffsetArr: "vec4",
|
|
500
|
+
layerOpacityArr: "float",
|
|
501
|
+
samplerArr: "sampler2darray",
|
|
502
|
+
defaultTexture: "sampler2d",
|
|
503
|
+
uNormalMap: "sampler2d",
|
|
504
|
+
nightTexture: "sampler2d",
|
|
505
|
+
specularTexture: "sampler2d",
|
|
506
|
+
lightsPositions: "vec3",
|
|
507
|
+
diffuse: "vec3",
|
|
508
|
+
ambient: "vec3",
|
|
509
|
+
specular: "vec4",
|
|
510
|
+
|
|
511
|
+
transmittanceTexture: "sampler2D",
|
|
512
|
+
scatteringTexture: "sampler2D",
|
|
513
|
+
camHeight: "float",
|
|
514
|
+
nightTextureCoefficient: "float",
|
|
515
|
+
maxMinOpacity: "vec2"
|
|
516
|
+
}, attributes: {
|
|
517
|
+
aVertexPositionHigh: "vec3",
|
|
518
|
+
aVertexPositionLow: "vec3",
|
|
519
|
+
aTextureCoord: "vec2"
|
|
520
|
+
},
|
|
521
|
+
|
|
522
|
+
vertexShader:
|
|
523
|
+
`#version 300 es
|
|
524
|
+
|
|
525
|
+
in vec3 aVertexPositionHigh;
|
|
526
|
+
in vec3 aVertexPositionLow;
|
|
527
|
+
in vec2 aTextureCoord;
|
|
528
|
+
|
|
529
|
+
uniform mat4 projectionMatrix;
|
|
530
|
+
uniform mat4 viewMatrix;
|
|
531
|
+
uniform vec4 uGlobalTextureCoord;
|
|
532
|
+
uniform vec3 uNormalMapBias;
|
|
533
|
+
uniform vec3 eyePositionHigh;
|
|
534
|
+
uniform vec3 eyePositionLow;
|
|
535
|
+
uniform float height;
|
|
536
|
+
|
|
537
|
+
out vec4 vTextureCoord;
|
|
538
|
+
out vec2 vGlobalTextureCoord;
|
|
539
|
+
out vec3 v_vertex;
|
|
540
|
+
out float v_height;
|
|
541
|
+
out vec3 cameraPosition;
|
|
542
|
+
|
|
543
|
+
void main(void) {
|
|
544
|
+
|
|
545
|
+
vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
|
|
546
|
+
|
|
547
|
+
cameraPosition = eyePositionHigh + eyePositionLow;
|
|
548
|
+
|
|
549
|
+
vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
|
|
550
|
+
vec3 lowDiff = aVertexPositionLow + normalize(aVertexPosition) * height - eyePositionLow;
|
|
551
|
+
|
|
552
|
+
mat4 viewMatrixRTE = viewMatrix;
|
|
553
|
+
viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
|
|
554
|
+
|
|
555
|
+
v_height = height;
|
|
556
|
+
v_vertex = aVertexPosition + normalize(aVertexPosition) * height;
|
|
557
|
+
|
|
558
|
+
vTextureCoord.xy = aTextureCoord;
|
|
559
|
+
vGlobalTextureCoord = uGlobalTextureCoord.xy + (uGlobalTextureCoord.zw - uGlobalTextureCoord.xy) * aTextureCoord;
|
|
560
|
+
vTextureCoord.zw = uNormalMapBias.z * ( aTextureCoord + uNormalMapBias.xy );
|
|
561
|
+
|
|
562
|
+
gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
|
|
563
|
+
}`,
|
|
564
|
+
|
|
565
|
+
fragmentShader:
|
|
566
|
+
`#version 300 es
|
|
567
|
+
|
|
568
|
+
precision highp float;
|
|
569
|
+
|
|
570
|
+
#define MAX_POINT_LIGHTS 1
|
|
571
|
+
#define SLICE_SIZE ${SLICE_SIZE + 1}
|
|
572
|
+
|
|
573
|
+
uniform vec3 diffuse;
|
|
574
|
+
uniform vec3 ambient;
|
|
575
|
+
uniform vec4 specular;
|
|
576
|
+
|
|
577
|
+
uniform sampler2D uNormalMap;
|
|
578
|
+
uniform vec3 lightsPositions[MAX_POINT_LIGHTS];
|
|
579
|
+
uniform sampler2D nightTexture;
|
|
580
|
+
uniform sampler2D specularTexture;
|
|
581
|
+
|
|
582
|
+
uniform sampler2D transmittanceTexture;
|
|
583
|
+
uniform sampler2D scatteringTexture;
|
|
584
|
+
|
|
585
|
+
uniform vec4 tileOffsetArr[SLICE_SIZE];
|
|
586
|
+
uniform float layerOpacityArr[SLICE_SIZE];
|
|
587
|
+
|
|
588
|
+
uniform sampler2D defaultTexture;
|
|
589
|
+
uniform sampler2D samplerArr[SLICE_SIZE];
|
|
590
|
+
uniform int samplerCount;
|
|
591
|
+
uniform float nightTextureCoefficient;
|
|
592
|
+
|
|
593
|
+
uniform vec2 maxMinOpacity;
|
|
594
|
+
|
|
595
|
+
uniform float camHeight;
|
|
596
|
+
|
|
597
|
+
in vec4 vTextureCoord;
|
|
598
|
+
in vec3 v_vertex;
|
|
599
|
+
in vec3 cameraPosition;
|
|
600
|
+
in vec2 vGlobalTextureCoord;
|
|
601
|
+
in float v_height;
|
|
602
|
+
|
|
603
|
+
vec3 sunPos;
|
|
604
|
+
|
|
605
|
+
layout(location = 0) out vec4 diffuseColor;
|
|
606
|
+
|
|
607
|
+
${NIGHT}
|
|
608
|
+
|
|
609
|
+
${DEF_BLEND}
|
|
610
|
+
|
|
611
|
+
${atmos.COMMON}
|
|
612
|
+
|
|
613
|
+
vec3 transmittanceFromTexture(float height, float angle)
|
|
614
|
+
{
|
|
615
|
+
float u = (angle + 1.0) * 0.5;
|
|
616
|
+
float v = height / ATMOS_HEIGHT;
|
|
617
|
+
return texture(transmittanceTexture, vec2(u, v)).xyz;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
vec3 multipleScatteringContributionFromTexture(float height, float angle)
|
|
621
|
+
{
|
|
622
|
+
float u = (angle + 1.0) * 0.5;
|
|
623
|
+
float v = height / ATMOS_HEIGHT;
|
|
624
|
+
return texture(scatteringTexture, vec2(u, v)).xyz;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
void getSunIlluminance(in vec3 point, in vec3 lightDir, out vec3 sunIlluminance)
|
|
628
|
+
{
|
|
629
|
+
// float r = length(point);
|
|
630
|
+
// float mu_s = dot(point, sun_direction) / r;
|
|
631
|
+
// float height = r - BOTTOM_RADIUS;
|
|
632
|
+
|
|
633
|
+
float mu_s = dot(normalize(point), lightDir);
|
|
634
|
+
float height = length(point) - BOTTOM_RADIUS;
|
|
635
|
+
sunIlluminance = SUN_INTENSITY * transmittanceFromTexture(height, mu_s);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
void atmosGroundColor(out vec4 fragColor, in vec3 normal)
|
|
639
|
+
{
|
|
640
|
+
vec3 rayDirection = normalize(v_vertex - cameraPosition);
|
|
641
|
+
vec3 lightDir = normalize(sunPos);
|
|
642
|
+
|
|
643
|
+
rayDirection = normalize(rayDirection * SPHERE_TO_ELLIPSOID_SCALE);
|
|
644
|
+
vec3 camPos = cameraPosition * SPHERE_TO_ELLIPSOID_SCALE;
|
|
645
|
+
lightDir = normalize(lightDir * SPHERE_TO_ELLIPSOID_SCALE);
|
|
646
|
+
|
|
647
|
+
vec3 light = vec3(0.0);
|
|
648
|
+
vec3 transmittanceFromCameraToSpace = vec3(1.0);
|
|
649
|
+
float offset = 0.0;
|
|
650
|
+
float distanceToSpace = 0.0;
|
|
651
|
+
|
|
652
|
+
intersectSphere(camPos, rayDirection, TOP_RADIUS, offset, distanceToSpace);
|
|
653
|
+
|
|
654
|
+
vec3 rayOrigin = camPos;
|
|
655
|
+
|
|
656
|
+
// above atmosphere
|
|
657
|
+
if (offset > 0.0)
|
|
658
|
+
{
|
|
659
|
+
// intersection of camera ray with atmosphere
|
|
660
|
+
rayOrigin += rayDirection * offset;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
float height = length(rayOrigin) - BOTTOM_RADIUS;
|
|
664
|
+
float rayAngle = dot(rayOrigin, rayDirection) / length(rayOrigin);
|
|
665
|
+
bool cameraBelow = rayAngle < 0.0;
|
|
666
|
+
|
|
667
|
+
transmittanceFromCameraToSpace = transmittanceFromTexture(height, cameraBelow ? -rayAngle : rayAngle);
|
|
668
|
+
|
|
669
|
+
float phaseAngle = dot(lightDir, rayDirection);
|
|
670
|
+
float rayleighPhase = rayleighPhase(phaseAngle);
|
|
671
|
+
float miePhase = miePhase(phaseAngle);
|
|
672
|
+
|
|
673
|
+
float distanceToGround = 0.0;
|
|
674
|
+
|
|
675
|
+
bool hitGround = intersectSphere(camPos, rayDirection, BOTTOM_RADIUS, distanceToGround) && distanceToGround > 0.0;
|
|
676
|
+
|
|
677
|
+
// Fix black dots on the edge of atmosphere
|
|
678
|
+
if(camHeight < 700000.0 || !hitGround)
|
|
679
|
+
{
|
|
680
|
+
distanceToGround = distance(camPos, v_vertex * SPHERE_TO_ELLIPSOID_SCALE);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
float segmentLength = (distanceToGround - max(offset, 0.0)) / float(SAMPLE_COUNT);
|
|
684
|
+
|
|
685
|
+
float t = segmentLength * 0.5;
|
|
686
|
+
|
|
687
|
+
vec3 transmittanceCamera;
|
|
688
|
+
vec3 transmittanceLight;
|
|
689
|
+
|
|
690
|
+
for (int i = 0; i < SAMPLE_COUNT; i++)
|
|
691
|
+
{
|
|
692
|
+
vec3 position = rayOrigin + t * rayDirection;
|
|
693
|
+
float height = length(position) - BOTTOM_RADIUS;
|
|
694
|
+
vec3 up = position / length(position);
|
|
695
|
+
float rayAngle = dot(up, rayDirection);
|
|
696
|
+
float lightAngle = dot(up, lightDir);
|
|
697
|
+
vec3 transmittanceToSpace = transmittanceFromTexture(height, cameraBelow ? -rayAngle : rayAngle);
|
|
698
|
+
transmittanceCamera = cameraBelow ? (transmittanceToSpace / transmittanceFromCameraToSpace) : (transmittanceFromCameraToSpace / transmittanceToSpace);
|
|
699
|
+
transmittanceLight = transmittanceFromTexture(height, lightAngle);
|
|
700
|
+
vec2 opticalDensity = exp(-height / rayleighMieHeights);
|
|
701
|
+
vec3 scatteredLight = transmittanceLight * (rayleighScatteringCoefficient * opticalDensity.x * rayleighPhase + mieScatteringCoefficient * opticalDensity.y * miePhase);
|
|
702
|
+
scatteredLight += multipleScatteringContributionFromTexture(height, lightAngle) * (rayleighScatteringCoefficient * opticalDensity.x + mieScatteringCoefficient * opticalDensity.y);
|
|
703
|
+
light += transmittanceCamera * scatteredLight * segmentLength;
|
|
704
|
+
t += segmentLength;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
light *= SUN_INTENSITY;
|
|
708
|
+
|
|
709
|
+
vec3 hitPoint = camPos + rayDirection * distanceToGround;
|
|
710
|
+
vec3 up = normalize(hitPoint);
|
|
711
|
+
float diffuseAngle = max(dot(up, lightDir), 0.0);
|
|
712
|
+
|
|
713
|
+
float lightAngle = dot(normal, lightDir);
|
|
714
|
+
vec3 tA = transmittanceCamera * GROUND_ALBEDO * SUN_INTENSITY;
|
|
715
|
+
vec3 scatteringLight = multipleScatteringContributionFromTexture(height, lightAngle);
|
|
716
|
+
vec3 diffuseTransmittanceLight = transmittanceLight * diffuseAngle;
|
|
717
|
+
light += tA * (scatteringLight + diffuseTransmittanceLight);
|
|
718
|
+
|
|
719
|
+
fragColor = vec4(pow(light * 8.0, vec3(1.0 / 2.2)), 1.0);
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
void getAtmosFadingOpacity(out float opacity)
|
|
723
|
+
{
|
|
724
|
+
float c = length(cameraPosition);
|
|
725
|
+
float maxDist = sqrt(c * c - BOTTOM_RADIUS * BOTTOM_RADIUS);
|
|
726
|
+
float minDist = c - BOTTOM_RADIUS;
|
|
727
|
+
float vertDist = distance(cameraPosition, v_vertex);
|
|
728
|
+
opacity = maxMinOpacity.y + ( maxMinOpacity.x - maxMinOpacity.y) * getLerpValue(minDist, maxDist, vertDist);
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
void main(void) {
|
|
732
|
+
|
|
733
|
+
sunPos = lightsPositions[0];
|
|
734
|
+
|
|
735
|
+
vec3 texNormal = texture(uNormalMap, vTextureCoord.zw).rgb;
|
|
736
|
+
vec3 normal = normalize((texNormal - 0.5) * 2.0);
|
|
737
|
+
|
|
738
|
+
float minH = 1200000.0;
|
|
739
|
+
float maxH = minH * 3.0;
|
|
740
|
+
float nightCoef = getLerpValue(minH, maxH, camHeight) * nightTextureCoefficient;
|
|
741
|
+
|
|
742
|
+
if(camHeight > 6000000.0)
|
|
743
|
+
{
|
|
744
|
+
normal = normalize(v_vertex);
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
vec3 lightDir = normalize(sunPos);
|
|
748
|
+
vec3 viewDir = normalize(cameraPosition - v_vertex);
|
|
749
|
+
|
|
750
|
+
vec4 atmosColor;
|
|
751
|
+
atmosGroundColor(atmosColor, normal);
|
|
752
|
+
|
|
753
|
+
vec3 sunIlluminance;
|
|
754
|
+
getSunIlluminance(v_vertex * SPHERE_TO_ELLIPSOID_SCALE, lightDir * SPHERE_TO_ELLIPSOID_SCALE, sunIlluminance);
|
|
755
|
+
|
|
756
|
+
float overGround = 1.0 - step(0.1, v_height);
|
|
757
|
+
|
|
758
|
+
float shininess = texture( specularTexture, vGlobalTextureCoord.st ).r * 255.0 * overGround;
|
|
759
|
+
vec3 reflectionDirection = reflect(-lightDir, normal);
|
|
760
|
+
float reflection = max( dot(reflectionDirection, viewDir), 0.0);
|
|
761
|
+
vec3 spec = sunIlluminance * specular.rgb * pow( reflection, specular.w) * shininess;
|
|
762
|
+
float diffuseLightWeighting = max(dot(normal, lightDir), 0.0);
|
|
763
|
+
|
|
764
|
+
vec4 nightImageColor = texture( nightTexture, vGlobalTextureCoord.st );
|
|
765
|
+
vec3 night = nightStep * (.18 - diffuseLightWeighting * 3.0) * nightImageColor.rgb * nightCoef;
|
|
766
|
+
night *= overGround * step(0.0, night);
|
|
767
|
+
vec4 lightWeighting = vec4(ambient + sunIlluminance * diffuse * diffuseLightWeighting + night, 1.0);
|
|
768
|
+
|
|
769
|
+
float fadingOpacity;
|
|
770
|
+
getAtmosFadingOpacity(fadingOpacity);
|
|
771
|
+
|
|
772
|
+
diffuseColor = texture( defaultTexture, vTextureCoord.xy );
|
|
400
773
|
if( samplerCount == 0 ) {
|
|
401
|
-
|
|
774
|
+
diffuseColor = mix(diffuseColor * lightWeighting, atmosColor, fadingOpacity) + vec4(spec, 0.0);
|
|
402
775
|
return;
|
|
403
776
|
}
|
|
404
777
|
|
|
405
778
|
vec4 src;
|
|
406
779
|
|
|
407
|
-
blend(
|
|
408
|
-
if( samplerCount == 1 ) {
|
|
409
|
-
|
|
780
|
+
blend(diffuseColor, samplerArr[0], tileOffsetArr[0], layerOpacityArr[0]);
|
|
781
|
+
if( samplerCount == 1 ) {
|
|
782
|
+
diffuseColor = mix(diffuseColor * lightWeighting, atmosColor, fadingOpacity) + vec4(spec, 0.0);
|
|
410
783
|
return;
|
|
411
784
|
}
|
|
412
785
|
|
|
413
|
-
blend(
|
|
786
|
+
blend(diffuseColor, samplerArr[1], tileOffsetArr[1], layerOpacityArr[1]);
|
|
414
787
|
if( samplerCount == 2 ) {
|
|
415
|
-
|
|
788
|
+
diffuseColor = mix(diffuseColor * lightWeighting, atmosColor, fadingOpacity) + vec4(spec, 0.0);
|
|
416
789
|
return;
|
|
417
790
|
}
|
|
418
791
|
|
|
419
|
-
blend(
|
|
792
|
+
blend(diffuseColor, samplerArr[2], tileOffsetArr[2], layerOpacityArr[2]);
|
|
420
793
|
if( samplerCount == 3 ) {
|
|
421
|
-
|
|
794
|
+
diffuseColor = mix(diffuseColor * lightWeighting, atmosColor, fadingOpacity) + vec4(spec, 0.0);
|
|
422
795
|
return;
|
|
423
796
|
}
|
|
424
797
|
|
|
425
|
-
blend(
|
|
798
|
+
blend(diffuseColor, samplerArr[3], tileOffsetArr[3], layerOpacityArr[3]);
|
|
426
799
|
if( samplerCount == 4 ) {
|
|
427
|
-
|
|
800
|
+
diffuseColor = mix(diffuseColor * lightWeighting, atmosColor, fadingOpacity) + vec4(spec, 0.0);
|
|
428
801
|
return;
|
|
429
802
|
}
|
|
430
803
|
|
|
431
|
-
blend(
|
|
432
|
-
|
|
804
|
+
blend(diffuseColor, samplerArr[4], tileOffsetArr[4], layerOpacityArr[4]);
|
|
805
|
+
diffuseColor = mix(diffuseColor * lightWeighting, atmosColor, fadingOpacity) + vec4(spec, 0.0);
|
|
433
806
|
}`
|
|
434
807
|
});
|
|
435
808
|
}
|
|
@@ -447,11 +820,8 @@ export function drawnode_colorPicking() {
|
|
|
447
820
|
pickingMaskArr: "sampler2darray",
|
|
448
821
|
pickingColorArr: "vec4",
|
|
449
822
|
height: "float"
|
|
450
|
-
},
|
|
451
|
-
|
|
452
|
-
aVertexPositionHigh: "vec3",
|
|
453
|
-
aVertexPositionLow: "vec3",
|
|
454
|
-
aTextureCoord: "vec2"
|
|
823
|
+
}, attributes: {
|
|
824
|
+
aVertexPositionHigh: "vec3", aVertexPositionLow: "vec3", aTextureCoord: "vec2"
|
|
455
825
|
},
|
|
456
826
|
|
|
457
827
|
vertexShader: `attribute vec3 aVertexPositionHigh;
|
|
@@ -523,10 +893,8 @@ export function drawnode_heightPicking() {
|
|
|
523
893
|
height: "float",
|
|
524
894
|
eyePositionHigh: "vec3",
|
|
525
895
|
eyePositionLow: "vec3"
|
|
526
|
-
},
|
|
527
|
-
|
|
528
|
-
aVertexPositionHigh: "vec3",
|
|
529
|
-
aVertexPositionLow: "vec3"
|
|
896
|
+
}, attributes: {
|
|
897
|
+
aVertexPositionHigh: "vec3", aVertexPositionLow: "vec3"
|
|
530
898
|
},
|
|
531
899
|
|
|
532
900
|
vertexShader: `attribute vec3 aVertexPositionHigh;
|
|
@@ -586,10 +954,8 @@ export function drawnode_depth() {
|
|
|
586
954
|
eyePositionHigh: "vec3",
|
|
587
955
|
eyePositionLow: "vec3",
|
|
588
956
|
frustumPickingColor: "vec3"
|
|
589
|
-
},
|
|
590
|
-
|
|
591
|
-
aVertexPositionHigh: "vec3",
|
|
592
|
-
aVertexPositionLow: "vec3"
|
|
957
|
+
}, attributes: {
|
|
958
|
+
aVertexPositionHigh: "vec3", aVertexPositionLow: "vec3"
|
|
593
959
|
},
|
|
594
960
|
|
|
595
961
|
vertexShader: `attribute vec3 aVertexPositionHigh;
|