@mapcatch/util 2.0.4 → 2.0.5-a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/.eslintrc.js +54 -0
  2. package/.husky/pre-commit +1 -0
  3. package/.prettierrc +4 -0
  4. package/.vscode/settings.json +2 -0
  5. package/README.md +44 -0
  6. package/debug/app.js +26 -0
  7. package/debug/index.html +55 -0
  8. package/debug/libs/vue.global.js +16159 -0
  9. package/debug/my_icon.png +0 -0
  10. package/docs/Catolog.md +24 -0
  11. package/docs/Constant.md +92 -0
  12. package/docs/Event.md +90 -0
  13. package/docs/Util.md +345 -0
  14. package/package.json +21 -1
  15. package/src/constants/crs.js +42098 -42098
  16. package/src/constants/default_layers.js +42 -94
  17. package/src/gl-operations/constants.js +9 -9
  18. package/src/gl-operations/default_options.js +97 -97
  19. package/src/gl-operations/index.js +532 -532
  20. package/src/gl-operations/reglCommands/contours.js +27 -27
  21. package/src/gl-operations/reglCommands/default.js +45 -45
  22. package/src/gl-operations/reglCommands/hillshading.js +340 -340
  23. package/src/gl-operations/reglCommands/index.js +6 -6
  24. package/src/gl-operations/reglCommands/multiLayers.js +303 -303
  25. package/src/gl-operations/reglCommands/transitions.js +111 -111
  26. package/src/gl-operations/reglCommands/util.js +71 -71
  27. package/src/gl-operations/renderer.js +209 -209
  28. package/src/gl-operations/shaders/fragment/convertDem.js +25 -25
  29. package/src/gl-operations/shaders/fragment/convolutionSmooth.js +54 -54
  30. package/src/gl-operations/shaders/fragment/diffCalc.js +33 -33
  31. package/src/gl-operations/shaders/fragment/drawResult.js +46 -46
  32. package/src/gl-operations/shaders/fragment/hillshading/hsAdvAmbientShadows.js +78 -78
  33. package/src/gl-operations/shaders/fragment/hillshading/hsAdvDirect.js +59 -59
  34. package/src/gl-operations/shaders/fragment/hillshading/hsAdvFinalBaselayer.js +30 -30
  35. package/src/gl-operations/shaders/fragment/hillshading/hsAdvFinalColorscale.js +60 -60
  36. package/src/gl-operations/shaders/fragment/hillshading/hsAdvMergeAndScaleTiles.js +26 -26
  37. package/src/gl-operations/shaders/fragment/hillshading/hsAdvNormals.js +25 -25
  38. package/src/gl-operations/shaders/fragment/hillshading/hsAdvSmooth.js +53 -53
  39. package/src/gl-operations/shaders/fragment/hillshading/hsAdvSoftShadows.js +80 -80
  40. package/src/gl-operations/shaders/fragment/hillshading/hsPregen.js +54 -54
  41. package/src/gl-operations/shaders/fragment/interpolateColor.js +65 -65
  42. package/src/gl-operations/shaders/fragment/interpolateColorOnly.js +49 -49
  43. package/src/gl-operations/shaders/fragment/interpolateValue.js +136 -136
  44. package/src/gl-operations/shaders/fragment/multiAnalyze1Calc.js +35 -35
  45. package/src/gl-operations/shaders/fragment/multiAnalyze2Calc.js +45 -45
  46. package/src/gl-operations/shaders/fragment/multiAnalyze3Calc.js +53 -53
  47. package/src/gl-operations/shaders/fragment/multiAnalyze4Calc.js +61 -61
  48. package/src/gl-operations/shaders/fragment/multiAnalyze5Calc.js +69 -69
  49. package/src/gl-operations/shaders/fragment/multiAnalyze6Calc.js +77 -77
  50. package/src/gl-operations/shaders/fragment/single.js +93 -93
  51. package/src/gl-operations/shaders/transform.js +21 -21
  52. package/src/gl-operations/shaders/util/computeColor.glsl +85 -85
  53. package/src/gl-operations/shaders/util/getTexelValue.glsl +10 -10
  54. package/src/gl-operations/shaders/util/isCloseEnough.glsl +9 -9
  55. package/src/gl-operations/shaders/util/rgbaToFloat.glsl +17 -17
  56. package/src/gl-operations/shaders/vertex/double.js +16 -16
  57. package/src/gl-operations/shaders/vertex/multi3.js +19 -19
  58. package/src/gl-operations/shaders/vertex/multi4.js +22 -22
  59. package/src/gl-operations/shaders/vertex/multi5.js +25 -25
  60. package/src/gl-operations/shaders/vertex/multi6.js +28 -28
  61. package/src/gl-operations/shaders/vertex/single.js +13 -13
  62. package/src/gl-operations/shaders/vertex/singleNotTransformed.js +11 -11
  63. package/src/gl-operations/texture_manager.js +141 -141
  64. package/src/gl-operations/util.js +336 -336
  65. package/src/util.js +14 -6
  66. package/vite.config.js +58 -0
  67. package/dist/catchUtil.min.esm.js +0 -113044
  68. package/dist/catchUtil.min.js +0 -2928
@@ -1,70 +1,70 @@
1
- import glsl from 'glslify'
2
-
3
- export default glsl`#ifdef GL_FRAGMENT_PRECISION_HIGH
4
- precision highp float;
5
- #else
6
- precision mediump float;
7
- #endif
8
-
9
- #pragma glslify: getTexelValue = require(../util/getTexelValue.glsl)
10
- #pragma glslify: floatToRgba = require(glsl-float-to-rgba)
11
- #pragma glslify: isCloseEnough = require(../util/isCloseEnough.glsl)
12
-
13
- uniform sampler2D textureA;
14
- uniform sampler2D textureB;
15
- uniform sampler2D textureC;
16
- uniform sampler2D textureD;
17
- uniform sampler2D textureE;
18
-
19
- uniform float nodataValue;
20
- uniform bool littleEndian;
21
-
22
- uniform float filterLowA;
23
- uniform float filterHighA;
24
- uniform float filterLowB;
25
- uniform float filterHighB;
26
- uniform float filterLowC;
27
- uniform float filterHighC;
28
- uniform float filterLowD;
29
- uniform float filterHighD;
30
- uniform float filterLowE;
31
- uniform float filterHighE;
32
- uniform float multiplierA;
33
- uniform float multiplierB;
34
- uniform float multiplierC;
35
- uniform float multiplierD;
36
- uniform float multiplierE;
37
-
38
- varying vec2 vTexCoordA;
39
- varying vec2 vTexCoordB;
40
- varying vec2 vTexCoordC;
41
- varying vec2 vTexCoordD;
42
- varying vec2 vTexCoordE;
43
-
44
- void main() {
45
- float texelFloatA = getTexelValue(textureA, vTexCoordA, littleEndian);
46
- float texelFloatB = getTexelValue(textureB, vTexCoordB, littleEndian);
47
- float texelFloatC = getTexelValue(textureC, vTexCoordC, littleEndian);
48
- float texelFloatD = getTexelValue(textureD, vTexCoordD, littleEndian);
49
- float texelFloatE = getTexelValue(textureE, vTexCoordE, littleEndian);
50
-
51
- bool aIsNodata = isCloseEnough(texelFloatA, nodataValue);
52
- bool bIsNodata = isCloseEnough(texelFloatB, nodataValue);
53
- bool cIsNodata = isCloseEnough(texelFloatC, nodataValue);
54
- bool dIsNodata = isCloseEnough(texelFloatD, nodataValue);
55
- bool eIsNodata = isCloseEnough(texelFloatE, nodataValue);
56
-
57
- if (aIsNodata || bIsNodata || cIsNodata || dIsNodata || eIsNodata ||
58
- texelFloatA < filterLowA || texelFloatA > filterHighA ||
59
- texelFloatB < filterLowB || texelFloatB > filterHighB ||
60
- texelFloatC < filterLowC || texelFloatC > filterHighC ||
61
- texelFloatD < filterLowD || texelFloatD > filterHighD ||
62
- texelFloatE < filterLowE || texelFloatE > filterHighE
63
- ) {
64
- gl_FragColor = floatToRgba(nodataValue, littleEndian);
65
- } else {
66
- float texelFloatFinal = texelFloatA * multiplierA + texelFloatB * multiplierB + texelFloatC * multiplierC + texelFloatD * multiplierD + texelFloatE * multiplierE;
67
- gl_FragColor = floatToRgba(texelFloatFinal, littleEndian);
68
- }
69
- }
1
+ import glsl from 'glslify'
2
+
3
+ export default glsl`#ifdef GL_FRAGMENT_PRECISION_HIGH
4
+ precision highp float;
5
+ #else
6
+ precision mediump float;
7
+ #endif
8
+
9
+ #pragma glslify: getTexelValue = require(../util/getTexelValue.glsl)
10
+ #pragma glslify: floatToRgba = require(glsl-float-to-rgba)
11
+ #pragma glslify: isCloseEnough = require(../util/isCloseEnough.glsl)
12
+
13
+ uniform sampler2D textureA;
14
+ uniform sampler2D textureB;
15
+ uniform sampler2D textureC;
16
+ uniform sampler2D textureD;
17
+ uniform sampler2D textureE;
18
+
19
+ uniform float nodataValue;
20
+ uniform bool littleEndian;
21
+
22
+ uniform float filterLowA;
23
+ uniform float filterHighA;
24
+ uniform float filterLowB;
25
+ uniform float filterHighB;
26
+ uniform float filterLowC;
27
+ uniform float filterHighC;
28
+ uniform float filterLowD;
29
+ uniform float filterHighD;
30
+ uniform float filterLowE;
31
+ uniform float filterHighE;
32
+ uniform float multiplierA;
33
+ uniform float multiplierB;
34
+ uniform float multiplierC;
35
+ uniform float multiplierD;
36
+ uniform float multiplierE;
37
+
38
+ varying vec2 vTexCoordA;
39
+ varying vec2 vTexCoordB;
40
+ varying vec2 vTexCoordC;
41
+ varying vec2 vTexCoordD;
42
+ varying vec2 vTexCoordE;
43
+
44
+ void main() {
45
+ float texelFloatA = getTexelValue(textureA, vTexCoordA, littleEndian);
46
+ float texelFloatB = getTexelValue(textureB, vTexCoordB, littleEndian);
47
+ float texelFloatC = getTexelValue(textureC, vTexCoordC, littleEndian);
48
+ float texelFloatD = getTexelValue(textureD, vTexCoordD, littleEndian);
49
+ float texelFloatE = getTexelValue(textureE, vTexCoordE, littleEndian);
50
+
51
+ bool aIsNodata = isCloseEnough(texelFloatA, nodataValue);
52
+ bool bIsNodata = isCloseEnough(texelFloatB, nodataValue);
53
+ bool cIsNodata = isCloseEnough(texelFloatC, nodataValue);
54
+ bool dIsNodata = isCloseEnough(texelFloatD, nodataValue);
55
+ bool eIsNodata = isCloseEnough(texelFloatE, nodataValue);
56
+
57
+ if (aIsNodata || bIsNodata || cIsNodata || dIsNodata || eIsNodata ||
58
+ texelFloatA < filterLowA || texelFloatA > filterHighA ||
59
+ texelFloatB < filterLowB || texelFloatB > filterHighB ||
60
+ texelFloatC < filterLowC || texelFloatC > filterHighC ||
61
+ texelFloatD < filterLowD || texelFloatD > filterHighD ||
62
+ texelFloatE < filterLowE || texelFloatE > filterHighE
63
+ ) {
64
+ gl_FragColor = floatToRgba(nodataValue, littleEndian);
65
+ } else {
66
+ float texelFloatFinal = texelFloatA * multiplierA + texelFloatB * multiplierB + texelFloatC * multiplierC + texelFloatD * multiplierD + texelFloatE * multiplierE;
67
+ gl_FragColor = floatToRgba(texelFloatFinal, littleEndian);
68
+ }
69
+ }
70
70
  `
@@ -1,78 +1,78 @@
1
- import glsl from 'glslify'
2
-
3
- export default glsl`#ifdef GL_FRAGMENT_PRECISION_HIGH
4
- precision highp float;
5
- #else
6
- precision mediump float;
7
- #endif
8
-
9
- #pragma glslify: getTexelValue = require(../util/getTexelValue.glsl)
10
- #pragma glslify: floatToRgba = require(glsl-float-to-rgba)
11
- #pragma glslify: isCloseEnough = require(../util/isCloseEnough.glsl)
12
-
13
- uniform sampler2D textureA;
14
- uniform sampler2D textureB;
15
- uniform sampler2D textureC;
16
- uniform sampler2D textureD;
17
- uniform sampler2D textureE;
18
- uniform sampler2D textureF;
19
-
20
- uniform float nodataValue;
21
- uniform bool littleEndian;
22
-
23
- uniform float filterLowA;
24
- uniform float filterHighA;
25
- uniform float filterLowB;
26
- uniform float filterHighB;
27
- uniform float filterLowC;
28
- uniform float filterHighC;
29
- uniform float filterLowD;
30
- uniform float filterHighD;
31
- uniform float filterLowE;
32
- uniform float filterHighE;
33
- uniform float filterLowF;
34
- uniform float filterHighF;
35
- uniform float multiplierA;
36
- uniform float multiplierB;
37
- uniform float multiplierC;
38
- uniform float multiplierD;
39
- uniform float multiplierE;
40
- uniform float multiplierF;
41
-
42
- varying vec2 vTexCoordA;
43
- varying vec2 vTexCoordB;
44
- varying vec2 vTexCoordC;
45
- varying vec2 vTexCoordD;
46
- varying vec2 vTexCoordE;
47
- varying vec2 vTexCoordF;
48
-
49
- void main() {
50
- float texelFloatA = getTexelValue(textureA, vTexCoordA, littleEndian);
51
- float texelFloatB = getTexelValue(textureB, vTexCoordB, littleEndian);
52
- float texelFloatC = getTexelValue(textureC, vTexCoordC, littleEndian);
53
- float texelFloatD = getTexelValue(textureD, vTexCoordD, littleEndian);
54
- float texelFloatE = getTexelValue(textureE, vTexCoordE, littleEndian);
55
- float texelFloatF = getTexelValue(textureF, vTexCoordF, littleEndian);
56
-
57
- bool aIsNodata = isCloseEnough(texelFloatA, nodataValue);
58
- bool bIsNodata = isCloseEnough(texelFloatB, nodataValue);
59
- bool cIsNodata = isCloseEnough(texelFloatC, nodataValue);
60
- bool dIsNodata = isCloseEnough(texelFloatD, nodataValue);
61
- bool eIsNodata = isCloseEnough(texelFloatE, nodataValue);
62
- bool fIsNodata = isCloseEnough(texelFloatF, nodataValue);
63
-
64
- if (aIsNodata || bIsNodata || cIsNodata || dIsNodata || eIsNodata || fIsNodata ||
65
- texelFloatA < filterLowA || texelFloatA > filterHighA ||
66
- texelFloatB < filterLowB || texelFloatB > filterHighB ||
67
- texelFloatC < filterLowC || texelFloatC > filterHighC ||
68
- texelFloatD < filterLowD || texelFloatD > filterHighD ||
69
- texelFloatE < filterLowE || texelFloatE > filterHighE ||
70
- texelFloatF < filterLowF || texelFloatF > filterHighF
71
- ) {
72
- gl_FragColor = floatToRgba(nodataValue, littleEndian);
73
- } else {
74
- float texelFloatFinal = texelFloatA * multiplierA + texelFloatB * multiplierB + texelFloatC * multiplierC + texelFloatD * multiplierD + texelFloatE * multiplierE + texelFloatF * multiplierF;
75
- gl_FragColor = floatToRgba(texelFloatFinal, littleEndian);
76
- }
77
- }
1
+ import glsl from 'glslify'
2
+
3
+ export default glsl`#ifdef GL_FRAGMENT_PRECISION_HIGH
4
+ precision highp float;
5
+ #else
6
+ precision mediump float;
7
+ #endif
8
+
9
+ #pragma glslify: getTexelValue = require(../util/getTexelValue.glsl)
10
+ #pragma glslify: floatToRgba = require(glsl-float-to-rgba)
11
+ #pragma glslify: isCloseEnough = require(../util/isCloseEnough.glsl)
12
+
13
+ uniform sampler2D textureA;
14
+ uniform sampler2D textureB;
15
+ uniform sampler2D textureC;
16
+ uniform sampler2D textureD;
17
+ uniform sampler2D textureE;
18
+ uniform sampler2D textureF;
19
+
20
+ uniform float nodataValue;
21
+ uniform bool littleEndian;
22
+
23
+ uniform float filterLowA;
24
+ uniform float filterHighA;
25
+ uniform float filterLowB;
26
+ uniform float filterHighB;
27
+ uniform float filterLowC;
28
+ uniform float filterHighC;
29
+ uniform float filterLowD;
30
+ uniform float filterHighD;
31
+ uniform float filterLowE;
32
+ uniform float filterHighE;
33
+ uniform float filterLowF;
34
+ uniform float filterHighF;
35
+ uniform float multiplierA;
36
+ uniform float multiplierB;
37
+ uniform float multiplierC;
38
+ uniform float multiplierD;
39
+ uniform float multiplierE;
40
+ uniform float multiplierF;
41
+
42
+ varying vec2 vTexCoordA;
43
+ varying vec2 vTexCoordB;
44
+ varying vec2 vTexCoordC;
45
+ varying vec2 vTexCoordD;
46
+ varying vec2 vTexCoordE;
47
+ varying vec2 vTexCoordF;
48
+
49
+ void main() {
50
+ float texelFloatA = getTexelValue(textureA, vTexCoordA, littleEndian);
51
+ float texelFloatB = getTexelValue(textureB, vTexCoordB, littleEndian);
52
+ float texelFloatC = getTexelValue(textureC, vTexCoordC, littleEndian);
53
+ float texelFloatD = getTexelValue(textureD, vTexCoordD, littleEndian);
54
+ float texelFloatE = getTexelValue(textureE, vTexCoordE, littleEndian);
55
+ float texelFloatF = getTexelValue(textureF, vTexCoordF, littleEndian);
56
+
57
+ bool aIsNodata = isCloseEnough(texelFloatA, nodataValue);
58
+ bool bIsNodata = isCloseEnough(texelFloatB, nodataValue);
59
+ bool cIsNodata = isCloseEnough(texelFloatC, nodataValue);
60
+ bool dIsNodata = isCloseEnough(texelFloatD, nodataValue);
61
+ bool eIsNodata = isCloseEnough(texelFloatE, nodataValue);
62
+ bool fIsNodata = isCloseEnough(texelFloatF, nodataValue);
63
+
64
+ if (aIsNodata || bIsNodata || cIsNodata || dIsNodata || eIsNodata || fIsNodata ||
65
+ texelFloatA < filterLowA || texelFloatA > filterHighA ||
66
+ texelFloatB < filterLowB || texelFloatB > filterHighB ||
67
+ texelFloatC < filterLowC || texelFloatC > filterHighC ||
68
+ texelFloatD < filterLowD || texelFloatD > filterHighD ||
69
+ texelFloatE < filterLowE || texelFloatE > filterHighE ||
70
+ texelFloatF < filterLowF || texelFloatF > filterHighF
71
+ ) {
72
+ gl_FragColor = floatToRgba(nodataValue, littleEndian);
73
+ } else {
74
+ float texelFloatFinal = texelFloatA * multiplierA + texelFloatB * multiplierB + texelFloatC * multiplierC + texelFloatD * multiplierD + texelFloatE * multiplierE + texelFloatF * multiplierF;
75
+ gl_FragColor = floatToRgba(texelFloatFinal, littleEndian);
76
+ }
77
+ }
78
78
  `
@@ -1,93 +1,93 @@
1
- import glsl from 'glslify'
2
-
3
- export default glsl`#ifdef GL_FRAGMENT_PRECISION_HIGH
4
- precision highp float;
5
- #else
6
- precision mediump float;
7
- #endif
8
-
9
- #pragma glslify: computeColor = require(../util/computeColor.glsl)
10
- #pragma glslify: isCloseEnough = require(../util/isCloseEnough.glsl)
11
- #pragma glslify: getTexelValue = require(../util/getTexelValue.glsl)
12
-
13
- uniform int scaleLength;
14
- uniform int sentinelLength;
15
- uniform sampler2D scaleColormap;
16
- uniform sampler2D sentinelColormap;
17
-
18
- uniform float nodataValue;
19
- uniform sampler2D texture;
20
- uniform bool littleEndian;
21
- uniform bool enableSimpleHillshade;
22
-
23
- uniform float textureSize;
24
- uniform float tileSize;
25
- uniform vec4 textureBounds;
26
- varying vec2 vTexCoord;
27
-
28
- uniform float offset;
29
- uniform float slopescale;
30
- uniform float slopeFactor;
31
- uniform float deg2rad;
32
- uniform float azimuth;
33
- uniform float altitude;
34
-
35
- uniform vec4 aboveColor;
36
- uniform vec4 belowColor;
37
-
38
- float getRelativeHeight(vec2 pos, float v, vec4 textureBounds) {
39
- float pixelFloatValue = getTexelValue(texture, pos, littleEndian);
40
- float test = step(0.0, pixelFloatValue);
41
- float testReturn = ((test * pixelFloatValue) + ((1.0 - test) * v)) * (slopescale*slopeFactor);
42
- return testReturn;
43
- }
44
-
45
- float hillshade(vec2 pos, float v, float offset, vec4 textureBounds) {
46
- float cv = v * (slopescale * slopeFactor);
47
- vec4 nv = vec4(
48
- getRelativeHeight(vec2(pos.x + offset, pos.y), v, textureBounds),
49
- getRelativeHeight(vec2(pos.x - offset, pos.y), v, textureBounds),
50
- getRelativeHeight(vec2(pos.x, pos.y + offset), v, textureBounds),
51
- getRelativeHeight(vec2(pos.x, pos.y - offset), v, textureBounds)
52
- );
53
-
54
- vec2 grad = vec2(
55
- (nv[0] - cv) / 2.0 + (cv - nv[1]) / 2.0,
56
- (nv[2] - cv) / 2.0 + (cv - nv[3]) / 2.0
57
- );
58
-
59
- float slope = max(3.141593 / 2.0 - atan(sqrt(dot(grad, grad))), 0.0);
60
- float aspect = atan(-grad.y, grad.x);
61
-
62
- float hs = sin(altitude * deg2rad) * sin(slope) +
63
- cos(altitude * deg2rad) * cos(slope) *
64
- cos((azimuth * deg2rad) - aspect);
65
-
66
- return clamp(hs, 0.0, 1.0);
67
- }
68
-
69
- void main() {
70
- float texelFloat = getTexelValue(texture, vTexCoord, littleEndian);
71
-
72
- if (isCloseEnough(texelFloat, nodataValue)) {
73
- discard;
74
- }
75
-
76
- vec4 clr = computeColor(
77
- texelFloat,
78
- scaleColormap,
79
- sentinelColormap,
80
- scaleLength,
81
- sentinelLength,
82
- littleEndian,
83
- aboveColor,
84
- belowColor
85
- );
86
-
87
- if (enableSimpleHillshade) {
88
- float hs = hillshade(vTexCoord, texelFloat, offset, textureBounds);
89
- clr.rgb = clr.rgb * hs;
90
- }
91
-
92
- gl_FragColor = clr;
93
- }`
1
+ import glsl from 'glslify'
2
+
3
+ export default glsl`#ifdef GL_FRAGMENT_PRECISION_HIGH
4
+ precision highp float;
5
+ #else
6
+ precision mediump float;
7
+ #endif
8
+
9
+ #pragma glslify: computeColor = require(../util/computeColor.glsl)
10
+ #pragma glslify: isCloseEnough = require(../util/isCloseEnough.glsl)
11
+ #pragma glslify: getTexelValue = require(../util/getTexelValue.glsl)
12
+
13
+ uniform int scaleLength;
14
+ uniform int sentinelLength;
15
+ uniform sampler2D scaleColormap;
16
+ uniform sampler2D sentinelColormap;
17
+
18
+ uniform float nodataValue;
19
+ uniform sampler2D texture;
20
+ uniform bool littleEndian;
21
+ uniform bool enableSimpleHillshade;
22
+
23
+ uniform float textureSize;
24
+ uniform float tileSize;
25
+ uniform vec4 textureBounds;
26
+ varying vec2 vTexCoord;
27
+
28
+ uniform float offset;
29
+ uniform float slopescale;
30
+ uniform float slopeFactor;
31
+ uniform float deg2rad;
32
+ uniform float azimuth;
33
+ uniform float altitude;
34
+
35
+ uniform vec4 aboveColor;
36
+ uniform vec4 belowColor;
37
+
38
+ float getRelativeHeight(vec2 pos, float v, vec4 textureBounds) {
39
+ float pixelFloatValue = getTexelValue(texture, pos, littleEndian);
40
+ float test = step(0.0, pixelFloatValue);
41
+ float testReturn = ((test * pixelFloatValue) + ((1.0 - test) * v)) * (slopescale*slopeFactor);
42
+ return testReturn;
43
+ }
44
+
45
+ float hillshade(vec2 pos, float v, float offset, vec4 textureBounds) {
46
+ float cv = v * (slopescale * slopeFactor);
47
+ vec4 nv = vec4(
48
+ getRelativeHeight(vec2(pos.x + offset, pos.y), v, textureBounds),
49
+ getRelativeHeight(vec2(pos.x - offset, pos.y), v, textureBounds),
50
+ getRelativeHeight(vec2(pos.x, pos.y + offset), v, textureBounds),
51
+ getRelativeHeight(vec2(pos.x, pos.y - offset), v, textureBounds)
52
+ );
53
+
54
+ vec2 grad = vec2(
55
+ (nv[0] - cv) / 2.0 + (cv - nv[1]) / 2.0,
56
+ (nv[2] - cv) / 2.0 + (cv - nv[3]) / 2.0
57
+ );
58
+
59
+ float slope = max(3.141593 / 2.0 - atan(sqrt(dot(grad, grad))), 0.0);
60
+ float aspect = atan(-grad.y, grad.x);
61
+
62
+ float hs = sin(altitude * deg2rad) * sin(slope) +
63
+ cos(altitude * deg2rad) * cos(slope) *
64
+ cos((azimuth * deg2rad) - aspect);
65
+
66
+ return clamp(hs, 0.0, 1.0);
67
+ }
68
+
69
+ void main() {
70
+ float texelFloat = getTexelValue(texture, vTexCoord, littleEndian);
71
+
72
+ if (isCloseEnough(texelFloat, nodataValue)) {
73
+ discard;
74
+ }
75
+
76
+ vec4 clr = computeColor(
77
+ texelFloat,
78
+ scaleColormap,
79
+ sentinelColormap,
80
+ scaleLength,
81
+ sentinelLength,
82
+ littleEndian,
83
+ aboveColor,
84
+ belowColor
85
+ );
86
+
87
+ if (enableSimpleHillshade) {
88
+ float hs = hillshade(vTexCoord, texelFloat, offset, textureBounds);
89
+ clr.rgb = clr.rgb * hs;
90
+ }
91
+
92
+ gl_FragColor = clr;
93
+ }`
@@ -1,22 +1,22 @@
1
- var fs = require('fs')
2
-
3
- function transform (file) {
4
- let extension = file.split('.').pop()
5
- let content = fs.readFileSync(file, 'utf-8')
6
- content = `import glsl from 'glslify'\n\nexport default glsl\`${content}\``
7
- fs.writeFileSync(file.replace(`.${extension}`, '.js'), content)
8
- }
9
-
10
- function readDir (dir) {
11
- let list = fs.readdirSync(dir)
12
- list.forEach(item => {
13
- let stats = fs.statSync(`${dir}/${item}`)
14
- if (stats.isFile() && (item.endsWith('.vs') || item.endsWith('.fs'))) {
15
- transform(`${dir}/${item}`)
16
- } else if (stats.isDirectory()) {
17
- readDir(`${dir}/${item}`)
18
- }
19
- })
20
- }
21
-
1
+ var fs = require('fs')
2
+
3
+ function transform (file) {
4
+ let extension = file.split('.').pop()
5
+ let content = fs.readFileSync(file, 'utf-8')
6
+ content = `import glsl from 'glslify'\n\nexport default glsl\`${content}\``
7
+ fs.writeFileSync(file.replace(`.${extension}`, '.js'), content)
8
+ }
9
+
10
+ function readDir (dir) {
11
+ let list = fs.readdirSync(dir)
12
+ list.forEach(item => {
13
+ let stats = fs.statSync(`${dir}/${item}`)
14
+ if (stats.isFile() && (item.endsWith('.vs') || item.endsWith('.fs'))) {
15
+ transform(`${dir}/${item}`)
16
+ } else if (stats.isDirectory()) {
17
+ readDir(`${dir}/${item}`)
18
+ }
19
+ })
20
+ }
21
+
22
22
  readDir('./')