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,27 +0,0 @@
1
- import frag from '../shaders/copy/copy.frag';
2
- import vert from '../shaders/copy/copy.vert';
3
-
4
- import { AlwaysDepth, NoBlending, ShaderMaterial, Vector2 } from 'three';
5
-
6
- class BlitMaterial extends ShaderMaterial
7
- {
8
- constructor(frag_shader?: string, vert_shader?: string, defines?: Record<string, any>)
9
- {
10
- super({
11
- uniforms: {
12
- _MainTex: { value: null },
13
- _Resolution: { value: new Vector2(0, 0) },
14
- _TargetResolution: { value: new Vector2(0, 0) }
15
- },
16
- defines: defines || {},
17
- vertexShader: vert_shader || vert,
18
- fragmentShader: frag_shader || frag,
19
- depthWrite: false,
20
- blending: NoBlending,
21
- depthTest: false,
22
- depthFunc: AlwaysDepth
23
- });
24
- }
25
- }
26
-
27
- export { BlitMaterial };
@@ -1,36 +0,0 @@
1
- import { BlitMaterial } from '../materials/BlitMaterial';
2
-
3
- import vert from '../shaders/deferred/blit_copy.vert';
4
- import frag from '../shaders/deferred/deferred_compose.frag';
5
-
6
- import type { RenderTarget, Texture } from 'three';
7
- import { Matrix4 } from 'three';
8
-
9
- class DeferredRendererComposeMaterial extends BlitMaterial
10
- {
11
- constructor()
12
- {
13
- super(frag, vert);
14
-
15
- this.uniforms._NormalDepthRT = { value: undefined };
16
- this.uniforms._AlbedoRT = { value: undefined };
17
- this.uniforms._InverseProjMatrix = { value: new Matrix4() };
18
- }
19
-
20
- set_normal_depth_rt(rt: RenderTarget)
21
- {
22
- this.uniforms._NormalDepthRT.value = rt.texture;
23
- }
24
-
25
- set_albedo_rt(tex: Texture)
26
- {
27
- this.uniforms._AlbedoRT.value = tex;
28
- }
29
-
30
- set_proj_matrix(mat4: Matrix4)
31
- {
32
- this.uniforms._InverseProjMatrix.value = mat4.clone().invert();
33
- }
34
- }
35
-
36
- export { DeferredRendererComposeMaterial };
@@ -1,18 +0,0 @@
1
- import { BlitMaterial } from '../materials/BlitMaterial';
2
-
3
- import frag from '../shaders/depth_normals/debug_normals.frag';
4
- import depth_normals_vert from '../shaders/ssao/ssao.vert';
5
-
6
- import { Matrix4 } from 'three';
7
-
8
- class DisplayNormalTextureMaterial extends BlitMaterial
9
- {
10
- constructor()
11
- {
12
- super(frag, depth_normals_vert);
13
- this.uniforms._FarPlane = { value: 1 };
14
- this.uniforms._InverseProjMatrix = { value: new Matrix4() };
15
- }
16
- }
17
-
18
- export { DisplayNormalTextureMaterial };
@@ -1,12 +0,0 @@
1
- import frag from 'js/core/shaders/anti_aliasing/fxaa.frag';
2
- import { BlitMaterial } from './BlitMaterial';
3
-
4
- class FXAAMaterial extends BlitMaterial
5
- {
6
- constructor()
7
- {
8
- super(frag);
9
- }
10
- }
11
-
12
- export { FXAAMaterial };
@@ -1,46 +0,0 @@
1
- import { BlitMaterial } from '../materials/BlitMaterial';
2
-
3
- import frag from '../shaders/median_filter/median_filter.frag';
4
-
5
- import type { Texture, VideoTexture, WebGLRenderTarget } from 'three';
6
- import { Vector2 } from 'three';
7
-
8
- class MedianFilterMaterial extends BlitMaterial
9
- {
10
- constructor()
11
- {
12
- super(frag, undefined, {
13
- kernel3x3: true
14
- });
15
-
16
- this.uniforms._SourceTex = { value: undefined };
17
- this.uniforms._SourceTexSize = { value: new Vector2(1, 1) };
18
- }
19
-
20
- set_texture(tex: Texture)
21
- {
22
- this.uniforms._SourceTex.value = tex;
23
-
24
- const size = this.get_size(tex);
25
- (this.uniforms._SourceTexSize.value as Vector2).copy(size);
26
- }
27
-
28
- get_size(tex: Texture)
29
- {
30
- if ((tex as VideoTexture).isVideoTexture)
31
- {
32
- return new Vector2(Math.max(1, (tex.image as HTMLVideoElement).videoWidth), Math.max(1, (tex.image as HTMLVideoElement).videoHeight));
33
- }
34
- if ((tex as unknown as WebGLRenderTarget).isWebGLRenderTarget)
35
- {
36
- return new Vector2(tex.width, tex.height);
37
- }
38
- if (tex.isTexture)
39
- {
40
- return new Vector2((tex.image as ImageBitmap).width, (tex.image as ImageBitmap).height);
41
- }
42
- return new Vector2(1, 1);
43
- }
44
- }
45
-
46
- export { MedianFilterMaterial };
@@ -1,32 +0,0 @@
1
- import { BaseShaderMaterial } from './BaseShaderMaterial';
2
-
3
- import frag from '../shaders/sdf_text/sdf_screen_text.frag';
4
- import vert from '../shaders/sdf_text/sdf_screen_text.vert';
5
-
6
- import type { Texture } from 'three';
7
- import { DoubleSide, LinearFilter, Vector2 } from 'three';
8
-
9
- class SDFScreenTextMaterial extends BaseShaderMaterial
10
- {
11
- constructor(texture: Texture)
12
- {
13
- super(vert, frag, {
14
- _Texture: { value: texture },
15
- _AtlasSize: { value: new Vector2(1, 1) }
16
- });
17
-
18
- this.transparent = true;
19
- this.depthWrite = false;
20
- this.side = DoubleSide;
21
- texture.minFilter = LinearFilter;
22
- texture.magFilter = LinearFilter;
23
- texture.generateMipmaps = false;
24
- }
25
-
26
- set_atlas_size(size: Vector2)
27
- {
28
- (this.uniforms._AtlasSize.value as Vector2).copy(size);
29
- }
30
- }
31
-
32
- export { SDFScreenTextMaterial };
@@ -1,20 +0,0 @@
1
- import { BlitMaterial } from '../materials/BlitMaterial';
2
-
3
- import frag from '../shaders/unreal_blur/unreal_blur.frag';
4
-
5
- import { Vector2 } from 'three';
6
-
7
- class UnrealBlurMaterial extends BlitMaterial
8
- {
9
- constructor(kernel_radius: number)
10
- {
11
- const defines = {
12
- KERNEL_RADIUS: kernel_radius,
13
- SIGMA: kernel_radius
14
- };
15
- super(frag, undefined, defines);
16
- this.uniforms._SampleDir = { value: new Vector2(0.5, 0.5) };
17
- }
18
- }
19
-
20
- export { UnrealBlurMaterial };
@@ -1,27 +0,0 @@
1
- import { BlitMaterial } from '../materials/BlitMaterial';
2
-
3
- import frag from '../shaders/unreal_blur/unreal_compose.frag';
4
-
5
- class UnrealComposeMaterial extends BlitMaterial
6
- {
7
- constructor(nMips: number)
8
- {
9
- const defines = {
10
- NUM_MIPS: nMips
11
- };
12
- super(frag, undefined, defines);
13
-
14
- this.uniforms.blurTexture1 = { value: null };
15
- this.uniforms.blurTexture2 = { value: null };
16
- this.uniforms.blurTexture3 = { value: null };
17
- this.uniforms.blurTexture4 = { value: null };
18
- this.uniforms.blurTexture5 = { value: null };
19
- this.uniforms.dirtTexture = { value: null };
20
- this.uniforms.bloomStrength = { value: 1.0 };
21
- this.uniforms.bloomFactors = { value: null };
22
- this.uniforms.bloomTintColors = { value: null };
23
- this.uniforms.bloomRadius = { value: 0.0 };
24
- }
25
- }
26
-
27
- export { UnrealComposeMaterial };
@@ -1,19 +0,0 @@
1
- import frag from '../shaders/write_view_position/write_view_position.frag';
2
- import vert from '../shaders/write_view_position/write_view_position.vert';
3
-
4
- import { ShaderMaterial } from 'three';
5
-
6
- class ViewPositionMaterial extends ShaderMaterial
7
- {
8
- constructor()
9
- {
10
- super({
11
- uniforms: {
12
- },
13
- vertexShader: vert,
14
- fragmentShader: frag
15
- });
16
- }
17
- }
18
-
19
- export { ViewPositionMaterial };
@@ -1,35 +0,0 @@
1
- import { ShaderChunk, Vector2 } from 'three';
2
- import { BlitMaterial } from '../../materials/BlitMaterial';
3
- import common_utils from '../../shaders/gpu_particles/common_utils.glsl';
4
- import frag from '../../shaders/gpu_particles/update/basic_update.frag';
5
- import { Time } from '../../Time';
6
-
7
- class AttributeUpdateMaterial extends BlitMaterial
8
- {
9
- multiplier: number;
10
-
11
- constructor(custom_frag?: string)
12
- {
13
- // @ts-expect-error -- IGNORE --
14
- ShaderChunk.gpu_particles_utils = common_utils;
15
-
16
- super(custom_frag || frag);
17
- this.uniforms._Time = { value: new Vector2() };
18
- this.multiplier = 0;
19
- }
20
-
21
- update()
22
- {
23
- (this.uniforms._Time.value as Vector2).x = Time.delta_time;
24
- (this.uniforms._Time.value as Vector2).y += Time.delta_time;
25
- // this.precision = "lowp";
26
- }
27
-
28
- set_multiplier(val: number)
29
- {
30
- console.log(val);
31
- this.multiplier = val;
32
- }
33
- }
34
-
35
- export { AttributeUpdateMaterial };
@@ -1,25 +0,0 @@
1
- import frag from '../../shaders/gpu_particles/visualize/visualize.frag';
2
- import vert from '../../shaders/gpu_particles/visualize/visualize.vert';
3
-
4
- import { ShaderMaterial } from 'three';
5
-
6
- class BasicParticleMaterial extends ShaderMaterial
7
- {
8
- constructor()
9
- {
10
- // ShaderChunk["gpu_particles_utils"] = common_utils;
11
-
12
- super({
13
- uniforms: {
14
- _Position: { value: undefined },
15
- _Time: { value: 0 }
16
- },
17
- vertexShader: vert,
18
- fragmentShader: frag,
19
- transparent: true,
20
- depthWrite: false
21
- });
22
- }
23
- }
24
-
25
- export { BasicParticleMaterial };
@@ -1,36 +0,0 @@
1
- import frag from '../../shaders/gpu_particles/generic_storage.frag';
2
-
3
- import { AlwaysDepth, NoBlending, ShaderMaterial } from 'three';
4
-
5
- class ParticleStorageMaterial extends ShaderMaterial
6
- {
7
- constructor(vert?: string)
8
- {
9
- vert = vert || `
10
- varying vec4 value;
11
- attribute vec4 data;
12
-
13
- void main()
14
- {
15
- gl_Position = vec4(position.xy * 2.0 - 1.0, 1.0,1.0);
16
- gl_PointSize = 1.0;
17
-
18
- value = data;
19
- }
20
- `;
21
-
22
- super({
23
- uniforms: {
24
-
25
- },
26
- vertexShader: vert,
27
- fragmentShader: frag,
28
- depthWrite: false,
29
- blending: NoBlending,
30
- depthTest: false,
31
- depthFunc: AlwaysDepth
32
- });
33
- }
34
- }
35
-
36
- export { ParticleStorageMaterial };
@@ -1,27 +0,0 @@
1
- import { ParticleStorageMaterial } from '../../materials/gpu_particles/ParticleStorageMaterial';
2
-
3
- class PositionStorageMaterial extends ParticleStorageMaterial
4
- {
5
- constructor()
6
- {
7
- const vert = `
8
-
9
- varying vec4 value;
10
-
11
- attribute vec2 storage_uv;
12
-
13
- void main()
14
- {
15
- gl_Position = vec4(storage_uv * 2.0 - 1.0, 1.0,1.0);
16
- gl_PointSize = 1.0;
17
-
18
- value = vec4(position.xyz, 1.0);
19
- }
20
-
21
- `;
22
-
23
- super(vert);
24
- }
25
- }
26
-
27
- export { PositionStorageMaterial };
@@ -1,72 +0,0 @@
1
- import { Graphics } from '../Graphics';
2
- import { MedianFilterMaterial } from '../materials/MedianFilterMaterial';
3
-
4
- import { FloatType, NearestFilter, RenderTarget, RGBAFormat, Vector2 } from 'three';
5
-
6
- class MedianFilter
7
- {
8
- RT: RenderTarget;
9
- RT1: RenderTarget;
10
- median_filter_mat: MedianFilterMaterial;
11
-
12
- constructor()
13
- {
14
- this.RT = new RenderTarget(1, 1, {
15
- type: FloatType,
16
- format: RGBAFormat,
17
- minFilter: NearestFilter,
18
- magFilter: NearestFilter
19
- });
20
- this.RT1 = new RenderTarget(1, 1, {
21
- type: FloatType,
22
- format: RGBAFormat,
23
- minFilter: NearestFilter,
24
- magFilter: NearestFilter
25
- });
26
-
27
- this.median_filter_mat = new MedianFilterMaterial();
28
- }
29
-
30
- filter(texture: any)
31
- {
32
- const tex_size = this.get_size(texture);
33
- if (tex_size.x !== this.RT.width || tex_size.y !== this.RT.height)
34
- {
35
- this.RT.setSize(tex_size.x, tex_size.y);
36
- this.RT1.setSize(tex_size.x, tex_size.y);
37
- }
38
-
39
- this.median_filter_mat.set_texture(texture);
40
- Graphics.material_pass(this.median_filter_mat, this.RT);
41
-
42
- for (let i = 0; i < 0; i++)
43
- {
44
- this.median_filter_mat.set_texture(this.RT.texture);
45
- Graphics.material_pass(this.median_filter_mat, this.RT1);
46
-
47
- this.median_filter_mat.set_texture(this.RT1.texture);
48
- Graphics.material_pass(this.median_filter_mat, this.RT);
49
- }
50
-
51
- return this.RT;
52
- }
53
-
54
- get_size(tex: any)
55
- {
56
- if (tex.isVideoTexture)
57
- {
58
- return new Vector2(Math.max(1, tex.image.videoWidth), Math.max(1, tex.image.videoHeight));
59
- }
60
- if (tex.isRenderTarget)
61
- {
62
- return new Vector2(tex.width, tex.height);
63
- }
64
- if (tex.isTexture)
65
- {
66
- return new Vector2(tex.image.width, tex.image.height);
67
- }
68
- return new Vector2(1, 1);
69
- }
70
- }
71
-
72
- export { MedianFilter };
@@ -1,53 +0,0 @@
1
- import type { Renderer } from 'three/webgpu';
2
- import { CameraManager } from '../CameraManager';
3
- import { OScreen } from '../OScreen';
4
- import { SceneManager } from '../SceneManager';
5
- import { ViewPositionMaterial } from '../materials/ViewPositionMaterial';
6
-
7
- import { Color, FloatType, RenderTarget } from 'three';
8
-
9
- class ViewPositionRenderer
10
- {
11
- RT: RenderTarget;
12
- clear_color: Color;
13
- render_pos_mat: ViewPositionMaterial;
14
-
15
- constructor()
16
- {
17
- this.RT = new RenderTarget(OScreen.width, OScreen.height, { type: FloatType });
18
- this.clear_color = new Color(0, 0, 0);
19
- this.render_pos_mat = new ViewPositionMaterial();
20
- }
21
-
22
- render(context: any, renderer: Renderer)
23
- {
24
- if (this.RT.width !== OScreen.width || this.RT.height !== OScreen.height)
25
- {
26
- this.RT.setSize(OScreen.width, OScreen.height);
27
- }
28
-
29
- if (CameraManager.current)
30
- {
31
- CameraManager.current.aspect = OScreen.aspect_ratio;
32
- CameraManager.current.updateProjectionMatrix();
33
- CameraManager.current.updateMatrix();
34
- CameraManager.current.updateMatrixWorld(true);
35
-
36
- renderer.setRenderTarget(this.RT);
37
- this.clear_color.set(CameraManager.current.far, CameraManager.current.far, CameraManager.current.far);
38
- renderer.setClearColor(this.clear_color, 1);
39
- renderer.clear(true, true, false);
40
-
41
- SceneManager.current.overrideMaterial = this.render_pos_mat;
42
- renderer.render(SceneManager.current, CameraManager.current); // ,this.RT, false
43
- SceneManager.current.overrideMaterial = undefined;
44
- }
45
- }
46
-
47
- get render_target()
48
- {
49
- return this.RT;
50
- }
51
- }
52
-
53
- export { ViewPositionRenderer };
@@ -1,28 +0,0 @@
1
- uniform sampler2D _MainTex;
2
- uniform sampler2D _SecondTex;
3
-
4
- varying vec2 vUv;
5
-
6
- vec4 sampleTex(sampler2D tex, vec2 uv)
7
- {
8
- vec4 col = texture2D( tex, uv);
9
-
10
- #ifndef USE_LINEAR_COLOR_SPACE
11
- col.rgb = pow(col.rgb, vec3(2.2));
12
- #endif
13
-
14
- return col;
15
- }
16
- void main()
17
- {
18
- vec4 col0 = sampleTex(_MainTex, vUv);
19
- vec4 col1 = sampleTex(_SecondTex, vUv);
20
-
21
-
22
- gl_FragColor = col0+col1;
23
- // gl_FragColor = texture2D(_SecondTex, vUv);
24
- gl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(0.4545));
25
-
26
- // gl_FragColor = texture2D(_MainTex, vUv)+texture2D(_SecondTex, vUv);
27
-
28
- }
@@ -1,72 +0,0 @@
1
- // FXAA shader, GLSL code adapted from:
2
- // http://horde3d.org/wiki/index.php5?title=Shading_Technique_-_FXAA
3
- // Whitepaper describing the technique:
4
- // http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf
5
-
6
- // from: https://code.google.com/p/processing/source/browse/trunk/processing/java/libraries/opengl/examples/Shaders/FXAA/data/fxaa.glsl?r=9668
7
-
8
- uniform sampler2D _MainTex;
9
- uniform vec2 _Resolution;
10
-
11
- varying vec2 vUv;
12
-
13
-
14
- void main() {
15
- // The inverse of the texture dimensions along X and Y
16
- vec2 texcoordOffset = 1. / _Resolution;
17
-
18
- //varying vec4 vertColor;
19
- vec4 vertTexcoord = vec4( vUv, 1., 1. );
20
-
21
- // The parameters are hardcoded for now, but could be
22
- // made into uniforms to control fromt he program.
23
- float FXAA_SPAN_MAX = 8.0;
24
- float FXAA_REDUCE_MUL = 1.0/8.0;
25
- float FXAA_REDUCE_MIN = (1.0/128.0);
26
-
27
- vec3 rgbNW = texture2D(_MainTex, vertTexcoord.xy + (vec2(-1.0, -1.0) * texcoordOffset)).xyz;
28
- vec3 rgbNE = texture2D(_MainTex, vertTexcoord.xy + (vec2(+1.0, -1.0) * texcoordOffset)).xyz;
29
- vec3 rgbSW = texture2D(_MainTex, vertTexcoord.xy + (vec2(-1.0, +1.0) * texcoordOffset)).xyz;
30
- vec3 rgbSE = texture2D(_MainTex, vertTexcoord.xy + (vec2(+1.0, +1.0) * texcoordOffset)).xyz;
31
- vec3 rgbM = texture2D(_MainTex, vertTexcoord.xy).xyz;
32
-
33
- vec3 luma = vec3(0.299, 0.587, 0.114);
34
- float lumaNW = dot(rgbNW, luma);
35
- float lumaNE = dot(rgbNE, luma);
36
- float lumaSW = dot(rgbSW, luma);
37
- float lumaSE = dot(rgbSE, luma);
38
- float lumaM = dot( rgbM, luma);
39
-
40
- float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
41
- float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
42
-
43
- vec2 dir;
44
- dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
45
- dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
46
-
47
- float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);
48
-
49
- float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce);
50
-
51
- dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),
52
- max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * texcoordOffset;
53
-
54
- vec3 rgbA = (1.0/2.0) * (
55
- texture2D(_MainTex, vertTexcoord.xy + dir * (1.0/3.0 - 0.5)).xyz +
56
- texture2D(_MainTex, vertTexcoord.xy + dir * (2.0/3.0 - 0.5)).xyz);
57
- vec3 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * (
58
- texture2D(_MainTex, vertTexcoord.xy + dir * (0.0/3.0 - 0.5)).xyz +
59
- texture2D(_MainTex, vertTexcoord.xy + dir * (3.0/3.0 - 0.5)).xyz);
60
- float lumaB = dot(rgbB, luma);
61
-
62
- if((lumaB < lumaMin) || (lumaB > lumaMax)){
63
- gl_FragColor.xyz=rgbA;
64
- } else {
65
- gl_FragColor.xyz=rgbB;
66
- }
67
- gl_FragColor.a = 1.0;
68
-
69
- // gl_FragColor = vec4(texture2D(_MainTex, vUv).rgb, 1.0);
70
- // gl_FragColor = vec4(1.0, 0.0, 0.0, 0.0);
71
- //gl_FragColor *= vertColor;
72
- }
@@ -1,6 +0,0 @@
1
- uniform vec3 _Color;
2
-
3
- void main()
4
- {
5
- gl_FragColor = vec4(_Color, 1.0);
6
- }
@@ -1,10 +0,0 @@
1
- varying vec2 vUv;
2
-
3
- void main()
4
- {
5
- vec3 pos = position;
6
- mat4 MVP = projectionMatrix * modelViewMatrix;
7
-
8
- gl_Position = MVP * vec4( pos, 1.0 );
9
- vUv = uv;
10
- }
@@ -1,37 +0,0 @@
1
- uniform float _Length;
2
- uniform float _ElapsedTime;
3
- uniform float _Thickness;
4
- uniform vec3 _Color;
5
-
6
- varying float line_coverage;
7
- varying float uv_u;
8
-
9
-
10
-
11
-
12
- float aastep(float threshold, float value) {
13
- #ifdef GL_OES_standard_derivatives
14
- float afwidth = length(vec2(dFdx(value), dFdy(value))) * 0.70710678118654757;
15
- return smoothstep(threshold-afwidth, threshold+afwidth, value);
16
- #else
17
- return step(threshold, value);
18
- #endif
19
- }
20
-
21
- void main()
22
- {
23
-
24
- // float y = fract(line_coverage /_Thickness - _TrueElapsedTime) ;
25
-
26
- // vec2 uv = vec2(uv_u, y);
27
-
28
-
29
- // vec4 col = texture2D(_ArrowsTex,uv);
30
- // col.rgb *= _ForwardColor;
31
- // col.a = aastep(0.5, col.a);
32
- // gl_FragColor = col;
33
- float u = (1.0 - abs(uv_u * 2.0 - 1.0));
34
- float diffuse = dot(vec2(u, u), vec2(0.0, 1.0)) * 0.5+0.5;
35
- gl_FragColor = vec4(_Color * diffuse, 1.0);
36
-
37
- }