@babylonjs/core 7.21.0 → 7.21.2
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.
- package/Animations/easing.d.ts +20 -20
- package/Animations/easing.js +10 -10
- package/Animations/easing.js.map +1 -1
- package/Buffers/buffer.nonFloatVertexBuffers.js +2 -1
- package/Buffers/buffer.nonFloatVertexBuffers.js.map +1 -1
- package/Cameras/VR/vrExperienceHelper.d.ts +2 -2
- package/Cameras/VR/vrExperienceHelper.js +1 -1
- package/Cameras/VR/vrExperienceHelper.js.map +1 -1
- package/Collisions/gpuPicker.d.ts +9 -4
- package/Collisions/gpuPicker.js +64 -44
- package/Collisions/gpuPicker.js.map +1 -1
- package/Collisions/index.d.ts +4 -0
- package/Collisions/index.js +4 -0
- package/Collisions/index.js.map +1 -1
- package/Culling/Helper/computeShaderBoundingHelper.js +0 -3
- package/Culling/Helper/computeShaderBoundingHelper.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.d.ts +0 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +0 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
- package/Engines/abstractEngine.d.ts +2 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/nativeEngine.js +0 -3
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/thinEngine.d.ts +2 -1
- package/Engines/thinEngine.js +3 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +3 -1
- package/Engines/webgpuEngine.js +6 -3
- package/Engines/webgpuEngine.js.map +1 -1
- package/Gizmos/gizmo.d.ts +2 -2
- package/Gizmos/gizmo.js +1 -1
- package/Gizmos/gizmo.js.map +1 -1
- package/Layers/effectLayer.d.ts +1 -1
- package/Layers/effectLayer.js +18 -16
- package/Layers/effectLayer.js.map +1 -1
- package/Layers/glowLayer.d.ts +1 -1
- package/Layers/glowLayer.js +3 -5
- package/Layers/glowLayer.js.map +1 -1
- package/Layers/highlightLayer.d.ts +1 -1
- package/Layers/highlightLayer.js +7 -9
- package/Layers/highlightLayer.js.map +1 -1
- package/Layers/layer.d.ts +0 -1
- package/Layers/layer.js +15 -17
- package/Layers/layer.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.d.ts +0 -3
- package/Lights/Shadows/cascadedShadowGenerator.js +0 -3
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Materials/Background/backgroundMaterial.d.ts +0 -1
- package/Materials/Background/backgroundMaterial.js +20 -20
- package/Materials/Background/backgroundMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.d.ts +0 -1
- package/Materials/PBR/pbrBaseMaterial.js +34 -39
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/effect.d.ts +7 -2
- package/Materials/effect.js +7 -3
- package/Materials/effect.js.map +1 -1
- package/Materials/shaderMaterial.d.ts +4 -0
- package/Materials/shaderMaterial.js +1 -0
- package/Materials/shaderMaterial.js.map +1 -1
- package/Materials/standardMaterial.d.ts +0 -1
- package/Materials/standardMaterial.js +20 -20
- package/Materials/standardMaterial.js.map +1 -1
- package/Maths/math.isovector.js +6 -6
- package/Maths/math.isovector.js.map +1 -1
- package/Meshes/Builders/geodesicBuilder.js +2 -2
- package/Meshes/Builders/geodesicBuilder.js.map +1 -1
- package/Meshes/Builders/goldbergBuilder.js +2 -2
- package/Meshes/Builders/goldbergBuilder.js.map +1 -1
- package/Meshes/linesMesh.d.ts +0 -2
- package/Meshes/linesMesh.js +16 -20
- package/Meshes/linesMesh.js.map +1 -1
- package/Misc/assetsManager.d.ts +16 -16
- package/Misc/assetsManager.js +8 -8
- package/Misc/assetsManager.js.map +1 -1
- package/Misc/copyTextureToTexture.d.ts +9 -1
- package/Misc/copyTextureToTexture.js +23 -2
- package/Misc/copyTextureToTexture.js.map +1 -1
- package/Misc/environmentTextureTools.d.ts +0 -2
- package/Misc/environmentTextureTools.js +0 -2
- package/Misc/environmentTextureTools.js.map +1 -1
- package/Misc/index.d.ts +2 -0
- package/Misc/index.js +3 -0
- package/Misc/index.js.map +1 -1
- package/Misc/sceneOptimizer.d.ts +16 -16
- package/Misc/sceneOptimizer.js +8 -8
- package/Misc/sceneOptimizer.js.map +1 -1
- package/Particles/EmitterTypes/coneParticleEmitter.d.ts +4 -4
- package/Particles/EmitterTypes/coneParticleEmitter.js +2 -2
- package/Particles/EmitterTypes/coneParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/cylinderParticleEmitter.d.ts +4 -4
- package/Particles/EmitterTypes/cylinderParticleEmitter.js +2 -2
- package/Particles/EmitterTypes/cylinderParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.d.ts +4 -4
- package/Particles/EmitterTypes/sphereParticleEmitter.js +2 -2
- package/Particles/EmitterTypes/sphereParticleEmitter.js.map +1 -1
- package/Particles/particleSystemComponent.d.ts +0 -1
- package/Particles/particleSystemComponent.js +8 -2
- package/Particles/particleSystemComponent.js.map +1 -1
- package/Particles/thinParticleSystem.d.ts +0 -2
- package/Particles/thinParticleSystem.js +0 -2
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Physics/v1/physicsJoint.js +0 -3
- package/Physics/v1/physicsJoint.js.map +1 -1
- package/Physics/v2/physicsConstraint.d.ts +14 -20
- package/Physics/v2/physicsConstraint.js +14 -20
- package/Physics/v2/physicsConstraint.js.map +1 -1
- package/PostProcesses/anaglyphPostProcess.d.ts +1 -2
- package/PostProcesses/anaglyphPostProcess.js +4 -5
- package/PostProcesses/anaglyphPostProcess.js.map +1 -1
- package/PostProcesses/blackAndWhitePostProcess.d.ts +1 -1
- package/PostProcesses/blackAndWhitePostProcess.js +4 -4
- package/PostProcesses/blackAndWhitePostProcess.js.map +1 -1
- package/PostProcesses/bloomMergePostProcess.d.ts +1 -1
- package/PostProcesses/bloomMergePostProcess.js +4 -4
- package/PostProcesses/bloomMergePostProcess.js.map +1 -1
- package/PostProcesses/blurPostProcess.d.ts +1 -3
- package/PostProcesses/blurPostProcess.js +4 -6
- package/PostProcesses/blurPostProcess.js.map +1 -1
- package/PostProcesses/chromaticAberrationPostProcess.d.ts +1 -1
- package/PostProcesses/chromaticAberrationPostProcess.js +4 -4
- package/PostProcesses/chromaticAberrationPostProcess.js.map +1 -1
- package/PostProcesses/circleOfConfusionPostProcess.d.ts +1 -1
- package/PostProcesses/circleOfConfusionPostProcess.js +4 -4
- package/PostProcesses/circleOfConfusionPostProcess.js.map +1 -1
- package/PostProcesses/colorCorrectionPostProcess.d.ts +1 -1
- package/PostProcesses/colorCorrectionPostProcess.js +4 -4
- package/PostProcesses/colorCorrectionPostProcess.js.map +1 -1
- package/PostProcesses/convolutionPostProcess.d.ts +1 -1
- package/PostProcesses/convolutionPostProcess.js +4 -4
- package/PostProcesses/convolutionPostProcess.js.map +1 -1
- package/PostProcesses/depthOfFieldMergePostProcess.d.ts +1 -1
- package/PostProcesses/depthOfFieldMergePostProcess.js +4 -4
- package/PostProcesses/depthOfFieldMergePostProcess.js.map +1 -1
- package/PostProcesses/displayPassPostProcess.d.ts +1 -1
- package/PostProcesses/displayPassPostProcess.js +10 -1
- package/PostProcesses/displayPassPostProcess.js.map +1 -1
- package/PostProcesses/extractHighlightsPostProcess.d.ts +1 -1
- package/PostProcesses/extractHighlightsPostProcess.js +4 -4
- package/PostProcesses/extractHighlightsPostProcess.js.map +1 -1
- package/PostProcesses/filterPostProcess.d.ts +1 -1
- package/PostProcesses/filterPostProcess.js +10 -1
- package/PostProcesses/filterPostProcess.js.map +1 -1
- package/PostProcesses/fxaaPostProcess.d.ts +1 -1
- package/PostProcesses/fxaaPostProcess.js +4 -4
- package/PostProcesses/fxaaPostProcess.js.map +1 -1
- package/PostProcesses/grainPostProcess.d.ts +1 -2
- package/PostProcesses/grainPostProcess.js +4 -5
- package/PostProcesses/grainPostProcess.js.map +1 -1
- package/PostProcesses/highlightsPostProcess.d.ts +1 -1
- package/PostProcesses/highlightsPostProcess.js +10 -1
- package/PostProcesses/highlightsPostProcess.js.map +1 -1
- package/PostProcesses/imageProcessingPostProcess.d.ts +1 -1
- package/PostProcesses/imageProcessingPostProcess.js +4 -4
- package/PostProcesses/imageProcessingPostProcess.js.map +1 -1
- package/PostProcesses/index.d.ts +8 -0
- package/PostProcesses/index.js +12 -0
- package/PostProcesses/index.js.map +1 -1
- package/PostProcesses/motionBlurPostProcess.d.ts +1 -1
- package/PostProcesses/motionBlurPostProcess.js +4 -4
- package/PostProcesses/motionBlurPostProcess.js.map +1 -1
- package/PostProcesses/passPostProcess.d.ts +2 -2
- package/PostProcesses/passPostProcess.js +8 -8
- package/PostProcesses/passPostProcess.js.map +1 -1
- package/PostProcesses/postProcess.d.ts +5 -4
- package/PostProcesses/postProcess.js +14 -27
- package/PostProcesses/postProcess.js.map +1 -1
- package/PostProcesses/sharpenPostProcess.d.ts +1 -1
- package/PostProcesses/sharpenPostProcess.js +4 -4
- package/PostProcesses/sharpenPostProcess.js.map +1 -1
- package/PostProcesses/tonemapPostProcess.d.ts +1 -1
- package/PostProcesses/tonemapPostProcess.js +10 -1
- package/PostProcesses/tonemapPostProcess.js.map +1 -1
- package/PostProcesses/vrDistortionCorrectionPostProcess.d.ts +1 -1
- package/PostProcesses/vrDistortionCorrectionPostProcess.js +4 -4
- package/PostProcesses/vrDistortionCorrectionPostProcess.js.map +1 -1
- package/ShadersWGSL/copyTextureToTexture.fragment.d.ts +6 -0
- package/ShadersWGSL/copyTextureToTexture.fragment.js +21 -0
- package/ShadersWGSL/copyTextureToTexture.fragment.js.map +1 -0
- package/ShadersWGSL/displayPass.fragment.d.ts +5 -0
- package/ShadersWGSL/displayPass.fragment.js +12 -0
- package/ShadersWGSL/displayPass.fragment.js.map +1 -0
- package/ShadersWGSL/filter.fragment.d.ts +5 -0
- package/ShadersWGSL/filter.fragment.js +12 -0
- package/ShadersWGSL/filter.fragment.js.map +1 -0
- package/ShadersWGSL/highlights.fragment.d.ts +5 -0
- package/ShadersWGSL/highlights.fragment.js +12 -0
- package/ShadersWGSL/highlights.fragment.js.map +1 -0
- package/ShadersWGSL/picking.fragment.d.ts +5 -0
- package/ShadersWGSL/picking.fragment.js +21 -0
- package/ShadersWGSL/picking.fragment.js.map +1 -0
- package/ShadersWGSL/picking.vertex.d.ts +15 -0
- package/ShadersWGSL/picking.vertex.js +43 -0
- package/ShadersWGSL/picking.vertex.js.map +1 -0
- package/ShadersWGSL/tonemap.fragment.d.ts +5 -0
- package/ShadersWGSL/tonemap.fragment.js +29 -0
- package/ShadersWGSL/tonemap.fragment.js.map +1 -0
- package/XR/features/WebXRControllerPointerSelection.js +1 -1
- package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,8 +4,6 @@ import type { PostProcessOptions } from "./postProcess";
|
|
|
4
4
|
import { PostProcess } from "./postProcess";
|
|
5
5
|
import type { Camera } from "../Cameras/camera";
|
|
6
6
|
import type { Effect } from "../Materials/effect";
|
|
7
|
-
import "../Shaders/kernelBlur.fragment";
|
|
8
|
-
import "../Shaders/kernelBlur.vertex";
|
|
9
7
|
import type { Scene } from "../scene";
|
|
10
8
|
import type { AbstractEngine } from "../Engines/abstractEngine.js";
|
|
11
9
|
/**
|
|
@@ -57,7 +55,7 @@ export declare class BlurPostProcess extends PostProcess {
|
|
|
57
55
|
* @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
|
|
58
56
|
*/
|
|
59
57
|
constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: AbstractEngine, reusable?: boolean, textureType?: number, defines?: string, _blockCompilation?: boolean, textureFormat?: number);
|
|
60
|
-
protected
|
|
58
|
+
protected _gatherImports(useWebGPU: boolean, list: Promise<any>[]): void;
|
|
61
59
|
/**
|
|
62
60
|
* Updates the effect with the current post process compile time values and recompiles the shader.
|
|
63
61
|
* @param defines Define statements that should be added at the beginning of the shader. (default: null)
|
|
@@ -2,8 +2,6 @@ import { __decorate } from "../tslib.es6.js";
|
|
|
2
2
|
import { PostProcess } from "./postProcess.js";
|
|
3
3
|
import { Texture } from "../Materials/Textures/texture.js";
|
|
4
4
|
|
|
5
|
-
import "../Shaders/kernelBlur.fragment.js";
|
|
6
|
-
import "../Shaders/kernelBlur.vertex.js";
|
|
7
5
|
import { RegisterClass } from "../Misc/typeStore.js";
|
|
8
6
|
import { serialize, serializeAsVector2 } from "../Misc/decorators.js";
|
|
9
7
|
import { SerializationHelper } from "../Misc/decorators.serialization.js";
|
|
@@ -89,15 +87,15 @@ export class BlurPostProcess extends PostProcess {
|
|
|
89
87
|
});
|
|
90
88
|
this.kernel = kernel;
|
|
91
89
|
}
|
|
92
|
-
|
|
90
|
+
_gatherImports(useWebGPU, list) {
|
|
93
91
|
if (useWebGPU) {
|
|
94
92
|
this._webGPUReady = true;
|
|
95
|
-
|
|
93
|
+
list.push(Promise.all([import("../ShadersWGSL/kernelBlur.fragment.js"), import("../ShadersWGSL/kernelBlur.vertex.js")]));
|
|
96
94
|
}
|
|
97
95
|
else {
|
|
98
|
-
|
|
96
|
+
list.push(Promise.all([import("../Shaders/kernelBlur.fragment.js"), import("../Shaders/kernelBlur.vertex.js")]));
|
|
99
97
|
}
|
|
100
|
-
super.
|
|
98
|
+
super._gatherImports(useWebGPU, list);
|
|
101
99
|
}
|
|
102
100
|
/**
|
|
103
101
|
* Updates the effect with the current post process compile time values and recompiles the shader.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blurPostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/blurPostProcess.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,gCAAgC,CAAC;AACxC,OAAO,8BAA8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OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACO,UAAU,CAAC,CAAS,EAAE,cAAc,GAAG,CAAC;QAC9C,OAAO,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACxD,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,eAAe,CACtB,iBAAiB,CAAC,IAAI,EACtB,iBAAiB,CAAC,SAAS,EAC3B,iBAAiB,CAAC,MAAM,EACxB,iBAAiB,CAAC,OAAO,EACzB,YAAY,EACZ,iBAAiB,CAAC,wBAAwB,EAC1C,KAAK,CAAC,SAAS,EAAE,EACjB,iBAAiB,CAAC,QAAQ,EAC1B,iBAAiB,CAAC,WAAW,EAC7B,SAAS,EACT,KAAK,CACR,CAAC;QACN,CAAC,EACD,iBAAiB,EACjB,KAAK,EACL,OAAO,CACV,CAAC;IACN,CAAC;CACJ;AA3Ua;IADT,SAAS,CAAC,QAAQ,CAAC;gDACM;AAGhB;IADT,SAAS,CAAC,aAAa,CAAC;qDACe;AAKjC;IADN,kBAAkB,EAAE;kDACK;AAqU9B,aAAa,CAAC,yBAAyB,EAAE,eAAe,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport type { Vector2 } from \"../Maths/math.vector\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { PostProcessOptions } from \"./postProcess\";\r\nimport { PostProcess } from \"./postProcess\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { Constants } from \"../Engines/constants\";\r\n\r\nimport \"../Shaders/kernelBlur.fragment\";\r\nimport \"../Shaders/kernelBlur.vertex\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport { serialize, serializeAsVector2 } from \"../Misc/decorators\";\r\nimport { SerializationHelper } from \"../Misc/decorators.serialization\";\r\n\r\nimport type { Scene } from \"../scene\";\r\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * The Blur Post Process which blurs an image based on a kernel and direction.\r\n * Can be used twice in x and y directions to perform a gaussian blur in two passes.\r\n */\r\nexport class BlurPostProcess extends PostProcess {\r\n @serialize(\"kernel\")\r\n protected _kernel: number;\r\n protected _idealKernel: number;\r\n @serialize(\"packedFloat\")\r\n protected _packedFloat: boolean = false;\r\n private _staticDefines: string = \"\";\r\n\r\n /** The direction in which to blur the image. */\r\n @serializeAsVector2()\r\n public direction: Vector2;\r\n\r\n /**\r\n * Sets the length in pixels of the blur sample region\r\n */\r\n public set kernel(v: number) {\r\n if (this._idealKernel === v) {\r\n return;\r\n }\r\n\r\n v = Math.max(v, 1);\r\n this._idealKernel = v;\r\n this._kernel = this._nearestBestKernel(v);\r\n if (!this._blockCompilation) {\r\n this._updateParameters();\r\n }\r\n }\r\n\r\n /**\r\n * Gets the length in pixels of the blur sample region\r\n */\r\n public get kernel(): number {\r\n return this._idealKernel;\r\n }\r\n\r\n /**\r\n * Sets whether or not the blur needs to unpack/repack floats\r\n */\r\n public set packedFloat(v: boolean) {\r\n if (this._packedFloat === v) {\r\n return;\r\n }\r\n this._packedFloat = v;\r\n if (!this._blockCompilation) {\r\n this._updateParameters();\r\n }\r\n }\r\n\r\n /**\r\n * Gets whether or not the blur is unpacking/repacking floats\r\n */\r\n public get packedFloat(): boolean {\r\n return this._packedFloat;\r\n }\r\n\r\n /**\r\n * Gets a string identifying the name of the class\r\n * @returns \"BlurPostProcess\" string\r\n */\r\n public override getClassName(): string {\r\n return \"BlurPostProcess\";\r\n }\r\n\r\n /**\r\n * Creates a new instance BlurPostProcess\r\n * @param name The name of the effect.\r\n * @param direction The direction in which to blur the image.\r\n * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.\r\n * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)\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 defines\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: false)\r\n * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)\r\n */\r\n constructor(\r\n name: string,\r\n direction: Vector2,\r\n kernel: number,\r\n options: number | PostProcessOptions,\r\n camera: Nullable<Camera>,\r\n samplingMode: number = Texture.BILINEAR_SAMPLINGMODE,\r\n engine?: AbstractEngine,\r\n reusable?: boolean,\r\n textureType = Constants.TEXTURETYPE_UNSIGNED_INT,\r\n defines = \"\",\r\n private _blockCompilation = false,\r\n textureFormat = Constants.TEXTUREFORMAT_RGBA\r\n ) {\r\n super(\r\n name,\r\n \"kernelBlur\",\r\n [\"delta\", \"direction\"],\r\n [\"circleOfConfusionSampler\"],\r\n options,\r\n camera,\r\n samplingMode,\r\n engine,\r\n reusable,\r\n null,\r\n textureType,\r\n \"kernelBlur\",\r\n { varyingCount: 0, depCount: 0 },\r\n true,\r\n textureFormat\r\n );\r\n this._staticDefines = defines;\r\n this.direction = direction;\r\n this.onApplyObservable.add((effect: Effect) => {\r\n if (this._outputTexture) {\r\n effect.setFloat2(\"delta\", (1 / this._outputTexture.width) * this.direction.x, (1 / this._outputTexture.height) * this.direction.y);\r\n } else {\r\n effect.setFloat2(\"delta\", (1 / this.width) * this.direction.x, (1 / this.height) * this.direction.y);\r\n }\r\n });\r\n\r\n this.kernel = kernel;\r\n }\r\n\r\n protected override async _initShaderSourceAsync(useWebGPU: boolean) {\r\n if (useWebGPU) {\r\n this._webGPUReady = true;\r\n await Promise.all([import(\"../ShadersWGSL/kernelBlur.fragment\"), import(\"../ShadersWGSL/kernelBlur.vertex\")]);\r\n } else {\r\n await Promise.all([import(\"../Shaders/kernelBlur.fragment\"), import(\"../Shaders/kernelBlur.vertex\")]);\r\n }\r\n\r\n super._initShaderSourceAsync(useWebGPU);\r\n }\r\n\r\n /**\r\n * Updates the effect with the current post process compile time values and recompiles the shader.\r\n * @param defines Define statements that should be added at the beginning of the shader. (default: null)\r\n * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)\r\n * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)\r\n * @param indexParameters The index parameters to be used for babylons include syntax \"#include<kernelBlurVaryingDeclaration>[0..varyingCount]\". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx\r\n * @param onCompiled Called when the shader has been compiled.\r\n * @param onError Called if there is an error when compiling a shader.\r\n */\r\n public override updateEffect(\r\n defines: Nullable<string> = null,\r\n uniforms: Nullable<string[]> = null,\r\n samplers: Nullable<string[]> = null,\r\n indexParameters?: any,\r\n onCompiled?: (effect: Effect) => void,\r\n onError?: (effect: Effect, errors: string) => void\r\n ) {\r\n this._updateParameters(onCompiled, onError);\r\n }\r\n\r\n protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void {\r\n // Generate sampling offsets and weights\r\n const N = this._kernel;\r\n const centerIndex = (N - 1) / 2;\r\n\r\n // Generate Gaussian sampling weights over kernel\r\n let offsets = [];\r\n let weights = [];\r\n let totalWeight = 0;\r\n for (let i = 0; i < N; i++) {\r\n const u = i / (N - 1);\r\n const w = this._gaussianWeight(u * 2.0 - 1);\r\n offsets[i] = i - centerIndex;\r\n weights[i] = w;\r\n totalWeight += w;\r\n }\r\n\r\n // Normalize weights\r\n for (let i = 0; i < weights.length; i++) {\r\n weights[i] /= totalWeight;\r\n }\r\n\r\n // Optimize: combine samples to take advantage of hardware linear sampling\r\n // Walk from left to center, combining pairs (symmetrically)\r\n const linearSamplingWeights = [];\r\n const linearSamplingOffsets = [];\r\n\r\n const linearSamplingMap = [];\r\n\r\n for (let i = 0; i <= centerIndex; i += 2) {\r\n const j = Math.min(i + 1, Math.floor(centerIndex));\r\n\r\n const singleCenterSample = i === j;\r\n\r\n if (singleCenterSample) {\r\n linearSamplingMap.push({ o: offsets[i], w: weights[i] });\r\n } else {\r\n const sharedCell = j === centerIndex;\r\n\r\n const weightLinear = weights[i] + weights[j] * (sharedCell ? 0.5 : 1);\r\n const offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);\r\n\r\n if (offsetLinear === 0) {\r\n linearSamplingMap.push({ o: offsets[i], w: weights[i] });\r\n linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });\r\n } else {\r\n linearSamplingMap.push({ o: offsetLinear, w: weightLinear });\r\n linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });\r\n }\r\n }\r\n }\r\n\r\n for (let i = 0; i < linearSamplingMap.length; i++) {\r\n linearSamplingOffsets[i] = linearSamplingMap[i].o;\r\n linearSamplingWeights[i] = linearSamplingMap[i].w;\r\n }\r\n\r\n // Replace with optimized\r\n offsets = linearSamplingOffsets;\r\n weights = linearSamplingWeights;\r\n\r\n // Generate shaders\r\n const maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors - (this.shaderLanguage === ShaderLanguage.WGSL ? 1 : 0); // Because of the additional builtins\r\n const freeVaryingVec2 = Math.max(maxVaryingRows, 0) - 1; // Because of sampleCenter\r\n\r\n let varyingCount = Math.min(offsets.length, freeVaryingVec2);\r\n\r\n let defines = \"\";\r\n defines += this._staticDefines;\r\n\r\n // The DOF fragment should ignore the center pixel when looping as it is handled manually in the fragment shader.\r\n if (this._staticDefines.indexOf(\"DOF\") != -1) {\r\n defines += `#define CENTER_WEIGHT ${this._glslFloat(weights[varyingCount - 1])}\\n`;\r\n varyingCount--;\r\n }\r\n\r\n for (let i = 0; i < varyingCount; i++) {\r\n defines += `#define KERNEL_OFFSET${i} ${this._glslFloat(offsets[i])}\\n`;\r\n defines += `#define KERNEL_WEIGHT${i} ${this._glslFloat(weights[i])}\\n`;\r\n }\r\n\r\n let depCount = 0;\r\n for (let i = freeVaryingVec2; i < offsets.length; i++) {\r\n defines += `#define KERNEL_DEP_OFFSET${depCount} ${this._glslFloat(offsets[i])}\\n`;\r\n defines += `#define KERNEL_DEP_WEIGHT${depCount} ${this._glslFloat(weights[i])}\\n`;\r\n depCount++;\r\n }\r\n\r\n if (this.packedFloat) {\r\n defines += `#define PACKEDFLOAT 1`;\r\n }\r\n\r\n this._blockCompilation = false;\r\n super.updateEffect(\r\n defines,\r\n null,\r\n null,\r\n {\r\n varyingCount: varyingCount,\r\n depCount: depCount,\r\n },\r\n onCompiled,\r\n onError\r\n );\r\n }\r\n\r\n /**\r\n * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.\r\n * Other odd kernels optimize correctly but require proportionally more samples, even kernels are\r\n * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we\r\n * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.\r\n * The gaps between physical kernels are compensated for in the weighting of the samples\r\n * @param idealKernel Ideal blur kernel.\r\n * @returns Nearest best kernel.\r\n */\r\n protected _nearestBestKernel(idealKernel: number): number {\r\n const v = Math.round(idealKernel);\r\n for (const k of [v, v - 1, v + 1, v - 2, v + 2]) {\r\n if (k % 2 !== 0 && Math.floor(k / 2) % 2 === 0 && k > 0) {\r\n return Math.max(k, 3);\r\n }\r\n }\r\n return Math.max(v, 3);\r\n }\r\n\r\n /**\r\n * Calculates the value of a Gaussian distribution with sigma 3 at a given point.\r\n * @param x The point on the Gaussian distribution to sample.\r\n * @returns the value of the Gaussian function at x.\r\n */\r\n protected _gaussianWeight(x: number): number {\r\n //reference: Engines/ImageProcessingBlur.cpp #dcc760\r\n // We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],\r\n // so we truncate at three standard deviations by setting stddev (sigma) to 1/3.\r\n // The choice of 3-sigma truncation is common but arbitrary, and means that the signal is\r\n // truncated at around 1.3% of peak strength.\r\n\r\n //the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size\r\n const sigma = 1 / 3;\r\n const denominator = Math.sqrt(2.0 * Math.PI) * sigma;\r\n const exponent = -((x * x) / (2.0 * sigma * sigma));\r\n const weight = (1.0 / denominator) * Math.exp(exponent);\r\n return weight;\r\n }\r\n\r\n /**\r\n * Generates a string that can be used as a floating point number in GLSL.\r\n * @param x Value to print.\r\n * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).\r\n * @returns GLSL float string.\r\n */\r\n protected _glslFloat(x: number, decimalFigures = 8) {\r\n return x.toFixed(decimalFigures).replace(/0+$/, \"\");\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<BlurPostProcess> {\r\n return SerializationHelper.Parse(\r\n () => {\r\n return new BlurPostProcess(\r\n parsedPostProcess.name,\r\n parsedPostProcess.direction,\r\n parsedPostProcess.kernel,\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 undefined,\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.BlurPostProcess\", BlurPostProcess);\r\n"]}
|
|
1
|
+
{"version":3,"file":"blurPostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/blurPostProcess.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,aAAa,E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AQ,CAAC,CAAC;QACxD,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACO,UAAU,CAAC,CAAS,EAAE,cAAc,GAAG,CAAC;QAC9C,OAAO,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACxD,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,eAAe,CACtB,iBAAiB,CAAC,IAAI,EACtB,iBAAiB,CAAC,SAAS,EAC3B,iBAAiB,CAAC,MAAM,EACxB,iBAAiB,CAAC,OAAO,EACzB,YAAY,EACZ,iBAAiB,CAAC,wBAAwB,EAC1C,KAAK,CAAC,SAAS,EAAE,EACjB,iBAAiB,CAAC,QAAQ,EAC1B,iBAAiB,CAAC,WAAW,EAC7B,SAAS,EACT,KAAK,CACR,CAAC;QACN,CAAC,EACD,iBAAiB,EACjB,KAAK,EACL,OAAO,CACV,CAAC;IACN,CAAC;CACJ;AA3Ua;IADT,SAAS,CAAC,QAAQ,CAAC;gDACM;AAGhB;IADT,SAAS,CAAC,aAAa,CAAC;qDACe;AAKjC;IADN,kBAAkB,EAAE;kDACK;AAqU9B,aAAa,CAAC,yBAAyB,EAAE,eAAe,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport type { Vector2 } from \"../Maths/math.vector\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { PostProcessOptions } from \"./postProcess\";\r\nimport { PostProcess } from \"./postProcess\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport { serialize, serializeAsVector2 } from \"../Misc/decorators\";\r\nimport { SerializationHelper } from \"../Misc/decorators.serialization\";\r\n\r\nimport type { Scene } from \"../scene\";\r\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * The Blur Post Process which blurs an image based on a kernel and direction.\r\n * Can be used twice in x and y directions to perform a gaussian blur in two passes.\r\n */\r\nexport class BlurPostProcess extends PostProcess {\r\n @serialize(\"kernel\")\r\n protected _kernel: number;\r\n protected _idealKernel: number;\r\n @serialize(\"packedFloat\")\r\n protected _packedFloat: boolean = false;\r\n private _staticDefines: string = \"\";\r\n\r\n /** The direction in which to blur the image. */\r\n @serializeAsVector2()\r\n public direction: Vector2;\r\n\r\n /**\r\n * Sets the length in pixels of the blur sample region\r\n */\r\n public set kernel(v: number) {\r\n if (this._idealKernel === v) {\r\n return;\r\n }\r\n\r\n v = Math.max(v, 1);\r\n this._idealKernel = v;\r\n this._kernel = this._nearestBestKernel(v);\r\n if (!this._blockCompilation) {\r\n this._updateParameters();\r\n }\r\n }\r\n\r\n /**\r\n * Gets the length in pixels of the blur sample region\r\n */\r\n public get kernel(): number {\r\n return this._idealKernel;\r\n }\r\n\r\n /**\r\n * Sets whether or not the blur needs to unpack/repack floats\r\n */\r\n public set packedFloat(v: boolean) {\r\n if (this._packedFloat === v) {\r\n return;\r\n }\r\n this._packedFloat = v;\r\n if (!this._blockCompilation) {\r\n this._updateParameters();\r\n }\r\n }\r\n\r\n /**\r\n * Gets whether or not the blur is unpacking/repacking floats\r\n */\r\n public get packedFloat(): boolean {\r\n return this._packedFloat;\r\n }\r\n\r\n /**\r\n * Gets a string identifying the name of the class\r\n * @returns \"BlurPostProcess\" string\r\n */\r\n public override getClassName(): string {\r\n return \"BlurPostProcess\";\r\n }\r\n\r\n /**\r\n * Creates a new instance BlurPostProcess\r\n * @param name The name of the effect.\r\n * @param direction The direction in which to blur the image.\r\n * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.\r\n * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)\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 defines\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: false)\r\n * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)\r\n */\r\n constructor(\r\n name: string,\r\n direction: Vector2,\r\n kernel: number,\r\n options: number | PostProcessOptions,\r\n camera: Nullable<Camera>,\r\n samplingMode: number = Texture.BILINEAR_SAMPLINGMODE,\r\n engine?: AbstractEngine,\r\n reusable?: boolean,\r\n textureType = Constants.TEXTURETYPE_UNSIGNED_INT,\r\n defines = \"\",\r\n private _blockCompilation = false,\r\n textureFormat = Constants.TEXTUREFORMAT_RGBA\r\n ) {\r\n super(\r\n name,\r\n \"kernelBlur\",\r\n [\"delta\", \"direction\"],\r\n [\"circleOfConfusionSampler\"],\r\n options,\r\n camera,\r\n samplingMode,\r\n engine,\r\n reusable,\r\n null,\r\n textureType,\r\n \"kernelBlur\",\r\n { varyingCount: 0, depCount: 0 },\r\n true,\r\n textureFormat\r\n );\r\n this._staticDefines = defines;\r\n this.direction = direction;\r\n this.onApplyObservable.add((effect: Effect) => {\r\n if (this._outputTexture) {\r\n effect.setFloat2(\"delta\", (1 / this._outputTexture.width) * this.direction.x, (1 / this._outputTexture.height) * this.direction.y);\r\n } else {\r\n effect.setFloat2(\"delta\", (1 / this.width) * this.direction.x, (1 / this.height) * this.direction.y);\r\n }\r\n });\r\n\r\n this.kernel = kernel;\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/kernelBlur.fragment\"), import(\"../ShadersWGSL/kernelBlur.vertex\")]));\r\n } else {\r\n list.push(Promise.all([import(\"../Shaders/kernelBlur.fragment\"), import(\"../Shaders/kernelBlur.vertex\")]));\r\n }\r\n\r\n super._gatherImports(useWebGPU, list);\r\n }\r\n\r\n /**\r\n * Updates the effect with the current post process compile time values and recompiles the shader.\r\n * @param defines Define statements that should be added at the beginning of the shader. (default: null)\r\n * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)\r\n * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)\r\n * @param indexParameters The index parameters to be used for babylons include syntax \"#include<kernelBlurVaryingDeclaration>[0..varyingCount]\". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx\r\n * @param onCompiled Called when the shader has been compiled.\r\n * @param onError Called if there is an error when compiling a shader.\r\n */\r\n public override updateEffect(\r\n defines: Nullable<string> = null,\r\n uniforms: Nullable<string[]> = null,\r\n samplers: Nullable<string[]> = null,\r\n indexParameters?: any,\r\n onCompiled?: (effect: Effect) => void,\r\n onError?: (effect: Effect, errors: string) => void\r\n ) {\r\n this._updateParameters(onCompiled, onError);\r\n }\r\n\r\n protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void {\r\n // Generate sampling offsets and weights\r\n const N = this._kernel;\r\n const centerIndex = (N - 1) / 2;\r\n\r\n // Generate Gaussian sampling weights over kernel\r\n let offsets = [];\r\n let weights = [];\r\n let totalWeight = 0;\r\n for (let i = 0; i < N; i++) {\r\n const u = i / (N - 1);\r\n const w = this._gaussianWeight(u * 2.0 - 1);\r\n offsets[i] = i - centerIndex;\r\n weights[i] = w;\r\n totalWeight += w;\r\n }\r\n\r\n // Normalize weights\r\n for (let i = 0; i < weights.length; i++) {\r\n weights[i] /= totalWeight;\r\n }\r\n\r\n // Optimize: combine samples to take advantage of hardware linear sampling\r\n // Walk from left to center, combining pairs (symmetrically)\r\n const linearSamplingWeights = [];\r\n const linearSamplingOffsets = [];\r\n\r\n const linearSamplingMap = [];\r\n\r\n for (let i = 0; i <= centerIndex; i += 2) {\r\n const j = Math.min(i + 1, Math.floor(centerIndex));\r\n\r\n const singleCenterSample = i === j;\r\n\r\n if (singleCenterSample) {\r\n linearSamplingMap.push({ o: offsets[i], w: weights[i] });\r\n } else {\r\n const sharedCell = j === centerIndex;\r\n\r\n const weightLinear = weights[i] + weights[j] * (sharedCell ? 0.5 : 1);\r\n const offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);\r\n\r\n if (offsetLinear === 0) {\r\n linearSamplingMap.push({ o: offsets[i], w: weights[i] });\r\n linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });\r\n } else {\r\n linearSamplingMap.push({ o: offsetLinear, w: weightLinear });\r\n linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });\r\n }\r\n }\r\n }\r\n\r\n for (let i = 0; i < linearSamplingMap.length; i++) {\r\n linearSamplingOffsets[i] = linearSamplingMap[i].o;\r\n linearSamplingWeights[i] = linearSamplingMap[i].w;\r\n }\r\n\r\n // Replace with optimized\r\n offsets = linearSamplingOffsets;\r\n weights = linearSamplingWeights;\r\n\r\n // Generate shaders\r\n const maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors - (this.shaderLanguage === ShaderLanguage.WGSL ? 1 : 0); // Because of the additional builtins\r\n const freeVaryingVec2 = Math.max(maxVaryingRows, 0) - 1; // Because of sampleCenter\r\n\r\n let varyingCount = Math.min(offsets.length, freeVaryingVec2);\r\n\r\n let defines = \"\";\r\n defines += this._staticDefines;\r\n\r\n // The DOF fragment should ignore the center pixel when looping as it is handled manually in the fragment shader.\r\n if (this._staticDefines.indexOf(\"DOF\") != -1) {\r\n defines += `#define CENTER_WEIGHT ${this._glslFloat(weights[varyingCount - 1])}\\n`;\r\n varyingCount--;\r\n }\r\n\r\n for (let i = 0; i < varyingCount; i++) {\r\n defines += `#define KERNEL_OFFSET${i} ${this._glslFloat(offsets[i])}\\n`;\r\n defines += `#define KERNEL_WEIGHT${i} ${this._glslFloat(weights[i])}\\n`;\r\n }\r\n\r\n let depCount = 0;\r\n for (let i = freeVaryingVec2; i < offsets.length; i++) {\r\n defines += `#define KERNEL_DEP_OFFSET${depCount} ${this._glslFloat(offsets[i])}\\n`;\r\n defines += `#define KERNEL_DEP_WEIGHT${depCount} ${this._glslFloat(weights[i])}\\n`;\r\n depCount++;\r\n }\r\n\r\n if (this.packedFloat) {\r\n defines += `#define PACKEDFLOAT 1`;\r\n }\r\n\r\n this._blockCompilation = false;\r\n super.updateEffect(\r\n defines,\r\n null,\r\n null,\r\n {\r\n varyingCount: varyingCount,\r\n depCount: depCount,\r\n },\r\n onCompiled,\r\n onError\r\n );\r\n }\r\n\r\n /**\r\n * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.\r\n * Other odd kernels optimize correctly but require proportionally more samples, even kernels are\r\n * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we\r\n * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.\r\n * The gaps between physical kernels are compensated for in the weighting of the samples\r\n * @param idealKernel Ideal blur kernel.\r\n * @returns Nearest best kernel.\r\n */\r\n protected _nearestBestKernel(idealKernel: number): number {\r\n const v = Math.round(idealKernel);\r\n for (const k of [v, v - 1, v + 1, v - 2, v + 2]) {\r\n if (k % 2 !== 0 && Math.floor(k / 2) % 2 === 0 && k > 0) {\r\n return Math.max(k, 3);\r\n }\r\n }\r\n return Math.max(v, 3);\r\n }\r\n\r\n /**\r\n * Calculates the value of a Gaussian distribution with sigma 3 at a given point.\r\n * @param x The point on the Gaussian distribution to sample.\r\n * @returns the value of the Gaussian function at x.\r\n */\r\n protected _gaussianWeight(x: number): number {\r\n //reference: Engines/ImageProcessingBlur.cpp #dcc760\r\n // We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],\r\n // so we truncate at three standard deviations by setting stddev (sigma) to 1/3.\r\n // The choice of 3-sigma truncation is common but arbitrary, and means that the signal is\r\n // truncated at around 1.3% of peak strength.\r\n\r\n //the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size\r\n const sigma = 1 / 3;\r\n const denominator = Math.sqrt(2.0 * Math.PI) * sigma;\r\n const exponent = -((x * x) / (2.0 * sigma * sigma));\r\n const weight = (1.0 / denominator) * Math.exp(exponent);\r\n return weight;\r\n }\r\n\r\n /**\r\n * Generates a string that can be used as a floating point number in GLSL.\r\n * @param x Value to print.\r\n * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).\r\n * @returns GLSL float string.\r\n */\r\n protected _glslFloat(x: number, decimalFigures = 8) {\r\n return x.toFixed(decimalFigures).replace(/0+$/, \"\");\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<BlurPostProcess> {\r\n return SerializationHelper.Parse(\r\n () => {\r\n return new BlurPostProcess(\r\n parsedPostProcess.name,\r\n parsedPostProcess.direction,\r\n parsedPostProcess.kernel,\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 undefined,\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.BlurPostProcess\", BlurPostProcess);\r\n"]}
|
|
@@ -48,7 +48,7 @@ export declare class ChromaticAberrationPostProcess extends PostProcess {
|
|
|
48
48
|
* @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: false)
|
|
49
49
|
*/
|
|
50
50
|
constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: AbstractEngine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
|
|
51
|
-
protected
|
|
51
|
+
protected _gatherImports(useWebGPU: boolean, list: Promise<any>[]): void;
|
|
52
52
|
/**
|
|
53
53
|
* @internal
|
|
54
54
|
*/
|
|
@@ -58,15 +58,15 @@ export class ChromaticAberrationPostProcess extends PostProcess {
|
|
|
58
58
|
effect.setFloat2("centerPosition", this.centerPosition.x, this.centerPosition.y);
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
_gatherImports(useWebGPU, list) {
|
|
62
62
|
if (useWebGPU) {
|
|
63
63
|
this._webGPUReady = true;
|
|
64
|
-
|
|
64
|
+
list.push(Promise.all([import("../ShadersWGSL/chromaticAberration.fragment.js")]));
|
|
65
65
|
}
|
|
66
66
|
else {
|
|
67
|
-
|
|
67
|
+
list.push(Promise.all([import("../Shaders/chromaticAberration.fragment.js")]));
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
super._gatherImports(useWebGPU, list);
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
72
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chromaticAberrationPostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/chromaticAberrationPostProcess.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAIvE;;GAEG;AACH,MAAM,OAAO,8BAA+B,SAAQ,WAAW;IAiC3D;;;OAGG;IACa,YAAY;QACxB,OAAO,gCAAgC,CAAC;IAC5C,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,YACI,IAAY,EACZ,WAAmB,EACnB,YAA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SAAS,CAAC,gBAAgB,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;QACrF,CAAC,CAAC,CAAC;IACP,CAAC;IAEkB,
|
|
1
|
+
{"version":3,"file":"chromaticAberrationPostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/chromaticAberrationPostProcess.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAIvE;;GAEG;AACH,MAAM,OAAO,8BAA+B,SAAQ,WAAW;IAiC3D;;;OAGG;IACa,YAAY;QACxB,OAAO,gCAAgC,CAAC;IAC5C,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,YACI,IAAY,EACZ,WAAmB,EACnB,YAAoB,EACpB,OAAoC,EACpC,MAAwB,EACxB,YAAqB,EACrB,MAAuB,EACvB,QAAkB,EAClB,cAAsB,SAAS,CAAC,wBAAwB,EACxD,gBAAgB,GAAG,KAAK;QAExB,KAAK,CACD,IAAI,EACJ,qBAAqB,EACrB,CAAC,sBAAsB,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,iBAAiB,EAAE,gBAAgB,CAAC,EAC3G,EAAE,EACF,OAAO,EACP,MAAM,EACN,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,SAAS,EACT,IAAI,EACJ,gBAAgB,CACnB,CAAC;QAhFN;;WAEG;QAEH,qBAAgB,GAAG,EAAE,CAAC;QAEtB;;WAEG;QAEH,oBAAe,GAA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AC/E;QAED,KAAK,CAAC,cAAc,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC1C,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,8BAA8B,CACrC,iBAAiB,CAAC,IAAI,EACtB,iBAAiB,CAAC,WAAW,EAC7B,iBAAiB,CAAC,YAAY,EAC9B,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;AA9HG;IADC,SAAS,EAAE;wEACU;AAMtB;IADC,SAAS,EAAE;uEACQ;AAMpB;IADC,SAAS,EAAE;iEAC0B;AAMtC;IADC,SAAS,EAAE;sEAC2B;AAIvC;IADC,SAAS,EAAE;mEACQ;AAIpB;IADC,SAAS,EAAE;oEACS;AAsGzB,aAAa,CAAC,wCAAwC,EAAE,8BAA8B,CAAC,CAAC","sourcesContent":["import { Vector2 } from \"../Maths/math.vector\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { PostProcessOptions } from \"./postProcess\";\r\nimport { PostProcess } from \"./postProcess\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport { Constants } from \"../Engines/constants\";\r\n\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport { serialize } from \"../Misc/decorators\";\r\nimport { SerializationHelper } from \"../Misc/decorators.serialization\";\r\n\r\nimport type { Scene } from \"../scene\";\r\n\r\n/**\r\n * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen\r\n */\r\nexport class ChromaticAberrationPostProcess extends PostProcess {\r\n /**\r\n * The amount of separation of rgb channels (default: 30)\r\n */\r\n @serialize()\r\n aberrationAmount = 30;\r\n\r\n /**\r\n * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)\r\n */\r\n @serialize()\r\n radialIntensity = 0;\r\n\r\n /**\r\n * The normalized direction in which the rgb channels should be separated. If set to 0,0 radial direction will be used. (default: Vector2(0.707,0.707))\r\n */\r\n @serialize()\r\n direction = new Vector2(0.707, 0.707);\r\n\r\n /**\r\n * The center position where the radialIntensity should be around. [0.5,0.5 is center of screen, 1,1 is top right corner] (default: Vector2(0.5 ,0.5))\r\n */\r\n @serialize()\r\n centerPosition = new Vector2(0.5, 0.5);\r\n\r\n /** The width of the screen to apply the effect on */\r\n @serialize()\r\n screenWidth: number;\r\n\r\n /** The height of the screen to apply the effect on */\r\n @serialize()\r\n screenHeight: number;\r\n\r\n /**\r\n * Gets a string identifying the name of the class\r\n * @returns \"ChromaticAberrationPostProcess\" string\r\n */\r\n public override getClassName(): string {\r\n return \"ChromaticAberrationPostProcess\";\r\n }\r\n\r\n /**\r\n * Creates a new instance ChromaticAberrationPostProcess\r\n * @param name The name of the effect.\r\n * @param screenWidth The width of the screen to apply the effect on.\r\n * @param screenHeight The height of the screen to apply the effect on.\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: false)\r\n */\r\n constructor(\r\n name: string,\r\n screenWidth: number,\r\n screenHeight: number,\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_INT,\r\n blockCompilation = false\r\n ) {\r\n super(\r\n name,\r\n \"chromaticAberration\",\r\n [\"chromatic_aberration\", \"screen_width\", \"screen_height\", \"direction\", \"radialIntensity\", \"centerPosition\"],\r\n [],\r\n options,\r\n camera,\r\n samplingMode,\r\n engine,\r\n reusable,\r\n null,\r\n textureType,\r\n undefined,\r\n null,\r\n blockCompilation\r\n );\r\n\r\n this.screenWidth = screenWidth;\r\n this.screenHeight = screenHeight;\r\n\r\n this.onApplyObservable.add((effect: Effect) => {\r\n effect.setFloat(\"chromatic_aberration\", this.aberrationAmount);\r\n effect.setFloat(\"screen_width\", screenWidth);\r\n effect.setFloat(\"screen_height\", screenHeight);\r\n effect.setFloat(\"radialIntensity\", this.radialIntensity);\r\n effect.setFloat2(\"direction\", this.direction.x, this.direction.y);\r\n effect.setFloat2(\"centerPosition\", this.centerPosition.x, this.centerPosition.y);\r\n });\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/chromaticAberration.fragment\")]));\r\n } else {\r\n list.push(Promise.all([import(\"../Shaders/chromaticAberration.fragment\")]));\r\n }\r\n\r\n super._gatherImports(useWebGPU, list);\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<ChromaticAberrationPostProcess> {\r\n return SerializationHelper.Parse(\r\n () => {\r\n return new ChromaticAberrationPostProcess(\r\n parsedPostProcess.name,\r\n parsedPostProcess.screenWidth,\r\n parsedPostProcess.screenHeight,\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.ChromaticAberrationPostProcess\", ChromaticAberrationPostProcess);\r\n"]}
|
|
@@ -43,7 +43,7 @@ export declare class CircleOfConfusionPostProcess extends PostProcess {
|
|
|
43
43
|
* @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: false)
|
|
44
44
|
*/
|
|
45
45
|
constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: AbstractEngine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
|
|
46
|
-
protected
|
|
46
|
+
protected _gatherImports(useWebGPU: boolean, list: Promise<any>[]): void;
|
|
47
47
|
/**
|
|
48
48
|
* Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.
|
|
49
49
|
*/
|
|
@@ -62,15 +62,15 @@ export class CircleOfConfusionPostProcess extends PostProcess {
|
|
|
62
62
|
effect.setFloat2("cameraMinMaxZ", activeCamera.minZ, activeCamera.maxZ - activeCamera.minZ);
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
_gatherImports(useWebGPU, list) {
|
|
66
66
|
if (useWebGPU) {
|
|
67
67
|
this._webGPUReady = true;
|
|
68
|
-
|
|
68
|
+
list.push(import("../ShadersWGSL/circleOfConfusion.fragment.js"));
|
|
69
69
|
}
|
|
70
70
|
else {
|
|
71
|
-
|
|
71
|
+
list.push(import("../Shaders/circleOfConfusion.fragment.js"));
|
|
72
72
|
}
|
|
73
|
-
super.
|
|
73
|
+
super._gatherImports(useWebGPU, list);
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
76
|
* Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"circleOfConfusionPostProcess.js","sourceRoot":"","sources":["../../../../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AC,CAAC;YACrD,MAAM,CAAC,QAAQ,CAAC,mBAAmB,EAAE,iBAAiB,CAAC,CAAC;YACxD,MAAM,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,YAAa,CAAC;YACtD,MAAM,CAAC,SAAS,CAAC,eAAe,EAAE,YAAY,CAAC,IAAI,EAAE,YAAY,CAAC,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QAChG,CAAC,CAAC,CAAC;IACP,CAAC;IAEkB,cAAc,CAAC,SAAkB,EAAE,IAAoB;QACtE,IAAI,SAAS,EAAE;YACX,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,2CAA2C,CAAC,CAAC,CAAC;SAClE;aAAM;YACH,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,uCAAuC,CAAC,CAAC,CAAC;SAC9D;QAED,KAAK,CAAC,cAAc,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,IAAW,YAAY,CAAC,KAA0B;QAC9C,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;IAC/B,CAAC;CACJ;AArGU;IADN,SAAS,EAAE;8DACS;AAKd;IADN,SAAS,EAAE;2DACO;AAKZ;IADN,SAAS,EAAE;mEACgB;AAKrB;IADN,SAAS,EAAE;iEACY;AAwF5B,aAAa,CAAC,sCAAsC,EAAE,4BAA4B,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { PostProcessOptions } from \"./postProcess\";\r\nimport { PostProcess } from \"./postProcess\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport type { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { Constants } from \"../Engines/constants\";\r\n\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport { serialize } from \"../Misc/decorators\";\r\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\n\r\n/**\r\n * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion\r\n */\r\nexport class CircleOfConfusionPostProcess extends PostProcess {\r\n /**\r\n * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diameter of the resulting aperture can be computed by lensSize/fStop.\r\n */\r\n @serialize()\r\n public lensSize = 50;\r\n /**\r\n * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)\r\n */\r\n @serialize()\r\n public fStop = 1.4;\r\n /**\r\n * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)\r\n */\r\n @serialize()\r\n public focusDistance = 2000;\r\n /**\r\n * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)\r\n */\r\n @serialize()\r\n public focalLength = 50;\r\n\r\n /**\r\n * Gets a string identifying the name of the class\r\n * @returns \"CircleOfConfusionPostProcess\" string\r\n */\r\n public override getClassName(): string {\r\n return \"CircleOfConfusionPostProcess\";\r\n }\r\n\r\n private _depthTexture: Nullable<RenderTargetTexture> = null;\r\n /**\r\n * Creates a new instance CircleOfConfusionPostProcess\r\n * @param name The name of the effect.\r\n * @param depthTexture The depth texture of the scene to compute the circle of confusion. This must be set in order for this to function but may be set after initialization if needed.\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: false)\r\n */\r\n constructor(\r\n name: string,\r\n depthTexture: Nullable<RenderTargetTexture>,\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 = Constants.TEXTURETYPE_UNSIGNED_INT,\r\n blockCompilation = false\r\n ) {\r\n super(\r\n name,\r\n \"circleOfConfusion\",\r\n [\"cameraMinMaxZ\", \"focusDistance\", \"cocPrecalculation\"],\r\n [\"depthSampler\"],\r\n options,\r\n camera,\r\n samplingMode,\r\n engine,\r\n reusable,\r\n null,\r\n textureType,\r\n undefined,\r\n null,\r\n blockCompilation\r\n );\r\n this._depthTexture = depthTexture;\r\n this.onApplyObservable.add((effect: Effect) => {\r\n if (!this._depthTexture) {\r\n Logger.Warn(\"No depth texture set on CircleOfConfusionPostProcess\");\r\n return;\r\n }\r\n effect.setTexture(\"depthSampler\", this._depthTexture);\r\n\r\n // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html\r\n const aperture = this.lensSize / this.fStop;\r\n const cocPrecalculation = (aperture * this.focalLength) / (this.focusDistance - this.focalLength); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]\r\n\r\n effect.setFloat(\"focusDistance\", this.focusDistance);\r\n effect.setFloat(\"cocPrecalculation\", cocPrecalculation);\r\n const activeCamera = this._depthTexture.activeCamera!;\r\n effect.setFloat2(\"cameraMinMaxZ\", activeCamera.minZ, activeCamera.maxZ - activeCamera.minZ);\r\n });\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(import(\"../ShadersWGSL/circleOfConfusion.fragment\"));\r\n } else {\r\n list.push(import(\"../Shaders/circleOfConfusion.fragment\"));\r\n }\r\n\r\n super._gatherImports(useWebGPU, list);\r\n }\r\n\r\n /**\r\n * Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.\r\n */\r\n public set depthTexture(value: RenderTargetTexture) {\r\n this._depthTexture = value;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.CircleOfConfusionPostProcess\", CircleOfConfusionPostProcess);\r\n"]}
|
|
@@ -31,7 +31,7 @@ export declare class ColorCorrectionPostProcess extends PostProcess {
|
|
|
31
31
|
*/
|
|
32
32
|
getClassName(): string;
|
|
33
33
|
constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: AbstractEngine, reusable?: boolean);
|
|
34
|
-
protected
|
|
34
|
+
protected _gatherImports(useWebGPU: boolean, list: Promise<any>[]): void;
|
|
35
35
|
/**
|
|
36
36
|
* @internal
|
|
37
37
|
*/
|
|
@@ -39,15 +39,15 @@ export class ColorCorrectionPostProcess extends PostProcess {
|
|
|
39
39
|
effect.setTexture("colorTable", this._colorTableTexture);
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
_gatherImports(useWebGPU, list) {
|
|
43
43
|
if (useWebGPU) {
|
|
44
44
|
this._webGPUReady = true;
|
|
45
|
-
|
|
45
|
+
list.push(Promise.all([import("../ShadersWGSL/colorCorrection.fragment.js")]));
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
|
-
|
|
48
|
+
list.push(Promise.all([import("../Shaders/colorCorrection.fragment.js")]));
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
super._gatherImports(useWebGPU, list);
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
53
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorCorrectionPostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/colorCorrectionPostProcess.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAIxD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAKvE;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,0BAA2B,SAAQ,WAAW;IASvD;;;OAGG;IACa,YAAY;QACxB,OAAO,4BAA4B,CAAC;IACxC,CAAC;IAED,YACI,IAAY,EACZ,aAAqB,EACrB,OAAoC,EACpC,MAAwB,EACxB,YAAqB,EACrB,MAAuB,EACvB,QAAkB;QAElB,KAAK,CAAC,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;QAEtG,MAAM,KAAK,GAAG,MAAM,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC;QACzC,IAAI,CAAC,kBAAkB,GAAG,IAAI,OAAO,CAAC,aAAa,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;QACzG,IAAI,CAAC,kBAAkB,CAAC,yBAAyB,GAAG,CAAC,CAAC;QACtD,IAAI,CAAC,kBAAkB,CAAC,KAAK,GAAG,OAAO,CAAC,iBAAiB,CAAC;QAC1D,IAAI,CAAC,kBAAkB,CAAC,KAAK,GAAG,OAAO,CAAC,iBAAiB,CAAC;QAE1D,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QAEnC,IAAI,CAAC,OAAO,GAAG,CAAC,MAAc,EAAE,EAAE;YAC9B,MAAM,CAAC,UAAU,CAAC,YAAY,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC7D,CAAC,CAAC;IACN,CAAC;IAEkB,
|
|
1
|
+
{"version":3,"file":"colorCorrectionPostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/colorCorrectionPostProcess.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAIxD,OAAO,EAAE,aA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CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,yCAAyC,CAAC,CAAC,CAAC,CAAC,CAAC;SAC/E;aAAM;YACH,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,qCAAqC,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3E;QAED,KAAK,CAAC,cAAc,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC1C,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,0BAA0B,CACjC,iBAAiB,CAAC,IAAI,EACtB,iBAAiB,CAAC,aAAa,EAC/B,iBAAiB,CAAC,OAAO,EACzB,YAAY,EACZ,iBAAiB,CAAC,wBAAwB,EAC1C,KAAK,CAAC,SAAS,EAAE,EACjB,iBAAiB,CAAC,QAAQ,CAC7B,CAAC;QACN,CAAC,EACD,iBAAiB,EACjB,KAAK,EACL,OAAO,CACV,CAAC;IACN,CAAC;CACJ;AAlEU;IADN,SAAS,EAAE;iEACiB;AAoEjC,aAAa,CAAC,oCAAoC,EAAE,0BAA0B,CAAC,CAAC","sourcesContent":["import type { PostProcessOptions } from \"./postProcess\";\r\nimport { PostProcess } from \"./postProcess\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\n\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport { serialize } from \"../Misc/decorators\";\r\nimport { SerializationHelper } from \"../Misc/decorators.serialization\";\r\nimport type { Nullable } from \"../types\";\r\n\r\nimport type { Scene } from \"../scene\";\r\n\r\n/**\r\n *\r\n * This post-process allows the modification of rendered colors by using\r\n * a 'look-up table' (LUT). This effect is also called Color Grading.\r\n *\r\n * The object needs to be provided an url to a texture containing the color\r\n * look-up table: the texture must be 256 pixels wide and 16 pixels high.\r\n * Use an image editing software to tweak the LUT to match your needs.\r\n *\r\n * For an example of a color LUT, see here:\r\n * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png\r\n * For explanations on color grading, see here:\r\n * @see http://udn.epicgames.com/Three/ColorGrading.html\r\n *\r\n */\r\nexport class ColorCorrectionPostProcess extends PostProcess {\r\n private _colorTableTexture: Texture;\r\n\r\n /**\r\n * Gets the color table url used to create the LUT texture\r\n */\r\n @serialize()\r\n public colorTableUrl: string;\r\n\r\n /**\r\n * Gets a string identifying the name of the class\r\n * @returns \"ColorCorrectionPostProcess\" string\r\n */\r\n public override getClassName(): string {\r\n return \"ColorCorrectionPostProcess\";\r\n }\r\n\r\n constructor(\r\n name: string,\r\n colorTableUrl: string,\r\n options: number | PostProcessOptions,\r\n camera: Nullable<Camera>,\r\n samplingMode?: number,\r\n engine?: AbstractEngine,\r\n reusable?: boolean\r\n ) {\r\n super(name, \"colorCorrection\", null, [\"colorTable\"], options, camera, samplingMode, engine, reusable);\r\n\r\n const scene = camera?.getScene() || null;\r\n this._colorTableTexture = new Texture(colorTableUrl, scene, true, false, Texture.TRILINEAR_SAMPLINGMODE);\r\n this._colorTableTexture.anisotropicFilteringLevel = 1;\r\n this._colorTableTexture.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n this._colorTableTexture.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n\r\n this.colorTableUrl = colorTableUrl;\r\n\r\n this.onApply = (effect: Effect) => {\r\n effect.setTexture(\"colorTable\", this._colorTableTexture);\r\n };\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/colorCorrection.fragment\")]));\r\n } else {\r\n list.push(Promise.all([import(\"../Shaders/colorCorrection.fragment\")]));\r\n }\r\n\r\n super._gatherImports(useWebGPU, list);\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<ColorCorrectionPostProcess> {\r\n return SerializationHelper.Parse(\r\n () => {\r\n return new ColorCorrectionPostProcess(\r\n parsedPostProcess.name,\r\n parsedPostProcess.colorTableUrl,\r\n parsedPostProcess.options,\r\n targetCamera,\r\n parsedPostProcess.renderTargetSamplingMode,\r\n scene.getEngine(),\r\n parsedPostProcess.reusable\r\n );\r\n },\r\n parsedPostProcess,\r\n scene,\r\n rootUrl\r\n );\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ColorCorrectionPostProcess\", ColorCorrectionPostProcess);\r\n"]}
|
|
@@ -29,7 +29,7 @@ export declare class ConvolutionPostProcess extends PostProcess {
|
|
|
29
29
|
* @param textureType Type of textures used when performing the post process. (default: 0)
|
|
30
30
|
*/
|
|
31
31
|
constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: AbstractEngine, reusable?: boolean, textureType?: number);
|
|
32
|
-
protected
|
|
32
|
+
protected _gatherImports(useWebGPU: boolean, list: Promise<any>[]): void;
|
|
33
33
|
/**
|
|
34
34
|
* @internal
|
|
35
35
|
*/
|
|
@@ -36,15 +36,15 @@ export class ConvolutionPostProcess extends PostProcess {
|
|
|
36
36
|
effect.setArray("kernel", this.kernel);
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
_gatherImports(useWebGPU, list) {
|
|
40
40
|
if (useWebGPU) {
|
|
41
41
|
this._webGPUReady = true;
|
|
42
|
-
|
|
42
|
+
list.push(Promise.all([import("../ShadersWGSL/convolution.fragment.js")]));
|
|
43
43
|
}
|
|
44
44
|
else {
|
|
45
|
-
|
|
45
|
+
list.push(Promise.all([import("../Shaders/convolution.fragment.js")]));
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
super._gatherImports(useWebGPU, list);
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convolutionPostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/convolutionPostProcess.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAK5C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAIvE;;;;GAIG;AACH,MAAM,OAAO,sBAAuB,SAAQ,WAAW;IAKnD;;;OAGG;IACa,YAAY;QACxB,OAAO,wBAAwB,CAAC;IACpC,CAAC;IAED;;;;;;;;;;OAUG;IACH,YACI,IAAY,EACZ,MAAgB,EAChB,OAAoC,EACpC,MAAwB,EACxB,YAAqB,EACrB,MAAuB,EACvB,QAAkB,EAClB,cAAsB,SAAS,CAAC,wBAAwB;QAExD,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;QAC/H,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,CAAC,MAAc,EAAE,EAAE;YAC9B,MAAM,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YACxD,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3C,CAAC,CAAC;IACN,CAAC;IAEkB,
|
|
1
|
+
{"version":3,"file":"convolutionPostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/convolutionPostProcess.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAK5C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAIvE;;;;GAIG;AACH,MAAM,OAAO,sBAAuB,SAAQ,WAAW;IAKnD;;;OAGG;IACa,YAAY;QACxB,OAAO,wBAAwB,CAAC;IACpC,CAAC;IAED;;;;;;;;;;OAUG;IACH,YACI,IAAY,EACZ,MAAgB,EAChB,OAAoC,EACpC,MAAwB,EACxB,YAAqB,EACrB,MAAuB,EACvB,QAAkB,EAClB,cAAsB,SAAS,CAAC,wBAAwB;QAExD,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;QAC/H,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,CAAC,MAAc,EAAE,EAAE;YAC9B,MAAM,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YACxD,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3C,CAAC,CAAC;IACN,CAAC;IAEkB,cAAc,CAAC,SAAkB,EAAE,IAAoB;QACtE,IAAI,SAAS,EAAE;YACX,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC,IAA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AAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACtE;;GAEG;AACW,oCAAa,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9D;;GAEG;AACW,mCAAY,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC5D;;GAEG;AACW,qCAAc,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAjGpD;IADN,SAAS,EAAE;sDACY;AAoG5B,aAAa,CAAC,gCAAgC,EAAE,sBAAsB,CAAC,CAAC","sourcesContent":["import type { PostProcessOptions } from \"./postProcess\";\r\nimport { PostProcess } from \"./postProcess\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { Constants } from \"../Engines/constants\";\r\n\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport { serialize } from \"../Misc/decorators\";\r\nimport { SerializationHelper } from \"../Misc/decorators.serialization\";\r\n\r\nimport type { Scene } from \"../scene\";\r\n\r\n/**\r\n * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the\r\n * input texture to perform effects such as edge detection or sharpening\r\n * See http://en.wikipedia.org/wiki/Kernel_(image_processing)\r\n */\r\nexport class ConvolutionPostProcess extends PostProcess {\r\n /** Array of 9 values corresponding to the 3x3 kernel to be applied */\r\n @serialize()\r\n public kernel: number[];\r\n\r\n /**\r\n * Gets a string identifying the name of the class\r\n * @returns \"ConvolutionPostProcess\" string\r\n */\r\n public override getClassName(): string {\r\n return \"ConvolutionPostProcess\";\r\n }\r\n\r\n /**\r\n * Creates a new instance ConvolutionPostProcess\r\n * @param name The name of the effect.\r\n * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied\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 */\r\n constructor(\r\n name: string,\r\n kernel: number[],\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_INT\r\n ) {\r\n super(name, \"convolution\", [\"kernel\", \"screenSize\"], null, options, camera, samplingMode, engine, reusable, null, textureType);\r\n this.kernel = kernel;\r\n this.onApply = (effect: Effect) => {\r\n effect.setFloat2(\"screenSize\", this.width, this.height);\r\n effect.setArray(\"kernel\", this.kernel);\r\n };\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/convolution.fragment\")]));\r\n } else {\r\n list.push(Promise.all([import(\"../Shaders/convolution.fragment\")]));\r\n }\r\n\r\n super._gatherImports(useWebGPU, list);\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<ConvolutionPostProcess> {\r\n return SerializationHelper.Parse(\r\n () => {\r\n return new ConvolutionPostProcess(\r\n parsedPostProcess.name,\r\n parsedPostProcess.kernel,\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 );\r\n },\r\n parsedPostProcess,\r\n scene,\r\n rootUrl\r\n );\r\n }\r\n\r\n // Statics\r\n /**\r\n * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)\r\n */\r\n public static EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];\r\n /**\r\n * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)\r\n */\r\n public static EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];\r\n /**\r\n * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)\r\n */\r\n public static EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];\r\n /**\r\n * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)\r\n */\r\n public static SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];\r\n /**\r\n * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)\r\n */\r\n public static EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];\r\n /**\r\n * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)\r\n */\r\n public static GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];\r\n}\r\n\r\nRegisterClass(\"BABYLON.ConvolutionPostProcess\", ConvolutionPostProcess);\r\n"]}
|
|
@@ -29,7 +29,7 @@ export declare class DepthOfFieldMergePostProcess extends PostProcess {
|
|
|
29
29
|
* @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: false)
|
|
30
30
|
*/
|
|
31
31
|
constructor(name: string, originalFromInput: PostProcess, circleOfConfusion: PostProcess, _blurSteps: Array<PostProcess>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: AbstractEngine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
|
|
32
|
-
protected
|
|
32
|
+
protected _gatherImports(useWebGPU: boolean, list: Promise<any>[]): void;
|
|
33
33
|
/**
|
|
34
34
|
* Updates the effect with the current post process compile time values and recompiles the shader.
|
|
35
35
|
* @param defines Define statements that should be added at the beginning of the shader. (default: null)
|
|
@@ -40,15 +40,15 @@ export class DepthOfFieldMergePostProcess extends PostProcess {
|
|
|
40
40
|
this.updateEffect();
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
_gatherImports(useWebGPU, list) {
|
|
44
44
|
if (useWebGPU) {
|
|
45
45
|
this._webGPUReady = true;
|
|
46
|
-
|
|
46
|
+
list.push(import("../ShadersWGSL/depthOfFieldMerge.fragment.js"));
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
|
-
|
|
49
|
+
list.push(import("../Shaders/depthOfFieldMerge.fragment.js"));
|
|
50
50
|
}
|
|
51
|
-
super.
|
|
51
|
+
super._gatherImports(useWebGPU, list);
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Updates the effect with the current post process compile time values and recompiles the shader.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"depthOfFieldMergePostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/depthOfFieldMergePostProcess.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIjD;;GAEG;AACH,MAAM,OAAO,4BAA6B,SAAQ,WAAW;IACzD;;;OAGG;IACa,YAAY;QACxB,OAAO,8BAA8B,CAAC;IAC1C,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,YACI,IAAY,EACZ,iBAA8B,EAC9B,iBAA8B,EACtB,UAA8B,EACtC,OAAoC,EACpC,MAAwB,EACxB,YAAqB,EACrB,MAAuB,EACvB,QAAkB,EAClB,WAAW,GAAG,SAAS,CAAC,wBAAwB,EAChD,gBAAgB,GAAG,KAAK;QAExB,KAAK,CACD,IAAI,EACJ,mBAAmB,EACnB,EAAE,EACF,CAAC,0BAA0B,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,CAAC,EACnE,OAAO,EACP,MAAM,EACN,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,SAAS,EACT,IAAI,EACJ,IAAI,CACP,CAAC;QAxBM,eAAU,GAAV,UAAU,CAAoB;QAyBtC,IAAI,CAAC,6BAA6B,GAAG,IAAI,CAAC;QAC1C,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,MAAc,EAAE,EAAE;YAC1C,MAAM,CAAC,yBAAyB,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;YACtE,MAAM,CAAC,+BAA+B,CAAC,0BAA0B,EAAE,iBAAiB,CAAC,CAAC;YACtF,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;gBAC/B,MAAM,CAAC,+BAA+B,CAAC,UAAU,GAAG,CAAC,UAAU,CAAC,MAAM,GAAG,KAAK,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;YAC/F,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,gBAAgB,EAAE;YACnB,IAAI,CAAC,YAAY,EAAE,CAAC;SACvB;IACL,CAAC;IAEkB,
|
|
1
|
+
{"version":3,"file":"depthOfFieldMergePostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/depthOfFieldMergePostProcess.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIjD;;GAEG;AACH,MAAM,OAAO,4BAA6B,SAAQ,WAAW;IACzD;;;OAGG;IACa,YAAY;QACxB,OAAO,8BAA8B,CAAC;IAC1C,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,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,IAAI,CAAC,MAAM,CAAC,uCAAuC,CAAC,CAAC,CAAC;SAC9D;QAED,KAAK,CAAC,cAAc,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;;;OAQG;IACa,YAAY,CACxB,UAA4B,IAAI,EAChC,WAA+B,IAAI,EACnC,WAA+B,IAAI,EACnC,eAAqB,EACrB,UAAqC,EACrC,OAAkD;QAElD,IAAI,CAAC,OAAO,EAAE;YACV,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,IAAI,qBAAqB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;SAC1E;QACD,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IAC1F,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\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\n\r\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\n\r\n/**\r\n * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.\r\n */\r\nexport class DepthOfFieldMergePostProcess extends PostProcess {\r\n /**\r\n * Gets a string identifying the name of the class\r\n * @returns \"DepthOfFieldMergePostProcess\" string\r\n */\r\n public override getClassName(): string {\r\n return \"DepthOfFieldMergePostProcess\";\r\n }\r\n\r\n /**\r\n * Creates a new instance of DepthOfFieldMergePostProcess\r\n * @param name The name of the effect.\r\n * @param originalFromInput Post process which's input will be used for the merge.\r\n * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.\r\n * @param _blurSteps Blur post processes from low to high which will be mixed with the original image.\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: false)\r\n */\r\n constructor(\r\n name: string,\r\n originalFromInput: PostProcess,\r\n circleOfConfusion: PostProcess,\r\n private _blurSteps: Array<PostProcess>,\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 = Constants.TEXTURETYPE_UNSIGNED_INT,\r\n blockCompilation = false\r\n ) {\r\n super(\r\n name,\r\n \"depthOfFieldMerge\",\r\n [],\r\n [\"circleOfConfusionSampler\", \"blurStep0\", \"blurStep1\", \"blurStep2\"],\r\n options,\r\n camera,\r\n samplingMode,\r\n engine,\r\n reusable,\r\n null,\r\n textureType,\r\n undefined,\r\n null,\r\n true\r\n );\r\n this.externalTextureSamplerBinding = true;\r\n this.onApplyObservable.add((effect: Effect) => {\r\n effect.setTextureFromPostProcess(\"textureSampler\", originalFromInput);\r\n effect.setTextureFromPostProcessOutput(\"circleOfConfusionSampler\", circleOfConfusion);\r\n _blurSteps.forEach((step, index) => {\r\n effect.setTextureFromPostProcessOutput(\"blurStep\" + (_blurSteps.length - index - 1), step);\r\n });\r\n });\r\n\r\n if (!blockCompilation) {\r\n this.updateEffect();\r\n }\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(import(\"../ShadersWGSL/depthOfFieldMerge.fragment\"));\r\n } else {\r\n list.push(import(\"../Shaders/depthOfFieldMerge.fragment\"));\r\n }\r\n\r\n super._gatherImports(useWebGPU, list);\r\n }\r\n\r\n /**\r\n * Updates the effect with the current post process compile time values and recompiles the shader.\r\n * @param defines Define statements that should be added at the beginning of the shader. (default: null)\r\n * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)\r\n * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)\r\n * @param indexParameters The index parameters to be used for babylons include syntax \"#include<kernelBlurVaryingDeclaration>[0..varyingCount]\". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx\r\n * @param onCompiled Called when the shader has been compiled.\r\n * @param onError Called if there is an error when compiling a shader.\r\n */\r\n public override updateEffect(\r\n defines: Nullable<string> = null,\r\n uniforms: Nullable<string[]> = null,\r\n samplers: Nullable<string[]> = null,\r\n indexParameters?: any,\r\n onCompiled?: (effect: Effect) => void,\r\n onError?: (effect: Effect, errors: string) => void\r\n ) {\r\n if (!defines) {\r\n defines = \"\";\r\n defines += \"#define BLUR_LEVEL \" + (this._blurSteps.length - 1) + \"\\n\";\r\n }\r\n super.updateEffect(defines, uniforms, samplers, indexParameters, onCompiled, onError);\r\n }\r\n}\r\n"]}
|
|
@@ -3,7 +3,6 @@ import type { Camera } from "../Cameras/camera";
|
|
|
3
3
|
import type { PostProcessOptions } from "./postProcess";
|
|
4
4
|
import { PostProcess } from "./postProcess";
|
|
5
5
|
import type { AbstractEngine } from "../Engines/abstractEngine";
|
|
6
|
-
import "../Shaders/displayPass.fragment";
|
|
7
6
|
import type { Scene } from "../scene";
|
|
8
7
|
/**
|
|
9
8
|
* DisplayPassPostProcess which produces an output the same as it's input
|
|
@@ -24,6 +23,7 @@ export declare class DisplayPassPostProcess extends PostProcess {
|
|
|
24
23
|
* @param reusable If the post process can be reused on the same frame. (default: false)
|
|
25
24
|
*/
|
|
26
25
|
constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: AbstractEngine, reusable?: boolean);
|
|
26
|
+
protected _gatherImports(useWebGPU: boolean, list: Promise<any>[]): void;
|
|
27
27
|
/**
|
|
28
28
|
* @internal
|
|
29
29
|
*/
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PostProcess } from "./postProcess.js";
|
|
2
|
-
import "../Shaders/displayPass.fragment.js";
|
|
3
2
|
import { RegisterClass } from "../Misc/typeStore.js";
|
|
4
3
|
import { SerializationHelper } from "../Misc/decorators.serialization.js";
|
|
5
4
|
/**
|
|
@@ -25,6 +24,16 @@ export class DisplayPassPostProcess extends PostProcess {
|
|
|
25
24
|
constructor(name, options, camera, samplingMode, engine, reusable) {
|
|
26
25
|
super(name, "displayPass", ["passSampler"], ["passSampler"], options, camera, samplingMode, engine, reusable);
|
|
27
26
|
}
|
|
27
|
+
_gatherImports(useWebGPU, list) {
|
|
28
|
+
if (useWebGPU) {
|
|
29
|
+
this._webGPUReady = true;
|
|
30
|
+
list.push(Promise.all([import("../ShadersWGSL/displayPass.fragment.js")]));
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
list.push(Promise.all([import("../Shaders/displayPass.fragment.js")]));
|
|
34
|
+
}
|
|
35
|
+
super._gatherImports(useWebGPU, list);
|
|
36
|
+
}
|
|
28
37
|
/**
|
|
29
38
|
* @internal
|
|
30
39
|
*/
|