@takram/three-clouds 0.1.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.
Files changed (103) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +1130 -0
  3. package/assets/local_weather.png +0 -0
  4. package/assets/shape.bin +1 -0
  5. package/assets/shape_detail.bin +1 -0
  6. package/assets/turbulence.png +0 -0
  7. package/build/index.cjs +583 -0
  8. package/build/index.cjs.map +1 -0
  9. package/build/index.js +728 -0
  10. package/build/index.js.map +1 -0
  11. package/build/r3f.cjs +2 -0
  12. package/build/r3f.cjs.map +1 -0
  13. package/build/r3f.js +205 -0
  14. package/build/r3f.js.map +1 -0
  15. package/build/shared.cjs +2189 -0
  16. package/build/shared.cjs.map +1 -0
  17. package/build/shared.js +3825 -0
  18. package/build/shared.js.map +1 -0
  19. package/package.json +77 -0
  20. package/src/CascadedShadowMaps.ts +288 -0
  21. package/src/CloudLayer.ts +85 -0
  22. package/src/CloudLayers.test.ts +61 -0
  23. package/src/CloudLayers.ts +181 -0
  24. package/src/CloudShape.ts +22 -0
  25. package/src/CloudShapeDetail.ts +22 -0
  26. package/src/CloudsEffect.ts +810 -0
  27. package/src/CloudsMaterial.ts +467 -0
  28. package/src/CloudsPass.ts +285 -0
  29. package/src/CloudsResolveMaterial.ts +108 -0
  30. package/src/DensityProfile.ts +38 -0
  31. package/src/LocalWeather.ts +21 -0
  32. package/src/PassBase.ts +28 -0
  33. package/src/Procedural3DTexture.ts +94 -0
  34. package/src/ProceduralTexture.ts +94 -0
  35. package/src/ShaderArrayPass.ts +32 -0
  36. package/src/ShadowMaterial.ts +141 -0
  37. package/src/ShadowPass.ts +185 -0
  38. package/src/ShadowResolveMaterial.ts +72 -0
  39. package/src/Turbulence.ts +21 -0
  40. package/src/bayer.ts +23 -0
  41. package/src/constants.ts +8 -0
  42. package/src/helpers/FrustumCorners.ts +138 -0
  43. package/src/helpers/setArrayRenderTargetLayers.ts +32 -0
  44. package/src/helpers/splitFrustum.ts +59 -0
  45. package/src/index.ts +14 -0
  46. package/src/qualityPresets.ts +117 -0
  47. package/src/r3f/CloudLayer.tsx +95 -0
  48. package/src/r3f/CloudLayers.tsx +54 -0
  49. package/src/r3f/Clouds.tsx +278 -0
  50. package/src/r3f/index.ts +2 -0
  51. package/src/shaders/catmullRomSampling.glsl +113 -0
  52. package/src/shaders/cloudShape.frag +78 -0
  53. package/src/shaders/cloudShapeDetail.frag +56 -0
  54. package/src/shaders/clouds.frag +996 -0
  55. package/src/shaders/clouds.glsl +190 -0
  56. package/src/shaders/clouds.vert +69 -0
  57. package/src/shaders/cloudsEffect.frag +11 -0
  58. package/src/shaders/cloudsResolve.frag +202 -0
  59. package/src/shaders/cloudsResolve.vert +10 -0
  60. package/src/shaders/localWeather.frag +83 -0
  61. package/src/shaders/parameters.glsl +64 -0
  62. package/src/shaders/perlin.glsl +211 -0
  63. package/src/shaders/shadow.frag +197 -0
  64. package/src/shaders/shadow.vert +16 -0
  65. package/src/shaders/shadowResolve.frag +76 -0
  66. package/src/shaders/shadowResolve.vert +10 -0
  67. package/src/shaders/structuredSampling.glsl +101 -0
  68. package/src/shaders/tileableNoise.glsl +88 -0
  69. package/src/shaders/turbulence.frag +51 -0
  70. package/src/shaders/types.glsl +18 -0
  71. package/src/shaders/varianceClipping.glsl +114 -0
  72. package/src/uniforms.ts +218 -0
  73. package/types/CascadedShadowMaps.d.ts +52 -0
  74. package/types/CloudLayer.d.ts +26 -0
  75. package/types/CloudLayers.d.ts +21 -0
  76. package/types/CloudShape.d.ts +5 -0
  77. package/types/CloudShapeDetail.d.ts +5 -0
  78. package/types/CloudsEffect.d.ts +170 -0
  79. package/types/CloudsMaterial.d.ts +86 -0
  80. package/types/CloudsPass.d.ts +44 -0
  81. package/types/CloudsResolveMaterial.d.ts +30 -0
  82. package/types/DensityProfile.d.ts +12 -0
  83. package/types/LocalWeather.d.ts +5 -0
  84. package/types/PassBase.d.ts +14 -0
  85. package/types/Procedural3DTexture.d.ts +20 -0
  86. package/types/ProceduralTexture.d.ts +24 -0
  87. package/types/ShaderArrayPass.d.ts +7 -0
  88. package/types/ShadowMaterial.d.ts +34 -0
  89. package/types/ShadowPass.d.ts +34 -0
  90. package/types/ShadowResolveMaterial.d.ts +20 -0
  91. package/types/Turbulence.d.ts +5 -0
  92. package/types/bayer.d.ts +4 -0
  93. package/types/constants.d.ts +6 -0
  94. package/types/helpers/FrustumCorners.d.ts +18 -0
  95. package/types/helpers/setArrayRenderTargetLayers.d.ts +3 -0
  96. package/types/helpers/splitFrustum.d.ts +9 -0
  97. package/types/index.d.ts +13 -0
  98. package/types/qualityPresets.d.ts +46 -0
  99. package/types/r3f/CloudLayer.d.ts +7 -0
  100. package/types/r3f/CloudLayers.d.ts +15 -0
  101. package/types/r3f/Clouds.d.ts +16 -0
  102. package/types/r3f/index.d.ts +2 -0
  103. package/types/uniforms.d.ts +66 -0
@@ -0,0 +1,78 @@
1
+ // Based on the following work with slight modifications.
2
+ // https://github.com/sebh/TileableVolumeNoise
3
+
4
+ /**
5
+ * The MIT License (MIT)
6
+ *
7
+ * Copyright(c) 2017 Sébastien Hillaire
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in
17
+ * all copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ */
27
+
28
+ precision highp float;
29
+ precision highp int;
30
+
31
+ #include "core/math"
32
+ #include "perlin"
33
+ #include "tileableNoise"
34
+
35
+ uniform float layer;
36
+
37
+ in vec2 vUv;
38
+
39
+ layout(location = 0) out float outputColor;
40
+
41
+ float getPerlinWorley(const vec3 point) {
42
+ int octaveCount = 3;
43
+ float frequency = 8.0;
44
+ float perlin = getPerlinNoise(point, frequency, octaveCount);
45
+ perlin = clamp(perlin, 0.0, 1.0);
46
+
47
+ float cellCount = 4.0;
48
+ vec3 noise = vec3(
49
+ 1.0 - getWorleyNoise(point, cellCount * 2.0),
50
+ 1.0 - getWorleyNoise(point, cellCount * 8.0),
51
+ 1.0 - getWorleyNoise(point, cellCount * 14.0)
52
+ );
53
+ float fbm = dot(noise, vec3(0.625, 0.25, 0.125));
54
+ return remap(perlin, 0.0, 1.0, fbm, 1.0);
55
+ }
56
+
57
+ float getWorleyFbm(const vec3 point) {
58
+ float cellCount = 4.0;
59
+ vec4 noise = vec4(
60
+ 1.0 - getWorleyNoise(point, cellCount * 2.0),
61
+ 1.0 - getWorleyNoise(point, cellCount * 4.0),
62
+ 1.0 - getWorleyNoise(point, cellCount * 8.0),
63
+ 1.0 - getWorleyNoise(point, cellCount * 16.0)
64
+ );
65
+ vec3 fbm = vec3(
66
+ dot(noise.xyz, vec3(0.625, 0.25, 0.125)),
67
+ dot(noise.yzw, vec3(0.625, 0.25, 0.125)),
68
+ dot(noise.zw, vec2(0.75, 0.25))
69
+ );
70
+ return dot(fbm, vec3(0.625, 0.25, 0.125));
71
+ }
72
+
73
+ void main() {
74
+ vec3 point = vec3(vUv.x, vUv.y, layer);
75
+ float perlinWorley = getPerlinWorley(point);
76
+ float worleyFbm = getWorleyFbm(point);
77
+ outputColor = remap(perlinWorley, worleyFbm - 1.0, 1.0);
78
+ }
@@ -0,0 +1,56 @@
1
+ // Based on the following work with slight modifications.
2
+ // https://github.com/sebh/TileableVolumeNoise
3
+
4
+ /**
5
+ * The MIT License (MIT)
6
+ *
7
+ * Copyright(c) 2017 Sébastien Hillaire
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in
17
+ * all copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ */
27
+
28
+ precision highp float;
29
+ precision highp int;
30
+
31
+ #include "core/math"
32
+ #include "perlin"
33
+ #include "tileableNoise"
34
+
35
+ uniform float layer;
36
+
37
+ in vec2 vUv;
38
+
39
+ layout(location = 0) out float outputColor;
40
+
41
+ void main() {
42
+ vec3 point = vec3(vUv.x, vUv.y, layer);
43
+ float cellCount = 2.0;
44
+ vec4 noise = vec4(
45
+ 1.0 - getWorleyNoise(point, cellCount * 1.0),
46
+ 1.0 - getWorleyNoise(point, cellCount * 2.0),
47
+ 1.0 - getWorleyNoise(point, cellCount * 4.0),
48
+ 1.0 - getWorleyNoise(point, cellCount * 8.0)
49
+ );
50
+ vec3 fbm = vec3(
51
+ dot(noise.xyz, vec3(0.625, 0.25, 0.125)),
52
+ dot(noise.yzw, vec3(0.625, 0.25, 0.125)),
53
+ dot(noise.zw, vec2(0.75, 0.25))
54
+ );
55
+ outputColor = dot(fbm, vec3(0.625, 0.25, 0.125));
56
+ }