@babylonjs/core 7.32.0 → 7.32.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Behaviors/Cameras/autoRotationBehavior.js +1 -0
- package/Behaviors/Cameras/autoRotationBehavior.js.map +1 -1
- package/Cameras/camera.d.ts +5 -2
- package/Cameras/camera.js +1 -0
- package/Cameras/camera.js.map +1 -1
- package/Decorators/nodeDecorator.d.ts +9 -1
- package/Decorators/nodeDecorator.js +8 -0
- package/Decorators/nodeDecorator.js.map +1 -1
- package/Engines/Extensions/engine.multiRender.js +40 -53
- package/Engines/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/Extensions/engine.renderTarget.js +20 -8
- package/Engines/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.debugging.js +16 -7
- package/Engines/WebGPU/Extensions/engine.debugging.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.js +43 -44
- package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js +8 -6
- package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.d.ts +3 -3
- package/Engines/WebGPU/webgpuHardwareTexture.js +12 -9
- package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.js +25 -19
- package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.d.ts +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +5 -3
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/abstractEngine.d.ts +6 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/constants.d.ts +6 -1
- package/Engines/constants.js +6 -1
- package/Engines/constants.js.map +1 -1
- package/Engines/renderTargetWrapper.d.ts +7 -0
- package/Engines/renderTargetWrapper.js +15 -0
- package/Engines/renderTargetWrapper.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +3 -1
- package/Engines/webgpuEngine.js +9 -8
- package/Engines/webgpuEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.d.ts +47 -0
- package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js +113 -0
- package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.d.ts +62 -0
- package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js +171 -0
- package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.d.ts +51 -0
- package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js +127 -0
- package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.d.ts +67 -0
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +187 -0
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.d.ts +77 -0
- package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js +232 -0
- package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.d.ts +47 -0
- package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js +113 -0
- package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/Rendering/cullObjectsBlock.d.ts +41 -0
- package/FrameGraph/Node/Blocks/Rendering/cullObjectsBlock.js +79 -0
- package/FrameGraph/Node/Blocks/Rendering/cullObjectsBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.d.ts +119 -0
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +451 -0
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.d.ts +63 -0
- package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.js +154 -0
- package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/Teleport/teleportInBlock.d.ts +59 -0
- package/FrameGraph/Node/Blocks/Teleport/teleportInBlock.js +131 -0
- package/FrameGraph/Node/Blocks/Teleport/teleportInBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/Teleport/teleportOutBlock.d.ts +49 -0
- package/FrameGraph/Node/Blocks/Teleport/teleportOutBlock.js +107 -0
- package/FrameGraph/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/Textures/clearBlock.d.ts +50 -0
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js +125 -0
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.d.ts +38 -0
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +71 -0
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.d.ts +34 -0
- package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js +59 -0
- package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/elbowBlock.d.ts +28 -0
- package/FrameGraph/Node/Blocks/elbowBlock.js +47 -0
- package/FrameGraph/Node/Blocks/elbowBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/index.d.ts +17 -0
- package/FrameGraph/Node/Blocks/index.js +18 -0
- package/FrameGraph/Node/Blocks/index.js.map +1 -0
- package/FrameGraph/Node/Blocks/inputBlock.d.ts +94 -0
- package/FrameGraph/Node/Blocks/inputBlock.js +270 -0
- package/FrameGraph/Node/Blocks/inputBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/outputBlock.d.ts +30 -0
- package/FrameGraph/Node/Blocks/outputBlock.js +51 -0
- package/FrameGraph/Node/Blocks/outputBlock.js.map +1 -0
- package/FrameGraph/Node/Types/nodeRenderGraphTypes.d.ts +110 -0
- package/FrameGraph/Node/Types/nodeRenderGraphTypes.js +78 -0
- package/FrameGraph/Node/Types/nodeRenderGraphTypes.js.map +1 -0
- package/FrameGraph/Node/nodeRenderGraph.d.ts +196 -0
- package/FrameGraph/Node/nodeRenderGraph.js +614 -0
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -0
- package/FrameGraph/Node/nodeRenderGraphBlock.d.ts +190 -0
- package/FrameGraph/Node/nodeRenderGraphBlock.js +495 -0
- package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -0
- package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.d.ts +143 -0
- package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js +275 -0
- package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js.map +1 -0
- package/FrameGraph/Node/nodeRenderGraphBuildState.d.ts +21 -0
- package/FrameGraph/Node/nodeRenderGraphBuildState.js +35 -0
- package/FrameGraph/Node/nodeRenderGraphBuildState.js.map +1 -0
- package/FrameGraph/Passes/cullPass.d.ts +28 -0
- package/FrameGraph/Passes/cullPass.js +38 -0
- package/FrameGraph/Passes/cullPass.js.map +1 -0
- package/FrameGraph/Passes/pass.d.ts +14 -0
- package/FrameGraph/Passes/pass.js +20 -0
- package/FrameGraph/Passes/pass.js.map +1 -0
- package/FrameGraph/Passes/renderPass.d.ts +49 -0
- package/FrameGraph/Passes/renderPass.js +72 -0
- package/FrameGraph/Passes/renderPass.js.map +1 -0
- package/FrameGraph/Tasks/PostProcesses/blackAndWhiteTask.d.ts +16 -0
- package/FrameGraph/Tasks/PostProcesses/blackAndWhiteTask.js +17 -0
- package/FrameGraph/Tasks/PostProcesses/blackAndWhiteTask.js.map +1 -0
- package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.d.ts +12 -0
- package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.js +21 -0
- package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.js.map +1 -0
- package/FrameGraph/Tasks/PostProcesses/bloomTask.d.ts +54 -0
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js +114 -0
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -0
- package/FrameGraph/Tasks/PostProcesses/blurTask.d.ts +17 -0
- package/FrameGraph/Tasks/PostProcesses/blurTask.js +24 -0
- package/FrameGraph/Tasks/PostProcesses/blurTask.js.map +1 -0
- package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.d.ts +30 -0
- package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.js +35 -0
- package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.js.map +1 -0
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.d.ts +12 -0
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.js +26 -0
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.js.map +1 -0
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.d.ts +12 -0
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js +29 -0
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js.map +1 -0
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.d.ts +65 -0
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js +134 -0
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js.map +1 -0
- package/FrameGraph/Tasks/PostProcesses/extractHighlightsTask.d.ts +16 -0
- package/FrameGraph/Tasks/PostProcesses/extractHighlightsTask.js +17 -0
- package/FrameGraph/Tasks/PostProcesses/extractHighlightsTask.js.map +1 -0
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.d.ts +41 -0
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +64 -0
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -0
- package/FrameGraph/Tasks/Rendering/cullObjectsTask.d.ts +28 -0
- package/FrameGraph/Tasks/Rendering/cullObjectsTask.js +52 -0
- package/FrameGraph/Tasks/Rendering/cullObjectsTask.js.map +1 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +145 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +259 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +66 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +127 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -0
- package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +34 -0
- package/FrameGraph/Tasks/Texture/clearTextureTask.js +42 -0
- package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -0
- package/FrameGraph/Tasks/Texture/copyToBackbufferColorTask.d.ts +12 -0
- package/FrameGraph/Tasks/Texture/copyToBackbufferColorTask.js +23 -0
- package/FrameGraph/Tasks/Texture/copyToBackbufferColorTask.js.map +1 -0
- package/FrameGraph/Tasks/Texture/copyToTextureTask.d.ts +26 -0
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js +31 -0
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -0
- package/FrameGraph/Tasks/Texture/generateMipMapsTask.d.ts +22 -0
- package/FrameGraph/Tasks/Texture/generateMipMapsTask.js +34 -0
- package/FrameGraph/Tasks/Texture/generateMipMapsTask.js.map +1 -0
- package/FrameGraph/frameGraph.d.ts +143 -0
- package/FrameGraph/frameGraph.js +275 -0
- package/FrameGraph/frameGraph.js.map +1 -0
- package/FrameGraph/frameGraphContext.d.ts +5 -0
- package/FrameGraph/frameGraphContext.js +6 -0
- package/FrameGraph/frameGraphContext.js.map +1 -0
- package/FrameGraph/frameGraphObjectList.d.ts +15 -0
- package/FrameGraph/frameGraphObjectList.js +7 -0
- package/FrameGraph/frameGraphObjectList.js.map +1 -0
- package/FrameGraph/frameGraphRenderContext.d.ts +110 -0
- package/FrameGraph/frameGraphRenderContext.js +237 -0
- package/FrameGraph/frameGraphRenderContext.js.map +1 -0
- package/FrameGraph/frameGraphTask.d.ts +49 -0
- package/FrameGraph/frameGraphTask.js +117 -0
- package/FrameGraph/frameGraphTask.js.map +1 -0
- package/FrameGraph/frameGraphTextureManager.d.ts +50 -0
- package/FrameGraph/frameGraphTextureManager.js +277 -0
- package/FrameGraph/frameGraphTextureManager.js.map +1 -0
- package/FrameGraph/frameGraphTypes.d.ts +59 -0
- package/FrameGraph/frameGraphTypes.js +9 -0
- package/FrameGraph/frameGraphTypes.js.map +1 -0
- package/FrameGraph/index.d.ts +28 -0
- package/FrameGraph/index.js +30 -0
- package/FrameGraph/index.js.map +1 -0
- package/Gamepads/gamepadSceneComponent.d.ts +0 -1
- package/Gamepads/gamepadSceneComponent.js +1 -7
- package/Gamepads/gamepadSceneComponent.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.d.ts +7 -0
- package/Gizmos/boundingBoxGizmo.js +19 -6
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Inputs/scene.inputManager.d.ts +3 -1
- package/Inputs/scene.inputManager.js +20 -8
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Layers/layer.d.ts +1 -1
- package/Layers/layer.js +1 -1
- package/Layers/layer.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.d.ts +4 -0
- package/Materials/PBR/pbrBaseMaterial.js +8 -0
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/dynamicTexture.d.ts +32 -2
- package/Materials/Textures/dynamicTexture.js +13 -18
- package/Materials/Textures/dynamicTexture.js.map +1 -1
- package/Materials/Textures/index.d.ts +1 -0
- package/Materials/Textures/index.js +1 -0
- package/Materials/Textures/index.js.map +1 -1
- package/Materials/Textures/mirrorTexture.js +0 -6
- package/Materials/Textures/mirrorTexture.js.map +1 -1
- package/Materials/Textures/multiRenderTarget.d.ts +20 -8
- package/Materials/Textures/multiRenderTarget.js +2 -0
- package/Materials/Textures/multiRenderTarget.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.d.ts +8 -1
- package/Materials/Textures/renderTargetTexture.js +28 -10
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/Textures/textureCreationOptions.d.ts +20 -2
- package/Materials/Textures/textureCreationOptions.js +20 -1
- package/Materials/Textures/textureCreationOptions.js.map +1 -1
- package/Materials/effectRenderer.d.ts +132 -14
- package/Materials/effectRenderer.js +229 -33
- package/Materials/effectRenderer.js.map +1 -1
- package/Materials/index.d.ts +1 -0
- package/Materials/index.js +1 -0
- package/Materials/index.js.map +1 -1
- package/Materials/materialHelper.functions.js +2 -0
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/materialHelper.geometryrendering.d.ts +122 -0
- package/Materials/materialHelper.geometryrendering.js +259 -0
- package/Materials/materialHelper.geometryrendering.js.map +1 -0
- package/Materials/standardMaterial.d.ts +4 -0
- package/Materials/standardMaterial.js +8 -0
- package/Materials/standardMaterial.js.map +1 -1
- package/Maths/index.d.ts +1 -0
- package/Maths/index.js +1 -0
- package/Maths/index.js.map +1 -1
- package/Meshes/Builders/greasedLineBuilder.d.ts +1 -1
- package/Meshes/Node/Blocks/geometryOptimizeBlock.d.ts +22 -1
- package/Meshes/Node/Blocks/geometryOptimizeBlock.js +39 -0
- package/Meshes/Node/Blocks/geometryOptimizeBlock.js.map +1 -1
- package/Misc/copyTextureToTexture.d.ts +3 -2
- package/Misc/copyTextureToTexture.js +11 -5
- package/Misc/copyTextureToTexture.js.map +1 -1
- package/PostProcesses/blackAndWhitePostProcess.d.ts +5 -3
- package/PostProcesses/blackAndWhitePostProcess.js +24 -19
- package/PostProcesses/blackAndWhitePostProcess.js.map +1 -1
- package/PostProcesses/bloomEffect.d.ts +7 -5
- package/PostProcesses/bloomEffect.js +49 -23
- package/PostProcesses/bloomEffect.js.map +1 -1
- package/PostProcesses/bloomMergePostProcess.d.ts +5 -5
- package/PostProcesses/bloomMergePostProcess.js +28 -19
- package/PostProcesses/bloomMergePostProcess.js.map +1 -1
- package/PostProcesses/blurPostProcess.d.ts +7 -43
- package/PostProcesses/blurPostProcess.js +47 -185
- package/PostProcesses/blurPostProcess.js.map +1 -1
- package/PostProcesses/circleOfConfusionPostProcess.d.ts +13 -6
- package/PostProcesses/circleOfConfusionPostProcess.js +59 -38
- package/PostProcesses/circleOfConfusionPostProcess.js.map +1 -1
- package/PostProcesses/depthOfFieldBlurPostProcess.d.ts +2 -6
- package/PostProcesses/depthOfFieldBlurPostProcess.js +14 -11
- package/PostProcesses/depthOfFieldBlurPostProcess.js.map +1 -1
- package/PostProcesses/depthOfFieldEffect.d.ts +5 -2
- package/PostProcesses/depthOfFieldEffect.js +53 -45
- package/PostProcesses/depthOfFieldEffect.js.map +1 -1
- package/PostProcesses/depthOfFieldMergePostProcess.d.ts +0 -1
- package/PostProcesses/depthOfFieldMergePostProcess.js +18 -12
- package/PostProcesses/depthOfFieldMergePostProcess.js.map +1 -1
- package/PostProcesses/extractHighlightsPostProcess.d.ts +8 -4
- package/PostProcesses/extractHighlightsPostProcess.js +35 -22
- package/PostProcesses/extractHighlightsPostProcess.js.map +1 -1
- package/PostProcesses/index.d.ts +6 -0
- package/PostProcesses/index.js +6 -0
- package/PostProcesses/index.js.map +1 -1
- package/PostProcesses/postProcess.d.ts +15 -70
- package/PostProcesses/postProcess.js +80 -97
- package/PostProcesses/postProcess.js.map +1 -1
- package/PostProcesses/thinBlackAndWhitePostProcess.d.ts +28 -0
- package/PostProcesses/thinBlackAndWhitePostProcess.js +50 -0
- package/PostProcesses/thinBlackAndWhitePostProcess.js.map +1 -0
- package/PostProcesses/thinBloomEffect.d.ts +49 -0
- package/PostProcesses/thinBloomEffect.js +59 -0
- package/PostProcesses/thinBloomEffect.js.map +1 -0
- package/PostProcesses/thinBloomMergePostProcess.d.ts +15 -0
- package/PostProcesses/thinBloomMergePostProcess.js +38 -0
- package/PostProcesses/thinBloomMergePostProcess.js.map +1 -0
- package/PostProcesses/thinBlurPostProcess.d.ts +89 -0
- package/PostProcesses/thinBlurPostProcess.js +242 -0
- package/PostProcesses/thinBlurPostProcess.js.map +1 -0
- package/PostProcesses/thinCircleOfConfusionPostProcess.d.ts +62 -0
- package/PostProcesses/thinCircleOfConfusionPostProcess.js +81 -0
- package/PostProcesses/thinCircleOfConfusionPostProcess.js.map +1 -0
- package/PostProcesses/thinDepthOfFieldBlurPostProcess.d.ts +8 -0
- package/PostProcesses/thinDepthOfFieldBlurPostProcess.js +13 -0
- package/PostProcesses/thinDepthOfFieldBlurPostProcess.js.map +1 -0
- package/PostProcesses/thinDepthOfFieldEffect.d.ts +70 -0
- package/PostProcesses/thinDepthOfFieldEffect.js +115 -0
- package/PostProcesses/thinDepthOfFieldEffect.js.map +1 -0
- package/PostProcesses/thinDepthOfFieldMergePostProcess.d.ts +11 -0
- package/PostProcesses/thinDepthOfFieldMergePostProcess.js +30 -0
- package/PostProcesses/thinDepthOfFieldMergePostProcess.js.map +1 -0
- package/PostProcesses/thinExtractHighlightsPostProcess.d.ts +30 -0
- package/PostProcesses/thinExtractHighlightsPostProcess.js +55 -0
- package/PostProcesses/thinExtractHighlightsPostProcess.js.map +1 -0
- package/Rendering/depthPeelingRenderer.js +2 -2
- package/Rendering/depthPeelingRenderer.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingObject.js +4 -4
- package/Rendering/fluidRenderer/fluidRenderingObject.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js +1 -1
- package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockPrePass.d.ts +5 -0
- package/Shaders/ShadersInclude/pbrBlockPrePass.js +75 -0
- package/Shaders/ShadersInclude/pbrBlockPrePass.js.map +1 -0
- package/Shaders/ShadersInclude/prePassVertex.js +1 -2
- package/Shaders/ShadersInclude/prePassVertex.js.map +1 -1
- package/Shaders/circleOfConfusion.fragment.js +9 -1
- package/Shaders/circleOfConfusion.fragment.js.map +1 -1
- package/Shaders/colorCorrection.fragment.js +1 -0
- package/Shaders/colorCorrection.fragment.js.map +1 -1
- package/Shaders/default.fragment.js +17 -25
- package/Shaders/default.fragment.js.map +1 -1
- package/Shaders/default.vertex.js +4 -6
- package/Shaders/default.vertex.js.map +1 -1
- package/Shaders/pbr.fragment.d.ts +1 -0
- package/Shaders/pbr.fragment.js +2 -74
- package/Shaders/pbr.fragment.js.map +1 -1
- package/Shaders/pbr.vertex.js +3 -3
- package/Shaders/pbr.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.js +100 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/prePassVertex.js +1 -2
- package/ShadersWGSL/ShadersInclude/prePassVertex.js.map +1 -1
- package/ShadersWGSL/background.vertex.js +1 -1
- package/ShadersWGSL/background.vertex.js.map +1 -1
- package/ShadersWGSL/circleOfConfusion.fragment.js +10 -2
- package/ShadersWGSL/circleOfConfusion.fragment.js.map +1 -1
- package/ShadersWGSL/default.fragment.js +20 -31
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/default.vertex.js +4 -5
- package/ShadersWGSL/default.vertex.js.map +1 -1
- package/ShadersWGSL/glowMapGeneration.fragment.js +1 -1
- package/ShadersWGSL/glowMapGeneration.fragment.js.map +1 -1
- package/ShadersWGSL/glowMapGeneration.vertex.js +1 -1
- package/ShadersWGSL/glowMapGeneration.vertex.js.map +1 -1
- package/ShadersWGSL/pbr.fragment.d.ts +1 -0
- package/ShadersWGSL/pbr.fragment.js +2 -100
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/ShadersWGSL/pbr.vertex.js +4 -2
- package/ShadersWGSL/pbr.vertex.js.map +1 -1
- package/XR/features/WebXRRawCameraAccess.js +1 -1
- package/XR/features/WebXRRawCameraAccess.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +19 -2
- package/scene.js +110 -13
- package/scene.js.map +1 -1
- package/sceneComponent.d.ts +0 -1
- package/sceneComponent.js +0 -1
- package/sceneComponent.js.map +1 -1
- package/types.d.ts +12 -0
- package/types.js.map +1 -1
|
@@ -12,10 +12,6 @@ import type { AbstractEngine } from "../Engines/abstractEngine.js";
|
|
|
12
12
|
* See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
|
|
13
13
|
*/
|
|
14
14
|
export declare class DepthOfFieldBlurPostProcess extends BlurPostProcess {
|
|
15
|
-
/**
|
|
16
|
-
* The direction the blur should be applied
|
|
17
|
-
*/
|
|
18
|
-
direction: Vector2;
|
|
19
15
|
/**
|
|
20
16
|
* Gets a string identifying the name of the class
|
|
21
17
|
* @returns "DepthOfFieldBlurPostProcess" string
|
|
@@ -24,7 +20,7 @@ export declare class DepthOfFieldBlurPostProcess extends BlurPostProcess {
|
|
|
24
20
|
/**
|
|
25
21
|
* Creates a new instance DepthOfFieldBlurPostProcess
|
|
26
22
|
* @param name The name of the effect.
|
|
27
|
-
* @param
|
|
23
|
+
* @param _scene The scene the effect belongs to (not used, you can pass null)
|
|
28
24
|
* @param direction The direction the blur should be applied.
|
|
29
25
|
* @param kernel The size of the kernel used to blur.
|
|
30
26
|
* @param options The required width/height ratio to downsize to before computing the render pass.
|
|
@@ -38,5 +34,5 @@ export declare class DepthOfFieldBlurPostProcess extends BlurPostProcess {
|
|
|
38
34
|
* @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)
|
|
39
35
|
* @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
|
|
40
36
|
*/
|
|
41
|
-
constructor(name: string,
|
|
37
|
+
constructor(name: string, _scene: Nullable<Scene>, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, circleOfConfusion: PostProcess, imageToBlur?: Nullable<PostProcess>, samplingMode?: number, engine?: AbstractEngine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, textureFormat?: number);
|
|
42
38
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { __decorate } from "../tslib.es6.js";
|
|
2
1
|
import { Texture } from "../Materials/Textures/texture.js";
|
|
3
2
|
import { BlurPostProcess } from "./blurPostProcess.js";
|
|
4
3
|
|
|
5
4
|
import { RegisterClass } from "../Misc/typeStore.js";
|
|
6
|
-
import { serialize } from "../Misc/decorators.js";
|
|
7
5
|
/**
|
|
8
6
|
* The DepthOfFieldBlurPostProcess applied a blur in a give direction.
|
|
9
7
|
* This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
|
|
@@ -21,7 +19,7 @@ export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
|
|
|
21
19
|
/**
|
|
22
20
|
* Creates a new instance DepthOfFieldBlurPostProcess
|
|
23
21
|
* @param name The name of the effect.
|
|
24
|
-
* @param
|
|
22
|
+
* @param _scene The scene the effect belongs to (not used, you can pass null)
|
|
25
23
|
* @param direction The direction the blur should be applied.
|
|
26
24
|
* @param kernel The size of the kernel used to blur.
|
|
27
25
|
* @param options The required width/height ratio to downsize to before computing the render pass.
|
|
@@ -35,11 +33,19 @@ export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
|
|
|
35
33
|
* @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)
|
|
36
34
|
* @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
|
|
37
35
|
*/
|
|
38
|
-
constructor(name,
|
|
39
|
-
super(name, direction, kernel,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
constructor(name, _scene, direction, kernel, options, camera, circleOfConfusion, imageToBlur = null, samplingMode = Texture.BILINEAR_SAMPLINGMODE, engine, reusable, textureType = 0, blockCompilation = false, textureFormat = 5) {
|
|
37
|
+
super(name, direction, kernel, {
|
|
38
|
+
camera,
|
|
39
|
+
engine,
|
|
40
|
+
reusable,
|
|
41
|
+
textureType,
|
|
42
|
+
defines: `#define DOF 1\n`,
|
|
43
|
+
blockCompilation,
|
|
44
|
+
textureFormat,
|
|
45
|
+
...options,
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
47
|
+
samplingMode: (samplingMode = 2),
|
|
48
|
+
});
|
|
43
49
|
this.externalTextureSamplerBinding = !!imageToBlur;
|
|
44
50
|
this.onApplyObservable.add((effect) => {
|
|
45
51
|
if (imageToBlur != null) {
|
|
@@ -49,8 +55,5 @@ export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
|
|
|
49
55
|
});
|
|
50
56
|
}
|
|
51
57
|
}
|
|
52
|
-
__decorate([
|
|
53
|
-
serialize()
|
|
54
|
-
], DepthOfFieldBlurPostProcess.prototype, "direction", void 0);
|
|
55
58
|
RegisterClass("BABYLON.DepthOfFieldBlurPostProcess", DepthOfFieldBlurPostProcess);
|
|
56
59
|
//# sourceMappingURL=depthOfFieldBlurPostProcess.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"depthOfFieldBlurPostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/depthOfFieldBlurPostProcess.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"depthOfFieldBlurPostProcess.js","sourceRoot":"","sources":["../../../../dev/core/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EAAE,iBAAiB,CAAC,CAAC;QAC1F,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,aAAa,CAAC,qCAAqC,EAAE,2BAA2B,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { Vector2 } from \"../Maths/math.vector\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport type { PostProcess, PostProcessOptions } from \"./postProcess\";\r\nimport { BlurPostProcess } from \"./blurPostProcess\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\n\r\n/**\r\n * The DepthOfFieldBlurPostProcess applied a blur in a give direction.\r\n * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels\r\n * based on samples that have a large difference in distance than the center pixel.\r\n * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf\r\n */\r\nexport class DepthOfFieldBlurPostProcess extends BlurPostProcess {\r\n /**\r\n * Gets a string identifying the name of the class\r\n * @returns \"DepthOfFieldBlurPostProcess\" string\r\n */\r\n public override getClassName(): string {\r\n return \"DepthOfFieldBlurPostProcess\";\r\n }\r\n\r\n /**\r\n * Creates a new instance DepthOfFieldBlurPostProcess\r\n * @param name The name of the effect.\r\n * @param _scene The scene the effect belongs to (not used, you can pass null)\r\n * @param direction The direction the blur should be applied.\r\n * @param kernel The size of the kernel used to blur.\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 circleOfConfusion The circle of confusion + depth map to be used to avoid blurring across edges\r\n * @param imageToBlur The image to apply the blur to (default: Current rendered frame)\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 * @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 _scene: Nullable<Scene>,\r\n direction: Vector2,\r\n kernel: number,\r\n options: number | PostProcessOptions,\r\n camera: Nullable<Camera>,\r\n circleOfConfusion: PostProcess,\r\n imageToBlur: Nullable<PostProcess> = null,\r\n samplingMode = Texture.BILINEAR_SAMPLINGMODE,\r\n engine?: AbstractEngine,\r\n reusable?: boolean,\r\n textureType = Constants.TEXTURETYPE_UNSIGNED_INT,\r\n blockCompilation = false,\r\n textureFormat = Constants.TEXTUREFORMAT_RGBA\r\n ) {\r\n super(name, direction, kernel, {\r\n camera,\r\n engine,\r\n reusable,\r\n textureType,\r\n defines: `#define DOF 1\\n`,\r\n blockCompilation,\r\n textureFormat,\r\n ...(options as PostProcessOptions),\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n samplingMode: (samplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE),\r\n });\r\n\r\n this.externalTextureSamplerBinding = !!imageToBlur;\r\n\r\n this.onApplyObservable.add((effect: Effect) => {\r\n if (imageToBlur != null) {\r\n effect.setTextureFromPostProcess(\"textureSampler\", imageToBlur);\r\n }\r\n effect.setTextureFromPostProcessOutput(\"circleOfConfusionSampler\", circleOfConfusion);\r\n });\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.DepthOfFieldBlurPostProcess\", DepthOfFieldBlurPostProcess);\r\n"]}
|
|
@@ -5,6 +5,7 @@ import type { PostProcess } from "./postProcess";
|
|
|
5
5
|
import { PostProcessRenderEffect } from "../PostProcesses/RenderPipeline/postProcessRenderEffect";
|
|
6
6
|
import { DepthOfFieldBlurPostProcess } from "./depthOfFieldBlurPostProcess";
|
|
7
7
|
import type { Scene } from "../scene";
|
|
8
|
+
import type { AbstractEngine } from "../Engines/abstractEngine.js";
|
|
8
9
|
/**
|
|
9
10
|
* Specifies the level of max blur that should be applied when using the depth of field effect
|
|
10
11
|
*/
|
|
@@ -57,15 +58,17 @@ export declare class DepthOfFieldEffect extends PostProcessRenderEffect {
|
|
|
57
58
|
*/
|
|
58
59
|
set lensSize(value: number);
|
|
59
60
|
get lensSize(): number;
|
|
61
|
+
private _thinDepthOfFieldEffect;
|
|
60
62
|
/**
|
|
61
63
|
* Creates a new instance DepthOfFieldEffect
|
|
62
|
-
* @param
|
|
64
|
+
* @param sceneOrEngine The scene or engine the effect belongs to.
|
|
63
65
|
* @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.
|
|
64
66
|
* @param blurLevel
|
|
65
67
|
* @param pipelineTextureType The type of texture to be used when performing the post processing.
|
|
66
68
|
* @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)
|
|
69
|
+
* @param depthNotNormalized If the depth from the depth texture is already normalized or if the normalization should be done at runtime in the shader (default: false)
|
|
67
70
|
*/
|
|
68
|
-
constructor(
|
|
71
|
+
constructor(sceneOrEngine: Scene | AbstractEngine, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean, depthNotNormalized?: boolean);
|
|
69
72
|
/**
|
|
70
73
|
* Get the current class name of the current effect
|
|
71
74
|
* @returns "DepthOfFieldEffect"
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Vector2 } from "../Maths/math.vector.js";
|
|
2
1
|
import { Texture } from "../Materials/Textures/texture.js";
|
|
3
2
|
import { PostProcessRenderEffect } from "../PostProcesses/RenderPipeline/postProcessRenderEffect.js";
|
|
4
3
|
import { CircleOfConfusionPostProcess } from "./circleOfConfusionPostProcess.js";
|
|
5
4
|
import { DepthOfFieldBlurPostProcess } from "./depthOfFieldBlurPostProcess.js";
|
|
6
5
|
import { DepthOfFieldMergePostProcess } from "./depthOfFieldMergePostProcess.js";
|
|
7
6
|
|
|
7
|
+
import { ThinDepthOfFieldEffect } from "./thinDepthOfFieldEffect.js";
|
|
8
8
|
/**
|
|
9
9
|
* Specifies the level of max blur that should be applied when using the depth of field effect
|
|
10
10
|
*/
|
|
@@ -31,91 +31,97 @@ export class DepthOfFieldEffect extends PostProcessRenderEffect {
|
|
|
31
31
|
* The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
|
|
32
32
|
*/
|
|
33
33
|
set focalLength(value) {
|
|
34
|
-
this.
|
|
34
|
+
this._thinDepthOfFieldEffect.focalLength = value;
|
|
35
35
|
}
|
|
36
36
|
get focalLength() {
|
|
37
|
-
return this.
|
|
37
|
+
return this._thinDepthOfFieldEffect.focalLength;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
|
|
41
41
|
*/
|
|
42
42
|
set fStop(value) {
|
|
43
|
-
this.
|
|
43
|
+
this._thinDepthOfFieldEffect.fStop = value;
|
|
44
44
|
}
|
|
45
45
|
get fStop() {
|
|
46
|
-
return this.
|
|
46
|
+
return this._thinDepthOfFieldEffect.fStop;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
|
|
50
50
|
*/
|
|
51
51
|
set focusDistance(value) {
|
|
52
|
-
this.
|
|
52
|
+
this._thinDepthOfFieldEffect.focusDistance = value;
|
|
53
53
|
}
|
|
54
54
|
get focusDistance() {
|
|
55
|
-
return this.
|
|
55
|
+
return this._thinDepthOfFieldEffect.focusDistance;
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
58
|
* 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.
|
|
59
59
|
*/
|
|
60
60
|
set lensSize(value) {
|
|
61
|
-
this.
|
|
61
|
+
this._thinDepthOfFieldEffect.lensSize = value;
|
|
62
62
|
}
|
|
63
63
|
get lensSize() {
|
|
64
|
-
return this.
|
|
64
|
+
return this._thinDepthOfFieldEffect.lensSize;
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* Creates a new instance DepthOfFieldEffect
|
|
68
|
-
* @param
|
|
68
|
+
* @param sceneOrEngine The scene or engine the effect belongs to.
|
|
69
69
|
* @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.
|
|
70
70
|
* @param blurLevel
|
|
71
71
|
* @param pipelineTextureType The type of texture to be used when performing the post processing.
|
|
72
72
|
* @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)
|
|
73
|
+
* @param depthNotNormalized If the depth from the depth texture is already normalized or if the normalization should be done at runtime in the shader (default: false)
|
|
73
74
|
*/
|
|
74
|
-
constructor(
|
|
75
|
-
|
|
75
|
+
constructor(sceneOrEngine, depthTexture, blurLevel = 0 /* DepthOfFieldEffectBlurLevel.Low */, pipelineTextureType = 0, blockCompilation = false, depthNotNormalized = false) {
|
|
76
|
+
const engine = sceneOrEngine._renderForCamera ? sceneOrEngine.getEngine() : sceneOrEngine;
|
|
77
|
+
super(engine, "depth of field", () => {
|
|
76
78
|
return this._effects;
|
|
77
79
|
}, true);
|
|
78
80
|
/**
|
|
79
81
|
* @internal Internal post processes in depth of field effect
|
|
80
82
|
*/
|
|
81
83
|
this._effects = [];
|
|
84
|
+
this._thinDepthOfFieldEffect = new ThinDepthOfFieldEffect("Depth of Field", engine, blurLevel, false, blockCompilation);
|
|
82
85
|
// Use R-only formats if supported to store the circle of confusion values.
|
|
83
86
|
// This should be more space and bandwidth efficient than using RGBA.
|
|
84
|
-
const engine = scene.getEngine();
|
|
85
87
|
const circleOfConfusionTextureFormat = engine.isWebGPU || engine.version > 1 ? 6 : 5;
|
|
86
88
|
// Circle of confusion value for each pixel is used to determine how much to blur that pixel
|
|
87
|
-
this._circleOfConfusion = new CircleOfConfusionPostProcess("circleOfConfusion", depthTexture,
|
|
89
|
+
this._circleOfConfusion = new CircleOfConfusionPostProcess("circleOfConfusion", depthTexture, {
|
|
90
|
+
size: 1,
|
|
91
|
+
samplingMode: Texture.BILINEAR_SAMPLINGMODE,
|
|
92
|
+
engine,
|
|
93
|
+
textureType: pipelineTextureType,
|
|
94
|
+
blockCompilation,
|
|
95
|
+
depthNotNormalized,
|
|
96
|
+
effectWrapper: this._thinDepthOfFieldEffect._circleOfConfusion,
|
|
97
|
+
}, null);
|
|
88
98
|
// Create a pyramid of blurred images (eg. fullSize 1/4 blur, half size 1/2 blur, quarter size 3/4 blur, eith size 4/4 blur)
|
|
89
99
|
// Blur the image but do not blur on sharp far to near distance changes to avoid bleeding artifacts
|
|
90
100
|
// See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
|
|
91
101
|
this._depthOfFieldBlurY = [];
|
|
92
102
|
this._depthOfFieldBlurX = [];
|
|
93
|
-
|
|
94
|
-
let kernelSize = 15;
|
|
95
|
-
switch (blurLevel) {
|
|
96
|
-
case 2 /* DepthOfFieldEffectBlurLevel.High */: {
|
|
97
|
-
blurCount = 3;
|
|
98
|
-
kernelSize = 51;
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
case 1 /* DepthOfFieldEffectBlurLevel.Medium */: {
|
|
102
|
-
blurCount = 2;
|
|
103
|
-
kernelSize = 31;
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
default: {
|
|
107
|
-
kernelSize = 15;
|
|
108
|
-
blurCount = 1;
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
const adjustedKernelSize = kernelSize / Math.pow(2, blurCount - 1);
|
|
113
|
-
let ratio = 1.0;
|
|
103
|
+
const blurCount = this._thinDepthOfFieldEffect._depthOfFieldBlurX.length;
|
|
114
104
|
for (let i = 0; i < blurCount; i++) {
|
|
115
|
-
const
|
|
105
|
+
const [thinBlurY, ratioY] = this._thinDepthOfFieldEffect._depthOfFieldBlurY[i];
|
|
106
|
+
const blurY = new DepthOfFieldBlurPostProcess("vertical blur", null, thinBlurY.direction, thinBlurY.kernel, {
|
|
107
|
+
size: ratioY,
|
|
108
|
+
samplingMode: Texture.BILINEAR_SAMPLINGMODE,
|
|
109
|
+
engine,
|
|
110
|
+
textureType: pipelineTextureType,
|
|
111
|
+
blockCompilation,
|
|
112
|
+
textureFormat: i == 0 ? circleOfConfusionTextureFormat : 5,
|
|
113
|
+
effectWrapper: thinBlurY,
|
|
114
|
+
}, null, this._circleOfConfusion, i == 0 ? this._circleOfConfusion : null);
|
|
116
115
|
blurY.autoClear = false;
|
|
117
|
-
|
|
118
|
-
const blurX = new DepthOfFieldBlurPostProcess("horizontal blur",
|
|
116
|
+
const [thinBlurX, ratioX] = this._thinDepthOfFieldEffect._depthOfFieldBlurX[i];
|
|
117
|
+
const blurX = new DepthOfFieldBlurPostProcess("horizontal blur", null, thinBlurX.direction, thinBlurX.kernel, {
|
|
118
|
+
size: ratioX,
|
|
119
|
+
samplingMode: Texture.BILINEAR_SAMPLINGMODE,
|
|
120
|
+
engine,
|
|
121
|
+
textureType: pipelineTextureType,
|
|
122
|
+
blockCompilation,
|
|
123
|
+
effectWrapper: thinBlurX,
|
|
124
|
+
}, null, this._circleOfConfusion, null);
|
|
119
125
|
blurX.autoClear = false;
|
|
120
126
|
this._depthOfFieldBlurY.push(blurY);
|
|
121
127
|
this._depthOfFieldBlurX.push(blurX);
|
|
@@ -127,7 +133,14 @@ export class DepthOfFieldEffect extends PostProcessRenderEffect {
|
|
|
127
133
|
this._effects.push(this._depthOfFieldBlurX[i]);
|
|
128
134
|
}
|
|
129
135
|
// Merge blurred images with original image based on circleOfConfusion
|
|
130
|
-
this._dofMerge = new DepthOfFieldMergePostProcess("dofMerge", this._circleOfConfusion, this._circleOfConfusion, this._depthOfFieldBlurX,
|
|
136
|
+
this._dofMerge = new DepthOfFieldMergePostProcess("dofMerge", this._circleOfConfusion, this._circleOfConfusion, this._depthOfFieldBlurX, {
|
|
137
|
+
size: this._thinDepthOfFieldEffect._depthOfFieldBlurX[blurCount - 1][1],
|
|
138
|
+
samplingMode: Texture.BILINEAR_SAMPLINGMODE,
|
|
139
|
+
engine,
|
|
140
|
+
textureType: pipelineTextureType,
|
|
141
|
+
blockCompilation,
|
|
142
|
+
effectWrapper: this._thinDepthOfFieldEffect._dofMerge,
|
|
143
|
+
}, null);
|
|
131
144
|
this._dofMerge.autoClear = false;
|
|
132
145
|
this._effects.push(this._dofMerge);
|
|
133
146
|
}
|
|
@@ -167,12 +180,7 @@ export class DepthOfFieldEffect extends PostProcessRenderEffect {
|
|
|
167
180
|
* @internal
|
|
168
181
|
*/
|
|
169
182
|
_isReady() {
|
|
170
|
-
|
|
171
|
-
if (!this._effects[effectIndex].isReady()) {
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
return true;
|
|
183
|
+
return this._thinDepthOfFieldEffect.isReady();
|
|
176
184
|
}
|
|
177
185
|
}
|
|
178
186
|
//# sourceMappingURL=depthOfFieldEffect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"depthOfFieldEffect.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/depthOfFieldEffect.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAGxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yDAAyD,CAAC;AAClG,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAE9E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAE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C,QAAQ,CAAC,WAAW,CAAC,CAAC,YAAY,EAAE,CAAC;SAC7C;IACL,CAAC;IAED;;;;OAIG;IACI,QAAQ;QACX,KAAK,IAAI,WAAW,GAAG,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE;YACzE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,EAAE;gBACvC,OAAO,KAAK,CAAC;aAChB;SACJ;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport { Vector2 } from \"../Maths/math.vector\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport type { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport type { PostProcess } from \"./postProcess\";\r\nimport { PostProcessRenderEffect } from \"../PostProcesses/RenderPipeline/postProcessRenderEffect\";\r\nimport { CircleOfConfusionPostProcess } from \"./circleOfConfusionPostProcess\";\r\nimport { DepthOfFieldBlurPostProcess } from \"./depthOfFieldBlurPostProcess\";\r\nimport { DepthOfFieldMergePostProcess } from \"./depthOfFieldMergePostProcess\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Constants } from \"../Engines/constants\";\r\n\r\n/**\r\n * Specifies the level of max blur that should be applied when using the depth of field effect\r\n */\r\nexport const enum DepthOfFieldEffectBlurLevel {\r\n /**\r\n * Subtle blur\r\n */\r\n Low,\r\n /**\r\n * Medium blur\r\n */\r\n Medium,\r\n /**\r\n * Large blur\r\n */\r\n High,\r\n}\r\n/**\r\n * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.\r\n */\r\nexport class DepthOfFieldEffect extends PostProcessRenderEffect {\r\n private _circleOfConfusion: CircleOfConfusionPostProcess;\r\n /**\r\n * @internal Internal, blurs from high to low\r\n */\r\n public _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;\r\n private _depthOfFieldBlurY: Array<DepthOfFieldBlurPostProcess>;\r\n private _dofMerge: Nullable<DepthOfFieldMergePostProcess>;\r\n\r\n /**\r\n * @internal Internal post processes in depth of field effect\r\n */\r\n public _effects: Array<PostProcess> = [];\r\n\r\n /**\r\n * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)\r\n */\r\n public set focalLength(value: number) {\r\n this._circleOfConfusion.focalLength = value;\r\n }\r\n public get focalLength() {\r\n return this._circleOfConfusion.focalLength;\r\n }\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 public set fStop(value: number) {\r\n this._circleOfConfusion.fStop = value;\r\n }\r\n public get fStop() {\r\n return this._circleOfConfusion.fStop;\r\n }\r\n /**\r\n * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)\r\n */\r\n public set focusDistance(value: number) {\r\n this._circleOfConfusion.focusDistance = value;\r\n }\r\n public get focusDistance() {\r\n return this._circleOfConfusion.focusDistance;\r\n }\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 public set lensSize(value: number) {\r\n this._circleOfConfusion.lensSize = value;\r\n }\r\n public get lensSize() {\r\n return this._circleOfConfusion.lensSize;\r\n }\r\n\r\n /**\r\n * Creates a new instance DepthOfFieldEffect\r\n * @param scene The scene the effect belongs to.\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 blurLevel\r\n * @param pipelineTextureType 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 scene: Scene,\r\n depthTexture: Nullable<RenderTargetTexture>,\r\n blurLevel: DepthOfFieldEffectBlurLevel = DepthOfFieldEffectBlurLevel.Low,\r\n pipelineTextureType = 0,\r\n blockCompilation = false\r\n ) {\r\n super(\r\n scene.getEngine(),\r\n \"depth of field\",\r\n () => {\r\n return this._effects;\r\n },\r\n true\r\n );\r\n\r\n // Use R-only formats if supported to store the circle of confusion values.\r\n // This should be more space and bandwidth efficient than using RGBA.\r\n const engine = scene.getEngine();\r\n const circleOfConfusionTextureFormat = engine.isWebGPU || engine.version > 1 ? Constants.TEXTUREFORMAT_RED : Constants.TEXTUREFORMAT_RGBA;\r\n\r\n // Circle of confusion value for each pixel is used to determine how much to blur that pixel\r\n this._circleOfConfusion = new CircleOfConfusionPostProcess(\r\n \"circleOfConfusion\",\r\n depthTexture,\r\n 1,\r\n null,\r\n Texture.BILINEAR_SAMPLINGMODE,\r\n engine,\r\n false,\r\n pipelineTextureType,\r\n blockCompilation\r\n );\r\n\r\n // Create a pyramid of blurred images (eg. fullSize 1/4 blur, half size 1/2 blur, quarter size 3/4 blur, eith size 4/4 blur)\r\n // Blur the image but do not blur on sharp far to near distance changes to avoid bleeding artifacts\r\n // See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf\r\n this._depthOfFieldBlurY = [];\r\n this._depthOfFieldBlurX = [];\r\n let blurCount = 1;\r\n let kernelSize = 15;\r\n switch (blurLevel) {\r\n case DepthOfFieldEffectBlurLevel.High: {\r\n blurCount = 3;\r\n kernelSize = 51;\r\n break;\r\n }\r\n case DepthOfFieldEffectBlurLevel.Medium: {\r\n blurCount = 2;\r\n kernelSize = 31;\r\n break;\r\n }\r\n default: {\r\n kernelSize = 15;\r\n blurCount = 1;\r\n break;\r\n }\r\n }\r\n const adjustedKernelSize = kernelSize / Math.pow(2, blurCount - 1);\r\n let ratio = 1.0;\r\n for (let i = 0; i < blurCount; i++) {\r\n const blurY = new DepthOfFieldBlurPostProcess(\r\n \"vertical blur\",\r\n scene,\r\n new Vector2(0, 1.0),\r\n adjustedKernelSize,\r\n ratio,\r\n null,\r\n this._circleOfConfusion,\r\n i == 0 ? this._circleOfConfusion : null,\r\n Texture.BILINEAR_SAMPLINGMODE,\r\n engine,\r\n false,\r\n pipelineTextureType,\r\n blockCompilation,\r\n i == 0 ? circleOfConfusionTextureFormat : Constants.TEXTUREFORMAT_RGBA\r\n );\r\n blurY.autoClear = false;\r\n ratio = 0.75 / Math.pow(2, i);\r\n const blurX = new DepthOfFieldBlurPostProcess(\r\n \"horizontal blur\",\r\n scene,\r\n new Vector2(1.0, 0),\r\n adjustedKernelSize,\r\n ratio,\r\n null,\r\n this._circleOfConfusion,\r\n null,\r\n Texture.BILINEAR_SAMPLINGMODE,\r\n engine,\r\n false,\r\n pipelineTextureType,\r\n blockCompilation\r\n );\r\n blurX.autoClear = false;\r\n this._depthOfFieldBlurY.push(blurY);\r\n this._depthOfFieldBlurX.push(blurX);\r\n }\r\n\r\n // Set all post processes on the effect.\r\n this._effects = [this._circleOfConfusion];\r\n for (let i = 0; i < this._depthOfFieldBlurX.length; i++) {\r\n this._effects.push(this._depthOfFieldBlurY[i]);\r\n this._effects.push(this._depthOfFieldBlurX[i]);\r\n }\r\n\r\n // Merge blurred images with original image based on circleOfConfusion\r\n this._dofMerge = new DepthOfFieldMergePostProcess(\r\n \"dofMerge\",\r\n this._circleOfConfusion,\r\n this._circleOfConfusion,\r\n this._depthOfFieldBlurX,\r\n ratio,\r\n null,\r\n Texture.BILINEAR_SAMPLINGMODE,\r\n engine,\r\n false,\r\n pipelineTextureType,\r\n blockCompilation\r\n );\r\n this._dofMerge.autoClear = false;\r\n this._effects.push(this._dofMerge);\r\n }\r\n\r\n /**\r\n * Get the current class name of the current effect\r\n * @returns \"DepthOfFieldEffect\"\r\n */\r\n public getClassName(): string {\r\n return \"DepthOfFieldEffect\";\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._circleOfConfusion.depthTexture = value;\r\n }\r\n\r\n /**\r\n * Disposes each of the internal effects for a given camera.\r\n * @param camera The camera to dispose the effect on.\r\n */\r\n public disposeEffects(camera: Camera) {\r\n for (let effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {\r\n this._effects[effectIndex].dispose(camera);\r\n }\r\n }\r\n\r\n /**\r\n * @internal Internal\r\n */\r\n public _updateEffects() {\r\n for (let effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {\r\n this._effects[effectIndex].updateEffect();\r\n }\r\n }\r\n\r\n /**\r\n * Internal\r\n * @returns if all the contained post processes are ready.\r\n * @internal\r\n */\r\n public _isReady() {\r\n for (let effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {\r\n if (!this._effects[effectIndex].isReady()) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"depthOfFieldEffect.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/depthOfFieldEffect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAGxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yDAAyD,CAAC;AAClG,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAE9E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE;;GAEG;AACH,MAAM,CAAN,IAAkB,2BAajB;AAbD,WAAkB,2BAA2B;IACzC;;OAEG;IACH,2EAAG,CAAA;IACH;;OAEG;IACH,iFAAM,CAAA;IACN;;OAEG;IACH,6EAAI,CAAA;AACR,CAAC,EAbiB,2BAA2B,KAA3B,2BAA2B,QAa5C;AAED;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,uBAAuB;IAc3D;;OAEG;IACH,IAAW,WAAW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CAAC;SAC7C;IACL,CAAC;IAED;;;;OAIG;IACI,QAAQ;QACX,OAAO,IAAI,CAAC,uBAAuB,CAAC,OAAO,EAAE,CAAC;IAClD,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport type { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport type { PostProcess } from \"./postProcess\";\r\nimport { PostProcessRenderEffect } from \"../PostProcesses/RenderPipeline/postProcessRenderEffect\";\r\nimport { CircleOfConfusionPostProcess } from \"./circleOfConfusionPostProcess\";\r\nimport { DepthOfFieldBlurPostProcess } from \"./depthOfFieldBlurPostProcess\";\r\nimport { DepthOfFieldMergePostProcess } from \"./depthOfFieldMergePostProcess\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport type { ThinDepthOfFieldEffectBlurLevel } from \"./thinDepthOfFieldEffect\";\r\nimport { ThinDepthOfFieldEffect } from \"./thinDepthOfFieldEffect\";\r\n\r\n/**\r\n * Specifies the level of max blur that should be applied when using the depth of field effect\r\n */\r\nexport const enum DepthOfFieldEffectBlurLevel {\r\n /**\r\n * Subtle blur\r\n */\r\n Low,\r\n /**\r\n * Medium blur\r\n */\r\n Medium,\r\n /**\r\n * Large blur\r\n */\r\n High,\r\n}\r\n\r\n/**\r\n * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.\r\n */\r\nexport class DepthOfFieldEffect extends PostProcessRenderEffect {\r\n private _circleOfConfusion: CircleOfConfusionPostProcess;\r\n /**\r\n * @internal Internal, blurs from high to low\r\n */\r\n public _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;\r\n private _depthOfFieldBlurY: Array<DepthOfFieldBlurPostProcess>;\r\n private _dofMerge: Nullable<DepthOfFieldMergePostProcess>;\r\n\r\n /**\r\n * @internal Internal post processes in depth of field effect\r\n */\r\n public _effects: Array<PostProcess> = [];\r\n\r\n /**\r\n * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)\r\n */\r\n public set focalLength(value: number) {\r\n this._thinDepthOfFieldEffect.focalLength = value;\r\n }\r\n public get focalLength() {\r\n return this._thinDepthOfFieldEffect.focalLength;\r\n }\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 public set fStop(value: number) {\r\n this._thinDepthOfFieldEffect.fStop = value;\r\n }\r\n public get fStop() {\r\n return this._thinDepthOfFieldEffect.fStop;\r\n }\r\n /**\r\n * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)\r\n */\r\n public set focusDistance(value: number) {\r\n this._thinDepthOfFieldEffect.focusDistance = value;\r\n }\r\n public get focusDistance() {\r\n return this._thinDepthOfFieldEffect.focusDistance;\r\n }\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 public set lensSize(value: number) {\r\n this._thinDepthOfFieldEffect.lensSize = value;\r\n }\r\n public get lensSize() {\r\n return this._thinDepthOfFieldEffect.lensSize;\r\n }\r\n\r\n private _thinDepthOfFieldEffect: ThinDepthOfFieldEffect;\r\n\r\n /**\r\n * Creates a new instance DepthOfFieldEffect\r\n * @param sceneOrEngine The scene or engine the effect belongs to.\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 blurLevel\r\n * @param pipelineTextureType 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 * @param depthNotNormalized If the depth from the depth texture is already normalized or if the normalization should be done at runtime in the shader (default: false)\r\n */\r\n constructor(\r\n sceneOrEngine: Scene | AbstractEngine,\r\n depthTexture: Nullable<RenderTargetTexture>,\r\n blurLevel: DepthOfFieldEffectBlurLevel = DepthOfFieldEffectBlurLevel.Low,\r\n pipelineTextureType = 0,\r\n blockCompilation = false,\r\n depthNotNormalized = false\r\n ) {\r\n const engine = (sceneOrEngine as Scene)._renderForCamera ? (sceneOrEngine as Scene).getEngine() : (sceneOrEngine as AbstractEngine);\r\n super(\r\n engine,\r\n \"depth of field\",\r\n () => {\r\n return this._effects;\r\n },\r\n true\r\n );\r\n\r\n this._thinDepthOfFieldEffect = new ThinDepthOfFieldEffect(\"Depth of Field\", engine, blurLevel as unknown as ThinDepthOfFieldEffectBlurLevel, false, blockCompilation);\r\n\r\n // Use R-only formats if supported to store the circle of confusion values.\r\n // This should be more space and bandwidth efficient than using RGBA.\r\n const circleOfConfusionTextureFormat = engine.isWebGPU || engine.version > 1 ? Constants.TEXTUREFORMAT_RED : Constants.TEXTUREFORMAT_RGBA;\r\n\r\n // Circle of confusion value for each pixel is used to determine how much to blur that pixel\r\n this._circleOfConfusion = new CircleOfConfusionPostProcess(\r\n \"circleOfConfusion\",\r\n depthTexture,\r\n {\r\n size: 1,\r\n samplingMode: Texture.BILINEAR_SAMPLINGMODE,\r\n engine,\r\n textureType: pipelineTextureType,\r\n blockCompilation,\r\n depthNotNormalized,\r\n effectWrapper: this._thinDepthOfFieldEffect._circleOfConfusion,\r\n },\r\n null\r\n );\r\n\r\n // Create a pyramid of blurred images (eg. fullSize 1/4 blur, half size 1/2 blur, quarter size 3/4 blur, eith size 4/4 blur)\r\n // Blur the image but do not blur on sharp far to near distance changes to avoid bleeding artifacts\r\n // See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf\r\n this._depthOfFieldBlurY = [];\r\n this._depthOfFieldBlurX = [];\r\n\r\n const blurCount = this._thinDepthOfFieldEffect._depthOfFieldBlurX.length;\r\n\r\n for (let i = 0; i < blurCount; i++) {\r\n const [thinBlurY, ratioY] = this._thinDepthOfFieldEffect._depthOfFieldBlurY[i];\r\n const blurY = new DepthOfFieldBlurPostProcess(\r\n \"vertical blur\",\r\n null,\r\n thinBlurY.direction,\r\n thinBlurY.kernel,\r\n {\r\n size: ratioY,\r\n samplingMode: Texture.BILINEAR_SAMPLINGMODE,\r\n engine,\r\n textureType: pipelineTextureType,\r\n blockCompilation,\r\n textureFormat: i == 0 ? circleOfConfusionTextureFormat : Constants.TEXTUREFORMAT_RGBA,\r\n effectWrapper: thinBlurY,\r\n },\r\n null,\r\n this._circleOfConfusion,\r\n i == 0 ? this._circleOfConfusion : null\r\n );\r\n blurY.autoClear = false;\r\n\r\n const [thinBlurX, ratioX] = this._thinDepthOfFieldEffect._depthOfFieldBlurX[i];\r\n const blurX = new DepthOfFieldBlurPostProcess(\r\n \"horizontal blur\",\r\n null,\r\n thinBlurX.direction,\r\n thinBlurX.kernel,\r\n {\r\n size: ratioX,\r\n samplingMode: Texture.BILINEAR_SAMPLINGMODE,\r\n engine,\r\n textureType: pipelineTextureType,\r\n blockCompilation,\r\n effectWrapper: thinBlurX,\r\n },\r\n null,\r\n this._circleOfConfusion,\r\n null\r\n );\r\n blurX.autoClear = false;\r\n this._depthOfFieldBlurY.push(blurY);\r\n this._depthOfFieldBlurX.push(blurX);\r\n }\r\n\r\n // Set all post processes on the effect.\r\n this._effects = [this._circleOfConfusion];\r\n for (let i = 0; i < this._depthOfFieldBlurX.length; i++) {\r\n this._effects.push(this._depthOfFieldBlurY[i]);\r\n this._effects.push(this._depthOfFieldBlurX[i]);\r\n }\r\n\r\n // Merge blurred images with original image based on circleOfConfusion\r\n this._dofMerge = new DepthOfFieldMergePostProcess(\r\n \"dofMerge\",\r\n this._circleOfConfusion,\r\n this._circleOfConfusion,\r\n this._depthOfFieldBlurX,\r\n {\r\n size: this._thinDepthOfFieldEffect._depthOfFieldBlurX[blurCount - 1][1],\r\n samplingMode: Texture.BILINEAR_SAMPLINGMODE,\r\n engine,\r\n textureType: pipelineTextureType,\r\n blockCompilation,\r\n effectWrapper: this._thinDepthOfFieldEffect._dofMerge,\r\n },\r\n null\r\n );\r\n this._dofMerge.autoClear = false;\r\n this._effects.push(this._dofMerge);\r\n }\r\n\r\n /**\r\n * Get the current class name of the current effect\r\n * @returns \"DepthOfFieldEffect\"\r\n */\r\n public getClassName(): string {\r\n return \"DepthOfFieldEffect\";\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._circleOfConfusion.depthTexture = value;\r\n }\r\n\r\n /**\r\n * Disposes each of the internal effects for a given camera.\r\n * @param camera The camera to dispose the effect on.\r\n */\r\n public disposeEffects(camera: Camera) {\r\n for (let effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {\r\n this._effects[effectIndex].dispose(camera);\r\n }\r\n }\r\n\r\n /**\r\n * @internal Internal\r\n */\r\n public _updateEffects() {\r\n for (let effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {\r\n this._effects[effectIndex].updateEffect();\r\n }\r\n }\r\n\r\n /**\r\n * Internal\r\n * @returns if all the contained post processes are ready.\r\n * @internal\r\n */\r\n public _isReady() {\r\n return this._thinDepthOfFieldEffect.isReady();\r\n }\r\n}\r\n"]}
|
|
@@ -29,7 +29,6 @@ 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 _gatherImports(useWebGPU: boolean, list: Promise<any>[]): void;
|
|
33
32
|
/**
|
|
34
33
|
* Updates the effect with the current post process compile time values and recompiles the shader.
|
|
35
34
|
* @param defines Define statements that should be added at the beginning of the shader. (default: null)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PostProcess } from "./postProcess.js";
|
|
2
2
|
|
|
3
|
+
import { ThinDepthOfFieldMergePostProcess } from "./thinDepthOfFieldMergePostProcess.js";
|
|
3
4
|
/**
|
|
4
5
|
* The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
|
|
5
6
|
*/
|
|
@@ -26,7 +27,22 @@ export class DepthOfFieldMergePostProcess extends PostProcess {
|
|
|
26
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)
|
|
27
28
|
*/
|
|
28
29
|
constructor(name, originalFromInput, circleOfConfusion, _blurSteps, options, camera, samplingMode, engine, reusable, textureType = 0, blockCompilation = false) {
|
|
29
|
-
|
|
30
|
+
const blockCompilationFinal = typeof options === "number" ? blockCompilation : !!options.blockCompilation;
|
|
31
|
+
const localOptions = {
|
|
32
|
+
samplers: ThinDepthOfFieldMergePostProcess.Samplers,
|
|
33
|
+
size: typeof options === "number" ? options : undefined,
|
|
34
|
+
camera,
|
|
35
|
+
samplingMode,
|
|
36
|
+
engine,
|
|
37
|
+
reusable,
|
|
38
|
+
textureType,
|
|
39
|
+
...options,
|
|
40
|
+
blockCompilation: true,
|
|
41
|
+
};
|
|
42
|
+
super(name, ThinDepthOfFieldMergePostProcess.FragmentUrl, {
|
|
43
|
+
effectWrapper: typeof options === "number" || !options.effectWrapper ? new ThinDepthOfFieldMergePostProcess(name, engine, localOptions) : undefined,
|
|
44
|
+
...localOptions,
|
|
45
|
+
});
|
|
30
46
|
this._blurSteps = _blurSteps;
|
|
31
47
|
this.externalTextureSamplerBinding = true;
|
|
32
48
|
this.onApplyObservable.add((effect) => {
|
|
@@ -36,20 +52,10 @@ export class DepthOfFieldMergePostProcess extends PostProcess {
|
|
|
36
52
|
effect.setTextureFromPostProcessOutput("blurStep" + (_blurSteps.length - index - 1), step);
|
|
37
53
|
});
|
|
38
54
|
});
|
|
39
|
-
if (!
|
|
55
|
+
if (!blockCompilationFinal) {
|
|
40
56
|
this.updateEffect();
|
|
41
57
|
}
|
|
42
58
|
}
|
|
43
|
-
_gatherImports(useWebGPU, list) {
|
|
44
|
-
if (useWebGPU) {
|
|
45
|
-
this._webGPUReady = true;
|
|
46
|
-
list.push(import("../ShadersWGSL/depthOfFieldMerge.fragment.js"));
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
list.push(import("../Shaders/depthOfFieldMerge.fragment.js"));
|
|
50
|
-
}
|
|
51
|
-
super._gatherImports(useWebGPU, list);
|
|
52
|
-
}
|
|
53
59
|
/**
|
|
54
60
|
* Updates the effect with the current post process compile time values and recompiles the shader.
|
|
55
61
|
* @param defines Define statements that should be added at the beginning of the shader. (default: null)
|
|
@@ -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;
|
|
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;AAGjD,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AAEtF;;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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C,CAAC;QACP,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,qBAAqB,EAAE;YACxB,IAAI,CAAC,YAAY,EAAE,CAAC;SACvB;IACL,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\nimport { ThinDepthOfFieldMergePostProcess } from \"./thinDepthOfFieldMergePostProcess\";\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 const blockCompilationFinal = typeof options === \"number\" ? blockCompilation : !!options.blockCompilation;\r\n const localOptions = {\r\n samplers: ThinDepthOfFieldMergePostProcess.Samplers,\r\n size: typeof options === \"number\" ? options : undefined,\r\n camera,\r\n samplingMode,\r\n engine,\r\n reusable,\r\n textureType,\r\n ...(options as PostProcessOptions),\r\n blockCompilation: true,\r\n };\r\n\r\n super(name, ThinDepthOfFieldMergePostProcess.FragmentUrl, {\r\n effectWrapper: typeof options === \"number\" || !options.effectWrapper ? new ThinDepthOfFieldMergePostProcess(name, engine, localOptions) : undefined,\r\n ...localOptions,\r\n });\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 (!blockCompilationFinal) {\r\n this.updateEffect();\r\n }\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,6 +3,7 @@ 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 { ThinExtractHighlightsPostProcess } from "./thinExtractHighlightsPostProcess";
|
|
6
7
|
/**
|
|
7
8
|
* The extract highlights post process sets all pixels to black except pixels above the specified luminance threshold. Used as the first step for a bloom effect.
|
|
8
9
|
*/
|
|
@@ -10,9 +11,12 @@ export declare class ExtractHighlightsPostProcess extends PostProcess {
|
|
|
10
11
|
/**
|
|
11
12
|
* The luminance threshold, pixels below this value will be set to black.
|
|
12
13
|
*/
|
|
13
|
-
threshold: number;
|
|
14
|
+
get threshold(): number;
|
|
15
|
+
set threshold(value: number);
|
|
14
16
|
/** @internal */
|
|
15
|
-
_exposure: number;
|
|
17
|
+
get _exposure(): number;
|
|
18
|
+
/** @internal */
|
|
19
|
+
set _exposure(value: number);
|
|
16
20
|
/**
|
|
17
21
|
* Post process which has the input texture to be used when performing highlight extraction
|
|
18
22
|
* @internal
|
|
@@ -23,6 +27,6 @@ export declare class ExtractHighlightsPostProcess extends PostProcess {
|
|
|
23
27
|
* @returns "ExtractHighlightsPostProcess" string
|
|
24
28
|
*/
|
|
25
29
|
getClassName(): string;
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
protected _effectWrapper: ThinExtractHighlightsPostProcess;
|
|
31
|
+
constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: AbstractEngine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
|
|
28
32
|
}
|
|
@@ -1,13 +1,30 @@
|
|
|
1
1
|
import { __decorate } from "../tslib.es6.js";
|
|
2
2
|
import { PostProcess } from "./postProcess.js";
|
|
3
|
-
import { ToGammaSpace } from "../Maths/math.constants.js";
|
|
4
3
|
|
|
5
4
|
import { serialize } from "../Misc/decorators.js";
|
|
6
5
|
import { RegisterClass } from "../Misc/typeStore.js";
|
|
6
|
+
import { ThinExtractHighlightsPostProcess } from "./thinExtractHighlightsPostProcess.js";
|
|
7
7
|
/**
|
|
8
8
|
* The extract highlights post process sets all pixels to black except pixels above the specified luminance threshold. Used as the first step for a bloom effect.
|
|
9
9
|
*/
|
|
10
10
|
export class ExtractHighlightsPostProcess extends PostProcess {
|
|
11
|
+
/**
|
|
12
|
+
* The luminance threshold, pixels below this value will be set to black.
|
|
13
|
+
*/
|
|
14
|
+
get threshold() {
|
|
15
|
+
return this._effectWrapper.threshold;
|
|
16
|
+
}
|
|
17
|
+
set threshold(value) {
|
|
18
|
+
this._effectWrapper.threshold = value;
|
|
19
|
+
}
|
|
20
|
+
/** @internal */
|
|
21
|
+
get _exposure() {
|
|
22
|
+
return this._effectWrapper._exposure;
|
|
23
|
+
}
|
|
24
|
+
/** @internal */
|
|
25
|
+
set _exposure(value) {
|
|
26
|
+
this._effectWrapper._exposure = value;
|
|
27
|
+
}
|
|
11
28
|
/**
|
|
12
29
|
* Gets a string identifying the name of the class
|
|
13
30
|
* @returns "ExtractHighlightsPostProcess" string
|
|
@@ -15,14 +32,22 @@ export class ExtractHighlightsPostProcess extends PostProcess {
|
|
|
15
32
|
getClassName() {
|
|
16
33
|
return "ExtractHighlightsPostProcess";
|
|
17
34
|
}
|
|
18
|
-
constructor(name, options, camera, samplingMode, engine, reusable, textureType = 0, blockCompilation = false) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
35
|
+
constructor(name, options, camera = null, samplingMode, engine, reusable, textureType = 0, blockCompilation = false) {
|
|
36
|
+
const localOptions = {
|
|
37
|
+
uniforms: ThinExtractHighlightsPostProcess.Uniforms,
|
|
38
|
+
size: typeof options === "number" ? options : undefined,
|
|
39
|
+
camera,
|
|
40
|
+
samplingMode,
|
|
41
|
+
engine,
|
|
42
|
+
reusable,
|
|
43
|
+
textureType,
|
|
44
|
+
blockCompilation,
|
|
45
|
+
...options,
|
|
46
|
+
};
|
|
47
|
+
super(name, ThinExtractHighlightsPostProcess.FragmentUrl, {
|
|
48
|
+
effectWrapper: typeof options === "number" || !options.effectWrapper ? new ThinExtractHighlightsPostProcess(name, engine, localOptions) : undefined,
|
|
49
|
+
...localOptions,
|
|
50
|
+
});
|
|
26
51
|
/**
|
|
27
52
|
* Post process which has the input texture to be used when performing highlight extraction
|
|
28
53
|
* @internal
|
|
@@ -33,23 +58,11 @@ export class ExtractHighlightsPostProcess extends PostProcess {
|
|
|
33
58
|
if (this._inputPostProcess) {
|
|
34
59
|
effect.setTextureFromPostProcess("textureSampler", this._inputPostProcess);
|
|
35
60
|
}
|
|
36
|
-
effect.setFloat("threshold", Math.pow(this.threshold, ToGammaSpace));
|
|
37
|
-
effect.setFloat("exposure", this._exposure);
|
|
38
61
|
});
|
|
39
62
|
}
|
|
40
|
-
_gatherImports(useWebGPU, list) {
|
|
41
|
-
if (useWebGPU) {
|
|
42
|
-
this._webGPUReady = true;
|
|
43
|
-
list.push(import("../ShadersWGSL/extractHighlights.fragment.js"));
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
list.push(import("../Shaders/extractHighlights.fragment.js"));
|
|
47
|
-
}
|
|
48
|
-
super._gatherImports(useWebGPU, list);
|
|
49
|
-
}
|
|
50
63
|
}
|
|
51
64
|
__decorate([
|
|
52
65
|
serialize()
|
|
53
|
-
], ExtractHighlightsPostProcess.prototype, "threshold",
|
|
66
|
+
], ExtractHighlightsPostProcess.prototype, "threshold", null);
|
|
54
67
|
RegisterClass("BABYLON.ExtractHighlightsPostProcess", ExtractHighlightsPostProcess);
|
|
55
68
|
//# sourceMappingURL=extractHighlightsPostProcess.js.map
|