ohzi-core 13.3.0 → 15.0.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 (226) hide show
  1. package/README.md +2 -1
  2. package/build/index.mjs +1 -1
  3. package/build/index.mjs.map +1 -1
  4. package/package.json +12 -6
  5. package/src/Capabilities.ts +0 -2
  6. package/src/Debug.ts +38 -33
  7. package/src/Graphics.ts +2 -2
  8. package/src/Initializer.ts +2 -1
  9. package/src/SceneManager.ts +4 -5
  10. package/src/action_sequencer/NumberInterpolator.ts +2 -0
  11. package/src/blitter_index.ts +1 -2
  12. package/src/camera_controller/CameraController.ts +106 -63
  13. package/src/camera_controller/states/common/CommonCameraState.ts +2 -1
  14. package/src/components/AxisHelper.ts +1 -0
  15. package/src/components/Line.ts +35 -27
  16. package/src/components/PlaneHelper.ts +1 -1
  17. package/src/components/Text2D.ts +3 -1
  18. package/src/components/WorldImage.ts +27 -20
  19. package/src/components/sdf_text/SDFTextBatch.ts +16 -26
  20. package/src/dev_bridge/CameraBridge.ts +363 -0
  21. package/src/dev_bridge/CaptureService.ts +256 -0
  22. package/src/dev_bridge/CommandDispatcher.ts +114 -0
  23. package/src/dev_bridge/ConsoleBuffer.ts +286 -0
  24. package/src/dev_bridge/DebugDrawer.ts +399 -0
  25. package/src/dev_bridge/DevBridge.ts +195 -0
  26. package/src/dev_bridge/InputSynthesizer.ts +287 -0
  27. package/src/dev_bridge/PerformanceProbe.ts +118 -0
  28. package/src/dev_bridge/RenderModeRegistry.ts +66 -0
  29. package/src/dev_bridge/SceneEditor.ts +288 -0
  30. package/src/dev_bridge/SceneInspector.ts +388 -0
  31. package/src/dev_bridge/ViewNavigator.ts +101 -0
  32. package/src/dev_bridge/protocol.ts +31 -0
  33. package/src/index.ts +21 -14
  34. package/src/materials/AddMaterial.ts +14 -7
  35. package/src/materials/BlitNodeMaterial.ts +85 -0
  36. package/src/materials/BloomComposeMaterial.ts +21 -9
  37. package/src/materials/BoxBlurMaterial.ts +26 -6
  38. package/src/materials/ClearDepthNormalMaterial.ts +12 -6
  39. package/src/materials/DepthNormalMaterial.ts +25 -14
  40. package/src/materials/DualFilteringBlurMaterial.ts +32 -5
  41. package/src/materials/GaussianBlurMaterial.ts +36 -14
  42. package/src/materials/LineMaterial.ts +52 -0
  43. package/src/materials/LuminosityHighPassMaterial.ts +23 -10
  44. package/src/materials/NormalMaterial.ts +10 -11
  45. package/src/materials/SDFTextMaterial.ts +63 -16
  46. package/src/materials/SSAOComposeMaterial.ts +14 -5
  47. package/src/materials/SSAOMaterial.ts +123 -24
  48. package/src/materials/ScreenSpaceTextureMaterial.ts +19 -31
  49. package/src/materials/UnrealBloomComposeMaterial.ts +41 -32
  50. package/src/materials/WorldImageMaterial.ts +51 -0
  51. package/src/materials/deferred/DeferredPointLightMaterial.ts +45 -14
  52. package/src/materials/deferred/depth_normal_encoding.ts +36 -0
  53. package/src/primitives/Cube.ts +1 -1
  54. package/src/primitives/Sphere.ts +1 -1
  55. package/src/raycast/GroupRaycaster.ts +2 -2
  56. package/src/render_mode/BloomRender.ts +18 -4
  57. package/src/render_mode/DebugNormalsRender.ts +6 -1
  58. package/src/render_mode/DeferredRender.ts +5 -34
  59. package/src/render_mode/NormalAORender.ts +9 -19
  60. package/src/render_mode/UnrealBloomRender.ts +2 -1
  61. package/src/render_mode/VRRender.ts +6 -3
  62. package/src/render_utilities/Blitter.ts +4 -4
  63. package/src/render_utilities/Blurrer.ts +7 -0
  64. package/src/render_utilities/DualFilteringBlurrer.ts +26 -10
  65. package/src/resource_loader/AudioLoader.ts +5 -3
  66. package/src/resource_loader/HDRTextureLoader.ts +1 -1
  67. package/src/scenes/AbstractScene.ts +7 -3
  68. package/src/scenes/Compilator.ts +5 -1
  69. package/src/scenes/loading_states/LoadingState.ts +15 -7
  70. package/src/scenes/loading_states/RegularLoadingState.ts +2 -1
  71. package/src/utilities/CameraUtilities.ts +57 -79
  72. package/src/utilities/HTMLUtilities.ts +2 -1
  73. package/src/utilities/MeshSampler.ts +8 -1
  74. package/src/utilities/OrthographicFrustumPointFitter.ts +53 -4
  75. package/src/view_components/ApplicationView.ts +1 -1
  76. package/src/view_components/ViewComponent.ts +1 -1
  77. package/src/view_components/ViewManager.ts +7 -1
  78. package/src/view_components/transition/DrawIOAnimationSheet.ts +1 -1
  79. package/types/Capabilities.d.ts +0 -1
  80. package/types/SceneManager.d.ts +1 -1
  81. package/types/blitter_index.d.ts +1 -2
  82. package/types/camera_controller/CameraController.d.ts +9 -0
  83. package/types/components/Line.d.ts +3 -2
  84. package/types/components/WorldImage.d.ts +3 -2
  85. package/types/index.d.ts +2 -7
  86. package/types/materials/AddMaterial.d.ts +2 -2
  87. package/types/materials/BlitNodeMaterial.d.ts +18 -0
  88. package/types/materials/BloomComposeMaterial.d.ts +2 -2
  89. package/types/materials/BoxBlurMaterial.d.ts +2 -2
  90. package/types/materials/ClearDepthNormalMaterial.d.ts +2 -2
  91. package/types/materials/DepthNormalMaterial.d.ts +2 -2
  92. package/types/materials/DualFilteringBlurMaterial.d.ts +2 -2
  93. package/types/materials/GaussianBlurMaterial.d.ts +2 -2
  94. package/types/materials/LuminosityHighPassMaterial.d.ts +2 -2
  95. package/types/materials/NormalMaterial.d.ts +2 -2
  96. package/types/materials/SDFTextMaterial.d.ts +2 -2
  97. package/types/materials/SSAOComposeMaterial.d.ts +2 -2
  98. package/types/materials/SSAOMaterial.d.ts +2 -2
  99. package/types/materials/ScreenSpaceTextureMaterial.d.ts +2 -2
  100. package/types/materials/UnrealBloomComposeMaterial.d.ts +2 -2
  101. package/types/materials/deferred/DeferredPointLightMaterial.d.ts +2 -2
  102. package/types/render_mode/DeferredRender.d.ts +0 -2
  103. package/types/render_mode/NormalAORender.d.ts +0 -2
  104. package/types/render_utilities/Blitter.d.ts +2 -2
  105. package/types/render_utilities/DualFilteringBlurrer.d.ts +0 -2
  106. package/types/utilities/CameraUtilities.d.ts +0 -1
  107. package/types/utilities/OrthographicFrustumPointFitter.d.ts +14 -8
  108. package/build/index.module.js +0 -2
  109. package/build/index.module.js.map +0 -1
  110. package/src/components/EdgeMesh.ts +0 -150
  111. package/src/components/GeometryEdgeVisualizer.ts +0 -49
  112. package/src/components/MultiLinePath.ts +0 -25
  113. package/src/components/MultiLineText2D.ts +0 -65
  114. package/src/components/Shape2D.ts +0 -42
  115. package/src/components/Shape3D.ts +0 -38
  116. package/src/gpu_particles/GPUParticleSystem.ts +0 -122
  117. package/src/gpu_particles/ParticleAttribute.ts +0 -110
  118. package/src/gpu_particles/ParticlePositionAttribute.ts +0 -46
  119. package/src/materials/AlphaFilterMaterial.ts +0 -21
  120. package/src/materials/BaseShaderMaterial.ts +0 -20
  121. package/src/materials/BlitMaterial.ts +0 -27
  122. package/src/materials/DeferredRendererComposeMaterial.ts +0 -36
  123. package/src/materials/DisplayNormalTextureMaterial.ts +0 -18
  124. package/src/materials/FXAAMaterial.ts +0 -12
  125. package/src/materials/MedianFilterMaterial.ts +0 -46
  126. package/src/materials/SDFScreenTextMaterial.ts +0 -32
  127. package/src/materials/UnrealBlurMaterial.ts +0 -20
  128. package/src/materials/UnrealComposeMaterial.ts +0 -27
  129. package/src/materials/ViewPositionMaterial.ts +0 -19
  130. package/src/materials/gpu_particles/AttributeUpdateMaterial.ts +0 -35
  131. package/src/materials/gpu_particles/BasicParticleMaterial.ts +0 -25
  132. package/src/materials/gpu_particles/ParticleStorageMaterial.ts +0 -36
  133. package/src/materials/gpu_particles/PositionStorageMaterial.ts +0 -27
  134. package/src/render_utilities/MedianFilter.ts +0 -72
  135. package/src/render_utilities/ViewPositionRenderer.ts +0 -53
  136. package/src/shaders/add/add.frag +0 -28
  137. package/src/shaders/anti_aliasing/fxaa.frag +0 -72
  138. package/src/shaders/basic_color/basic_color.frag +0 -6
  139. package/src/shaders/basic_color/basic_color.vert +0 -10
  140. package/src/shaders/basic_line/basic_line.frag +0 -37
  141. package/src/shaders/basic_line/basic_line.vert +0 -37
  142. package/src/shaders/basic_texture/basic_texture.frag +0 -10
  143. package/src/shaders/basic_texture/basic_texture.vert +0 -17
  144. package/src/shaders/bloom/bloom_compose.frag +0 -22
  145. package/src/shaders/bloom/cheap_bloom_compose.frag +0 -13
  146. package/src/shaders/box_blur/box_blur.frag +0 -24
  147. package/src/shaders/box_blur/compose.frag +0 -31
  148. package/src/shaders/clear/clear_depth_normal.frag +0 -25
  149. package/src/shaders/copy/copy.frag +0 -7
  150. package/src/shaders/copy/copy.vert +0 -6
  151. package/src/shaders/deferred/blit_copy.vert +0 -11
  152. package/src/shaders/deferred/deferred_compose.frag +0 -59
  153. package/src/shaders/deferred/point_light.frag +0 -66
  154. package/src/shaders/deferred/point_light.vert +0 -13
  155. package/src/shaders/depth_normals/debug_normals.frag +0 -48
  156. package/src/shaders/depth_normals/depth_normals.frag +0 -30
  157. package/src/shaders/depth_normals/depth_normals.vert +0 -13
  158. package/src/shaders/dual_filter_blur/alpha_filter.frag +0 -14
  159. package/src/shaders/dual_filter_blur/downsample.frag +0 -21
  160. package/src/shaders/dual_filter_blur/upsample.frag +0 -24
  161. package/src/shaders/edge_visualizer/edge_visualizer.frag +0 -18
  162. package/src/shaders/edge_visualizer/edge_visualizer.vert +0 -16
  163. package/src/shaders/edges/corners.frag +0 -11
  164. package/src/shaders/edges/corners.vert +0 -31
  165. package/src/shaders/edges/edges.frag +0 -7
  166. package/src/shaders/edges/edges.vert +0 -27
  167. package/src/shaders/gaussian_blur/gaussian_blur.frag +0 -44
  168. package/src/shaders/gaussian_blur/unreal_bloom_compose.frag +0 -36
  169. package/src/shaders/gpu_particles/common_utils.glsl +0 -13
  170. package/src/shaders/gpu_particles/generic_storage.frag +0 -6
  171. package/src/shaders/gpu_particles/store/store_position.vert +0 -14
  172. package/src/shaders/gpu_particles/update/basic_update.frag +0 -21
  173. package/src/shaders/gpu_particles/visualize/visualize.frag +0 -11
  174. package/src/shaders/gpu_particles/visualize/visualize.vert +0 -12
  175. package/src/shaders/grid/grid.frag +0 -17
  176. package/src/shaders/grid/grid.vert +0 -10
  177. package/src/shaders/luminosity_high_pass/luminosity_high_pass.frag +0 -38
  178. package/src/shaders/median_filter/median_filter.frag +0 -134
  179. package/src/shaders/normal/normal.frag +0 -6
  180. package/src/shaders/normal/normal.vert +0 -6
  181. package/src/shaders/sdf_text/sdf_screen_text.frag +0 -51
  182. package/src/shaders/sdf_text/sdf_screen_text.vert +0 -42
  183. package/src/shaders/sdf_text/sdf_text.frag +0 -53
  184. package/src/shaders/sdf_text/sdf_text.vert +0 -42
  185. package/src/shaders/ssao/hbao.frag +0 -264
  186. package/src/shaders/ssao/ssao.frag +0 -95
  187. package/src/shaders/ssao/ssao.vert +0 -11
  188. package/src/shaders/ssao/ssao_compose.frag +0 -14
  189. package/src/shaders/transparent_mix/copy.frag +0 -7
  190. package/src/shaders/transparent_mix/transparent_mix.frag +0 -19
  191. package/src/shaders/transparent_mix/transparent_mix.vert +0 -8
  192. package/src/shaders/ui/ss_texture.frag +0 -11
  193. package/src/shaders/ui/ss_texture.vert +0 -32
  194. package/src/shaders/ui/ws_texture.vert +0 -39
  195. package/src/shaders/unreal_blur/unreal_blur.frag +0 -25
  196. package/src/shaders/unreal_blur/unreal_compose.frag +0 -24
  197. package/src/shaders/write_view_position/write_view_position.frag +0 -7
  198. package/src/shaders/write_view_position/write_view_position.vert +0 -9
  199. package/src/types.d.ts +0 -14
  200. package/types/components/EdgeMesh.d.ts +0 -16
  201. package/types/components/GeometryEdgeVisualizer.d.ts +0 -8
  202. package/types/components/MultiLinePath.d.ts +0 -8
  203. package/types/components/MultiLineText2D.d.ts +0 -12
  204. package/types/components/Shape2D.d.ts +0 -7
  205. package/types/components/Shape3D.d.ts +0 -6
  206. package/types/gpu_particles/GPUParticleSystem.d.ts +0 -19
  207. package/types/gpu_particles/ParticleAttribute.d.ts +0 -20
  208. package/types/gpu_particles/ParticlePositionAttribute.d.ts +0 -6
  209. package/types/materials/AlphaFilterMaterial.d.ts +0 -7
  210. package/types/materials/BaseShaderMaterial.d.ts +0 -4
  211. package/types/materials/BlitMaterial.d.ts +0 -4
  212. package/types/materials/DeferredRendererComposeMaterial.d.ts +0 -10
  213. package/types/materials/DisplayNormalTextureMaterial.d.ts +0 -4
  214. package/types/materials/FXAAMaterial.d.ts +0 -5
  215. package/types/materials/MedianFilterMaterial.d.ts +0 -8
  216. package/types/materials/SDFScreenTextMaterial.d.ts +0 -8
  217. package/types/materials/UIElementMaterial.d.ts +0 -4
  218. package/types/materials/UnrealBlurMaterial.d.ts +0 -5
  219. package/types/materials/UnrealComposeMaterial.d.ts +0 -5
  220. package/types/materials/ViewPositionMaterial.d.ts +0 -5
  221. package/types/materials/gpu_particles/AttributeUpdateMaterial.d.ts +0 -8
  222. package/types/materials/gpu_particles/BasicParticleMaterial.d.ts +0 -5
  223. package/types/materials/gpu_particles/ParticleStorageMaterial.d.ts +0 -5
  224. package/types/materials/gpu_particles/PositionStorageMaterial.d.ts +0 -5
  225. package/types/render_utilities/MedianFilter.d.ts +0 -12
  226. package/types/render_utilities/ViewPositionRenderer.d.ts +0 -12
@@ -1,264 +0,0 @@
1
- uniform sampler2D _MainTex;
2
- uniform mat4 _InverseProjMatrix;
3
- uniform mat4 _InverseViewMatrix;
4
-
5
- uniform float _Bias;
6
- uniform float _Radius;
7
-
8
- uniform vec2 _TargetResolution;
9
- uniform float _FarPlane;
10
-
11
-
12
- varying vec2 vUv;
13
- varying vec4 vRay;
14
-
15
-
16
- uniform vec3 _SampleKernel[64];
17
- uniform sampler2D _RandomRotation;
18
- uniform mat4 _ProjectionMatrix;
19
-
20
- vec3 decode_normal (vec4 enc)
21
- {
22
- float scale = 1.7777;
23
- vec3 nn =
24
- enc.xyz*vec3(2.0*scale,2.0*scale,0.0) +
25
- vec3(-scale,-scale,1.0);
26
- float g = 2.0 / dot(nn.xyz,nn.xyz);
27
- vec3 n;
28
- n.xy = g*nn.xy;
29
- n.z = g-1.0;
30
- return n;
31
- }
32
-
33
- float DecodeFloatRG( vec2 enc )
34
- {
35
- vec2 kDecodeDot = vec2(1.0, 1.0/255.0);
36
- return dot( enc, kDecodeDot );
37
- }
38
-
39
- vec3 DecodeNormal(vec2 uv)
40
- {
41
- // vec2 encoded_normal = texture2D(_MainTex, uv).zw;
42
- // vec3 normalValue = normalize(decode_normal(vec4(encoded_normal, 0., 0.)));
43
- // return normalize(normalValue);
44
- return normalize(texture2D(_MainTex, uv).xyz * 2.0 - vec3(1.0));
45
- }
46
-
47
-
48
- vec3 DecodeViewPos(vec2 uv)
49
- {
50
- float depth = texture2D(_MainTex, uv).w;
51
-
52
- float x = uv.x * 2.0 - 1.0;
53
- float y = uv.y * 2.0 - 1.0;
54
- vec4 inv_proj = _InverseProjMatrix * vec4(x,y, 1.0, 1.0);
55
-
56
- return (inv_proj.xyz / inv_proj.w) * depth;
57
- }
58
-
59
- float fast_length(vec3 V)
60
- {
61
- return dot(V,V);
62
- }
63
-
64
- vec3 MinDiff(vec3 P, vec3 Pr, vec3 Pl)
65
- {
66
- vec3 V1 = Pr - P;
67
- vec3 V2 = P - Pl;
68
- return (fast_length(V1) < fast_length(V2)) ? V1 : V2;
69
- }
70
-
71
-
72
-
73
-
74
- #define PI 3.14
75
- #define PI_OVER_2 1.5707963
76
- #define PI_OVER_4 0.785398
77
- #define EPSILON 0.000001
78
-
79
- // Maps a unit square in [-1, 1] to a unit disk in [-1, 1]. Shirley 97 "A Low Distortion Map Between Disk and Square"
80
- // Inputs: cartesian coordinates
81
- // Return: new circle-mapped polar coordinates (radius, angle)
82
- vec2 UnitSquareToUnitDiskPolar(float a, float b) {
83
- float radius, angle;
84
- if (abs(a) > abs(b)) { // First region (left and right quadrants of the disk)
85
- radius = a;
86
- angle = b / (a + EPSILON) * PI_OVER_4;
87
- } else { // Second region (top and botom quadrants of the disk)
88
- radius = b;
89
- angle = PI_OVER_2 - (a / (b + EPSILON) * PI_OVER_4);
90
- }
91
- if (radius < 0.0) { // Always keep radius positive
92
- radius *= -1.0;
93
- angle += PI;
94
- }
95
- return vec2(radius, angle);
96
- }
97
-
98
- // Maps a unit square in [-1, 1] to a unit disk in [-1, 1]
99
- // Inputs: cartesian coordinates
100
- // Return: new circle-mapped cartesian coordinates
101
- vec2 SquareToDiskMapping(float a, float b) {
102
- vec2 PolarCoord = UnitSquareToUnitDiskPolar(a, b);
103
- return vec2(PolarCoord.x * cos(PolarCoord.y), PolarCoord.x * sin(PolarCoord.y));
104
- }
105
-
106
-
107
-
108
-
109
-
110
- // // Retrieves the occlusion factor for a particular sample
111
- // // uv: the centre coordinate of the kernel
112
- // // frustumVector: The frustum vector of the sample point
113
- // // centerViewPos: The view space position of the centre point
114
- // // centerNormal: The normal of the centre point
115
- // // tangent: The tangent vector in the sampling direction at the centre point
116
- // // topOcclusion: The maximum cos(angle) found so far, will be updated when a new occlusion segment has been found
117
- // float GetSampleOcclusion(vec2 uv, vec3 centerViewPos, vec3 centerNormal, vec3 tangent, inout float topOcclusion)
118
- // {
119
- // // reconstruct sample's view space position based on depth buffer and interpolated frustum vector
120
- // vec3 sampleViewPos = DecodeViewPos(uv);
121
-
122
- // // get occlusion factor based on candidate horizon elevation
123
- // vec3 horizonVector = sampleViewPos - centerViewPos;
124
- // float horizonVectorLength = length(horizonVector);
125
-
126
- // float occlusion;
127
-
128
- // // If the horizon vector points away from the tangent, make an estimate
129
- // if (dot(tangent, horizonVector) < 0.0)
130
- // return 0.5;
131
- // else
132
- // occlusion = dot(centerNormal, horizonVector) / horizonVectorLength;
133
-
134
- // // this adds occlusion only if angle of the horizon vector is higher than the previous highest one without branching
135
- // float diff = max(occlusion - topOcclusion, 0.0);
136
- // topOcclusion = max(occlusion, topOcclusion);
137
-
138
- // // attenuate occlusion contribution using distance function 1 - (d/f)^2
139
- // float fallOff = 2.0;
140
- // float distanceFactor = saturate(horizonVectorLength / fallOff);
141
- // distanceFactor = 1.0 - distanceFactor * distanceFactor;
142
- // return diff * distanceFactor;
143
- // }
144
-
145
-
146
- #define MAX_DIRECTIONS 8
147
- #define MAX_DIRECTIONS_F 8.0
148
- #define MAX_STEPS 8
149
- #define MAX_STEPS_F 8.0
150
- #define KERNEL_SIZE 8
151
- #define KERNEL_SIZE_F 8.0
152
- #define MAX_TAPS (KERNEL_SIZE*KERNEL_SIZE)
153
- #define MAX_TAPS_F (KERNEL_SIZE_F*KERNEL_SIZE_F)
154
-
155
- float InvLength(vec2 V)
156
- {
157
- return inversesqrt(dot(V,V));
158
- }
159
- vec2 viewToScreen(vec3 viewPos)
160
- {
161
- vec4 P_screen = _ProjectionMatrix * vec4(viewPos, 1.0);
162
- P_screen.xyz/= P_screen.w;
163
- P_screen.xy = P_screen.xy * 0.5 + vec2(0.5, 0.5);
164
- return P_screen.xy;
165
- }
166
-
167
- float BiasedTangent(vec3 V)
168
- {
169
- return V.z / length(V.xy) + _Bias;
170
- }
171
-
172
- float TanToSin(float x)
173
- {
174
- return x * inversesqrt(x*x + 1.0);
175
- }
176
-
177
- float Tangent(vec3 V)
178
- {
179
- return V.z * InvLength(V.xy);
180
- }
181
-
182
-
183
- float Tangent(vec3 P, vec3 S)
184
- {
185
- return -(P.z - S.z) * InvLength(S.xy - P.xy);
186
- }
187
-
188
- void main()
189
- {
190
- vec2 half_pixel = vec2(0.5/_TargetResolution.x, 0.5/_TargetResolution.y);
191
- vec2 pixel_size = vec2(1.0/_TargetResolution.x, 1.0/_TargetResolution.y);
192
-
193
- vec2 uv = vUv;
194
-
195
- vec3 P = DecodeViewPos(uv);
196
- vec3 normal = DecodeNormal(uv);
197
-
198
-
199
- vec2 P_s = viewToScreen(P);
200
-
201
- // float radius = 0.5;
202
- vec2 P1_s = viewToScreen(P + vec3(0.0, _Radius, 0.0));
203
-
204
- float step_size_px = length(P1_s - P_s);
205
-
206
-
207
-
208
- // vec3 Pt = DecodeViewPos(uv + vec2(0.0, pixel_size.y));
209
- // vec3 Pb = DecodeViewPos(uv + vec2(0.0, -pixel_size.y));
210
-
211
- // vec3 Pl = DecodeViewPos(uv + vec2(-pixel_size.x, 0.0));
212
- // vec3 Pr = DecodeViewPos(uv + vec2(pixel_size.x, 0.0));
213
-
214
- // vec3 dPv = normalize(MinDiff(P, Pt, Pb));
215
- // vec3 dPh = normalize(MinDiff(P, Pr, Pl));
216
-
217
- // gl_FragColor.rgb = normalize(cross(dPh, dPv))* 0.5 + vec3(0.5,0.5,0.5);
218
-
219
- float alpha = (2.0 * PI) / MAX_DIRECTIONS_F;
220
- float accum = 0.0;
221
- for(int i=0; i< MAX_DIRECTIONS; i++)
222
- {
223
- float theta = alpha * float(i);
224
- // Apply noise to the direction
225
- vec2 dir = vec2(cos(theta), sin(theta)) * (step_size_px/MAX_DIRECTIONS_F);
226
- float max_angle = 0.0;
227
-
228
-
229
- for(int j=1; j< MAX_STEPS; j++)
230
- {
231
- vec2 uv_offset = dir * float(j);
232
-
233
- vec3 sample = DecodeViewPos(vUv + uv_offset);
234
-
235
-
236
- vec3 dir = sample - P;
237
- vec3 tangent = cross(normalize(dir), normal);
238
- tangent = cross(normal, tangent);
239
-
240
- float sin_t = TanToSin(BiasedTangent(tangent)); //sin(t)
241
-
242
- float horizon_angle = Tangent(P, sample);
243
- if(length(dir) < _Radius && horizon_angle > max_angle)
244
- {
245
- float sin_h = TanToSin(horizon_angle);
246
- accum += sin_h - sin_t;
247
- max_angle = horizon_angle;
248
- }
249
- }
250
- }
251
-
252
- gl_FragColor.rgb = vec3(accum/MAX_DIRECTIONS_F);
253
-
254
- // gl_FragColor.rgb = vec3(sin(abs(max_angle)));
255
- // gl_FragColor.rgb = normalize(dPv+dPh) * 0.5 + vec3(0.5);
256
- // gl_FragColor.rgb = vec3(sample_length);
257
-
258
- gl_FragColor.a = 1.0;
259
-
260
- }
261
-
262
-
263
-
264
-
@@ -1,95 +0,0 @@
1
- uniform sampler2D _MainTex;
2
- uniform mat4 _InverseProjMatrix;
3
-
4
- uniform float _Bias;
5
- uniform float _Radius;
6
-
7
- uniform vec2 _Resolution;
8
- uniform float _FarPlane;
9
-
10
-
11
- varying vec2 vUv;
12
- varying vec4 vRay;
13
-
14
-
15
- uniform vec3 _SampleKernel[64];
16
- uniform sampler2D _RandomRotation;
17
- uniform mat4 _ProjectionMatrix;
18
-
19
- vec3 decode_normal (vec4 enc)
20
- {
21
- float scale = 1.7777;
22
- vec3 nn =
23
- enc.xyz*vec3(2.0*scale,2.0*scale,0.0) +
24
- vec3(-scale,-scale,1.0);
25
- float g = 2.0 / dot(nn.xyz,nn.xyz);
26
- vec3 n;
27
- n.xy = g*nn.xy;
28
- n.z = g-1.0;
29
- return n;
30
- }
31
-
32
- float DecodeFloatRG( vec2 enc )
33
- {
34
- vec2 kDecodeDot = vec2(1.0, 1.0/255.0);
35
- return dot( enc, kDecodeDot );
36
- }
37
-
38
- vec3 DecodeNormal(vec2 uv)
39
- {
40
- vec2 encoded_normal = texture2D(_MainTex, uv).zw;
41
- vec3 normalValue = normalize(decode_normal(vec4(encoded_normal, 0., 0.)));
42
- return normalize(normalValue);
43
- }
44
- vec3 DecodeViewPos(vec2 uv)
45
- {
46
- vec2 depth = texture2D(_MainTex, uv).xy;
47
- vec4 inv_proj = _InverseProjMatrix * vec4(vUv * 2.0 - 1.0, 1.0, 1.0);
48
- return DecodeFloatRG(depth) * (vRay.xyz/vRay.w);
49
-
50
- }
51
-
52
-
53
-
54
-
55
- void main()
56
- {
57
-
58
- vec2 noiseScale = vec2(_Resolution.x/4.0,_Resolution.y/4.0); // noise texture 4x4
59
-
60
- vec3 fragPos = DecodeViewPos(vUv);
61
- vec3 normal = DecodeNormal(vUv);
62
- vec3 randomVec = texture2D(_RandomRotation, vUv * noiseScale).xyz;
63
- randomVec = vec3(randomVec.xy * 2.0 - 1.0, 0);
64
- randomVec = normalize(randomVec);
65
-
66
-
67
- vec3 tangent = normalize(randomVec - normal * dot(randomVec, normal));
68
- vec3 bitangent = normalize(cross(normal, tangent));
69
- mat3 TBN = mat3(tangent, bitangent, normal);
70
-
71
-
72
- float occlusion = 0.0;
73
- const int kernelSize = 64;
74
-
75
-
76
- for(int i = 0; i < kernelSize; ++i)
77
- {
78
- // get sample position
79
- vec3 sample = TBN * _SampleKernel[i]; // From tangent to view-space
80
- sample = fragPos + sample * _Radius;
81
- vec4 projPos = _ProjectionMatrix * vec4(sample, 1.0);
82
- vec2 screenPos = projPos.xy / projPos.w;
83
- screenPos = screenPos * 0.5 +0.5;
84
-
85
- float sampled_depth = DecodeViewPos(screenPos).z;
86
- float rangeCheck = smoothstep(0.0, 1.0, _Radius / abs(fragPos.z - sampled_depth));
87
- occlusion += step(sample.z+_Bias, sampled_depth) * rangeCheck;
88
-
89
- }
90
- occlusion = (occlusion / float(kernelSize));
91
- gl_FragColor.rgb = vec3(occlusion,occlusion,occlusion);
92
- gl_FragColor.a = 1.0;
93
-
94
-
95
- }
@@ -1,11 +0,0 @@
1
- varying vec2 vUv;
2
- varying vec4 vRay;
3
-
4
- uniform mat4 _InverseProjMatrix;
5
-
6
- void main()
7
- {
8
- gl_Position = vec4(uv * 2.0 - 1.0, 1.0, 1.0);
9
- vRay = _InverseProjMatrix * vec4(uv * 2.0 - 1.0, 1.0, 1.0);
10
- vUv = uv;
11
- }
@@ -1,14 +0,0 @@
1
- uniform sampler2D _MainTex;
2
- uniform sampler2D _AO;
3
- uniform vec2 _Resolution;
4
- uniform vec2 _SampleDir;
5
- varying vec2 vUv;
6
-
7
- void main()
8
- {
9
-
10
-
11
- gl_FragColor.rgb = texture2D(_MainTex, vUv).rgb * (1.0 - texture2D(_AO, vUv).r);
12
- gl_FragColor.a = 1.0;
13
-
14
- }
@@ -1,7 +0,0 @@
1
- uniform sampler2D _MainTex;
2
- varying vec2 vUv;
3
-
4
- void main()
5
- {
6
- gl_FragColor = texture2D( _MainTex, vUv);
7
- }
@@ -1,19 +0,0 @@
1
- uniform sampler2D _OpaqueTex;
2
- uniform sampler2D _TransparentTex;
3
- uniform vec2 _Resolution;
4
- uniform float _Opacity;
5
- varying vec2 vUv;
6
-
7
- void main()
8
- {
9
- vec4 opaque = texture2D( _OpaqueTex, vUv);
10
- vec4 transparent = texture2D( _TransparentTex, vUv);
11
-
12
- gl_FragColor = vec4(mix(opaque.rgb, transparent.rgb, transparent.a*_Opacity), 1.0);
13
- // if(vUv.x > 0.5)
14
- // gl_FragColor = vec4(opaque.rgb, 1.0);
15
- // else
16
- // gl_FragColor = vec4(transparent.rgb, 1.0);
17
-
18
-
19
- }
@@ -1,8 +0,0 @@
1
-
2
- varying vec2 vUv;
3
-
4
- void main()
5
- {
6
- gl_Position = vec4(uv * 2.0 - 1.0, 0.0, 1.0);
7
- vUv = uv;
8
- }
@@ -1,11 +0,0 @@
1
- uniform sampler2D _MainTex;
2
- uniform vec2 _ScreenSize;
3
- uniform vec2 _TextureSize;
4
- varying vec2 vUv;
5
-
6
-
7
-
8
- void main()
9
- {
10
- gl_FragColor = texture2D(_MainTex, vUv + vec2(0.5, 0.5)/_TextureSize);
11
- }
@@ -1,32 +0,0 @@
1
- uniform vec2 _ScreenSize;
2
- uniform vec2 _TextureSize;
3
- uniform vec2 _PixelOffset;
4
- uniform vec3 _NDC;
5
- uniform vec2 _PivotPoint;
6
- uniform float _DepthOffset;
7
- varying vec2 vUv;
8
-
9
-
10
- vec2 round_to_ceil(vec2 pos)
11
- {
12
- pos = pos * 0.5 + 0.5;
13
- pos *= _ScreenSize;
14
- pos = ceil(pos)+0.5;
15
- pos /= _ScreenSize;
16
- return pos * 2.0 - 1.0;
17
- }
18
- void main()
19
- {
20
- vec4 projected_pos = projectionMatrix * viewMatrix * vec4(_NDC, 1.0);
21
- projected_pos.zw += _DepthOffset;
22
-
23
- projected_pos.xyz /= projected_pos.w;
24
-
25
- vec2 normalized_size = _TextureSize/_ScreenSize;
26
- vec2 dir = uv * 2.0 - 1.0;
27
- dir -= _PivotPoint;
28
- vec2 pos = projected_pos.xy+ dir * normalized_size;
29
- gl_Position = vec4(round_to_ceil(pos), projected_pos.z, 1.0);
30
- vUv = uv;
31
-
32
- }
@@ -1,39 +0,0 @@
1
-
2
- uniform vec2 _ScreenSize;
3
- uniform vec2 _TextSize;
4
- uniform vec2 _PixelOffset;
5
- uniform float _DepthOffset;
6
- uniform float _FixedDepth;
7
- uniform float _DepthValue;
8
- uniform float _UseAbsoluteScreenPosition;
9
- uniform vec2 _ScreenPosition;
10
- uniform float _WorldTextSize;
11
- varying vec2 vUv;
12
-
13
-
14
-
15
- void main()
16
- {
17
- vec3 w_pos;
18
- w_pos.x = modelMatrix[0][3];
19
- w_pos.y = modelMatrix[1][3];
20
- w_pos.z = modelMatrix[2][3];
21
-
22
- vec2 dir = uv * 2.0 - 1.0;
23
- dir.x *= (_TextSize.x / _TextSize.y);
24
-
25
- vec4 view_pos = modelViewMatrix * vec4(w_pos, 1.0);
26
- vec3 forward = vec3(0., 0., 1.);
27
- vec3 binormal = normalize(cross(forward, vec3(0.0, -1.0, 0.0)));
28
- vec3 up = cross(forward, binormal);
29
- vec3 normal = (binormal * dir.x + up * dir.y);
30
-
31
- normal = normalize(normal);
32
- view_pos.xyz += normal * _WorldTextSize * 0.5;
33
-
34
- gl_Position = projectionMatrix * view_pos;
35
-
36
-
37
- vUv = uv;
38
-
39
- }
@@ -1,25 +0,0 @@
1
- #include <common>
2
- varying vec2 vUv;
3
- uniform sampler2D _MainTex;
4
- uniform vec2 _Resolution;
5
- uniform vec2 _SampleDir;
6
-
7
- float gaussianPdf(in float x, in float sigma) {
8
- return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;
9
- }
10
- void main() {
11
- vec2 invSize = 1.0 / _Resolution;
12
- float fSigma = float(SIGMA);
13
- float weightSum = gaussianPdf(0.0, fSigma);
14
- vec3 diffuseSum = texture2D( _MainTex, vUv).rgb * weightSum;
15
- for( int i = 1; i < KERNEL_RADIUS; i ++ ) {
16
- float x = float(i);
17
- float w = gaussianPdf(x, fSigma);
18
- vec2 uvOffset = _SampleDir * invSize * x;
19
- vec3 sample1 = texture2D( _MainTex, vUv + uvOffset).rgb;
20
- vec3 sample2 = texture2D( _MainTex, vUv - uvOffset).rgb;
21
- diffuseSum += (sample1 + sample2) * w;
22
- weightSum += 2.0 * w;
23
- }
24
- gl_FragColor = vec4(diffuseSum/weightSum, 1.0);
25
- }
@@ -1,24 +0,0 @@
1
- varying vec2 vUv;
2
- uniform sampler2D blurTexture1;
3
- uniform sampler2D blurTexture2;
4
- uniform sampler2D blurTexture3;
5
- uniform sampler2D blurTexture4;
6
- uniform sampler2D blurTexture5;
7
- uniform sampler2D dirtTexture;
8
- uniform float bloomStrength;
9
- uniform float bloomRadius;
10
- uniform float bloomFactors[NUM_MIPS];
11
- uniform vec3 bloomTintColors[NUM_MIPS];
12
-
13
- float lerpBloomFactor(const in float factor) {
14
- float mirrorFactor = 1.2 - factor;
15
- return mix(factor, mirrorFactor, bloomRadius);
16
- }
17
-
18
- void main() {
19
- gl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +
20
- lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +
21
- lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +
22
- lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +
23
- lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );
24
- }
@@ -1,7 +0,0 @@
1
- varying vec3 v_pos;
2
-
3
-
4
- void main()
5
- {
6
- gl_FragColor = vec4(v_pos, 1.0);
7
- }
@@ -1,9 +0,0 @@
1
- varying vec3 v_pos;
2
-
3
- void main()
4
- {
5
- mat4 MVP = projectionMatrix * modelViewMatrix;
6
-
7
- v_pos = (modelViewMatrix * vec4( position, 1.0 )).xyz;
8
- gl_Position = MVP * vec4( position, 1.0 );
9
- }
package/src/types.d.ts DELETED
@@ -1,14 +0,0 @@
1
- declare module '*.vert' {
2
- const content: string;
3
- export default content;
4
- }
5
-
6
- declare module '*.frag' {
7
- const content: string;
8
- export default content;
9
- }
10
-
11
- declare module '*.glsl' {
12
- const content: string;
13
- export default content;
14
- }
@@ -1,16 +0,0 @@
1
- import type { BufferGeometry, BufferGeometryEventMap, InterleavedBufferAttribute, NormalBufferAttributes } from 'three';
2
- import { BufferAttribute, Mesh, Object3D, ShaderMaterial, Vector3 } from 'three';
3
- declare class EdgeMesh extends Object3D {
4
- corners_material: ShaderMaterial;
5
- corners_mesh: Mesh;
6
- edges_material: ShaderMaterial;
7
- edges_mesh: Mesh;
8
- constructor(buffer_geometry: BufferGeometry, thickness: number, color: string);
9
- __get_edges(cube_geometry: BufferGeometry): Vector3[];
10
- update(time: number): void;
11
- __get_edges_geometry(points: Vector3[]): BufferGeometry<NormalBufferAttributes, BufferGeometryEventMap>;
12
- __get_corners_geometry(geometry_vertices: BufferAttribute | InterleavedBufferAttribute): BufferGeometry;
13
- set_visible(boolean: boolean): void;
14
- dispose(): void;
15
- }
16
- export { EdgeMesh };
@@ -1,8 +0,0 @@
1
- import type { BufferGeometry } from 'three';
2
- import { Mesh, ShaderMaterial } from 'three';
3
- declare class GeometryEdgeVisualizer extends Mesh {
4
- material: ShaderMaterial;
5
- constructor(geometry: BufferGeometry, line_color?: string | number);
6
- hide_faces(): void;
7
- }
8
- export { GeometryEdgeVisualizer };
@@ -1,8 +0,0 @@
1
- import { Line } from './Line';
2
- import type { Vector3 } from 'three';
3
- import { Object3D } from 'three';
4
- declare class MultiLinePath extends Object3D {
5
- paths: Line[];
6
- constructor(paths: Array<Vector3[]>);
7
- }
8
- export { MultiLinePath };
@@ -1,12 +0,0 @@
1
- import { Text2D } from './Text2D';
2
- import { Object3D, Vector2 } from 'three';
3
- declare class MultiLineText2D extends Object3D {
4
- text_array: Text2D[];
5
- constructor(text_array: string[], font?: string, color?: string | number, pivot?: Vector2, is_static?: boolean);
6
- update_text_positions(): void;
7
- set texts(text_array: string[]);
8
- set size(value: number);
9
- get texts(): string[];
10
- get size(): number;
11
- }
12
- export { MultiLineText2D };
@@ -1,7 +0,0 @@
1
- import type { Vector2 } from 'three';
2
- import { Mesh, ShapeGeometry } from 'three';
3
- declare class Shape2D extends Mesh {
4
- constructor(points_2D: Vector2[], show_edges: boolean);
5
- invert_normals(geometry: ShapeGeometry): void;
6
- }
7
- export { Shape2D };
@@ -1,6 +0,0 @@
1
- import type { Vector2 } from 'three';
2
- import { Mesh } from 'three';
3
- declare class Shape3D extends Mesh {
4
- constructor(points_2D: Vector2[], show_edges: boolean, height?: number);
5
- }
6
- export { Shape3D };
@@ -1,19 +0,0 @@
1
- import type { InstancedBufferAttribute, Mesh, Points, Scene } from "three";
2
- import { Object3D } from "three";
3
-
4
- export class GPUParticleSystem extends Object3D {
5
- constructor(particle_count: any, material: any);
6
- attributes: any[];
7
- mesh: Mesh;
8
- attribute_writter_mesh: Points;
9
- attribute_writter_scene: Scene;
10
-
11
- add_texture_attribute(buffer_attribute: any): void;
12
- add_update_attribute_array(name: any, array: any, item_size: any): void;
13
- add_attribute_array(name: any, array: any, item_size: any): void;
14
- update(): void;
15
- dispose(): void;
16
- build_point_mesh(instance_count: number, material: any): Mesh;
17
- build_attribute_writter_mesh(particle_count: any): Points;
18
- build_uv_storage_attribute(particle_count: any): InstancedBufferAttribute;
19
- }