@babylonjs/core 8.7.0 → 8.7.1

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 (125) hide show
  1. package/Animations/animatable.core.js +2 -2
  2. package/Animations/animatable.core.js.map +1 -1
  3. package/AudioV2/abstractAudio/abstractSound.d.ts +3 -35
  4. package/AudioV2/abstractAudio/abstractSound.js +2 -58
  5. package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
  6. package/AudioV2/abstractAudio/abstractSoundSource.d.ts +57 -0
  7. package/AudioV2/abstractAudio/abstractSoundSource.js +72 -0
  8. package/AudioV2/abstractAudio/abstractSoundSource.js.map +1 -0
  9. package/AudioV2/abstractAudio/audioEngineV2.d.ts +33 -0
  10. package/AudioV2/abstractAudio/audioEngineV2.js +23 -0
  11. package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
  12. package/AudioV2/webAudio/index.d.ts +1 -0
  13. package/AudioV2/webAudio/index.js +1 -0
  14. package/AudioV2/webAudio/index.js.map +1 -1
  15. package/AudioV2/webAudio/webAudioEngine.d.ts +5 -0
  16. package/AudioV2/webAudio/webAudioEngine.js +18 -0
  17. package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
  18. package/AudioV2/webAudio/webAudioSoundSource.d.ts +41 -0
  19. package/AudioV2/webAudio/webAudioSoundSource.js +115 -0
  20. package/AudioV2/webAudio/webAudioSoundSource.js.map +1 -0
  21. package/AudioV2/webAudio/webAudioStaticSound.js +1 -1
  22. package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
  23. package/Collisions/collider.d.ts +1 -1
  24. package/Collisions/collider.js +14 -3
  25. package/Collisions/collider.js.map +1 -1
  26. package/Collisions/collisionCoordinator.d.ts +2 -2
  27. package/Collisions/collisionCoordinator.js +9 -5
  28. package/Collisions/collisionCoordinator.js.map +1 -1
  29. package/Culling/ray.core.d.ts +1 -1
  30. package/Culling/ray.core.js +1 -1
  31. package/Culling/ray.core.js.map +1 -1
  32. package/Engines/abstractEngine.d.ts +2 -2
  33. package/Engines/abstractEngine.js +3 -3
  34. package/Engines/abstractEngine.js.map +1 -1
  35. package/Engines/constants.d.ts +1 -1
  36. package/Engines/constants.js +1 -1
  37. package/Engines/constants.js.map +1 -1
  38. package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.d.ts +46 -0
  39. package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.js +107 -0
  40. package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.js.map +1 -0
  41. package/FrameGraph/Node/Blocks/index.d.ts +1 -0
  42. package/FrameGraph/Node/Blocks/index.js +1 -0
  43. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  44. package/FrameGraph/Passes/renderPass.d.ts +1 -1
  45. package/FrameGraph/Passes/renderPass.js +3 -0
  46. package/FrameGraph/Passes/renderPass.js.map +1 -1
  47. package/FrameGraph/Tasks/PostProcesses/motionBlurTask.d.ts +27 -0
  48. package/FrameGraph/Tasks/PostProcesses/motionBlurTask.js +41 -0
  49. package/FrameGraph/Tasks/PostProcesses/motionBlurTask.js.map +1 -0
  50. package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +12 -0
  51. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +30 -1
  52. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
  53. package/FrameGraph/index.d.ts +2 -1
  54. package/FrameGraph/index.js +2 -1
  55. package/FrameGraph/index.js.map +1 -1
  56. package/Gizmos/cameraGizmo.js +2 -2
  57. package/Gizmos/cameraGizmo.js.map +1 -1
  58. package/Maths/ThinMaths/index.d.ts +2 -0
  59. package/Maths/ThinMaths/index.js +3 -0
  60. package/Maths/ThinMaths/index.js.map +1 -0
  61. package/Maths/ThinMaths/thinMath.matrix.d.ts +20 -0
  62. package/Maths/ThinMaths/thinMath.matrix.functions.d.ts +53 -0
  63. package/Maths/ThinMaths/thinMath.matrix.functions.js +190 -0
  64. package/Maths/ThinMaths/thinMath.matrix.functions.js.map +1 -0
  65. package/Maths/ThinMaths/thinMath.matrix.js +23 -0
  66. package/Maths/ThinMaths/thinMath.matrix.js.map +1 -0
  67. package/Maths/index.d.ts +1 -0
  68. package/Maths/index.js +2 -0
  69. package/Maths/index.js.map +1 -1
  70. package/Maths/math.vector.js +7 -89
  71. package/Maths/math.vector.js.map +1 -1
  72. package/Meshes/abstractMesh.d.ts +2 -1
  73. package/Meshes/abstractMesh.js +3 -2
  74. package/Meshes/abstractMesh.js.map +1 -1
  75. package/Misc/screenshotTools.js +2 -0
  76. package/Misc/screenshotTools.js.map +1 -1
  77. package/Particles/flowMap.d.ts +18 -3
  78. package/Particles/flowMap.js +19 -7
  79. package/Particles/flowMap.js.map +1 -1
  80. package/Particles/particleSystem.js +2 -1
  81. package/Particles/particleSystem.js.map +1 -1
  82. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js +0 -3
  83. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
  84. package/PostProcesses/index.d.ts +1 -0
  85. package/PostProcesses/index.js +1 -0
  86. package/PostProcesses/index.js.map +1 -1
  87. package/PostProcesses/motionBlurPostProcess.d.ts +4 -11
  88. package/PostProcesses/motionBlurPostProcess.js +40 -62
  89. package/PostProcesses/motionBlurPostProcess.js.map +1 -1
  90. package/PostProcesses/thinMotionBlurPostProcess.d.ts +67 -0
  91. package/PostProcesses/thinMotionBlurPostProcess.js +127 -0
  92. package/PostProcesses/thinMotionBlurPostProcess.js.map +1 -0
  93. package/PostProcesses/thinSSRPostProcess.js +1 -2
  94. package/PostProcesses/thinSSRPostProcess.js.map +1 -1
  95. package/Rendering/depthRenderer.js +1 -1
  96. package/Rendering/depthRenderer.js.map +1 -1
  97. package/Rendering/geometryBufferRenderer.js +1 -1
  98. package/Rendering/geometryBufferRenderer.js.map +1 -1
  99. package/Rendering/prePassRenderer.js +1 -1
  100. package/Rendering/prePassRenderer.js.map +1 -1
  101. package/Shaders/ShadersInclude/pbrBlockReflection.js +1 -1
  102. package/Shaders/ShadersInclude/pbrBlockReflection.js.map +1 -1
  103. package/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.js +4 -4
  104. package/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.js.map +1 -1
  105. package/Shaders/ShadersInclude/screenSpaceRayTrace.js +3 -2
  106. package/Shaders/ShadersInclude/screenSpaceRayTrace.js.map +1 -1
  107. package/Shaders/motionBlur.fragment.js +6 -17
  108. package/Shaders/motionBlur.fragment.js.map +1 -1
  109. package/ShadersWGSL/ShadersInclude/bonesDeclaration.js +4 -4
  110. package/ShadersWGSL/ShadersInclude/bonesDeclaration.js.map +1 -1
  111. package/ShadersWGSL/ShadersInclude/bonesVertex.js +8 -8
  112. package/ShadersWGSL/ShadersInclude/bonesVertex.js.map +1 -1
  113. package/ShadersWGSL/ShadersInclude/pbrBlockReflection.js +1 -1
  114. package/ShadersWGSL/ShadersInclude/pbrBlockReflection.js.map +1 -1
  115. package/ShadersWGSL/ShadersInclude/prePassVertex.js +8 -8
  116. package/ShadersWGSL/ShadersInclude/prePassVertex.js.map +1 -1
  117. package/ShadersWGSL/ShadersInclude/screenSpaceRayTrace.js +3 -0
  118. package/ShadersWGSL/ShadersInclude/screenSpaceRayTrace.js.map +1 -1
  119. package/ShadersWGSL/geometry.vertex.js +8 -8
  120. package/ShadersWGSL/geometry.vertex.js.map +1 -1
  121. package/ShadersWGSL/motionBlur.fragment.js +6 -17
  122. package/ShadersWGSL/motionBlur.fragment.js.map +1 -1
  123. package/assetContainer.js +3 -0
  124. package/assetContainer.js.map +1 -1
  125. package/package.json +5 -2
@@ -1,6 +1,5 @@
1
1
  import { __decorate } from "../tslib.es6.js";
2
2
  import { Logger } from "../Misc/logger.js";
3
- import { Matrix, TmpVectors, Vector2 } from "../Maths/math.vector.js";
4
3
  import { PostProcess } from "./postProcess.js";
5
4
 
6
5
  import { GeometryBufferRenderer } from "../Rendering/geometryBufferRenderer.js";
@@ -10,6 +9,7 @@ import "../Rendering/geometryBufferRendererSceneComponent.js";
10
9
  import { serialize } from "../Misc/decorators.js";
11
10
  import { SerializationHelper } from "../Misc/decorators.serialization.js";
12
11
  import { RegisterClass } from "../Misc/typeStore.js";
12
+ import { ThinMotionBlurPostProcess } from "./thinMotionBlurPostProcess.js";
13
13
  /**
14
14
  * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
15
15
  * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
@@ -23,33 +23,41 @@ import { RegisterClass } from "../Misc/typeStore.js";
23
23
  * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
24
24
  */
25
25
  export class MotionBlurPostProcess extends PostProcess {
26
+ /**
27
+ * Defines how much the image is blurred by the movement. Default value is equal to 1
28
+ */
29
+ get motionStrength() {
30
+ return this._effectWrapper.motionStrength;
31
+ }
32
+ set motionStrength(value) {
33
+ this._effectWrapper.motionStrength = value;
34
+ }
26
35
  /**
27
36
  * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
28
37
  */
29
38
  get motionBlurSamples() {
30
- return this._motionBlurSamples;
39
+ return this._effectWrapper.motionBlurSamples;
31
40
  }
32
41
  /**
33
42
  * Sets the number of iterations to be used for motion blur quality
34
43
  */
35
44
  set motionBlurSamples(samples) {
36
- this._motionBlurSamples = samples;
37
- this._updateEffect();
45
+ this._effectWrapper.motionBlurSamples = samples;
38
46
  }
39
47
  /**
40
48
  * Gets whether or not the motion blur post-process is in object based mode.
41
49
  */
42
50
  get isObjectBased() {
43
- return this._isObjectBased;
51
+ return this._effectWrapper.isObjectBased;
44
52
  }
45
53
  /**
46
54
  * Sets whether or not the motion blur post-process is in object based mode.
47
55
  */
48
56
  set isObjectBased(value) {
49
- if (this._isObjectBased === value) {
57
+ if (this.isObjectBased === value) {
50
58
  return;
51
59
  }
52
- this._isObjectBased = value;
60
+ this._effectWrapper.isObjectBased = value;
53
61
  this._applyMode();
54
62
  }
55
63
  get _geometryBufferRenderer() {
@@ -85,22 +93,30 @@ export class MotionBlurPostProcess extends PostProcess {
85
93
  * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
86
94
  */
87
95
  constructor(name, scene, options, camera, samplingMode, engine, reusable, textureType = 0, blockCompilation = false, forceGeometryBuffer = false) {
88
- super(name, "motionBlur", ["motionStrength", "motionScale", "screenSize", "inverseViewProjection", "prevViewProjection", "projection"], ["velocitySampler", "depthSampler"], options, camera, samplingMode, engine, reusable, "#define GEOMETRY_SUPPORTED\n#define SAMPLES 64.0\n#define OBJECT_BASED", textureType, undefined, null, blockCompilation);
89
- /**
90
- * Defines how much the image is blurred by the movement. Default value is equal to 1
91
- */
92
- this.motionStrength = 1;
93
- this._motionBlurSamples = 32;
94
- this._isObjectBased = true;
96
+ const localOptions = {
97
+ uniforms: ThinMotionBlurPostProcess.Uniforms,
98
+ samplers: ThinMotionBlurPostProcess.Samplers,
99
+ defines: ThinMotionBlurPostProcess.Defines,
100
+ size: typeof options === "number" ? options : undefined,
101
+ camera,
102
+ samplingMode,
103
+ engine,
104
+ reusable,
105
+ textureType,
106
+ blockCompilation,
107
+ ...options,
108
+ };
109
+ super(name, ThinMotionBlurPostProcess.FragmentUrl, {
110
+ effectWrapper: typeof options === "number" || !options.effectWrapper ? new ThinMotionBlurPostProcess(name, scene, localOptions) : undefined,
111
+ ...localOptions,
112
+ });
95
113
  this._forceGeometryBuffer = false;
96
- this._invViewProjection = null;
97
- this._previousViewProjection = null;
98
114
  this._forceGeometryBuffer = forceGeometryBuffer;
99
115
  // Set up assets
100
116
  if (this._forceGeometryBuffer) {
101
117
  scene.enableGeometryBufferRenderer();
102
118
  if (this._geometryBufferRenderer) {
103
- this._geometryBufferRenderer.enableVelocity = this._isObjectBased;
119
+ this._geometryBufferRenderer.enableVelocity = this.isObjectBased;
104
120
  }
105
121
  }
106
122
  else {
@@ -112,16 +128,6 @@ export class MotionBlurPostProcess extends PostProcess {
112
128
  }
113
129
  this._applyMode();
114
130
  }
115
- _gatherImports(useWebGPU, list) {
116
- if (useWebGPU) {
117
- this._webGPUReady = true;
118
- list.push(Promise.all([import("../ShadersWGSL/motionBlur.fragment.js")]));
119
- }
120
- else {
121
- list.push(Promise.all([import("../Shaders/motionBlur.fragment.js")]));
122
- }
123
- super._gatherImports(useWebGPU, list);
124
- }
125
131
  /**
126
132
  * Excludes the given skinned mesh from computing bones velocities.
127
133
  * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
@@ -180,20 +186,16 @@ export class MotionBlurPostProcess extends PostProcess {
180
186
  }
181
187
  /**
182
188
  * Called on the mode changed (object based or screen based).
183
- * @returns void
184
189
  */
185
190
  _applyMode() {
186
191
  if (!this._geometryBufferRenderer && !this._prePassRenderer) {
187
192
  // We can't get a velocity or depth texture. So, work as a passthrough.
188
193
  Logger.Warn("Multiple Render Target support needed to compute object based motion blur");
189
- return this.updateEffect();
194
+ return;
190
195
  }
191
196
  if (this._geometryBufferRenderer) {
192
- this._geometryBufferRenderer.enableVelocity = this._isObjectBased;
197
+ this._geometryBufferRenderer.enableVelocity = this.isObjectBased;
193
198
  }
194
- this._updateEffect();
195
- this._invViewProjection = null;
196
- this._previousViewProjection = null;
197
199
  if (this.isObjectBased) {
198
200
  if (this._prePassRenderer && this._prePassEffectConfiguration) {
199
201
  this._prePassEffectConfiguration.texturesRequired[0] = 2;
@@ -201,8 +203,6 @@ export class MotionBlurPostProcess extends PostProcess {
201
203
  this.onApply = (effect) => this._onApplyObjectBased(effect);
202
204
  }
203
205
  else {
204
- this._invViewProjection = Matrix.Identity();
205
- this._previousViewProjection = this._scene.getTransformMatrix().clone();
206
206
  if (this._prePassRenderer && this._prePassEffectConfiguration) {
207
207
  this._prePassEffectConfiguration.texturesRequired[0] = 5;
208
208
  }
@@ -214,9 +214,8 @@ export class MotionBlurPostProcess extends PostProcess {
214
214
  * @param effect
215
215
  */
216
216
  _onApplyObjectBased(effect) {
217
- effect.setVector2("screenSize", new Vector2(this.width, this.height));
218
- effect.setFloat("motionScale", this._scene.getAnimationRatio());
219
- effect.setFloat("motionStrength", this.motionStrength);
217
+ this._effectWrapper.textureWidth = this.width;
218
+ this._effectWrapper.textureHeight = this.height;
220
219
  if (this._geometryBufferRenderer) {
221
220
  const velocityIndex = this._geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE);
222
221
  effect.setTexture("velocitySampler", this._geometryBufferRenderer.getGBuffer().textures[velocityIndex]);
@@ -231,16 +230,8 @@ export class MotionBlurPostProcess extends PostProcess {
231
230
  * @param effect
232
231
  */
233
232
  _onApplyScreenBased(effect) {
234
- const viewProjection = TmpVectors.Matrix[0];
235
- viewProjection.copyFrom(this._scene.getTransformMatrix());
236
- viewProjection.invertToRef(this._invViewProjection);
237
- effect.setMatrix("inverseViewProjection", this._invViewProjection);
238
- effect.setMatrix("prevViewProjection", this._previousViewProjection);
239
- this._previousViewProjection.copyFrom(viewProjection);
240
- effect.setMatrix("projection", this._scene.getProjectionMatrix());
241
- effect.setVector2("screenSize", new Vector2(this.width, this.height));
242
- effect.setFloat("motionScale", this._scene.getAnimationRatio());
243
- effect.setFloat("motionStrength", this.motionStrength);
233
+ this._effectWrapper.textureWidth = this.width;
234
+ this._effectWrapper.textureHeight = this.height;
244
235
  if (this._geometryBufferRenderer) {
245
236
  const depthIndex = this._geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.DEPTH_TEXTURE_TYPE);
246
237
  effect.setTexture("depthSampler", this._geometryBufferRenderer.getGBuffer().textures[depthIndex]);
@@ -250,19 +241,6 @@ export class MotionBlurPostProcess extends PostProcess {
250
241
  effect.setTexture("depthSampler", this._prePassRenderer.getRenderTarget().textures[depthIndex]);
251
242
  }
252
243
  }
253
- /**
254
- * Called on the effect must be updated (changed mode, samples count, etc.).
255
- */
256
- _updateEffect() {
257
- if (this._geometryBufferRenderer || this._prePassRenderer) {
258
- const defines = [
259
- "#define GEOMETRY_SUPPORTED",
260
- "#define SAMPLES " + this._motionBlurSamples.toFixed(1),
261
- this._isObjectBased ? "#define OBJECT_BASED" : "#define SCREEN_BASED",
262
- ];
263
- this.updateEffect(defines.join("\n"));
264
- }
265
- }
266
244
  /**
267
245
  * @internal
268
246
  */
@@ -274,7 +252,7 @@ export class MotionBlurPostProcess extends PostProcess {
274
252
  }
275
253
  __decorate([
276
254
  serialize()
277
- ], MotionBlurPostProcess.prototype, "motionStrength", void 0);
255
+ ], MotionBlurPostProcess.prototype, "motionStrength", null);
278
256
  __decorate([
279
257
  serialize()
280
258
  ], MotionBlurPostProcess.prototype, "motionBlurSamples", null);
@@ -1 +1 @@
1
- {"version":3,"file":"motionBlurPostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/motionBlurPostProcess.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAInE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAE7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAG/E,OAAO,0BAA0B,CAAC;AAClC,OAAO,mDAAmD,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAKlD;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,qBAAsB,SAAQ,WAAW;IAOlD;;OAEG;IAEH,IAAW,iBAAiB;QACxB,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,IAAW,iBAAiB,CAAC,OAAe;QACxC,IA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,cAAc,EAAE,IAAI,CAAC,gBAAgB,CAAC,eAAe,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;QACpG,CAAC;IACL,CAAC;IAED;;OAEG;IACK,aAAa;QACjB,IAAI,IAAI,CAAC,uBAAuB,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACxD,MAAM,OAAO,GAAa;gBACtB,4BAA4B;gBAC5B,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;gBACvD,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,sBAAsB;aACxE,CAAC;YAEF,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1C,CAAC;IACL,CAAC;IAED;;OAEG;IACI,MAAM,CAAU,MAAM,CAAC,iBAAsB,EAAE,YAAoB,EAAE,KAAY,EAAE,OAAe;QACrG,OAAO,mBAAmB,CAAC,KAAK,CAC5B,GAAG,EAAE;YACD,OAAO,IAAI,qBAAqB,CAC5B,iBAAiB,CAAC,IAAI,EACtB,KAAK,EACL,iBAAiB,CAAC,OAAO,EACzB,YAAY,EACZ,iBAAiB,CAAC,wBAAwB,EAC1C,KAAK,CAAC,SAAS,EAAE,EACjB,iBAAiB,CAAC,QAAQ,EAC1B,iBAAiB,CAAC,WAAW,EAC7B,KAAK,CACR,CAAC;QACN,CAAC,EACD,iBAAiB,EACjB,KAAK,EACL,OAAO,CACV,CAAC;IACN,CAAC;CACJ;AAtUU;IADN,SAAS,EAAE;6DACsB;AAMlC;IADC,SAAS,EAAE;8DAGX;AAgBD;IADC,SAAS,EAAE;0DAGX;AA8SL,aAAa,CAAC,+BAA+B,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { Matrix, TmpVectors, Vector2 } from \"../Maths/math.vector\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport type { PostProcessOptions } from \"./postProcess\";\r\nimport { PostProcess } from \"./postProcess\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { GeometryBufferRenderer } from \"../Rendering/geometryBufferRenderer\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { MotionBlurConfiguration } from \"../Rendering/motionBlurConfiguration\";\r\nimport type { PrePassRenderer } from \"../Rendering/prePassRenderer\";\r\n\r\nimport \"../Animations/animatable\";\r\nimport \"../Rendering/geometryBufferRendererSceneComponent\";\r\nimport { serialize } from \"../Misc/decorators\";\r\nimport { SerializationHelper } from \"../Misc/decorators.serialization\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\n\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport type { Scene } from \"../scene\";\r\n\r\n/**\r\n * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.\r\n * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.\r\n * As an example, all you have to do is to create the post-process:\r\n * var mb = new BABYLON.MotionBlurPostProcess(\r\n * 'mb', // The name of the effect.\r\n * scene, // The scene containing the objects to blur according to their velocity.\r\n * 1.0, // The required width/height ratio to downsize to before computing the render pass.\r\n * camera // The camera to apply the render pass to.\r\n * );\r\n * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.\r\n */\r\nexport class MotionBlurPostProcess extends PostProcess {\r\n /**\r\n * Defines how much the image is blurred by the movement. Default value is equal to 1\r\n */\r\n @serialize()\r\n public motionStrength: number = 1;\r\n\r\n /**\r\n * Gets the number of iterations are used for motion blur quality. Default value is equal to 32\r\n */\r\n @serialize()\r\n public get motionBlurSamples(): number {\r\n return this._motionBlurSamples;\r\n }\r\n\r\n /**\r\n * Sets the number of iterations to be used for motion blur quality\r\n */\r\n public set motionBlurSamples(samples: number) {\r\n this._motionBlurSamples = samples;\r\n this._updateEffect();\r\n }\r\n\r\n private _motionBlurSamples: number = 32;\r\n\r\n /**\r\n * Gets whether or not the motion blur post-process is in object based mode.\r\n */\r\n @serialize()\r\n public get isObjectBased(): boolean {\r\n return this._isObjectBased;\r\n }\r\n\r\n /**\r\n * Sets whether or not the motion blur post-process is in object based mode.\r\n */\r\n public set isObjectBased(value: boolean) {\r\n if (this._isObjectBased === value) {\r\n return;\r\n }\r\n\r\n this._isObjectBased = value;\r\n this._applyMode();\r\n }\r\n\r\n private _isObjectBased: boolean = true;\r\n\r\n private _forceGeometryBuffer: boolean = false;\r\n private get _geometryBufferRenderer(): Nullable<GeometryBufferRenderer> {\r\n if (!this._forceGeometryBuffer) {\r\n return null;\r\n }\r\n\r\n return this._scene.geometryBufferRenderer;\r\n }\r\n\r\n private get _prePassRenderer(): Nullable<PrePassRenderer> {\r\n if (this._forceGeometryBuffer) {\r\n return null;\r\n }\r\n\r\n return this._scene.prePassRenderer;\r\n }\r\n\r\n private _invViewProjection: Nullable<Matrix> = null;\r\n private _previousViewProjection: Nullable<Matrix> = null;\r\n\r\n /**\r\n * Gets a string identifying the name of the class\r\n * @returns \"MotionBlurPostProcess\" string\r\n */\r\n public override getClassName(): string {\r\n return \"MotionBlurPostProcess\";\r\n }\r\n\r\n /**\r\n * Creates a new instance MotionBlurPostProcess\r\n * @param name The name of the effect.\r\n * @param scene The scene containing the objects to blur according to their velocity.\r\n * @param options The required width/height ratio to downsize to before computing the render pass.\r\n * @param camera The camera to apply the render pass to.\r\n * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)\r\n * @param engine The engine which the post process will be applied. (default: current engine)\r\n * @param reusable If the post process can be reused on the same frame. (default: false)\r\n * @param textureType Type of textures used when performing the post process. (default: 0)\r\n * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: true)\r\n * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)\r\n */\r\n constructor(\r\n name: string,\r\n scene: Scene,\r\n options: number | PostProcessOptions,\r\n camera: Nullable<Camera>,\r\n samplingMode?: number,\r\n engine?: AbstractEngine,\r\n reusable?: boolean,\r\n textureType: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n blockCompilation = false,\r\n forceGeometryBuffer = false\r\n ) {\r\n super(\r\n name,\r\n \"motionBlur\",\r\n [\"motionStrength\", \"motionScale\", \"screenSize\", \"inverseViewProjection\", \"prevViewProjection\", \"projection\"],\r\n [\"velocitySampler\", \"depthSampler\"],\r\n options,\r\n camera,\r\n samplingMode,\r\n engine,\r\n reusable,\r\n \"#define GEOMETRY_SUPPORTED\\n#define SAMPLES 64.0\\n#define OBJECT_BASED\",\r\n textureType,\r\n undefined,\r\n null,\r\n blockCompilation\r\n );\r\n\r\n this._forceGeometryBuffer = forceGeometryBuffer;\r\n\r\n // Set up assets\r\n if (this._forceGeometryBuffer) {\r\n scene.enableGeometryBufferRenderer();\r\n\r\n if (this._geometryBufferRenderer) {\r\n this._geometryBufferRenderer.enableVelocity = this._isObjectBased;\r\n }\r\n } else {\r\n scene.enablePrePassRenderer();\r\n\r\n if (this._prePassRenderer) {\r\n this._prePassRenderer.markAsDirty();\r\n this._prePassEffectConfiguration = new MotionBlurConfiguration();\r\n }\r\n }\r\n\r\n this._applyMode();\r\n }\r\n\r\n protected override _gatherImports(useWebGPU: boolean, list: Promise<any>[]) {\r\n if (useWebGPU) {\r\n this._webGPUReady = true;\r\n list.push(Promise.all([import(\"../ShadersWGSL/motionBlur.fragment\")]));\r\n } else {\r\n list.push(Promise.all([import(\"../Shaders/motionBlur.fragment\")]));\r\n }\r\n\r\n super._gatherImports(useWebGPU, list);\r\n }\r\n\r\n /**\r\n * Excludes the given skinned mesh from computing bones velocities.\r\n * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.\r\n * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.\r\n */\r\n public excludeSkinnedMesh(skinnedMesh: AbstractMesh): void {\r\n if (skinnedMesh.skeleton) {\r\n let list;\r\n if (this._geometryBufferRenderer) {\r\n list = this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity;\r\n } else if (this._prePassRenderer) {\r\n list = this._prePassRenderer.excludedSkinnedMesh;\r\n } else {\r\n return;\r\n }\r\n list.push(skinnedMesh);\r\n }\r\n }\r\n\r\n /**\r\n * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.\r\n * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.\r\n * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.\r\n */\r\n public removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void {\r\n if (skinnedMesh.skeleton) {\r\n let list;\r\n if (this._geometryBufferRenderer) {\r\n list = this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity;\r\n } else if (this._prePassRenderer) {\r\n list = this._prePassRenderer.excludedSkinnedMesh;\r\n } else {\r\n return;\r\n }\r\n\r\n const index = list.indexOf(skinnedMesh);\r\n if (index !== -1) {\r\n list.splice(index, 1);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Disposes the post process.\r\n * @param camera The camera to dispose the post process on.\r\n */\r\n public override dispose(camera?: Camera): void {\r\n if (this._geometryBufferRenderer) {\r\n // Clear previous transformation matrices dictionary used to compute objects velocities\r\n this._geometryBufferRenderer._previousTransformationMatrices = {};\r\n this._geometryBufferRenderer._previousBonesTransformationMatrices = {};\r\n this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity = [];\r\n }\r\n\r\n super.dispose(camera);\r\n }\r\n\r\n /**\r\n * Called on the mode changed (object based or screen based).\r\n * @returns void\r\n */\r\n private _applyMode() {\r\n if (!this._geometryBufferRenderer && !this._prePassRenderer) {\r\n // We can't get a velocity or depth texture. So, work as a passthrough.\r\n Logger.Warn(\"Multiple Render Target support needed to compute object based motion blur\");\r\n return this.updateEffect();\r\n }\r\n\r\n if (this._geometryBufferRenderer) {\r\n this._geometryBufferRenderer.enableVelocity = this._isObjectBased;\r\n }\r\n\r\n this._updateEffect();\r\n\r\n this._invViewProjection = null;\r\n this._previousViewProjection = null;\r\n\r\n if (this.isObjectBased) {\r\n if (this._prePassRenderer && this._prePassEffectConfiguration) {\r\n this._prePassEffectConfiguration.texturesRequired[0] = Constants.PREPASS_VELOCITY_TEXTURE_TYPE;\r\n }\r\n\r\n this.onApply = (effect: Effect) => this._onApplyObjectBased(effect);\r\n } else {\r\n this._invViewProjection = Matrix.Identity();\r\n this._previousViewProjection = this._scene.getTransformMatrix().clone();\r\n\r\n if (this._prePassRenderer && this._prePassEffectConfiguration) {\r\n this._prePassEffectConfiguration.texturesRequired[0] = Constants.PREPASS_DEPTH_TEXTURE_TYPE;\r\n }\r\n\r\n this.onApply = (effect: Effect) => this._onApplyScreenBased(effect);\r\n }\r\n }\r\n\r\n /**\r\n * Called on the effect is applied when the motion blur post-process is in object based mode.\r\n * @param effect\r\n */\r\n private _onApplyObjectBased(effect: Effect): void {\r\n effect.setVector2(\"screenSize\", new Vector2(this.width, this.height));\r\n\r\n effect.setFloat(\"motionScale\", this._scene.getAnimationRatio());\r\n effect.setFloat(\"motionStrength\", this.motionStrength);\r\n\r\n if (this._geometryBufferRenderer) {\r\n const velocityIndex = this._geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE);\r\n effect.setTexture(\"velocitySampler\", this._geometryBufferRenderer.getGBuffer().textures[velocityIndex]);\r\n } else if (this._prePassRenderer) {\r\n const velocityIndex = this._prePassRenderer.getIndex(Constants.PREPASS_VELOCITY_TEXTURE_TYPE);\r\n effect.setTexture(\"velocitySampler\", this._prePassRenderer.getRenderTarget().textures[velocityIndex]);\r\n }\r\n }\r\n\r\n /**\r\n * Called on the effect is applied when the motion blur post-process is in screen based mode.\r\n * @param effect\r\n */\r\n private _onApplyScreenBased(effect: Effect): void {\r\n const viewProjection = TmpVectors.Matrix[0];\r\n viewProjection.copyFrom(this._scene.getTransformMatrix());\r\n\r\n viewProjection.invertToRef(this._invViewProjection!);\r\n effect.setMatrix(\"inverseViewProjection\", this._invViewProjection!);\r\n\r\n effect.setMatrix(\"prevViewProjection\", this._previousViewProjection!);\r\n this._previousViewProjection!.copyFrom(viewProjection);\r\n\r\n effect.setMatrix(\"projection\", this._scene.getProjectionMatrix());\r\n\r\n effect.setVector2(\"screenSize\", new Vector2(this.width, this.height));\r\n\r\n effect.setFloat(\"motionScale\", this._scene.getAnimationRatio());\r\n effect.setFloat(\"motionStrength\", this.motionStrength);\r\n\r\n if (this._geometryBufferRenderer) {\r\n const depthIndex = this._geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.DEPTH_TEXTURE_TYPE);\r\n effect.setTexture(\"depthSampler\", this._geometryBufferRenderer.getGBuffer().textures[depthIndex]);\r\n } else if (this._prePassRenderer) {\r\n const depthIndex = this._prePassRenderer.getIndex(Constants.PREPASS_DEPTH_TEXTURE_TYPE);\r\n effect.setTexture(\"depthSampler\", this._prePassRenderer.getRenderTarget().textures[depthIndex]);\r\n }\r\n }\r\n\r\n /**\r\n * Called on the effect must be updated (changed mode, samples count, etc.).\r\n */\r\n private _updateEffect(): void {\r\n if (this._geometryBufferRenderer || this._prePassRenderer) {\r\n const defines: string[] = [\r\n \"#define GEOMETRY_SUPPORTED\",\r\n \"#define SAMPLES \" + this._motionBlurSamples.toFixed(1),\r\n this._isObjectBased ? \"#define OBJECT_BASED\" : \"#define SCREEN_BASED\",\r\n ];\r\n\r\n this.updateEffect(defines.join(\"\\n\"));\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static override _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess> {\r\n return SerializationHelper.Parse(\r\n () => {\r\n return new MotionBlurPostProcess(\r\n parsedPostProcess.name,\r\n scene,\r\n parsedPostProcess.options,\r\n targetCamera,\r\n parsedPostProcess.renderTargetSamplingMode,\r\n scene.getEngine(),\r\n parsedPostProcess.reusable,\r\n parsedPostProcess.textureType,\r\n false\r\n );\r\n },\r\n parsedPostProcess,\r\n scene,\r\n rootUrl\r\n );\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.MotionBlurPostProcess\", MotionBlurPostProcess);\r\n"]}
1
+ {"version":3,"file":"motionBlurPostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/motionBlurPostProcess.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAIxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAE7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAG/E,OAAO,0BAA0B,CAAC;AAClC,OAAO,mDAAmD,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAIlD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,qBAAsB,SAAQ,WAAW;IAClD;;OAEG;IAEH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC;IAC9C,CAAC;IAED,IAAW,cAAc,CAAC,KAAa;QACnC,IAAI,CAAC,cAAc,CAAC,cAAc,GAAG,KAAK,CAAC;IAC/C,CAAC;IAED;;OAEG;IAEH,IAAW,iBAAiB;QACxB,OAAO,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,IAAW,iBAAiB,CAAC,OAAe;QACxC,IAAI,CAAC,cAAc,CAAC,iBAAiB,GAAG,OAAO,CAAC;IACpD,CAAC;IAED;;OAEG;IAEH,IAAW,aAAa;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OAAO,EACzB,YAAY,EACZ,iBAAiB,CAAC,wBAAwB,EAC1C,KAAK,CAAC,SAAS,EAAE,EACjB,iBAAiB,CAAC,QAAQ,EAC1B,iBAAiB,CAAC,WAAW,EAC7B,KAAK,CACR,CAAC;QACN,CAAC,EACD,iBAAiB,EACjB,KAAK,EACL,OAAO,CACV,CAAC;IACN,CAAC;CACJ;AApRG;IADC,SAAS,EAAE;2DAGX;AAUD;IADC,SAAS,EAAE;8DAGX;AAaD;IADC,SAAS,EAAE;0DAGX;AAyPL,aAAa,CAAC,+BAA+B,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport type { PostProcessOptions } from \"./postProcess\";\r\nimport { PostProcess } from \"./postProcess\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { GeometryBufferRenderer } from \"../Rendering/geometryBufferRenderer\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { MotionBlurConfiguration } from \"../Rendering/motionBlurConfiguration\";\r\nimport type { PrePassRenderer } from \"../Rendering/prePassRenderer\";\r\n\r\nimport \"../Animations/animatable\";\r\nimport \"../Rendering/geometryBufferRendererSceneComponent\";\r\nimport { serialize } from \"../Misc/decorators\";\r\nimport { SerializationHelper } from \"../Misc/decorators.serialization\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\n\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport type { Scene } from \"../scene\";\r\nimport { ThinMotionBlurPostProcess } from \"./thinMotionBlurPostProcess\";\r\n\r\n/**\r\n * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.\r\n * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.\r\n * As an example, all you have to do is to create the post-process:\r\n * var mb = new BABYLON.MotionBlurPostProcess(\r\n * 'mb', // The name of the effect.\r\n * scene, // The scene containing the objects to blur according to their velocity.\r\n * 1.0, // The required width/height ratio to downsize to before computing the render pass.\r\n * camera // The camera to apply the render pass to.\r\n * );\r\n * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.\r\n */\r\nexport class MotionBlurPostProcess extends PostProcess {\r\n /**\r\n * Defines how much the image is blurred by the movement. Default value is equal to 1\r\n */\r\n @serialize()\r\n public get motionStrength() {\r\n return this._effectWrapper.motionStrength;\r\n }\r\n\r\n public set motionStrength(value: number) {\r\n this._effectWrapper.motionStrength = value;\r\n }\r\n\r\n /**\r\n * Gets the number of iterations are used for motion blur quality. Default value is equal to 32\r\n */\r\n @serialize()\r\n public get motionBlurSamples(): number {\r\n return this._effectWrapper.motionBlurSamples;\r\n }\r\n\r\n /**\r\n * Sets the number of iterations to be used for motion blur quality\r\n */\r\n public set motionBlurSamples(samples: number) {\r\n this._effectWrapper.motionBlurSamples = samples;\r\n }\r\n\r\n /**\r\n * Gets whether or not the motion blur post-process is in object based mode.\r\n */\r\n @serialize()\r\n public get isObjectBased(): boolean {\r\n return this._effectWrapper.isObjectBased;\r\n }\r\n\r\n /**\r\n * Sets whether or not the motion blur post-process is in object based mode.\r\n */\r\n public set isObjectBased(value: boolean) {\r\n if (this.isObjectBased === value) {\r\n return;\r\n }\r\n\r\n this._effectWrapper.isObjectBased = value;\r\n this._applyMode();\r\n }\r\n\r\n private _forceGeometryBuffer: boolean = false;\r\n private get _geometryBufferRenderer(): Nullable<GeometryBufferRenderer> {\r\n if (!this._forceGeometryBuffer) {\r\n return null;\r\n }\r\n\r\n return this._scene.geometryBufferRenderer;\r\n }\r\n\r\n private get _prePassRenderer(): Nullable<PrePassRenderer> {\r\n if (this._forceGeometryBuffer) {\r\n return null;\r\n }\r\n\r\n return this._scene.prePassRenderer;\r\n }\r\n\r\n /**\r\n * Gets a string identifying the name of the class\r\n * @returns \"MotionBlurPostProcess\" string\r\n */\r\n public override getClassName(): string {\r\n return \"MotionBlurPostProcess\";\r\n }\r\n\r\n protected override _effectWrapper: ThinMotionBlurPostProcess;\r\n\r\n /**\r\n * Creates a new instance MotionBlurPostProcess\r\n * @param name The name of the effect.\r\n * @param scene The scene containing the objects to blur according to their velocity.\r\n * @param options The required width/height ratio to downsize to before computing the render pass.\r\n * @param camera The camera to apply the render pass to.\r\n * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)\r\n * @param engine The engine which the post process will be applied. (default: current engine)\r\n * @param reusable If the post process can be reused on the same frame. (default: false)\r\n * @param textureType Type of textures used when performing the post process. (default: 0)\r\n * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: true)\r\n * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)\r\n */\r\n constructor(\r\n name: string,\r\n scene: Scene,\r\n options: number | PostProcessOptions,\r\n camera: Nullable<Camera>,\r\n samplingMode?: number,\r\n engine?: AbstractEngine,\r\n reusable?: boolean,\r\n textureType: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n blockCompilation = false,\r\n forceGeometryBuffer = false\r\n ) {\r\n const localOptions = {\r\n uniforms: ThinMotionBlurPostProcess.Uniforms,\r\n samplers: ThinMotionBlurPostProcess.Samplers,\r\n defines: ThinMotionBlurPostProcess.Defines,\r\n size: typeof options === \"number\" ? options : undefined,\r\n camera,\r\n samplingMode,\r\n engine,\r\n reusable,\r\n textureType,\r\n blockCompilation,\r\n ...(options as PostProcessOptions),\r\n };\r\n\r\n super(name, ThinMotionBlurPostProcess.FragmentUrl, {\r\n effectWrapper: typeof options === \"number\" || !options.effectWrapper ? new ThinMotionBlurPostProcess(name, scene, localOptions) : undefined,\r\n ...localOptions,\r\n });\r\n\r\n this._forceGeometryBuffer = forceGeometryBuffer;\r\n\r\n // Set up assets\r\n if (this._forceGeometryBuffer) {\r\n scene.enableGeometryBufferRenderer();\r\n\r\n if (this._geometryBufferRenderer) {\r\n this._geometryBufferRenderer.enableVelocity = this.isObjectBased;\r\n }\r\n } else {\r\n scene.enablePrePassRenderer();\r\n\r\n if (this._prePassRenderer) {\r\n this._prePassRenderer.markAsDirty();\r\n this._prePassEffectConfiguration = new MotionBlurConfiguration();\r\n }\r\n }\r\n\r\n this._applyMode();\r\n }\r\n\r\n /**\r\n * Excludes the given skinned mesh from computing bones velocities.\r\n * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.\r\n * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.\r\n */\r\n public excludeSkinnedMesh(skinnedMesh: AbstractMesh): void {\r\n if (skinnedMesh.skeleton) {\r\n let list;\r\n if (this._geometryBufferRenderer) {\r\n list = this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity;\r\n } else if (this._prePassRenderer) {\r\n list = this._prePassRenderer.excludedSkinnedMesh;\r\n } else {\r\n return;\r\n }\r\n list.push(skinnedMesh);\r\n }\r\n }\r\n\r\n /**\r\n * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.\r\n * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.\r\n * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.\r\n */\r\n public removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void {\r\n if (skinnedMesh.skeleton) {\r\n let list;\r\n if (this._geometryBufferRenderer) {\r\n list = this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity;\r\n } else if (this._prePassRenderer) {\r\n list = this._prePassRenderer.excludedSkinnedMesh;\r\n } else {\r\n return;\r\n }\r\n\r\n const index = list.indexOf(skinnedMesh);\r\n if (index !== -1) {\r\n list.splice(index, 1);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Disposes the post process.\r\n * @param camera The camera to dispose the post process on.\r\n */\r\n public override dispose(camera?: Camera): void {\r\n if (this._geometryBufferRenderer) {\r\n // Clear previous transformation matrices dictionary used to compute objects velocities\r\n this._geometryBufferRenderer._previousTransformationMatrices = {};\r\n this._geometryBufferRenderer._previousBonesTransformationMatrices = {};\r\n this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity = [];\r\n }\r\n\r\n super.dispose(camera);\r\n }\r\n\r\n /**\r\n * Called on the mode changed (object based or screen based).\r\n */\r\n private _applyMode() {\r\n if (!this._geometryBufferRenderer && !this._prePassRenderer) {\r\n // We can't get a velocity or depth texture. So, work as a passthrough.\r\n Logger.Warn(\"Multiple Render Target support needed to compute object based motion blur\");\r\n return;\r\n }\r\n\r\n if (this._geometryBufferRenderer) {\r\n this._geometryBufferRenderer.enableVelocity = this.isObjectBased;\r\n }\r\n\r\n if (this.isObjectBased) {\r\n if (this._prePassRenderer && this._prePassEffectConfiguration) {\r\n this._prePassEffectConfiguration.texturesRequired[0] = Constants.PREPASS_VELOCITY_TEXTURE_TYPE;\r\n }\r\n\r\n this.onApply = (effect: Effect) => this._onApplyObjectBased(effect);\r\n } else {\r\n if (this._prePassRenderer && this._prePassEffectConfiguration) {\r\n this._prePassEffectConfiguration.texturesRequired[0] = Constants.PREPASS_DEPTH_TEXTURE_TYPE;\r\n }\r\n\r\n this.onApply = (effect: Effect) => this._onApplyScreenBased(effect);\r\n }\r\n }\r\n\r\n /**\r\n * Called on the effect is applied when the motion blur post-process is in object based mode.\r\n * @param effect\r\n */\r\n private _onApplyObjectBased(effect: Effect): void {\r\n this._effectWrapper.textureWidth = this.width;\r\n this._effectWrapper.textureHeight = this.height;\r\n if (this._geometryBufferRenderer) {\r\n const velocityIndex = this._geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE);\r\n effect.setTexture(\"velocitySampler\", this._geometryBufferRenderer.getGBuffer().textures[velocityIndex]);\r\n } else if (this._prePassRenderer) {\r\n const velocityIndex = this._prePassRenderer.getIndex(Constants.PREPASS_VELOCITY_TEXTURE_TYPE);\r\n effect.setTexture(\"velocitySampler\", this._prePassRenderer.getRenderTarget().textures[velocityIndex]);\r\n }\r\n }\r\n\r\n /**\r\n * Called on the effect is applied when the motion blur post-process is in screen based mode.\r\n * @param effect\r\n */\r\n private _onApplyScreenBased(effect: Effect): void {\r\n this._effectWrapper.textureWidth = this.width;\r\n this._effectWrapper.textureHeight = this.height;\r\n if (this._geometryBufferRenderer) {\r\n const depthIndex = this._geometryBufferRenderer.getTextureIndex(GeometryBufferRenderer.DEPTH_TEXTURE_TYPE);\r\n effect.setTexture(\"depthSampler\", this._geometryBufferRenderer.getGBuffer().textures[depthIndex]);\r\n } else if (this._prePassRenderer) {\r\n const depthIndex = this._prePassRenderer.getIndex(Constants.PREPASS_DEPTH_TEXTURE_TYPE);\r\n effect.setTexture(\"depthSampler\", this._prePassRenderer.getRenderTarget().textures[depthIndex]);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static override _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess> {\r\n return SerializationHelper.Parse(\r\n () => {\r\n return new MotionBlurPostProcess(\r\n parsedPostProcess.name,\r\n scene,\r\n parsedPostProcess.options,\r\n targetCamera,\r\n parsedPostProcess.renderTargetSamplingMode,\r\n scene.getEngine(),\r\n parsedPostProcess.reusable,\r\n parsedPostProcess.textureType,\r\n false\r\n );\r\n },\r\n parsedPostProcess,\r\n scene,\r\n rootUrl\r\n );\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.MotionBlurPostProcess\", MotionBlurPostProcess);\r\n"]}
@@ -0,0 +1,67 @@
1
+ import type { EffectWrapperCreationOptions, Scene } from "../index.js";
2
+ import { EffectWrapper } from "../Materials/effectRenderer.js";
3
+ /**
4
+ * Post process used to apply a motion blur post process
5
+ */
6
+ export declare class ThinMotionBlurPostProcess extends EffectWrapper {
7
+ /**
8
+ * The fragment shader url
9
+ */
10
+ static readonly FragmentUrl = "motionBlur";
11
+ /**
12
+ * The list of uniforms used by the effect
13
+ */
14
+ static readonly Uniforms: string[];
15
+ /**
16
+ * The list of samplers used by the effect
17
+ */
18
+ static readonly Samplers: string[];
19
+ /**
20
+ * The default defines used by the effect
21
+ */
22
+ static readonly Defines = "#define GEOMETRY_SUPPORTED\n#define SAMPLES 64.0\n#define OBJECT_BASED";
23
+ protected _gatherImports(useWebGPU: boolean, list: Promise<any>[]): void;
24
+ private _scene;
25
+ private _invViewProjection;
26
+ private _previousViewProjection;
27
+ /**
28
+ * Constructs a new motion blur post process
29
+ * @param name Name of the effect
30
+ * @param scene The scene the effect belongs to
31
+ * @param options Options to configure the effect
32
+ */
33
+ constructor(name: string, scene: Scene, options?: EffectWrapperCreationOptions);
34
+ /**
35
+ * Defines how much the image is blurred by the movement. Default value is equal to 1
36
+ */
37
+ motionStrength: number;
38
+ private _motionBlurSamples;
39
+ /**
40
+ * Gets the number of iterations that are used for motion blur quality. Default value is equal to 32
41
+ */
42
+ get motionBlurSamples(): number;
43
+ /**
44
+ * Sets the number of iterations to be used for motion blur quality
45
+ */
46
+ set motionBlurSamples(samples: number);
47
+ private _isObjectBased;
48
+ /**
49
+ * Gets whether or not the motion blur post-process is in object based mode.
50
+ */
51
+ get isObjectBased(): boolean;
52
+ /**
53
+ * Sets whether or not the motion blur post-process is in object based mode.
54
+ */
55
+ set isObjectBased(value: boolean);
56
+ /**
57
+ * The width of the source texture
58
+ */
59
+ textureWidth: number;
60
+ /**
61
+ * The height of the source texture
62
+ */
63
+ textureHeight: number;
64
+ bind(noDefaultBindings?: boolean): void;
65
+ private _updateEffect;
66
+ private _applyMode;
67
+ }
@@ -0,0 +1,127 @@
1
+ import { EffectWrapper } from "../Materials/effectRenderer.js";
2
+ import { Matrix, TmpVectors } from "../Maths/math.vector.js";
3
+ /**
4
+ * Post process used to apply a motion blur post process
5
+ */
6
+ export class ThinMotionBlurPostProcess extends EffectWrapper {
7
+ _gatherImports(useWebGPU, list) {
8
+ if (useWebGPU) {
9
+ this._webGPUReady = true;
10
+ list.push(import("../ShadersWGSL/motionBlur.fragment.js"));
11
+ }
12
+ else {
13
+ list.push(import("../Shaders/motionBlur.fragment.js"));
14
+ }
15
+ }
16
+ /**
17
+ * Constructs a new motion blur post process
18
+ * @param name Name of the effect
19
+ * @param scene The scene the effect belongs to
20
+ * @param options Options to configure the effect
21
+ */
22
+ constructor(name, scene, options) {
23
+ super({
24
+ ...options,
25
+ name,
26
+ engine: scene.getEngine(),
27
+ useShaderStore: true,
28
+ useAsPostProcess: true,
29
+ fragmentShader: ThinMotionBlurPostProcess.FragmentUrl,
30
+ uniforms: ThinMotionBlurPostProcess.Uniforms,
31
+ samplers: ThinMotionBlurPostProcess.Samplers,
32
+ defines: ThinMotionBlurPostProcess.Defines,
33
+ });
34
+ this._invViewProjection = Matrix.Identity();
35
+ this._previousViewProjection = Matrix.Identity();
36
+ /**
37
+ * Defines how much the image is blurred by the movement. Default value is equal to 1
38
+ */
39
+ this.motionStrength = 1;
40
+ this._motionBlurSamples = 32;
41
+ this._isObjectBased = true;
42
+ /**
43
+ * The width of the source texture
44
+ */
45
+ this.textureWidth = 0;
46
+ /**
47
+ * The height of the source texture
48
+ */
49
+ this.textureHeight = 0;
50
+ this._scene = scene;
51
+ this._applyMode();
52
+ }
53
+ /**
54
+ * Gets the number of iterations that are used for motion blur quality. Default value is equal to 32
55
+ */
56
+ get motionBlurSamples() {
57
+ return this._motionBlurSamples;
58
+ }
59
+ /**
60
+ * Sets the number of iterations to be used for motion blur quality
61
+ */
62
+ set motionBlurSamples(samples) {
63
+ this._motionBlurSamples = samples;
64
+ this._updateEffect();
65
+ }
66
+ /**
67
+ * Gets whether or not the motion blur post-process is in object based mode.
68
+ */
69
+ get isObjectBased() {
70
+ return this._isObjectBased;
71
+ }
72
+ /**
73
+ * Sets whether or not the motion blur post-process is in object based mode.
74
+ */
75
+ set isObjectBased(value) {
76
+ if (this._isObjectBased === value) {
77
+ return;
78
+ }
79
+ this._isObjectBased = value;
80
+ this._applyMode();
81
+ }
82
+ bind(noDefaultBindings = false) {
83
+ super.bind(noDefaultBindings);
84
+ const effect = this._drawWrapper.effect;
85
+ effect.setFloat2("screenSize", this.textureWidth, this.textureHeight);
86
+ effect.setFloat("motionScale", this._scene.getAnimationRatio());
87
+ effect.setFloat("motionStrength", this.motionStrength);
88
+ if (!this.isObjectBased) {
89
+ const viewProjection = TmpVectors.Matrix[0];
90
+ viewProjection.copyFrom(this._scene.getTransformMatrix());
91
+ viewProjection.invertToRef(this._invViewProjection);
92
+ effect.setMatrix("inverseViewProjection", this._invViewProjection);
93
+ effect.setMatrix("prevViewProjection", this._previousViewProjection);
94
+ this._previousViewProjection.copyFrom(viewProjection);
95
+ effect.setMatrix("projection", this._scene.getProjectionMatrix());
96
+ }
97
+ }
98
+ _updateEffect() {
99
+ const defines = [
100
+ "#define GEOMETRY_SUPPORTED",
101
+ "#define SAMPLES " + this._motionBlurSamples.toFixed(1),
102
+ this._isObjectBased ? "#define OBJECT_BASED" : "#define SCREEN_BASED",
103
+ ];
104
+ this.updateEffect(defines.join("\n"));
105
+ }
106
+ _applyMode() {
107
+ this._updateEffect();
108
+ this._previousViewProjection.copyFrom(this._scene.getTransformMatrix());
109
+ }
110
+ }
111
+ /**
112
+ * The fragment shader url
113
+ */
114
+ ThinMotionBlurPostProcess.FragmentUrl = "motionBlur";
115
+ /**
116
+ * The list of uniforms used by the effect
117
+ */
118
+ ThinMotionBlurPostProcess.Uniforms = ["motionStrength", "motionScale", "screenSize", "inverseViewProjection", "prevViewProjection", "projection"];
119
+ /**
120
+ * The list of samplers used by the effect
121
+ */
122
+ ThinMotionBlurPostProcess.Samplers = ["velocitySampler", "depthSampler"];
123
+ /**
124
+ * The default defines used by the effect
125
+ */
126
+ ThinMotionBlurPostProcess.Defines = "#define GEOMETRY_SUPPORTED\n#define SAMPLES 64.0\n#define OBJECT_BASED";
127
+ //# sourceMappingURL=thinMotionBlurPostProcess.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thinMotionBlurPostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/thinMotionBlurPostProcess.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC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,MAAM,CAAC,SAAS,CAAC,oBAAoB,EAAE,IAAI,CAAC,uBAAuB,CAAC,CAAC;YACrE,IAAI,CAAC,uBAAuB,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;YAEtD,MAAM,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC,CAAC;QACtE,CAAC;IACL,CAAC;IAEO,aAAa;QACjB,MAAM,OAAO,GAAa;YACtB,4BAA4B;YAC5B,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;YACvD,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,sBAAsB;SACxE,CAAC;QAEF,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1C,CAAC;IAEO,UAAU;QACd,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,uBAAuB,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAC5E,CAAC;;AAlJD;;GAEG;AACoB,qCAAW,GAAG,YAAY,AAAf,CAAgB;AAElD;;GAEG;AACoB,kCAAQ,GAAG,CAAC,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,YAAY,CAAC,AAA/G,CAAgH;AAE/I;;GAEG;AACoB,kCAAQ,GAAG,CAAC,iBAAiB,EAAE,cAAc,CAAC,AAAtC,CAAuC;AAEtE;;GAEG;AACoB,iCAAO,GAAG,wEAAwE,AAA3E,CAA4E","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { EffectWrapperCreationOptions, Scene } from \"core/index\";\r\nimport { EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport { Matrix, TmpVectors } from \"../Maths/math.vector\";\r\n\r\n/**\r\n * Post process used to apply a motion blur post process\r\n */\r\nexport class ThinMotionBlurPostProcess extends EffectWrapper {\r\n /**\r\n * The fragment shader url\r\n */\r\n public static readonly FragmentUrl = \"motionBlur\";\r\n\r\n /**\r\n * The list of uniforms used by the effect\r\n */\r\n public static readonly Uniforms = [\"motionStrength\", \"motionScale\", \"screenSize\", \"inverseViewProjection\", \"prevViewProjection\", \"projection\"];\r\n\r\n /**\r\n * The list of samplers used by the effect\r\n */\r\n public static readonly Samplers = [\"velocitySampler\", \"depthSampler\"];\r\n\r\n /**\r\n * The default defines used by the effect\r\n */\r\n public static readonly Defines = \"#define GEOMETRY_SUPPORTED\\n#define SAMPLES 64.0\\n#define OBJECT_BASED\";\r\n\r\n protected override _gatherImports(useWebGPU: boolean, list: Promise<any>[]) {\r\n if (useWebGPU) {\r\n this._webGPUReady = true;\r\n list.push(import(\"../ShadersWGSL/motionBlur.fragment\"));\r\n } else {\r\n list.push(import(\"../Shaders/motionBlur.fragment\"));\r\n }\r\n }\r\n\r\n private _scene: Scene;\r\n private _invViewProjection = Matrix.Identity();\r\n private _previousViewProjection = Matrix.Identity();\r\n\r\n /**\r\n * Constructs a new motion blur post process\r\n * @param name Name of the effect\r\n * @param scene The scene the effect belongs to\r\n * @param options Options to configure the effect\r\n */\r\n constructor(name: string, scene: Scene, options?: EffectWrapperCreationOptions) {\r\n super({\r\n ...options,\r\n name,\r\n engine: scene.getEngine(),\r\n useShaderStore: true,\r\n useAsPostProcess: true,\r\n fragmentShader: ThinMotionBlurPostProcess.FragmentUrl,\r\n uniforms: ThinMotionBlurPostProcess.Uniforms,\r\n samplers: ThinMotionBlurPostProcess.Samplers,\r\n defines: ThinMotionBlurPostProcess.Defines,\r\n });\r\n\r\n this._scene = scene;\r\n\r\n this._applyMode();\r\n }\r\n\r\n /**\r\n * Defines how much the image is blurred by the movement. Default value is equal to 1\r\n */\r\n public motionStrength: number = 1;\r\n\r\n private _motionBlurSamples: number = 32;\r\n\r\n /**\r\n * Gets the number of iterations that are used for motion blur quality. Default value is equal to 32\r\n */\r\n public get motionBlurSamples(): number {\r\n return this._motionBlurSamples;\r\n }\r\n\r\n /**\r\n * Sets the number of iterations to be used for motion blur quality\r\n */\r\n public set motionBlurSamples(samples: number) {\r\n this._motionBlurSamples = samples;\r\n this._updateEffect();\r\n }\r\n\r\n private _isObjectBased: boolean = true;\r\n\r\n /**\r\n * Gets whether or not the motion blur post-process is in object based mode.\r\n */\r\n public get isObjectBased(): boolean {\r\n return this._isObjectBased;\r\n }\r\n\r\n /**\r\n * Sets whether or not the motion blur post-process is in object based mode.\r\n */\r\n public set isObjectBased(value: boolean) {\r\n if (this._isObjectBased === value) {\r\n return;\r\n }\r\n\r\n this._isObjectBased = value;\r\n this._applyMode();\r\n }\r\n\r\n /**\r\n * The width of the source texture\r\n */\r\n public textureWidth: number = 0;\r\n\r\n /**\r\n * The height of the source texture\r\n */\r\n public textureHeight: number = 0;\r\n\r\n public override bind(noDefaultBindings = false) {\r\n super.bind(noDefaultBindings);\r\n\r\n const effect = this._drawWrapper.effect!;\r\n\r\n effect.setFloat2(\"screenSize\", this.textureWidth, this.textureHeight);\r\n effect.setFloat(\"motionScale\", this._scene.getAnimationRatio());\r\n effect.setFloat(\"motionStrength\", this.motionStrength);\r\n\r\n if (!this.isObjectBased) {\r\n const viewProjection = TmpVectors.Matrix[0];\r\n viewProjection.copyFrom(this._scene.getTransformMatrix());\r\n\r\n viewProjection.invertToRef(this._invViewProjection);\r\n effect.setMatrix(\"inverseViewProjection\", this._invViewProjection);\r\n\r\n effect.setMatrix(\"prevViewProjection\", this._previousViewProjection);\r\n this._previousViewProjection.copyFrom(viewProjection);\r\n\r\n effect.setMatrix(\"projection\", this._scene.getProjectionMatrix());\r\n }\r\n }\r\n\r\n private _updateEffect(): void {\r\n const defines: string[] = [\r\n \"#define GEOMETRY_SUPPORTED\",\r\n \"#define SAMPLES \" + this._motionBlurSamples.toFixed(1),\r\n this._isObjectBased ? \"#define OBJECT_BASED\" : \"#define SCREEN_BASED\",\r\n ];\r\n\r\n this.updateEffect(defines.join(\"\\n\"));\r\n }\r\n\r\n private _applyMode() {\r\n this._updateEffect();\r\n this._previousViewProjection.copyFrom(this._scene.getTransformMatrix());\r\n }\r\n}\r\n"]}
@@ -1,5 +1,4 @@
1
1
 
2
- import { Engine } from "../Engines/engine.js";
3
2
  import { EffectWrapper } from "../Materials/effectRenderer.js";
4
3
  import { Vector3, Matrix, Quaternion, TmpVectors } from "../Maths/math.vector.js";
5
4
  const Trs = Matrix.Compose(new Vector3(0.5, 0.5, 0.5), Quaternion.Identity(), new Vector3(0.5, 0.5, 0.5));
@@ -228,7 +227,7 @@ export class ThinSSRPostProcess extends EffectWrapper {
228
227
  super({
229
228
  ...options,
230
229
  name,
231
- engine: scene.getEngine() || Engine.LastCreatedEngine,
230
+ engine: scene.getEngine(),
232
231
  useShaderStore: true,
233
232
  useAsPostProcess: true,
234
233
  fragmentShader: ThinSSRPostProcess.FragmentUrl,