@babylonjs/core 7.19.0 → 7.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Buffers/buffer.nonFloatVertexBuffers.js +1 -1
- package/Buffers/buffer.nonFloatVertexBuffers.js.map +1 -1
- package/Collisions/gpuPicker.d.ts +8 -2
- package/Collisions/gpuPicker.js +41 -20
- package/Collisions/gpuPicker.js.map +1 -1
- package/Engines/Processors/shaderProcessor.d.ts +1 -0
- package/Engines/Processors/shaderProcessor.js +1 -0
- package/Engines/Processors/shaderProcessor.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.rawTexture.js +1 -0
- package/Engines/WebGPU/Extensions/engine.rawTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessingContext.d.ts +1 -1
- package/Engines/WebGPU/webgpuShaderProcessingContext.js +4 -2
- package/Engines/WebGPU/webgpuShaderProcessingContext.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.d.ts +2 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +12 -5
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.d.ts +1 -4
- package/Engines/WebGPU/webgpuTextureManager.js +90 -75
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/abstractEngine.d.ts +2 -2
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/nativeEngine.d.ts +1 -1
- package/Engines/nativeEngine.js +2 -1
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/thinEngine.d.ts +1 -1
- package/Engines/thinEngine.functions.d.ts +1 -1
- package/Engines/thinEngine.functions.js +2 -1
- package/Engines/thinEngine.functions.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +9 -5
- package/Engines/webgpuEngine.js +35 -22
- package/Engines/webgpuEngine.js.map +1 -1
- package/Layers/effectLayer.d.ts +16 -1
- package/Layers/effectLayer.js +32 -2
- package/Layers/effectLayer.js.map +1 -1
- package/Layers/glowLayer.d.ts +1 -2
- package/Layers/glowLayer.js +16 -3
- package/Layers/glowLayer.js.map +1 -1
- package/Layers/highlightLayer.d.ts +5 -4
- package/Layers/highlightLayer.js +36 -11
- package/Layers/highlightLayer.js.map +1 -1
- package/Layers/index.d.ts +10 -0
- package/Layers/index.js +12 -0
- package/Layers/index.js.map +1 -1
- package/Lights/Shadows/index.d.ts +8 -0
- package/Lights/Shadows/index.js +9 -0
- package/Lights/Shadows/index.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.d.ts +18 -5
- package/Lights/Shadows/shadowGenerator.js +44 -5
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Loading/sceneLoader.d.ts +155 -16
- package/Loading/sceneLoader.js +197 -99
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +1 -0
- package/Materials/Node/nodeMaterial.js +15 -1
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildState.js +1 -1
- package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
- package/Materials/effect.functions.d.ts +1 -1
- package/Materials/effect.functions.js +6 -3
- package/Materials/effect.functions.js.map +1 -1
- package/Materials/effect.js +1 -1
- package/Materials/effect.js.map +1 -1
- package/Materials/standardMaterial.d.ts +1 -1
- package/Materials/standardMaterial.js +1 -1
- package/Materials/standardMaterial.js.map +1 -1
- package/Maths/math.constants.d.ts +1 -2
- package/Maths/math.constants.js +1 -2
- package/Maths/math.constants.js.map +1 -1
- package/Maths/math.like.d.ts +9 -0
- package/Maths/math.like.js.map +1 -1
- package/Maths/math.vector.d.ts +23 -23
- package/Maths/math.vector.js +43 -11
- package/Maths/math.vector.js.map +1 -1
- package/Misc/index.d.ts +4 -0
- package/Misc/index.js +5 -0
- package/Misc/index.js.map +1 -1
- package/Misc/rgbdTextureTools.d.ts +1 -0
- package/Misc/rgbdTextureTools.js +15 -2
- package/Misc/rgbdTextureTools.js.map +1 -1
- package/PostProcesses/blurPostProcess.d.ts +6 -0
- package/PostProcesses/blurPostProcess.js +21 -2
- package/PostProcesses/blurPostProcess.js.map +1 -1
- package/PostProcesses/index.d.ts +8 -0
- package/PostProcesses/index.js +10 -0
- package/PostProcesses/index.js.map +1 -1
- package/PostProcesses/passPostProcess.d.ts +2 -0
- package/PostProcesses/passPostProcess.js +26 -2
- package/PostProcesses/passPostProcess.js.map +1 -1
- package/PostProcesses/postProcess.d.ts +11 -2
- package/PostProcesses/postProcess.js +17 -1
- package/PostProcesses/postProcess.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bayerDitherFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/bayerDitherFunctions.js +17 -0
- package/ShadersWGSL/ShadersInclude/bayerDitherFunctions.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/imageProcessingFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/imageProcessingFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/kernelBlurFragment.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/kernelBlurFragment.js +20 -0
- package/ShadersWGSL/ShadersInclude/kernelBlurFragment.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/kernelBlurFragment2.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/kernelBlurFragment2.js +19 -0
- package/ShadersWGSL/ShadersInclude/kernelBlurFragment2.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/kernelBlurVaryingDeclaration.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/kernelBlurVaryingDeclaration.js +9 -0
- package/ShadersWGSL/ShadersInclude/kernelBlurVaryingDeclaration.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/kernelBlurVertex.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/kernelBlurVertex.js +9 -0
- package/ShadersWGSL/ShadersInclude/kernelBlurVertex.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js +4 -4
- package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/shadowMapFragment.js +5 -5
- package/ShadersWGSL/ShadersInclude/shadowMapFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/shadowMapFragmentExtraDeclaration.d.ts +7 -0
- package/ShadersWGSL/ShadersInclude/shadowMapFragmentExtraDeclaration.js +26 -0
- package/ShadersWGSL/ShadersInclude/shadowMapFragmentExtraDeclaration.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/shadowMapFragmentSoftTransparentShadow.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/shadowMapFragmentSoftTransparentShadow.js +12 -0
- package/ShadersWGSL/ShadersInclude/shadowMapFragmentSoftTransparentShadow.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/shadowMapVertexExtraDeclaration.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/shadowMapVertexExtraDeclaration.js +19 -0
- package/ShadersWGSL/ShadersInclude/shadowMapVertexExtraDeclaration.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/shadowMapVertexMetric.js +4 -4
- package/ShadersWGSL/ShadersInclude/shadowMapVertexMetric.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/shadowMapVertexNormalBias.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/shadowMapVertexNormalBias.js +17 -0
- package/ShadersWGSL/ShadersInclude/shadowMapVertexNormalBias.js.map +1 -0
- package/ShadersWGSL/default.fragment.js +2 -2
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/depthBoxBlur.fragment.d.ts +5 -0
- package/ShadersWGSL/depthBoxBlur.fragment.js +14 -0
- package/ShadersWGSL/depthBoxBlur.fragment.js.map +1 -0
- package/ShadersWGSL/glowBlurPostProcess.fragment.d.ts +5 -0
- package/ShadersWGSL/glowBlurPostProcess.fragment.js +15 -0
- package/ShadersWGSL/glowBlurPostProcess.fragment.js.map +1 -0
- package/ShadersWGSL/glowMapGeneration.fragment.d.ts +8 -0
- package/ShadersWGSL/glowMapGeneration.fragment.js +74 -0
- package/ShadersWGSL/glowMapGeneration.fragment.js.map +1 -0
- package/ShadersWGSL/glowMapGeneration.vertex.d.ts +17 -0
- package/ShadersWGSL/glowMapGeneration.vertex.js +92 -0
- package/ShadersWGSL/glowMapGeneration.vertex.js.map +1 -0
- package/ShadersWGSL/glowMapMerge.fragment.d.ts +5 -0
- package/ShadersWGSL/glowMapMerge.fragment.js +32 -0
- package/ShadersWGSL/glowMapMerge.fragment.js.map +1 -0
- package/ShadersWGSL/glowMapMerge.vertex.d.ts +5 -0
- package/ShadersWGSL/glowMapMerge.vertex.js +16 -0
- package/ShadersWGSL/glowMapMerge.vertex.js.map +1 -0
- package/ShadersWGSL/kernelBlur.fragment.d.ts +9 -0
- package/ShadersWGSL/kernelBlur.fragment.js +48 -0
- package/ShadersWGSL/kernelBlur.fragment.js.map +1 -0
- package/ShadersWGSL/kernelBlur.vertex.d.ts +7 -0
- package/ShadersWGSL/kernelBlur.vertex.js +21 -0
- package/ShadersWGSL/kernelBlur.vertex.js.map +1 -0
- package/ShadersWGSL/pass.fragment.d.ts +5 -0
- package/ShadersWGSL/pass.fragment.js +12 -0
- package/ShadersWGSL/pass.fragment.js.map +1 -0
- package/ShadersWGSL/passCube.fragment.d.ts +5 -0
- package/ShadersWGSL/passCube.fragment.js +31 -0
- package/ShadersWGSL/passCube.fragment.js.map +1 -0
- package/ShadersWGSL/rgbdDecode.fragment.d.ts +6 -0
- package/ShadersWGSL/rgbdDecode.fragment.js +14 -0
- package/ShadersWGSL/rgbdDecode.fragment.js.map +1 -0
- package/ShadersWGSL/rgbdEncode.fragment.d.ts +6 -0
- package/ShadersWGSL/rgbdEncode.fragment.js +14 -0
- package/ShadersWGSL/rgbdEncode.fragment.js.map +1 -0
- package/ShadersWGSL/shadowMap.fragment.d.ts +9 -0
- package/ShadersWGSL/shadowMap.fragment.js +39 -0
- package/ShadersWGSL/shadowMap.fragment.js.map +1 -0
- package/ShadersWGSL/shadowMap.vertex.d.ts +22 -0
- package/ShadersWGSL/shadowMap.vertex.js +89 -0
- package/ShadersWGSL/shadowMap.vertex.js.map +1 -0
- package/package.json +1 -1
package/Misc/index.d.ts
CHANGED
|
@@ -66,3 +66,7 @@ export * from "./greasedLineTools";
|
|
|
66
66
|
export * from "./equirectangularCapture";
|
|
67
67
|
export * from "./decorators.serialization";
|
|
68
68
|
export * from "./asyncLock";
|
|
69
|
+
export * from "../Shaders/rgbdDecode.fragment";
|
|
70
|
+
export * from "../Shaders/rgbdEncode.fragment";
|
|
71
|
+
export * from "../ShadersWGSL/rgbdDecode.fragment";
|
|
72
|
+
export * from "../ShadersWGSL/rgbdEncode.fragment";
|
package/Misc/index.js
CHANGED
|
@@ -68,4 +68,9 @@ export * from "./greasedLineTools.js";
|
|
|
68
68
|
export * from "./equirectangularCapture.js";
|
|
69
69
|
export * from "./decorators.serialization.js";
|
|
70
70
|
export * from "./asyncLock.js";
|
|
71
|
+
// RGBDTextureTools
|
|
72
|
+
export * from "../Shaders/rgbdDecode.fragment.js";
|
|
73
|
+
export * from "../Shaders/rgbdEncode.fragment.js";
|
|
74
|
+
export * from "../ShadersWGSL/rgbdDecode.fragment.js";
|
|
75
|
+
export * from "../ShadersWGSL/rgbdEncode.fragment.js";
|
|
71
76
|
//# sourceMappingURL=index.js.map
|
package/Misc/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,c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B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,yCAAyC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,aAAa,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./andOrNotEvaluator\";\r\nexport * from \"./assetsManager\";\r\nexport * from \"./basis\";\r\nexport * from \"./dds\";\r\nexport * from \"./decorators\";\r\nexport * from \"./deferred\";\r\nexport * from \"./environmentTextureTools\";\r\nexport * from \"./meshExploder\";\r\nexport * from \"./filesInput\";\r\nexport * from \"./HighDynamicRange/index\";\r\nexport * from \"./khronosTextureContainer\";\r\nexport * from \"./observable\";\r\nexport * from \"./observable.extensions\";\r\nexport * from \"./performanceMonitor\";\r\nexport * from \"./sceneOptimizer\";\r\nexport * from \"./sceneSerializer\";\r\nexport * from \"./smartArray\";\r\nexport * from \"./stringDictionary\";\r\nexport * from \"./tags\";\r\nexport * from \"./textureTools\";\r\nexport * from \"./tga\";\r\nexport * from \"./tools\";\r\nexport * from \"./videoRecorder\";\r\nexport * from \"./virtualJoystick\";\r\nexport * from \"./workerPool\";\r\nexport * from \"./logger\";\r\nexport * from \"./typeStore\";\r\nexport * from \"./filesInputStore\";\r\nexport * from \"./deepCopier\";\r\nexport * from \"./pivotTools\";\r\nexport * from \"./precisionDate\";\r\nexport * from \"./screenshotTools\";\r\nexport * from \"./webRequest\";\r\nexport * from \"./iInspectable\";\r\nexport * from \"./brdfTextureTools\";\r\nexport * from \"./rgbdTextureTools\";\r\nexport * from \"./gradients\";\r\nexport * from \"./perfCounter\";\r\nexport * from \"./fileRequest\";\r\nexport * from \"./customAnimationFrameRequester\";\r\nexport * from \"./retryStrategy\";\r\nexport * from \"./interfaces/screenshotSize\";\r\nexport * from \"./interfaces/iPerfViewer\";\r\nexport * from \"./fileTools\";\r\nexport * from \"./stringTools\";\r\nexport * from \"./dataReader\";\r\nexport * from \"./minMaxReducer\";\r\nexport * from \"./depthReducer\";\r\nexport * from \"./dataStorage\";\r\nexport * from \"./sceneRecorder\";\r\nexport * from \"./khronosTextureContainer2\";\r\nexport * from \"./trajectoryClassifier\";\r\nexport * from \"./timer\";\r\nexport * from \"./copyTools\";\r\nexport * from \"./reflector\";\r\nexport * from \"./domManagement\";\r\nexport * from \"./pressureObserverWrapper\";\r\nexport * from \"./PerformanceViewer/index\";\r\nexport * from \"./coroutine\";\r\nexport * from \"./guid\";\r\nexport * from \"./error\";\r\n// eslint-disable-next-line import/export\r\nexport * from \"./observableCoroutine\";\r\nexport * from \"./copyTextureToTexture\";\r\nexport * from \"./dumpTools\";\r\nexport * from \"./greasedLineTools\";\r\nexport * from \"./equirectangularCapture\";\r\nexport * from \"./decorators.serialization\";\r\nexport * from \"./asyncLock\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,cAAc,CAAC;AAC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QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,yCAAyC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,aAAa,CAAC;AAE5B,mBAAmB;AACnB,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./andOrNotEvaluator\";\r\nexport * from \"./assetsManager\";\r\nexport * from \"./basis\";\r\nexport * from \"./dds\";\r\nexport * from \"./decorators\";\r\nexport * from \"./deferred\";\r\nexport * from \"./environmentTextureTools\";\r\nexport * from \"./meshExploder\";\r\nexport * from \"./filesInput\";\r\nexport * from \"./HighDynamicRange/index\";\r\nexport * from \"./khronosTextureContainer\";\r\nexport * from \"./observable\";\r\nexport * from \"./observable.extensions\";\r\nexport * from \"./performanceMonitor\";\r\nexport * from \"./sceneOptimizer\";\r\nexport * from \"./sceneSerializer\";\r\nexport * from \"./smartArray\";\r\nexport * from \"./stringDictionary\";\r\nexport * from \"./tags\";\r\nexport * from \"./textureTools\";\r\nexport * from \"./tga\";\r\nexport * from \"./tools\";\r\nexport * from \"./videoRecorder\";\r\nexport * from \"./virtualJoystick\";\r\nexport * from \"./workerPool\";\r\nexport * from \"./logger\";\r\nexport * from \"./typeStore\";\r\nexport * from \"./filesInputStore\";\r\nexport * from \"./deepCopier\";\r\nexport * from \"./pivotTools\";\r\nexport * from \"./precisionDate\";\r\nexport * from \"./screenshotTools\";\r\nexport * from \"./webRequest\";\r\nexport * from \"./iInspectable\";\r\nexport * from \"./brdfTextureTools\";\r\nexport * from \"./rgbdTextureTools\";\r\nexport * from \"./gradients\";\r\nexport * from \"./perfCounter\";\r\nexport * from \"./fileRequest\";\r\nexport * from \"./customAnimationFrameRequester\";\r\nexport * from \"./retryStrategy\";\r\nexport * from \"./interfaces/screenshotSize\";\r\nexport * from \"./interfaces/iPerfViewer\";\r\nexport * from \"./fileTools\";\r\nexport * from \"./stringTools\";\r\nexport * from \"./dataReader\";\r\nexport * from \"./minMaxReducer\";\r\nexport * from \"./depthReducer\";\r\nexport * from \"./dataStorage\";\r\nexport * from \"./sceneRecorder\";\r\nexport * from \"./khronosTextureContainer2\";\r\nexport * from \"./trajectoryClassifier\";\r\nexport * from \"./timer\";\r\nexport * from \"./copyTools\";\r\nexport * from \"./reflector\";\r\nexport * from \"./domManagement\";\r\nexport * from \"./pressureObserverWrapper\";\r\nexport * from \"./PerformanceViewer/index\";\r\nexport * from \"./coroutine\";\r\nexport * from \"./guid\";\r\nexport * from \"./error\";\r\n// eslint-disable-next-line import/export\r\nexport * from \"./observableCoroutine\";\r\nexport * from \"./copyTextureToTexture\";\r\nexport * from \"./dumpTools\";\r\nexport * from \"./greasedLineTools\";\r\nexport * from \"./equirectangularCapture\";\r\nexport * from \"./decorators.serialization\";\r\nexport * from \"./asyncLock\";\r\n\r\n// RGBDTextureTools\r\nexport * from \"../Shaders/rgbdDecode.fragment\";\r\nexport * from \"../Shaders/rgbdEncode.fragment\";\r\nexport * from \"../ShadersWGSL/rgbdDecode.fragment\";\r\nexport * from \"../ShadersWGSL/rgbdEncode.fragment\";\r\n"]}
|
|
@@ -7,6 +7,7 @@ import type { Scene } from "../scene";
|
|
|
7
7
|
* Class used to host RGBD texture specific utilities
|
|
8
8
|
*/
|
|
9
9
|
export declare class RGBDTextureTools {
|
|
10
|
+
private static _ShaderImported;
|
|
10
11
|
/**
|
|
11
12
|
* Expand the RGBD Texture from RGBD to Half Float if possible.
|
|
12
13
|
* @param texture the texture to expand.
|
package/Misc/rgbdTextureTools.js
CHANGED
|
@@ -37,10 +37,22 @@ export class RGBDTextureTools {
|
|
|
37
37
|
internalTexture._isRGBD = false;
|
|
38
38
|
internalTexture.invertY = false;
|
|
39
39
|
}
|
|
40
|
-
const expandRGBDTexture = () => {
|
|
40
|
+
const expandRGBDTexture = async () => {
|
|
41
|
+
const isWebGPU = engine.isWebGPU;
|
|
42
|
+
let shaderLanguage = 0 /* ShaderLanguage.GLSL */;
|
|
43
|
+
if (!this._ShaderImported) {
|
|
44
|
+
this._ShaderImported = true;
|
|
45
|
+
if (isWebGPU) {
|
|
46
|
+
shaderLanguage = 1 /* ShaderLanguage.WGSL */;
|
|
47
|
+
await Promise.all([import("../ShadersWGSL/rgbdDecode.fragment.js"), import("../ShadersWGSL/rgbdEncode.fragment.js")]);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
await Promise.all([import("../Shaders/rgbdDecode.fragment.js"), import("../Shaders/rgbdEncode.fragment.js")]);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
41
53
|
// Expand the texture if possible
|
|
42
54
|
// Simply run through the decode PP.
|
|
43
|
-
const rgbdPostProcess = new PostProcess("rgbdDecode", "rgbdDecode", null, null, 1, null, 3, engine, false, undefined, internalTexture.type, undefined, null, false);
|
|
55
|
+
const rgbdPostProcess = new PostProcess("rgbdDecode", "rgbdDecode", null, null, 1, null, 3, engine, false, undefined, internalTexture.type, undefined, null, false, undefined, shaderLanguage);
|
|
44
56
|
rgbdPostProcess.externalTextureSamplerBinding = true;
|
|
45
57
|
// Hold the output of the decoding.
|
|
46
58
|
const expandedTexture = engine.createRenderTargetTexture(internalTexture.width, {
|
|
@@ -90,4 +102,5 @@ export class RGBDTextureTools {
|
|
|
90
102
|
return ApplyPostProcess("rgbdEncode", internalTexture, scene, outputTextureType, 1, 5);
|
|
91
103
|
}
|
|
92
104
|
}
|
|
105
|
+
RGBDTextureTools._ShaderImported = false;
|
|
93
106
|
//# sourceMappingURL=rgbdTextureTools.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rgbdTextureTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/rgbdTextureTools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,gCAAgC,CAAC;AAGxC,OAAO,2CAA2C,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"rgbdTextureTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/rgbdTextureTools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,gCAAgC,CAAC;AAGxC,OAAO,2CAA2C,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAOlD;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAGzB;;;OAGG;IACI,MAAM,CAAC,iBAAiB,CAAC,OAAgB;QAC5C,MAAM,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;QACzC,IAAI,CAAC,eAAe,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACrC,OAAO;SACV;QAED,yBAAyB;QACzB,MAAM,MAAM,GAAG,eAAe,CAAC,SAAS,EAAY,CAAC;QACrD,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC;QACxC,IAAI,aAAa,GAAG,KAAK,CAAC;QAE1B,wDAAwD;QACxD,IAAI,IAAI,CAAC,sBAAsB,IAAI,IAAI,CAAC,+BAA+B,EAAE;YACrE,aAAa,GAAG,IAAI,CAAC;YACrB,eAAe,CAAC,IAAI,GAAG,SAAS,CAAC,sBAAsB,CAAC;SAC3D;QACD,wDAAwD;aACnD,IAAI,IAAI,CAAC,kBAAkB,IAAI,IAAI,CAAC,2BAA2B,EAAE;YAClE,aA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OAAO,gBAAgB,CAAC,YAAY,EAAE,eAAe,EAAE,KAAK,EAAE,iBAAiB,EAAE,SAAS,CAAC,4BAA4B,EAAE,SAAS,CAAC,kBAAkB,CAAC,CAAC;IAC3J,CAAC;;AA3Hc,gCAAe,GAAG,KAAK,CAAC","sourcesContent":["import { Constants } from \"../Engines/constants\";\r\nimport { PostProcess } from \"../PostProcesses/postProcess\";\r\nimport \"../Shaders/rgbdDecode.fragment\";\r\nimport type { Engine } from \"../Engines/engine\";\r\n\r\nimport \"../Engines/Extensions/engine.renderTarget\";\r\nimport { ApplyPostProcess } from \"./textureTools\";\r\n\r\nimport type { Texture } from \"../Materials/Textures/texture\";\r\nimport type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport type { Scene } from \"../scene\";\r\nimport { ShaderLanguage } from \"core/Materials\";\r\n\r\n/**\r\n * Class used to host RGBD texture specific utilities\r\n */\r\nexport class RGBDTextureTools {\r\n private static _ShaderImported = false;\r\n\r\n /**\r\n * Expand the RGBD Texture from RGBD to Half Float if possible.\r\n * @param texture the texture to expand.\r\n */\r\n public static ExpandRGBDTexture(texture: Texture) {\r\n const internalTexture = texture._texture;\r\n if (!internalTexture || !texture.isRGBD) {\r\n return;\r\n }\r\n\r\n // Gets everything ready.\r\n const engine = internalTexture.getEngine() as Engine;\r\n const caps = engine.getCaps();\r\n const isReady = internalTexture.isReady;\r\n let expandTexture = false;\r\n\r\n // If half float available we can uncompress the texture\r\n if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {\r\n expandTexture = true;\r\n internalTexture.type = Constants.TEXTURETYPE_HALF_FLOAT;\r\n }\r\n // If full float available we can uncompress the texture\r\n else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {\r\n expandTexture = true;\r\n internalTexture.type = Constants.TEXTURETYPE_FLOAT;\r\n }\r\n\r\n if (expandTexture) {\r\n // Do not use during decode.\r\n internalTexture.isReady = false;\r\n internalTexture._isRGBD = false;\r\n internalTexture.invertY = false;\r\n }\r\n\r\n const expandRGBDTexture = async () => {\r\n const isWebGPU = engine.isWebGPU;\r\n let shaderLanguage = ShaderLanguage.GLSL;\r\n\r\n if (!this._ShaderImported) {\r\n this._ShaderImported = true;\r\n if (isWebGPU) {\r\n shaderLanguage = ShaderLanguage.WGSL;\r\n await Promise.all([import(\"../ShadersWGSL/rgbdDecode.fragment\"), import(\"../ShadersWGSL/rgbdEncode.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../Shaders/rgbdDecode.fragment\"), import(\"../Shaders/rgbdEncode.fragment\")]);\r\n }\r\n }\r\n\r\n // Expand the texture if possible\r\n // Simply run through the decode PP.\r\n const rgbdPostProcess = new PostProcess(\r\n \"rgbdDecode\",\r\n \"rgbdDecode\",\r\n null,\r\n null,\r\n 1,\r\n null,\r\n Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n engine,\r\n false,\r\n undefined,\r\n internalTexture.type,\r\n undefined,\r\n null,\r\n false,\r\n undefined,\r\n shaderLanguage\r\n );\r\n rgbdPostProcess.externalTextureSamplerBinding = true;\r\n\r\n // Hold the output of the decoding.\r\n const expandedTexture = engine.createRenderTargetTexture(internalTexture.width, {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n generateStencilBuffer: false,\r\n samplingMode: internalTexture.samplingMode,\r\n type: internalTexture.type,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n });\r\n\r\n rgbdPostProcess.getEffect().executeWhenCompiled(() => {\r\n // PP Render Pass\r\n rgbdPostProcess.onApply = (effect) => {\r\n effect._bindTexture(\"textureSampler\", internalTexture);\r\n effect.setFloat2(\"scale\", 1, 1);\r\n };\r\n texture.getScene()!.postProcessManager.directRender([rgbdPostProcess!], expandedTexture, true);\r\n\r\n // Cleanup\r\n engine.restoreDefaultFramebuffer();\r\n engine._releaseTexture(internalTexture);\r\n if (rgbdPostProcess) {\r\n rgbdPostProcess.dispose();\r\n }\r\n\r\n // Internal Swap\r\n expandedTexture._swapAndDie(internalTexture);\r\n\r\n // Ready to get rolling again.\r\n internalTexture.isReady = true;\r\n });\r\n };\r\n\r\n if (expandTexture) {\r\n if (isReady) {\r\n expandRGBDTexture();\r\n } else {\r\n texture.onLoadObservable.addOnce(expandRGBDTexture);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Encode the texture to RGBD if possible.\r\n * @param internalTexture the texture to encode\r\n * @param scene the scene hosting the texture\r\n * @param outputTextureType type of the texture in which the encoding is performed\r\n * @returns a promise with the internalTexture having its texture replaced by the result of the processing\r\n */\r\n public static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType = Constants.TEXTURETYPE_UNSIGNED_BYTE): Promise<InternalTexture> {\r\n return ApplyPostProcess(\"rgbdEncode\", internalTexture, scene, outputTextureType, Constants.TEXTURE_NEAREST_SAMPLINGMODE, Constants.TEXTUREFORMAT_RGBA);\r\n }\r\n}\r\n"]}
|
|
@@ -57,6 +57,12 @@ export declare class BlurPostProcess extends PostProcess {
|
|
|
57
57
|
* @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
|
|
58
58
|
*/
|
|
59
59
|
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 _initShaderSourceAsync(forceGLSL?: boolean): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Get a value indicating if the post-process is ready to be used
|
|
63
|
+
* @returns true if the post-process is ready (shader is compiled)
|
|
64
|
+
*/
|
|
65
|
+
isReady(): boolean;
|
|
60
66
|
/**
|
|
61
67
|
* Updates the effect with the current post process compile time values and recompiles the shader.
|
|
62
68
|
* @param defines Define statements that should be added at the beginning of the shader. (default: null)
|
|
@@ -73,7 +73,7 @@ export class BlurPostProcess extends PostProcess {
|
|
|
73
73
|
* @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
|
|
74
74
|
*/
|
|
75
75
|
constructor(name, direction, kernel, options, camera, samplingMode = Texture.BILINEAR_SAMPLINGMODE, engine, reusable, textureType = 0, defines = "", _blockCompilation = false, textureFormat = 5) {
|
|
76
|
-
super(name, "kernelBlur", ["delta", "direction"], ["circleOfConfusionSampler"], options, camera, samplingMode, engine, reusable, null, textureType, "kernelBlur", { varyingCount: 0, depCount: 0 }, true, textureFormat);
|
|
76
|
+
super(name, "kernelBlur", ["delta", "direction"], ["circleOfConfusionSampler"], options, camera, samplingMode, engine, reusable, null, textureType, "kernelBlur", { varyingCount: 0, depCount: 0 }, true, textureFormat, undefined, true);
|
|
77
77
|
this._blockCompilation = _blockCompilation;
|
|
78
78
|
this._packedFloat = false;
|
|
79
79
|
this._staticDefines = "";
|
|
@@ -89,6 +89,25 @@ export class BlurPostProcess extends PostProcess {
|
|
|
89
89
|
});
|
|
90
90
|
this.kernel = kernel;
|
|
91
91
|
}
|
|
92
|
+
async _initShaderSourceAsync(forceGLSL = false) {
|
|
93
|
+
const engine = this.getEngine();
|
|
94
|
+
this._shadersLoaded = false;
|
|
95
|
+
if (engine.isWebGPU && !forceGLSL) {
|
|
96
|
+
this._shaderLanguage = 1 /* ShaderLanguage.WGSL */;
|
|
97
|
+
await Promise.all([import("../ShadersWGSL/kernelBlur.fragment.js"), import("../ShadersWGSL/kernelBlur.vertex.js")]);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
await Promise.all([import("../Shaders/kernelBlur.fragment.js"), import("../Shaders/kernelBlur.vertex.js")]);
|
|
101
|
+
}
|
|
102
|
+
this._shadersLoaded = true;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Get a value indicating if the post-process is ready to be used
|
|
106
|
+
* @returns true if the post-process is ready (shader is compiled)
|
|
107
|
+
*/
|
|
108
|
+
isReady() {
|
|
109
|
+
return this._shadersLoaded && super.isReady();
|
|
110
|
+
}
|
|
92
111
|
/**
|
|
93
112
|
* Updates the effect with the current post process compile time values and recompiles the shader.
|
|
94
113
|
* @param defines Define statements that should be added at the beginning of the shader. (default: null)
|
|
@@ -153,7 +172,7 @@ export class BlurPostProcess extends PostProcess {
|
|
|
153
172
|
offsets = linearSamplingOffsets;
|
|
154
173
|
weights = linearSamplingWeights;
|
|
155
174
|
// Generate shaders
|
|
156
|
-
const maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors;
|
|
175
|
+
const maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors - (this._shaderLanguage === 1 /* ShaderLanguage.WGSL */ ? 1 : 0); // Because of the additional builtins
|
|
157
176
|
const freeVaryingVec2 = Math.max(maxVaryingRows, 0) - 1; // Because of sampleCenter
|
|
158
177
|
let varyingCount = Math.min(offsets.length, freeVaryingVec2);
|
|
159
178
|
let defines = "";
|
|
@@ -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,8BAA8B,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAKvE;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAY5C;;OAEG;IACH,IAAW,MAAM,CAAC,CAAS;QACvB,IAAI,IAAI,CAAC,YAAY,KAAK,CAAC,EAAE;YACzB,OAAO;SACV;QAED,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACnB,IAAI,C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\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\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 /**\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;\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;AAEjD,OAAO,gCAAgC,CAAC;AACxC,OAAO,8BAA8B,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,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,CAAC,GAAG,CAAC,GAAG,GAAG,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC;QACpD,MAAM,MAAM,GAAG,CAAC,GAAG,GAAG,WAAW,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,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;AAzVa;IADT,SAAS,CAAC,QAAQ,CAAC;gDACM;AAGhB;IADT,SAAS,CAAC,aAAa,CAAC;qDACe;AAKjC;IADN,kBAAkB,EAAE;kDACK;AAmV9B,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 undefined,\r\n true\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(forceGLSL = false) {\r\n const engine = this.getEngine();\r\n\r\n this._shadersLoaded = false;\r\n if (engine.isWebGPU && !forceGLSL) {\r\n this._shaderLanguage = ShaderLanguage.WGSL;\r\n\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 this._shadersLoaded = true;\r\n }\r\n\r\n /**\r\n * Get a value indicating if the post-process is ready to be used\r\n * @returns true if the post-process is ready (shader is compiled)\r\n */\r\n public override isReady(): boolean {\r\n return this._shadersLoaded && super.isReady();\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"]}
|
package/PostProcesses/index.d.ts
CHANGED
|
@@ -31,3 +31,11 @@ export * from "./vrDistortionCorrectionPostProcess";
|
|
|
31
31
|
export * from "./vrMultiviewToSingleviewPostProcess";
|
|
32
32
|
export * from "./screenSpaceReflectionPostProcess";
|
|
33
33
|
export * from "./screenSpaceCurvaturePostProcess";
|
|
34
|
+
export * from "../Shaders/kernelBlur.fragment";
|
|
35
|
+
export * from "../Shaders/kernelBlur.vertex";
|
|
36
|
+
export * from "../ShadersWGSL/kernelBlur.fragment";
|
|
37
|
+
export * from "../ShadersWGSL/kernelBlur.vertex";
|
|
38
|
+
export * from "../Shaders/pass.fragment";
|
|
39
|
+
export * from "../Shaders/passCube.fragment";
|
|
40
|
+
export * from "../ShadersWGSL/pass.fragment";
|
|
41
|
+
export * from "../ShadersWGSL/passCube.fragment";
|
package/PostProcesses/index.js
CHANGED
|
@@ -32,4 +32,14 @@ export * from "./vrDistortionCorrectionPostProcess.js";
|
|
|
32
32
|
export * from "./vrMultiviewToSingleviewPostProcess.js";
|
|
33
33
|
export * from "./screenSpaceReflectionPostProcess.js";
|
|
34
34
|
export * from "./screenSpaceCurvaturePostProcess.js";
|
|
35
|
+
// Blur postprocess
|
|
36
|
+
export * from "../Shaders/kernelBlur.fragment.js";
|
|
37
|
+
export * from "../Shaders/kernelBlur.vertex.js";
|
|
38
|
+
export * from "../ShadersWGSL/kernelBlur.fragment.js";
|
|
39
|
+
export * from "../ShadersWGSL/kernelBlur.vertex.js";
|
|
40
|
+
// Pass postprocess
|
|
41
|
+
export * from "../Shaders/pass.fragment.js";
|
|
42
|
+
export * from "../Shaders/passCube.fragment.js";
|
|
43
|
+
export * from "../ShadersWGSL/pass.fragment.js";
|
|
44
|
+
export * from "../ShadersWGSL/passCube.fragment.js";
|
|
35
45
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oCAAoC,CAAC;AACnD,cAAc,sBAAsB,CAAC;AACrC,cAAc,wCAAwC,CAAC;AACvD,cAAc,qCAAqC,CAAC;AACpD,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./anaglyphPostProcess\";\r\nexport * from \"./blackAndWhitePostProcess\";\r\nexport * from \"./bloomEffect\";\r\nexport * from \"./bloomMergePostProcess\";\r\nexport * from \"./blurPostProcess\";\r\nexport * from \"./chromaticAberrationPostProcess\";\r\nexport * from \"./circleOfConfusionPostProcess\";\r\nexport * from \"./colorCorrectionPostProcess\";\r\nexport * from \"./convolutionPostProcess\";\r\nexport * from \"./depthOfFieldBlurPostProcess\";\r\nexport * from \"./depthOfFieldEffect\";\r\nexport * from \"./depthOfFieldMergePostProcess\";\r\nexport * from \"./displayPassPostProcess\";\r\nexport * from \"./extractHighlightsPostProcess\";\r\nexport * from \"./filterPostProcess\";\r\nexport * from \"./fxaaPostProcess\";\r\nexport * from \"./grainPostProcess\";\r\nexport * from \"./highlightsPostProcess\";\r\nexport * from \"./imageProcessingPostProcess\";\r\nexport * from \"./motionBlurPostProcess\";\r\nexport * from \"./passPostProcess\";\r\nexport * from \"./postProcess\";\r\nexport * from \"./postProcessManager\";\r\nexport * from \"./refractionPostProcess\";\r\nexport * from \"./RenderPipeline/index\";\r\nexport * from \"./sharpenPostProcess\";\r\nexport * from \"./stereoscopicInterlacePostProcess\";\r\nexport * from \"./tonemapPostProcess\";\r\nexport * from \"./volumetricLightScatteringPostProcess\";\r\nexport * from \"./vrDistortionCorrectionPostProcess\";\r\nexport * from \"./vrMultiviewToSingleviewPostProcess\";\r\nexport * from \"./screenSpaceReflectionPostProcess\";\r\nexport * from \"./screenSpaceCurvaturePostProcess\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oCAAoC,CAAC;AACnD,cAAc,sBAAsB,CAAC;AACrC,cAAc,wCAAwC,CAAC;AACvD,cAAc,qCAAqC,CAAC;AACpD,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAElD,mBAAmB;AACnB,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AAEjD,mBAAmB;AACnB,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kCAAkC,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./anaglyphPostProcess\";\r\nexport * from \"./blackAndWhitePostProcess\";\r\nexport * from \"./bloomEffect\";\r\nexport * from \"./bloomMergePostProcess\";\r\nexport * from \"./blurPostProcess\";\r\nexport * from \"./chromaticAberrationPostProcess\";\r\nexport * from \"./circleOfConfusionPostProcess\";\r\nexport * from \"./colorCorrectionPostProcess\";\r\nexport * from \"./convolutionPostProcess\";\r\nexport * from \"./depthOfFieldBlurPostProcess\";\r\nexport * from \"./depthOfFieldEffect\";\r\nexport * from \"./depthOfFieldMergePostProcess\";\r\nexport * from \"./displayPassPostProcess\";\r\nexport * from \"./extractHighlightsPostProcess\";\r\nexport * from \"./filterPostProcess\";\r\nexport * from \"./fxaaPostProcess\";\r\nexport * from \"./grainPostProcess\";\r\nexport * from \"./highlightsPostProcess\";\r\nexport * from \"./imageProcessingPostProcess\";\r\nexport * from \"./motionBlurPostProcess\";\r\nexport * from \"./passPostProcess\";\r\nexport * from \"./postProcess\";\r\nexport * from \"./postProcessManager\";\r\nexport * from \"./refractionPostProcess\";\r\nexport * from \"./RenderPipeline/index\";\r\nexport * from \"./sharpenPostProcess\";\r\nexport * from \"./stereoscopicInterlacePostProcess\";\r\nexport * from \"./tonemapPostProcess\";\r\nexport * from \"./volumetricLightScatteringPostProcess\";\r\nexport * from \"./vrDistortionCorrectionPostProcess\";\r\nexport * from \"./vrMultiviewToSingleviewPostProcess\";\r\nexport * from \"./screenSpaceReflectionPostProcess\";\r\nexport * from \"./screenSpaceCurvaturePostProcess\";\r\n\r\n// Blur postprocess\r\nexport * from \"../Shaders/kernelBlur.fragment\";\r\nexport * from \"../Shaders/kernelBlur.vertex\";\r\nexport * from \"../ShadersWGSL/kernelBlur.fragment\";\r\nexport * from \"../ShadersWGSL/kernelBlur.vertex\";\r\n\r\n// Pass postprocess\r\nexport * from \"../Shaders/pass.fragment\";\r\nexport * from \"../Shaders/passCube.fragment\";\r\nexport * from \"../ShadersWGSL/pass.fragment\";\r\nexport * from \"../ShadersWGSL/passCube.fragment\";\r\n"]}
|
|
@@ -27,6 +27,7 @@ export declare class PassPostProcess extends PostProcess {
|
|
|
27
27
|
* @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)
|
|
28
28
|
*/
|
|
29
29
|
constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: AbstractEngine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
|
|
30
|
+
protected _initShaderSourceAsync(forceGLSL?: boolean): Promise<void>;
|
|
30
31
|
/**
|
|
31
32
|
* @internal
|
|
32
33
|
*/
|
|
@@ -65,6 +66,7 @@ export declare class PassCubePostProcess extends PostProcess {
|
|
|
65
66
|
* @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)
|
|
66
67
|
*/
|
|
67
68
|
constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: AbstractEngine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
|
|
69
|
+
protected _initShaderSourceAsync(forceGLSL?: boolean): Promise<void>;
|
|
68
70
|
/**
|
|
69
71
|
* @internal
|
|
70
72
|
*/
|
|
@@ -28,7 +28,19 @@ export class PassPostProcess extends PostProcess {
|
|
|
28
28
|
* @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)
|
|
29
29
|
*/
|
|
30
30
|
constructor(name, options, camera = null, samplingMode, engine, reusable, textureType = 0, blockCompilation = false) {
|
|
31
|
-
super(name, "pass", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation);
|
|
31
|
+
super(name, "pass", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation, undefined, undefined, true);
|
|
32
|
+
}
|
|
33
|
+
async _initShaderSourceAsync(forceGLSL = false) {
|
|
34
|
+
const engine = this.getEngine();
|
|
35
|
+
this._shadersLoaded = false;
|
|
36
|
+
if (engine.isWebGPU && !forceGLSL) {
|
|
37
|
+
this._shaderLanguage = 1 /* ShaderLanguage.WGSL */;
|
|
38
|
+
await Promise.all([import("../ShadersWGSL/pass.fragment.js")]);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
await Promise.all([import("../Shaders/pass.fragment.js")]);
|
|
42
|
+
}
|
|
43
|
+
this._shadersLoaded = true;
|
|
32
44
|
}
|
|
33
45
|
/**
|
|
34
46
|
* @internal
|
|
@@ -101,9 +113,21 @@ export class PassCubePostProcess extends PostProcess {
|
|
|
101
113
|
* @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)
|
|
102
114
|
*/
|
|
103
115
|
constructor(name, options, camera = null, samplingMode, engine, reusable, textureType = 0, blockCompilation = false) {
|
|
104
|
-
super(name, "passCube", null, null, options, camera, samplingMode, engine, reusable, "#define POSITIVEX", textureType, undefined, null, blockCompilation);
|
|
116
|
+
super(name, "passCube", null, null, options, camera, samplingMode, engine, reusable, "#define POSITIVEX", textureType, undefined, null, blockCompilation, undefined, undefined, true);
|
|
105
117
|
this._face = 0;
|
|
106
118
|
}
|
|
119
|
+
async _initShaderSourceAsync(forceGLSL = false) {
|
|
120
|
+
const engine = this.getEngine();
|
|
121
|
+
this._shadersLoaded = false;
|
|
122
|
+
if (engine.isWebGPU && !forceGLSL) {
|
|
123
|
+
this._shaderLanguage = 1 /* ShaderLanguage.WGSL */;
|
|
124
|
+
await Promise.all([import("../ShadersWGSL/passCube.fragment.js")]);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
await Promise.all([import("../Shaders/passCube.fragment.js")]);
|
|
128
|
+
}
|
|
129
|
+
this._shadersLoaded = true;
|
|
130
|
+
}
|
|
107
131
|
/**
|
|
108
132
|
* @internal
|
|
109
133
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"passPostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/passPostProcess.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,0BAA0B,CAAC;AAClC,OAAO,8BAA8B,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAIvE;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAC5C;;;OAGG;IACa,YAAY;QACxB,OAAO,iBAAiB,CAAC;IAC7B,CAAC;IAED;;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D,iBAAiB,EACjB,KAAK,EACL,OAAO,CACV,CAAC;IACN,CAAC;CACJ;AAED,cAAc,CAAC,0BAA0B,GAAG,CAAC,MAAsB,EAAE,EAAE;IACnE,OAAO,IAAI,eAAe,CAAC,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,6BAA6B,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,wBAAwB,CAAC,CAAC;AAC/I,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport type { PostProcessOptions } from \"./postProcess\";\r\nimport { PostProcess } from \"./postProcess\";\r\nimport { AbstractEngine } from \"../Engines/abstractEngine\";\r\n\r\nimport \"../Shaders/pass.fragment\";\r\nimport \"../Shaders/passCube.fragment\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport { SerializationHelper } from \"../Misc/decorators.serialization\";\r\n\r\nimport type { Scene } from \"../scene\";\r\n\r\n/**\r\n * PassPostProcess which produces an output the same as it's input\r\n */\r\nexport class PassPostProcess extends PostProcess {\r\n /**\r\n * Gets a string identifying the name of the class\r\n * @returns \"PassPostProcess\" string\r\n */\r\n public override getClassName(): string {\r\n return \"PassPostProcess\";\r\n }\r\n\r\n /**\r\n * Creates the PassPostProcess\r\n * @param name The name of the effect.\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 The type of texture to be used when performing the post processing.\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 options: number | PostProcessOptions,\r\n camera: Nullable<Camera> = null,\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(name, \"pass\", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation);\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) {\r\n return SerializationHelper.Parse(\r\n () => {\r\n return new PassPostProcess(\r\n parsedPostProcess.name,\r\n parsedPostProcess.options,\r\n targetCamera,\r\n parsedPostProcess.renderTargetSamplingMode,\r\n parsedPostProcess._engine,\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.PassPostProcess\", PassPostProcess);\r\n\r\n/**\r\n * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)\r\n */\r\nexport class PassCubePostProcess extends PostProcess {\r\n private _face = 0;\r\n\r\n /**\r\n * Gets or sets the cube face to display.\r\n * * 0 is +X\r\n * * 1 is -X\r\n * * 2 is +Y\r\n * * 3 is -Y\r\n * * 4 is +Z\r\n * * 5 is -Z\r\n */\r\n public get face(): number {\r\n return this._face;\r\n }\r\n\r\n public set face(value: number) {\r\n if (value < 0 || value > 5) {\r\n return;\r\n }\r\n\r\n this._face = value;\r\n switch (this._face) {\r\n case 0:\r\n this.updateEffect(\"#define POSITIVEX\");\r\n break;\r\n case 1:\r\n this.updateEffect(\"#define NEGATIVEX\");\r\n break;\r\n case 2:\r\n this.updateEffect(\"#define POSITIVEY\");\r\n break;\r\n case 3:\r\n this.updateEffect(\"#define NEGATIVEY\");\r\n break;\r\n case 4:\r\n this.updateEffect(\"#define POSITIVEZ\");\r\n break;\r\n case 5:\r\n this.updateEffect(\"#define NEGATIVEZ\");\r\n break;\r\n }\r\n }\r\n\r\n /**\r\n * Gets a string identifying the name of the class\r\n * @returns \"PassCubePostProcess\" string\r\n */\r\n public override getClassName(): string {\r\n return \"PassCubePostProcess\";\r\n }\r\n\r\n /**\r\n * Creates the PassCubePostProcess\r\n * @param name The name of the effect.\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 The type of texture to be used when performing the post processing.\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 options: number | PostProcessOptions,\r\n camera: Nullable<Camera> = null,\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(name, \"passCube\", null, null, options, camera, samplingMode, engine, reusable, \"#define POSITIVEX\", textureType, undefined, null, blockCompilation);\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) {\r\n return SerializationHelper.Parse(\r\n () => {\r\n return new PassCubePostProcess(\r\n parsedPostProcess.name,\r\n parsedPostProcess.options,\r\n targetCamera,\r\n parsedPostProcess.renderTargetSamplingMode,\r\n parsedPostProcess._engine,\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\nAbstractEngine._RescalePostProcessFactory = (engine: AbstractEngine) => {\r\n return new PassPostProcess(\"rescale\", 1, null, Constants.TEXTURE_BILINEAR_SAMPLINGMODE, engine, false, Constants.TEXTURETYPE_UNSIGNED_INT);\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"passPostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/passPostProcess.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,S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AAK,CAC5B,GAAG,EAAE;YACD,OAAO,IAAI,mBAAmB,CAC1B,iBAAiB,CAAC,IAAI,EACtB,iBAAiB,CAAC,OAAO,EACzB,YAAY,EACZ,iBAAiB,CAAC,wBAAwB,EAC1C,iBAAiB,CAAC,OAAO,EACzB,iBAAiB,CAAC,QAAQ,CAC7B,CAAC;QACN,CAAC,EACD,iBAAiB,EACjB,KAAK,EACL,OAAO,CACV,CAAC;IACN,CAAC;CACJ;AAED,cAAc,CAAC,0BAA0B,GAAG,CAAC,MAAsB,EAAE,EAAE;IACnE,OAAO,IAAI,eAAe,CAAC,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,6BAA6B,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,wBAAwB,CAAC,CAAC;AAC/I,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport type { PostProcessOptions } from \"./postProcess\";\r\nimport { PostProcess } from \"./postProcess\";\r\nimport { AbstractEngine } from \"../Engines/abstractEngine\";\r\n\r\nimport \"../Shaders/pass.fragment\";\r\nimport \"../Shaders/passCube.fragment\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport { SerializationHelper } from \"../Misc/decorators.serialization\";\r\n\r\nimport type { Scene } from \"../scene\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * PassPostProcess which produces an output the same as it's input\r\n */\r\nexport class PassPostProcess extends PostProcess {\r\n /**\r\n * Gets a string identifying the name of the class\r\n * @returns \"PassPostProcess\" string\r\n */\r\n public override getClassName(): string {\r\n return \"PassPostProcess\";\r\n }\r\n\r\n /**\r\n * Creates the PassPostProcess\r\n * @param name The name of the effect.\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 The type of texture to be used when performing the post processing.\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 options: number | PostProcessOptions,\r\n camera: Nullable<Camera> = null,\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(name, \"pass\", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation, undefined, undefined, true);\r\n }\r\n\r\n protected override async _initShaderSourceAsync(forceGLSL = false) {\r\n const engine = this.getEngine();\r\n\r\n this._shadersLoaded = false;\r\n\r\n if (engine.isWebGPU && !forceGLSL) {\r\n this._shaderLanguage = ShaderLanguage.WGSL;\r\n\r\n await Promise.all([import(\"../ShadersWGSL/pass.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../Shaders/pass.fragment\")]);\r\n }\r\n\r\n this._shadersLoaded = true;\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) {\r\n return SerializationHelper.Parse(\r\n () => {\r\n return new PassPostProcess(\r\n parsedPostProcess.name,\r\n parsedPostProcess.options,\r\n targetCamera,\r\n parsedPostProcess.renderTargetSamplingMode,\r\n parsedPostProcess._engine,\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.PassPostProcess\", PassPostProcess);\r\n\r\n/**\r\n * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)\r\n */\r\nexport class PassCubePostProcess extends PostProcess {\r\n private _face = 0;\r\n\r\n /**\r\n * Gets or sets the cube face to display.\r\n * * 0 is +X\r\n * * 1 is -X\r\n * * 2 is +Y\r\n * * 3 is -Y\r\n * * 4 is +Z\r\n * * 5 is -Z\r\n */\r\n public get face(): number {\r\n return this._face;\r\n }\r\n\r\n public set face(value: number) {\r\n if (value < 0 || value > 5) {\r\n return;\r\n }\r\n\r\n this._face = value;\r\n switch (this._face) {\r\n case 0:\r\n this.updateEffect(\"#define POSITIVEX\");\r\n break;\r\n case 1:\r\n this.updateEffect(\"#define NEGATIVEX\");\r\n break;\r\n case 2:\r\n this.updateEffect(\"#define POSITIVEY\");\r\n break;\r\n case 3:\r\n this.updateEffect(\"#define NEGATIVEY\");\r\n break;\r\n case 4:\r\n this.updateEffect(\"#define POSITIVEZ\");\r\n break;\r\n case 5:\r\n this.updateEffect(\"#define NEGATIVEZ\");\r\n break;\r\n }\r\n }\r\n\r\n /**\r\n * Gets a string identifying the name of the class\r\n * @returns \"PassCubePostProcess\" string\r\n */\r\n public override getClassName(): string {\r\n return \"PassCubePostProcess\";\r\n }\r\n\r\n /**\r\n * Creates the PassCubePostProcess\r\n * @param name The name of the effect.\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 The type of texture to be used when performing the post processing.\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 options: number | PostProcessOptions,\r\n camera: Nullable<Camera> = null,\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 \"passCube\",\r\n null,\r\n null,\r\n options,\r\n camera,\r\n samplingMode,\r\n engine,\r\n reusable,\r\n \"#define POSITIVEX\",\r\n textureType,\r\n undefined,\r\n null,\r\n blockCompilation,\r\n undefined,\r\n undefined,\r\n true\r\n );\r\n }\r\n\r\n protected override async _initShaderSourceAsync(forceGLSL = false) {\r\n const engine = this.getEngine();\r\n this._shadersLoaded = false;\r\n if (engine.isWebGPU && !forceGLSL) {\r\n this._shaderLanguage = ShaderLanguage.WGSL;\r\n\r\n await Promise.all([import(\"../ShadersWGSL/passCube.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../Shaders/passCube.fragment\")]);\r\n }\r\n\r\n this._shadersLoaded = true;\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) {\r\n return SerializationHelper.Parse(\r\n () => {\r\n return new PassCubePostProcess(\r\n parsedPostProcess.name,\r\n parsedPostProcess.options,\r\n targetCamera,\r\n parsedPostProcess.renderTargetSamplingMode,\r\n parsedPostProcess._engine,\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\nAbstractEngine._RescalePostProcessFactory = (engine: AbstractEngine) => {\r\n return new PassPostProcess(\"rescale\", 1, null, Constants.TEXTURE_BILINEAR_SAMPLINGMODE, engine, false, Constants.TEXTURETYPE_UNSIGNED_INT);\r\n};\r\n"]}
|
|
@@ -162,6 +162,11 @@ export type PostProcessOptions = {
|
|
|
162
162
|
* See https://doc.babylonjs.com/features/featuresDeepDive/postProcesses/usePostProcesses
|
|
163
163
|
*/
|
|
164
164
|
export declare class PostProcess {
|
|
165
|
+
/**
|
|
166
|
+
* Force all the postprocesses to compile to glsl even on WebGPU engines.
|
|
167
|
+
* False by default. This is mostly meant for backward compatibility.
|
|
168
|
+
*/
|
|
169
|
+
static ForceGLSL: boolean;
|
|
165
170
|
/** @internal */
|
|
166
171
|
_parentContainer: Nullable<AbstractScene>;
|
|
167
172
|
private static _CustomShaderCodeProcessing;
|
|
@@ -267,12 +272,14 @@ export declare class PostProcess {
|
|
|
267
272
|
private _camera;
|
|
268
273
|
protected _scene: Scene;
|
|
269
274
|
private _engine;
|
|
275
|
+
protected _shadersLoaded: boolean;
|
|
270
276
|
private _options;
|
|
271
277
|
private _reusable;
|
|
272
278
|
private _renderId;
|
|
273
279
|
private _textureType;
|
|
274
280
|
private _textureFormat;
|
|
275
|
-
|
|
281
|
+
/** @internal */
|
|
282
|
+
protected _shaderLanguage: ShaderLanguage;
|
|
276
283
|
/**
|
|
277
284
|
* if externalTextureSamplerBinding is true, the "apply" method won't bind the textureSampler texture, it is expected to be done by the "outside" (by the onApplyObservable observer most probably).
|
|
278
285
|
* counter-productive in some cases because if the texture bound by "apply" is different from the currently texture bound, (the one set by the onApplyObservable observer, for eg) some
|
|
@@ -409,7 +416,9 @@ export declare class PostProcess {
|
|
|
409
416
|
* @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
|
|
410
417
|
* @param shaderLanguage The shader language of the shader. (default: GLSL)
|
|
411
418
|
*/
|
|
412
|
-
constructor(name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: AbstractEngine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number, shaderLanguage?: ShaderLanguage);
|
|
419
|
+
constructor(name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: AbstractEngine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number, shaderLanguage?: ShaderLanguage, dealyLoadShaders?: boolean);
|
|
420
|
+
protected _initShaderSourceAsync(_forceGLSL?: boolean): Promise<void>;
|
|
421
|
+
private _postConstructor;
|
|
413
422
|
/**
|
|
414
423
|
* Gets a string identifying the name of the class
|
|
415
424
|
* @returns "PostProcess" string
|
|
@@ -171,7 +171,7 @@ export class PostProcess {
|
|
|
171
171
|
return this._texelSize;
|
|
172
172
|
}
|
|
173
173
|
/** @internal */
|
|
174
|
-
constructor(name, fragmentUrl, parameters, samplers, _size, camera, samplingMode = 1, engine, reusable, defines = null, textureType = 0, vertexUrl = "postprocess", indexParameters, blockCompilation = false, textureFormat = 5, shaderLanguage = 0 /* ShaderLanguage.GLSL
|
|
174
|
+
constructor(name, fragmentUrl, parameters, samplers, _size, camera, samplingMode = 1, engine, reusable, defines = null, textureType = 0, vertexUrl = "postprocess", indexParameters, blockCompilation = false, textureFormat = 5, shaderLanguage = 0 /* ShaderLanguage.GLSL */, dealyLoadShaders = false) {
|
|
175
175
|
/** @internal */
|
|
176
176
|
this._parentContainer = null;
|
|
177
177
|
/**
|
|
@@ -238,6 +238,7 @@ export class PostProcess {
|
|
|
238
238
|
* Modify the scale of the post process to be the same as the viewport (default: false)
|
|
239
239
|
*/
|
|
240
240
|
this.adaptScaleToCurrentViewport = false;
|
|
241
|
+
this._shadersLoaded = true;
|
|
241
242
|
this._reusable = false;
|
|
242
243
|
this._renderId = 0;
|
|
243
244
|
/**
|
|
@@ -340,6 +341,13 @@ export class PostProcess {
|
|
|
340
341
|
this._uniformBuffers = uniformBuffers || [];
|
|
341
342
|
this._indexParameters = indexParameters;
|
|
342
343
|
this._drawWrapper = new DrawWrapper(this._engine);
|
|
344
|
+
this._postConstructor(blockCompilation, defines, dealyLoadShaders);
|
|
345
|
+
}
|
|
346
|
+
async _initShaderSourceAsync(_forceGLSL = false) { }
|
|
347
|
+
async _postConstructor(blockCompilation, defines = null, dealyLoadShaders = false) {
|
|
348
|
+
if (dealyLoadShaders) {
|
|
349
|
+
await this._initShaderSourceAsync(PostProcess.ForceGLSL);
|
|
350
|
+
}
|
|
343
351
|
if (!blockCompilation) {
|
|
344
352
|
this.updateEffect(defines);
|
|
345
353
|
}
|
|
@@ -630,6 +638,9 @@ export class PostProcess {
|
|
|
630
638
|
* @returns true if the post-process is ready (shader is compiled)
|
|
631
639
|
*/
|
|
632
640
|
isReady() {
|
|
641
|
+
if (!this._shadersLoaded) {
|
|
642
|
+
return false;
|
|
643
|
+
}
|
|
633
644
|
return this._drawWrapper.effect?.isReady() ?? false;
|
|
634
645
|
}
|
|
635
646
|
/**
|
|
@@ -805,6 +816,11 @@ export class PostProcess {
|
|
|
805
816
|
}, parsedPostProcess, scene, rootUrl);
|
|
806
817
|
}
|
|
807
818
|
}
|
|
819
|
+
/**
|
|
820
|
+
* Force all the postprocesses to compile to glsl even on WebGPU engines.
|
|
821
|
+
* False by default. This is mostly meant for backward compatibility.
|
|
822
|
+
*/
|
|
823
|
+
PostProcess.ForceGLSL = false;
|
|
808
824
|
PostProcess._CustomShaderCodeProcessing = {};
|
|
809
825
|
__decorate([
|
|
810
826
|
serialize()
|