deeptwins-engine-3d 0.1.65 → 0.1.66
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/dist/esm/constant.d.ts +1 -0
- package/dist/esm/drawCommand/viewShed/RectangularSensorPrimitive.d.ts +1 -0
- package/dist/esm/drawCommand/viewShed/ViewShedAnalyserLayer.d.ts +1 -0
- package/dist/esm/drawer/common.d.ts +1 -0
- package/dist/esm/drawer/coordinate.d.ts +1 -0
- package/dist/esm/drawer/index.d.ts +1 -1
- package/dist/esm/drawer/shape/BaseShape.d.ts +1 -0
- package/dist/esm/graphicLayer/BaseSource.d.ts +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +6 -2
- package/dist/esm/map/Map.d.ts +9 -0
- package/dist/esm/map/Map.js +115 -2
- package/dist/esm/material/AtmosphericDispersion.d.ts +71 -0
- package/dist/esm/material/AtmosphericDispersion.js +485 -33
- package/dist/esm/material/GlobalVolumetricCloud.d.ts +117 -0
- package/dist/esm/material/GlobalVolumetricCloud.js +219 -223
- package/dist/esm/material/entity/ImageMaterialProperty.d.ts +1 -0
- package/dist/esm/material/shader/AtmosphericShader.glsl +244 -0
- package/dist/esm/measure/BaseDraw.d.ts +1 -0
- package/dist/esm/measure/types.d.ts +1 -0
- package/dist/esm/measure/utils.d.ts +1 -0
- package/dist/esm/sceneFusion/Airway.d.ts +0 -0
- package/dist/esm/sceneFusion/Airway.js +692 -0
- package/dist/esm/tileLayer/ArcGisLayer.d.ts +1 -0
- package/dist/esm/tileLayer/ImageryLayer.d.ts +1 -0
- package/dist/esm/tileLayer/MvtVectorLoad.d.ts +1 -0
- package/dist/esm/tool/common.d.ts +1 -0
- package/dist/esm/tool/utils.d.ts +1 -0
- package/dist/esm/typings.d.ts +8 -0
- package/dist/esm/visualization/BaseHeatmap.d.ts +5 -0
- package/dist/esm/visualization/BaseHeatmap.js +54 -12
- package/dist/esm/visualization/Heatmap2d.d.ts +1 -0
- package/dist/esm/visualization/Heatmap2d.js +17 -26
- package/dist/esm/visualization/Heatmap3d.d.ts +8 -2
- package/dist/esm/visualization/Heatmap3d.js +195 -59
- package/dist/umd/deeptwins-engine-3d.min.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
precision highp float;
|
|
2
|
+
uniform sampler2D colorTexture;
|
|
3
|
+
uniform sampler2D depthTexture;
|
|
4
|
+
uniform float u_threshold;
|
|
5
|
+
uniform float u_blendFactor;
|
|
6
|
+
uniform float u_lightIntensity;
|
|
7
|
+
uniform float u_scatterStrength;
|
|
8
|
+
uniform float u_tonemapExposure;
|
|
9
|
+
uniform float u_mieExtinctionStrength;
|
|
10
|
+
uniform float u_fogOpacity;
|
|
11
|
+
uniform float u_fogPower;
|
|
12
|
+
uniform float u_clearMixBias;
|
|
13
|
+
in vec2 v_textureCoordinates;
|
|
14
|
+
const float PI = 3.14159265359;
|
|
15
|
+
const float TWO_PI = PI * 2.0;
|
|
16
|
+
const float FOUR_PI = PI * 4.0;
|
|
17
|
+
const float SCATTER_VISIBILITY_SCALE = 30000.0;
|
|
18
|
+
const float MAX_EXPOSURE_RESPONSE = 1.8;
|
|
19
|
+
const float MAX_LIGHT_RESPONSE = 3.0;
|
|
20
|
+
|
|
21
|
+
const vec3 betaR = vec3(5.5e-6, 13.0e-6, 22.4e-6);
|
|
22
|
+
|
|
23
|
+
const vec3 betaM = vec3(21e-6);
|
|
24
|
+
|
|
25
|
+
const float hR = 10e3;
|
|
26
|
+
const float hM = 3.8e3;
|
|
27
|
+
const int num_samples = 16;
|
|
28
|
+
const int num_samples_light = 4;
|
|
29
|
+
#ifdef GL_ES
|
|
30
|
+
#define _in(T) const in T
|
|
31
|
+
#define _inout(T) inout T
|
|
32
|
+
#define _out(T) out T
|
|
33
|
+
#define _begin(type) type (
|
|
34
|
+
#define _end )
|
|
35
|
+
#define mul(a, b) (a) * (b)
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
struct ray_t {
|
|
39
|
+
vec3 origin;
|
|
40
|
+
vec3 direction;
|
|
41
|
+
};
|
|
42
|
+
struct sphere_t {
|
|
43
|
+
vec3 origin;
|
|
44
|
+
float radius;
|
|
45
|
+
int material;
|
|
46
|
+
};
|
|
47
|
+
struct plane_t {
|
|
48
|
+
vec3 direction;
|
|
49
|
+
float distance;
|
|
50
|
+
int material;
|
|
51
|
+
};
|
|
52
|
+
plane_t plane;
|
|
53
|
+
mat3 rotate_around_x(_in(float) angle_degrees) {
|
|
54
|
+
float angle = radians(angle_degrees);
|
|
55
|
+
float _sin = sin(angle);
|
|
56
|
+
float _cos = cos(angle);
|
|
57
|
+
return mat3(1, 0, 0, 0, _cos, -_sin, 0, _sin, _cos);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
bool isect_sphere(_in(ray_t) ray, _in(sphere_t) sphere, _inout(float) t0, _inout(float) t1) {
|
|
61
|
+
vec3 rc = sphere.origin - ray.origin;
|
|
62
|
+
float radius2 = sphere.radius * sphere.radius;
|
|
63
|
+
float tca = dot(rc, ray.direction);
|
|
64
|
+
float d2 = dot(rc, rc) - tca * tca;
|
|
65
|
+
if (d2 > radius2) return false;
|
|
66
|
+
float thc = sqrt(radius2 - d2);
|
|
67
|
+
t0 = tca - thc;
|
|
68
|
+
t1 = tca + thc;
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
float rayleigh_phase_func(float mu) {
|
|
72
|
+
return
|
|
73
|
+
3. * (1. + mu * mu)
|
|
74
|
+
/
|
|
75
|
+
(16. * PI);
|
|
76
|
+
}
|
|
77
|
+
const float g = 0.76;
|
|
78
|
+
float henyey_greenstein_phase_func(float mu) {
|
|
79
|
+
return
|
|
80
|
+
(1. - g * g)
|
|
81
|
+
/
|
|
82
|
+
((4. * PI) * pow(1. + g * g - 2. * g * mu, 1.5));
|
|
83
|
+
}
|
|
84
|
+
const float k = 1.55 * g - 0.55 * (g * g * g);
|
|
85
|
+
float schlick_phase_func(float mu) {
|
|
86
|
+
return
|
|
87
|
+
(1. - k * k)
|
|
88
|
+
/
|
|
89
|
+
(4. * PI * (1. + k * mu) * (1. + k * mu));
|
|
90
|
+
}
|
|
91
|
+
const sphere_t atmosphere = _begin(sphere_t)
|
|
92
|
+
vec3(0, 0, 0), 6420e3, 0
|
|
93
|
+
_end;
|
|
94
|
+
|
|
95
|
+
bool get_sun_light(
|
|
96
|
+
_in(ray_t) ray, _inout(float) optical_depthR, _inout(float) optical_depthM
|
|
97
|
+
) {
|
|
98
|
+
float t0, t1;
|
|
99
|
+
isect_sphere(ray, atmosphere, t0, t1);
|
|
100
|
+
float march_pos = 0.;
|
|
101
|
+
float march_step = t1 / float(num_samples_light);
|
|
102
|
+
for (int i = 0; i < num_samples_light; i++) {
|
|
103
|
+
vec3 s = ray.origin +
|
|
104
|
+
ray.direction * (march_pos + 0.5 * march_step);
|
|
105
|
+
float height = length(s) - 6360e3;
|
|
106
|
+
if (height < 0.)
|
|
107
|
+
return false;
|
|
108
|
+
optical_depthR += exp(-height / hR) * march_step;
|
|
109
|
+
optical_depthM += exp(-height / hM) * march_step;
|
|
110
|
+
march_pos += march_step;
|
|
111
|
+
}
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
vec4 get_incident_light(_in(ray_t) ray) {
|
|
115
|
+
vec3 dir = ray.direction;
|
|
116
|
+
vec3 start = ray.origin;
|
|
117
|
+
float a = dot(dir, dir);
|
|
118
|
+
float b = 2.0 * dot(dir, start);
|
|
119
|
+
float radius2 = atmosphere.radius * atmosphere.radius;
|
|
120
|
+
float c = dot(start, start) - radius2;
|
|
121
|
+
float d = (b * b) - 4.0 * a * c;
|
|
122
|
+
if (d < 0.0) return vec4(0.0);
|
|
123
|
+
float squaredD = sqrt(d);
|
|
124
|
+
vec2 ray_length = vec2(
|
|
125
|
+
max((-b - squaredD) / (2.0 * a), 0.0), min((-b + squaredD) / (2.0 * a), plane.distance)
|
|
126
|
+
);
|
|
127
|
+
if (ray_length.x > ray_length.y) return vec4(0.0);
|
|
128
|
+
float march_step = (ray_length.y - ray_length.x) / float(num_samples);
|
|
129
|
+
float mu = dot(ray.direction, normalize(czm_sunPositionWC));
|
|
130
|
+
float phaseR = rayleigh_phase_func(mu);
|
|
131
|
+
float phaseM =
|
|
132
|
+
#if 1
|
|
133
|
+
henyey_greenstein_phase_func(mu);
|
|
134
|
+
#else
|
|
135
|
+
schlick_phase_func(mu);
|
|
136
|
+
#endif
|
|
137
|
+
|
|
138
|
+
float optical_depthR = 0.;
|
|
139
|
+
float optical_depthM = 0.;
|
|
140
|
+
vec3 sumR = vec3(0);
|
|
141
|
+
vec3 sumM = vec3(0);
|
|
142
|
+
float march_pos = 0.;
|
|
143
|
+
for (int i = 0; i < num_samples; i++) {
|
|
144
|
+
vec3 s = ray.origin +
|
|
145
|
+
ray.direction * (march_pos + 0.5 * march_step);
|
|
146
|
+
float height = length(s) - 6360e3;
|
|
147
|
+
|
|
148
|
+
float hr = exp(-height / hR) * march_step;
|
|
149
|
+
float hm = exp(-height / hM) * march_step;
|
|
150
|
+
optical_depthR += hr;
|
|
151
|
+
optical_depthM += hm;
|
|
152
|
+
|
|
153
|
+
ray_t light_ray = _begin(ray_t)
|
|
154
|
+
s, normalize(czm_sunPositionWC)
|
|
155
|
+
_end;
|
|
156
|
+
float optical_depth_lightR = 0.;
|
|
157
|
+
float optical_depth_lightM = 0.;
|
|
158
|
+
bool overground = get_sun_light(
|
|
159
|
+
light_ray,
|
|
160
|
+
optical_depth_lightR,
|
|
161
|
+
optical_depth_lightM);
|
|
162
|
+
|
|
163
|
+
if (overground) {
|
|
164
|
+
|
|
165
|
+
vec3 tau =
|
|
166
|
+
betaR * (optical_depthR + optical_depth_lightR) +
|
|
167
|
+
betaM * u_mieExtinctionStrength * (optical_depthM + optical_depth_lightM);
|
|
168
|
+
vec3 attenuation = exp(-tau);
|
|
169
|
+
sumR += hr * attenuation;
|
|
170
|
+
sumM += hm * attenuation;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
march_pos += march_step;
|
|
174
|
+
}
|
|
175
|
+
vec3 transmittance = exp(-((betaM * optical_depthM * u_mieExtinctionStrength)
|
|
176
|
+
+ (betaR * optical_depthR)) * 4.);
|
|
177
|
+
float attenuation = clamp(dot(transmittance, vec3(0.3333333)), 0.0, 1.0);
|
|
178
|
+
|
|
179
|
+
return vec4(
|
|
180
|
+
u_scatterStrength *
|
|
181
|
+
(sumR * phaseR * betaR +
|
|
182
|
+
sumM * phaseM * betaM), 1.0 - attenuation);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
void main() {
|
|
186
|
+
vec4 rawColor = texture(colorTexture, v_textureCoordinates);
|
|
187
|
+
float depth = czm_unpackDepth(texture(depthTexture, v_textureCoordinates));
|
|
188
|
+
|
|
189
|
+
vec4 positionEC = czm_windowToEyeCoordinates(gl_FragCoord.xy, depth);
|
|
190
|
+
vec4 positionWC = czm_inverseView * positionEC;
|
|
191
|
+
positionWC.xyz = positionWC.xyz / positionWC.w;
|
|
192
|
+
|
|
193
|
+
vec3 lVector = positionWC.xyz - czm_viewerPositionWC;
|
|
194
|
+
ray_t ray;
|
|
195
|
+
ray.origin = czm_viewerPositionWC;
|
|
196
|
+
ray.direction = normalize(lVector);
|
|
197
|
+
plane.distance = length(lVector);
|
|
198
|
+
|
|
199
|
+
vec4 atmosphereColor = get_incident_light(ray);
|
|
200
|
+
float lightControl = clamp(u_lightIntensity / 4.0, 0.0, 1.0);
|
|
201
|
+
float lightStrength = MAX_LIGHT_RESPONSE * (
|
|
202
|
+
1.0 - exp(-2.6 * pow(lightControl, 1.6))
|
|
203
|
+
);
|
|
204
|
+
vec3 scatterColor = atmosphereColor.rgb * lightStrength;
|
|
205
|
+
float exposureControl = clamp(u_tonemapExposure / 3.0, 0.0, 1.0);
|
|
206
|
+
float exposureStrength = pow(exposureControl, 1.25) * MAX_EXPOSURE_RESPONSE;
|
|
207
|
+
float mieVisualFactor = mix(
|
|
208
|
+
0.6,
|
|
209
|
+
1.8,
|
|
210
|
+
clamp(u_mieExtinctionStrength / 2.0, 0.0, 1.0)
|
|
211
|
+
);
|
|
212
|
+
vec3 visibleScatter = 1.0 - exp(
|
|
213
|
+
-max(scatterColor * SCATTER_VISIBILITY_SCALE, 0.0) * exposureStrength
|
|
214
|
+
);
|
|
215
|
+
visibleScatter *= mieVisualFactor;
|
|
216
|
+
float brightness = dot(visibleScatter, vec3(0.299, 0.587, 0.114));
|
|
217
|
+
float thresholdMask = u_threshold > 0.0
|
|
218
|
+
? smoothstep(0.0, u_threshold, brightness)
|
|
219
|
+
: 1.0;
|
|
220
|
+
visibleScatter *= thresholdMask;
|
|
221
|
+
float fogSignal = clamp(atmosphereColor.a * 2.5, 0.0, 1.0);
|
|
222
|
+
float fogAlpha = clamp(
|
|
223
|
+
pow(fogSignal, u_fogPower) * u_fogOpacity * mieVisualFactor,
|
|
224
|
+
0.0,
|
|
225
|
+
1.0
|
|
226
|
+
);
|
|
227
|
+
float clearPreserve = clamp(1.0 - u_clearMixBias, 0.0, 1.0);
|
|
228
|
+
float fogMix = fogAlpha * clearPreserve * 0.85;
|
|
229
|
+
vec3 foggedBase = mix(
|
|
230
|
+
rawColor.rgb,
|
|
231
|
+
rawColor.rgb * (1.0 - fogAlpha * 0.35),
|
|
232
|
+
fogMix
|
|
233
|
+
);
|
|
234
|
+
vec3 overlayColor = visibleScatter *
|
|
235
|
+
(0.55 + fogAlpha * 1.25) *
|
|
236
|
+
mix(1.0, 0.6, u_clearMixBias);
|
|
237
|
+
vec3 finalColor = mix(
|
|
238
|
+
rawColor.rgb,
|
|
239
|
+
foggedBase + overlayColor,
|
|
240
|
+
u_blendFactor
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
out_FragColor = vec4(clamp(finalColor, 0.0, 1.0), rawColor.a);
|
|
244
|
+
}
|
|
File without changes
|