@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
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { EffectWrapper } from "../Materials/effectRenderer.js";
|
|
2
|
+
import { Engine } from "../Engines/engine.js";
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export class ThinBloomMergePostProcess extends EffectWrapper {
|
|
7
|
+
_gatherImports(useWebGPU, list) {
|
|
8
|
+
if (useWebGPU) {
|
|
9
|
+
this._webGPUReady = true;
|
|
10
|
+
list.push(import("../ShadersWGSL/bloomMerge.fragment.js"));
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
list.push(import("../Shaders/bloomMerge.fragment.js"));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
constructor(name, engine = null, options) {
|
|
17
|
+
super({
|
|
18
|
+
...options,
|
|
19
|
+
name,
|
|
20
|
+
engine: engine || Engine.LastCreatedEngine,
|
|
21
|
+
useShaderStore: true,
|
|
22
|
+
useAsPostProcess: true,
|
|
23
|
+
fragmentShader: ThinBloomMergePostProcess.FragmentUrl,
|
|
24
|
+
uniforms: ThinBloomMergePostProcess.Uniforms,
|
|
25
|
+
samplers: ThinBloomMergePostProcess.Samplers,
|
|
26
|
+
});
|
|
27
|
+
/** Weight of the bloom to be added to the original input. */
|
|
28
|
+
this.weight = 1;
|
|
29
|
+
}
|
|
30
|
+
bind() {
|
|
31
|
+
super.bind();
|
|
32
|
+
this._drawWrapper.effect.setFloat("bloomWeight", this.weight);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
ThinBloomMergePostProcess.FragmentUrl = "bloomMerge";
|
|
36
|
+
ThinBloomMergePostProcess.Uniforms = ["bloomWeight"];
|
|
37
|
+
ThinBloomMergePostProcess.Samplers = ["bloomBlur"];
|
|
38
|
+
//# sourceMappingURL=thinBloomMergePostProcess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thinBloomMergePostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/thinBloomMergePostProcess.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,yBAA0B,SAAQ,aAAa;IAOrC,cAAc,CAAC,SAAkB,EAAE,IAAoB;QACtE,IAAI,SAAS,EAAE;YACX,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,oCAAoC,CAAC,CAAC,CAAC;SAC3D;aAAM;YACH,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,gCAAgC,CAAC,CAAC,CAAC;SACvD;IACL,CAAC;IAED,YAAY,IAAY,EAAE,SAAmC,IAAI,EAAE,OAAsC;QACrG,KAAK,CAAC;YACF,GAAG,OAAO;YACV,IAAI;YACJ,MAAM,EAAE,MAAM,IAAI,MAAM,CAAC,iBAAkB;YAC3C,cAAc,EAAE,IAAI;YACpB,gBAAgB,EAAE,IAAI;YACtB,cAAc,EAAE,yBAAyB,CAAC,WAAW;YACrD,QAAQ,EAAE,yBAAyB,CAAC,QAAQ;YAC5C,QAAQ,EAAE,yBAAyB,CAAC,QAAQ;SAC/C,CAAC,CAAC;QAGP,6DAA6D;QACtD,WAAM,GAAG,CAAC,CAAC;IAHlB,CAAC;IAKe,IAAI;QAChB,KAAK,CAAC,IAAI,EAAE,CAAC;QACb,IAAI,CAAC,YAAY,CAAC,MAAO,CAAC,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACnE,CAAC;;AAlCsB,qCAAW,GAAG,YAAY,AAAf,CAAgB;AAE3B,kCAAQ,GAAG,CAAC,aAAa,CAAC,AAAlB,CAAmB;AAE3B,kCAAQ,GAAG,CAAC,WAAW,CAAC,AAAhB,CAAiB","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { Nullable, AbstractEngine, EffectWrapperCreationOptions } from \"core/index\";\r\nimport { EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport { Engine } from \"../Engines/engine\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class ThinBloomMergePostProcess extends EffectWrapper {\r\n public static readonly FragmentUrl = \"bloomMerge\";\r\n\r\n public static readonly Uniforms = [\"bloomWeight\"];\r\n\r\n public static readonly Samplers = [\"bloomBlur\"];\r\n\r\n protected override _gatherImports(useWebGPU: boolean, list: Promise<any>[]) {\r\n if (useWebGPU) {\r\n this._webGPUReady = true;\r\n list.push(import(\"../ShadersWGSL/bloomMerge.fragment\"));\r\n } else {\r\n list.push(import(\"../Shaders/bloomMerge.fragment\"));\r\n }\r\n }\r\n\r\n constructor(name: string, engine: Nullable<AbstractEngine> = null, options?: EffectWrapperCreationOptions) {\r\n super({\r\n ...options,\r\n name,\r\n engine: engine || Engine.LastCreatedEngine!,\r\n useShaderStore: true,\r\n useAsPostProcess: true,\r\n fragmentShader: ThinBloomMergePostProcess.FragmentUrl,\r\n uniforms: ThinBloomMergePostProcess.Uniforms,\r\n samplers: ThinBloomMergePostProcess.Samplers,\r\n });\r\n }\r\n\r\n /** Weight of the bloom to be added to the original input. */\r\n public weight = 1;\r\n\r\n public override bind() {\r\n super.bind();\r\n this._drawWrapper.effect!.setFloat(\"bloomWeight\", this.weight);\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { Nullable, AbstractEngine, EffectWrapperCreationOptions, Vector2, Effect } from "../index.js";
|
|
2
|
+
import { EffectWrapper } from "../Materials/effectRenderer";
|
|
3
|
+
/**
|
|
4
|
+
* Post process used to apply a blur effect
|
|
5
|
+
*/
|
|
6
|
+
export declare class ThinBlurPostProcess extends EffectWrapper {
|
|
7
|
+
/**
|
|
8
|
+
* The vertex shader url
|
|
9
|
+
*/
|
|
10
|
+
static readonly VertexUrl = "kernelBlur";
|
|
11
|
+
/**
|
|
12
|
+
* The fragment shader url
|
|
13
|
+
*/
|
|
14
|
+
static readonly FragmentUrl = "kernelBlur";
|
|
15
|
+
/**
|
|
16
|
+
* The list of uniforms used by the effect
|
|
17
|
+
*/
|
|
18
|
+
static readonly Uniforms: string[];
|
|
19
|
+
/**
|
|
20
|
+
* The list of samplers used by the effect
|
|
21
|
+
*/
|
|
22
|
+
static readonly Samplers: string[];
|
|
23
|
+
protected _gatherImports(useWebGPU: boolean, list: Promise<any>[]): void;
|
|
24
|
+
protected _kernel: number;
|
|
25
|
+
protected _idealKernel: number;
|
|
26
|
+
protected _packedFloat: boolean;
|
|
27
|
+
private _staticDefines;
|
|
28
|
+
/**
|
|
29
|
+
* Constructs a new blur post process
|
|
30
|
+
* @param name Name of the effect
|
|
31
|
+
* @param engine Engine to use to render the effect. If not provided, the last created engine will be used
|
|
32
|
+
* @param direction Direction in which to apply the blur
|
|
33
|
+
* @param kernel Kernel size of the blur
|
|
34
|
+
* @param options Options to configure the effect
|
|
35
|
+
*/
|
|
36
|
+
constructor(name: string, engine?: Nullable<AbstractEngine>, direction?: Vector2, kernel?: number, options?: EffectWrapperCreationOptions);
|
|
37
|
+
/**
|
|
38
|
+
* Width of the texture to apply the blur on
|
|
39
|
+
*/
|
|
40
|
+
textureWidth: number;
|
|
41
|
+
/**
|
|
42
|
+
* Height of the texture to apply the blur on
|
|
43
|
+
*/
|
|
44
|
+
textureHeight: number;
|
|
45
|
+
/** The direction in which to blur the image. */
|
|
46
|
+
direction: Vector2;
|
|
47
|
+
/**
|
|
48
|
+
* Sets the length in pixels of the blur sample region
|
|
49
|
+
*/
|
|
50
|
+
set kernel(v: number);
|
|
51
|
+
/**
|
|
52
|
+
* Gets the length in pixels of the blur sample region
|
|
53
|
+
*/
|
|
54
|
+
get kernel(): number;
|
|
55
|
+
/**
|
|
56
|
+
* Sets whether or not the blur needs to unpack/repack floats
|
|
57
|
+
*/
|
|
58
|
+
set packedFloat(v: boolean);
|
|
59
|
+
/**
|
|
60
|
+
* Gets whether or not the blur is unpacking/repacking floats
|
|
61
|
+
*/
|
|
62
|
+
get packedFloat(): boolean;
|
|
63
|
+
bind(): void;
|
|
64
|
+
/** @internal */
|
|
65
|
+
_updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
|
|
66
|
+
/**
|
|
67
|
+
* Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
|
|
68
|
+
* Other odd kernels optimize correctly but require proportionally more samples, even kernels are
|
|
69
|
+
* possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
|
|
70
|
+
* want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
|
|
71
|
+
* The gaps between physical kernels are compensated for in the weighting of the samples
|
|
72
|
+
* @param idealKernel Ideal blur kernel.
|
|
73
|
+
* @returns Nearest best kernel.
|
|
74
|
+
*/
|
|
75
|
+
protected _nearestBestKernel(idealKernel: number): number;
|
|
76
|
+
/**
|
|
77
|
+
* Calculates the value of a Gaussian distribution with sigma 3 at a given point.
|
|
78
|
+
* @param x The point on the Gaussian distribution to sample.
|
|
79
|
+
* @returns the value of the Gaussian function at x.
|
|
80
|
+
*/
|
|
81
|
+
protected _gaussianWeight(x: number): number;
|
|
82
|
+
/**
|
|
83
|
+
* Generates a string that can be used as a floating point number in GLSL.
|
|
84
|
+
* @param x Value to print.
|
|
85
|
+
* @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
|
|
86
|
+
* @returns GLSL float string.
|
|
87
|
+
*/
|
|
88
|
+
protected _glslFloat(x: number, decimalFigures?: number): string;
|
|
89
|
+
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { EffectWrapper } from "../Materials/effectRenderer.js";
|
|
2
|
+
import { Engine } from "../Engines/engine.js";
|
|
3
|
+
/**
|
|
4
|
+
* Post process used to apply a blur effect
|
|
5
|
+
*/
|
|
6
|
+
export class ThinBlurPostProcess extends EffectWrapper {
|
|
7
|
+
_gatherImports(useWebGPU, list) {
|
|
8
|
+
if (useWebGPU) {
|
|
9
|
+
this._webGPUReady = true;
|
|
10
|
+
list.push(Promise.all([import("../ShadersWGSL/kernelBlur.fragment.js"), import("../ShadersWGSL/kernelBlur.vertex.js")]));
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
list.push(Promise.all([import("../Shaders/kernelBlur.fragment.js"), import("../Shaders/kernelBlur.vertex.js")]));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Constructs a new blur post process
|
|
18
|
+
* @param name Name of the effect
|
|
19
|
+
* @param engine Engine to use to render the effect. If not provided, the last created engine will be used
|
|
20
|
+
* @param direction Direction in which to apply the blur
|
|
21
|
+
* @param kernel Kernel size of the blur
|
|
22
|
+
* @param options Options to configure the effect
|
|
23
|
+
*/
|
|
24
|
+
constructor(name, engine = null, direction, kernel, options) {
|
|
25
|
+
const blockCompilationFinal = !!options?.blockCompilation;
|
|
26
|
+
super({
|
|
27
|
+
...options,
|
|
28
|
+
name,
|
|
29
|
+
engine: engine || Engine.LastCreatedEngine,
|
|
30
|
+
useShaderStore: true,
|
|
31
|
+
useAsPostProcess: true,
|
|
32
|
+
fragmentShader: ThinBlurPostProcess.FragmentUrl,
|
|
33
|
+
uniforms: ThinBlurPostProcess.Uniforms,
|
|
34
|
+
samplers: ThinBlurPostProcess.Samplers,
|
|
35
|
+
vertexUrl: ThinBlurPostProcess.VertexUrl,
|
|
36
|
+
blockCompilation: true,
|
|
37
|
+
});
|
|
38
|
+
this._packedFloat = false;
|
|
39
|
+
this._staticDefines = "";
|
|
40
|
+
/**
|
|
41
|
+
* Width of the texture to apply the blur on
|
|
42
|
+
*/
|
|
43
|
+
this.textureWidth = 0;
|
|
44
|
+
/**
|
|
45
|
+
* Height of the texture to apply the blur on
|
|
46
|
+
*/
|
|
47
|
+
this.textureHeight = 0;
|
|
48
|
+
this.options.blockCompilation = blockCompilationFinal;
|
|
49
|
+
if (direction !== undefined) {
|
|
50
|
+
this.direction = direction;
|
|
51
|
+
}
|
|
52
|
+
if (kernel !== undefined) {
|
|
53
|
+
this.kernel = kernel;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Sets the length in pixels of the blur sample region
|
|
58
|
+
*/
|
|
59
|
+
set kernel(v) {
|
|
60
|
+
if (this._idealKernel === v) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
v = Math.max(v, 1);
|
|
64
|
+
this._idealKernel = v;
|
|
65
|
+
this._kernel = this._nearestBestKernel(v);
|
|
66
|
+
if (!this.options.blockCompilation) {
|
|
67
|
+
this._updateParameters();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Gets the length in pixels of the blur sample region
|
|
72
|
+
*/
|
|
73
|
+
get kernel() {
|
|
74
|
+
return this._idealKernel;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Sets whether or not the blur needs to unpack/repack floats
|
|
78
|
+
*/
|
|
79
|
+
set packedFloat(v) {
|
|
80
|
+
if (this._packedFloat === v) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
this._packedFloat = v;
|
|
84
|
+
if (!this.options.blockCompilation) {
|
|
85
|
+
this._updateParameters();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Gets whether or not the blur is unpacking/repacking floats
|
|
90
|
+
*/
|
|
91
|
+
get packedFloat() {
|
|
92
|
+
return this._packedFloat;
|
|
93
|
+
}
|
|
94
|
+
bind() {
|
|
95
|
+
super.bind();
|
|
96
|
+
this._drawWrapper.effect.setFloat2("delta", (1 / this.textureWidth) * this.direction.x, (1 / this.textureHeight) * this.direction.y);
|
|
97
|
+
}
|
|
98
|
+
/** @internal */
|
|
99
|
+
_updateParameters(onCompiled, onError) {
|
|
100
|
+
// Generate sampling offsets and weights
|
|
101
|
+
const N = this._kernel;
|
|
102
|
+
const centerIndex = (N - 1) / 2;
|
|
103
|
+
// Generate Gaussian sampling weights over kernel
|
|
104
|
+
let offsets = [];
|
|
105
|
+
let weights = [];
|
|
106
|
+
let totalWeight = 0;
|
|
107
|
+
for (let i = 0; i < N; i++) {
|
|
108
|
+
const u = i / (N - 1);
|
|
109
|
+
const w = this._gaussianWeight(u * 2.0 - 1);
|
|
110
|
+
offsets[i] = i - centerIndex;
|
|
111
|
+
weights[i] = w;
|
|
112
|
+
totalWeight += w;
|
|
113
|
+
}
|
|
114
|
+
// Normalize weights
|
|
115
|
+
for (let i = 0; i < weights.length; i++) {
|
|
116
|
+
weights[i] /= totalWeight;
|
|
117
|
+
}
|
|
118
|
+
// Optimize: combine samples to take advantage of hardware linear sampling
|
|
119
|
+
// Walk from left to center, combining pairs (symmetrically)
|
|
120
|
+
const linearSamplingWeights = [];
|
|
121
|
+
const linearSamplingOffsets = [];
|
|
122
|
+
const linearSamplingMap = [];
|
|
123
|
+
for (let i = 0; i <= centerIndex; i += 2) {
|
|
124
|
+
const j = Math.min(i + 1, Math.floor(centerIndex));
|
|
125
|
+
const singleCenterSample = i === j;
|
|
126
|
+
if (singleCenterSample) {
|
|
127
|
+
linearSamplingMap.push({ o: offsets[i], w: weights[i] });
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
const sharedCell = j === centerIndex;
|
|
131
|
+
const weightLinear = weights[i] + weights[j] * (sharedCell ? 0.5 : 1);
|
|
132
|
+
const offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);
|
|
133
|
+
if (offsetLinear === 0) {
|
|
134
|
+
linearSamplingMap.push({ o: offsets[i], w: weights[i] });
|
|
135
|
+
linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
linearSamplingMap.push({ o: offsetLinear, w: weightLinear });
|
|
139
|
+
linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
for (let i = 0; i < linearSamplingMap.length; i++) {
|
|
144
|
+
linearSamplingOffsets[i] = linearSamplingMap[i].o;
|
|
145
|
+
linearSamplingWeights[i] = linearSamplingMap[i].w;
|
|
146
|
+
}
|
|
147
|
+
// Replace with optimized
|
|
148
|
+
offsets = linearSamplingOffsets;
|
|
149
|
+
weights = linearSamplingWeights;
|
|
150
|
+
// Generate shaders
|
|
151
|
+
const maxVaryingRows = this.options.engine.getCaps().maxVaryingVectors - (this.options.shaderLanguage === 1 /* ShaderLanguage.WGSL */ ? 1 : 0); // Because of the additional builtins
|
|
152
|
+
const freeVaryingVec2 = Math.max(maxVaryingRows, 0) - 1; // Because of sampleCenter
|
|
153
|
+
let varyingCount = Math.min(offsets.length, freeVaryingVec2);
|
|
154
|
+
let defines = "";
|
|
155
|
+
defines += this._staticDefines;
|
|
156
|
+
// The DOF fragment should ignore the center pixel when looping as it is handled manually in the fragment shader.
|
|
157
|
+
if (this._staticDefines.indexOf("DOF") != -1) {
|
|
158
|
+
defines += `#define CENTER_WEIGHT ${this._glslFloat(weights[varyingCount - 1])}\n`;
|
|
159
|
+
varyingCount--;
|
|
160
|
+
}
|
|
161
|
+
for (let i = 0; i < varyingCount; i++) {
|
|
162
|
+
defines += `#define KERNEL_OFFSET${i} ${this._glslFloat(offsets[i])}\n`;
|
|
163
|
+
defines += `#define KERNEL_WEIGHT${i} ${this._glslFloat(weights[i])}\n`;
|
|
164
|
+
}
|
|
165
|
+
let depCount = 0;
|
|
166
|
+
for (let i = freeVaryingVec2; i < offsets.length; i++) {
|
|
167
|
+
defines += `#define KERNEL_DEP_OFFSET${depCount} ${this._glslFloat(offsets[i])}\n`;
|
|
168
|
+
defines += `#define KERNEL_DEP_WEIGHT${depCount} ${this._glslFloat(weights[i])}\n`;
|
|
169
|
+
depCount++;
|
|
170
|
+
}
|
|
171
|
+
if (this.packedFloat) {
|
|
172
|
+
defines += `#define PACKEDFLOAT 1`;
|
|
173
|
+
}
|
|
174
|
+
this.options.blockCompilation = false;
|
|
175
|
+
this.updateEffect(defines, null, null, {
|
|
176
|
+
varyingCount: varyingCount,
|
|
177
|
+
depCount: depCount,
|
|
178
|
+
}, onCompiled, onError);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
|
|
182
|
+
* Other odd kernels optimize correctly but require proportionally more samples, even kernels are
|
|
183
|
+
* possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
|
|
184
|
+
* want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
|
|
185
|
+
* The gaps between physical kernels are compensated for in the weighting of the samples
|
|
186
|
+
* @param idealKernel Ideal blur kernel.
|
|
187
|
+
* @returns Nearest best kernel.
|
|
188
|
+
*/
|
|
189
|
+
_nearestBestKernel(idealKernel) {
|
|
190
|
+
const v = Math.round(idealKernel);
|
|
191
|
+
for (const k of [v, v - 1, v + 1, v - 2, v + 2]) {
|
|
192
|
+
if (k % 2 !== 0 && Math.floor(k / 2) % 2 === 0 && k > 0) {
|
|
193
|
+
return Math.max(k, 3);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return Math.max(v, 3);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Calculates the value of a Gaussian distribution with sigma 3 at a given point.
|
|
200
|
+
* @param x The point on the Gaussian distribution to sample.
|
|
201
|
+
* @returns the value of the Gaussian function at x.
|
|
202
|
+
*/
|
|
203
|
+
_gaussianWeight(x) {
|
|
204
|
+
//reference: Engines/ImageProcessingBlur.cpp #dcc760
|
|
205
|
+
// We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],
|
|
206
|
+
// so we truncate at three standard deviations by setting stddev (sigma) to 1/3.
|
|
207
|
+
// The choice of 3-sigma truncation is common but arbitrary, and means that the signal is
|
|
208
|
+
// truncated at around 1.3% of peak strength.
|
|
209
|
+
//the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size
|
|
210
|
+
const sigma = 1 / 3;
|
|
211
|
+
const denominator = Math.sqrt(2.0 * Math.PI) * sigma;
|
|
212
|
+
const exponent = -((x * x) / (2.0 * sigma * sigma));
|
|
213
|
+
const weight = (1.0 / denominator) * Math.exp(exponent);
|
|
214
|
+
return weight;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Generates a string that can be used as a floating point number in GLSL.
|
|
218
|
+
* @param x Value to print.
|
|
219
|
+
* @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
|
|
220
|
+
* @returns GLSL float string.
|
|
221
|
+
*/
|
|
222
|
+
_glslFloat(x, decimalFigures = 8) {
|
|
223
|
+
return x.toFixed(decimalFigures).replace(/0+$/, "");
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* The vertex shader url
|
|
228
|
+
*/
|
|
229
|
+
ThinBlurPostProcess.VertexUrl = "kernelBlur";
|
|
230
|
+
/**
|
|
231
|
+
* The fragment shader url
|
|
232
|
+
*/
|
|
233
|
+
ThinBlurPostProcess.FragmentUrl = "kernelBlur";
|
|
234
|
+
/**
|
|
235
|
+
* The list of uniforms used by the effect
|
|
236
|
+
*/
|
|
237
|
+
ThinBlurPostProcess.Uniforms = ["delta", "direction"];
|
|
238
|
+
/**
|
|
239
|
+
* The list of samplers used by the effect
|
|
240
|
+
*/
|
|
241
|
+
ThinBlurPostProcess.Samplers = ["circleOfConfusionSampler"];
|
|
242
|
+
//# sourceMappingURL=thinBlurPostProcess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thinBlurPostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/thinBlurPostProcess.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,aAAa;IAqB/B,cAAc,CAAC,SAAkB,EAAE,IAAoB;QACtE,IAAI,SAAS,EAAE;YACX,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,oCAAoC,CAAC,EAAE,MAAM,CAAC,kCAAkC,CAAC,CAAC,CAAC,CAAC,CAAC;SACtH;aAAM;YACH,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,gCAAgC,CAAC,EAAE,MAAM,CAAC,8BAA8B,CAAC,CAAC,CAAC,CAAC,CAAC;SAC9G;IACL,CAAC;IAOD;;;;;;;OAOG;IACH,YAAY,IAAY,EAAE,SAAmC,IAAI,EAAE,SAAmB,EAAE,MAAe,EAAE,OAAsC;QAC3I,MAAM,qBAAqB,GAAG,CAAC,CAAC,OAAO,EAAE,gBAAgB,CAAC;QAC1D,KAAK,CAAC;YACF,GAAG,OAAO;YACV,IAAI;YACJ,MAAM,EAAE,MAAM,IAAI,MAAM,CAAC,iBAAkB;YAC3C,cAAc,EAAE,IAAI;YACpB,gBAAgB,EAAE,IAAI;YACtB,cAAc,EAAE,mBAAmB,CAAC,WAA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E,EAAE,CAAC,CAAC;IACxD,CAAC;;AA3RD;;GAEG;AACoB,6BAAS,GAAG,YAAY,AAAf,CAAgB;AAEhD;;GAEG;AACoB,+BAAW,GAAG,YAAY,AAAf,CAAgB;AAElD;;GAEG;AACoB,4BAAQ,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,AAAzB,CAA0B;AAEzD;;GAEG;AACoB,4BAAQ,GAAG,CAAC,0BAA0B,CAAC,AAA/B,CAAgC","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { Nullable, AbstractEngine, EffectWrapperCreationOptions, Vector2, Effect } from \"core/index\";\r\nimport { EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport { ShaderLanguage } from \"../Materials/shaderLanguage\";\r\nimport { Engine } from \"../Engines/engine\";\r\n\r\n/**\r\n * Post process used to apply a blur effect\r\n */\r\nexport class ThinBlurPostProcess extends EffectWrapper {\r\n /**\r\n * The vertex shader url\r\n */\r\n public static readonly VertexUrl = \"kernelBlur\";\r\n\r\n /**\r\n * The fragment shader url\r\n */\r\n public static readonly FragmentUrl = \"kernelBlur\";\r\n\r\n /**\r\n * The list of uniforms used by the effect\r\n */\r\n public static readonly Uniforms = [\"delta\", \"direction\"];\r\n\r\n /**\r\n * The list of samplers used by the effect\r\n */\r\n public static readonly Samplers = [\"circleOfConfusionSampler\"];\r\n\r\n protected override _gatherImports(useWebGPU: boolean, list: Promise<any>[]) {\r\n if (useWebGPU) {\r\n this._webGPUReady = true;\r\n list.push(Promise.all([import(\"../ShadersWGSL/kernelBlur.fragment\"), import(\"../ShadersWGSL/kernelBlur.vertex\")]));\r\n } else {\r\n list.push(Promise.all([import(\"../Shaders/kernelBlur.fragment\"), import(\"../Shaders/kernelBlur.vertex\")]));\r\n }\r\n }\r\n\r\n protected _kernel: number;\r\n protected _idealKernel: number;\r\n protected _packedFloat: boolean = false;\r\n private _staticDefines: string = \"\";\r\n\r\n /**\r\n * Constructs a new blur post process\r\n * @param name Name of the effect\r\n * @param engine Engine to use to render the effect. If not provided, the last created engine will be used\r\n * @param direction Direction in which to apply the blur\r\n * @param kernel Kernel size of the blur\r\n * @param options Options to configure the effect\r\n */\r\n constructor(name: string, engine: Nullable<AbstractEngine> = null, direction?: Vector2, kernel?: number, options?: EffectWrapperCreationOptions) {\r\n const blockCompilationFinal = !!options?.blockCompilation;\r\n super({\r\n ...options,\r\n name,\r\n engine: engine || Engine.LastCreatedEngine!,\r\n useShaderStore: true,\r\n useAsPostProcess: true,\r\n fragmentShader: ThinBlurPostProcess.FragmentUrl,\r\n uniforms: ThinBlurPostProcess.Uniforms,\r\n samplers: ThinBlurPostProcess.Samplers,\r\n vertexUrl: ThinBlurPostProcess.VertexUrl,\r\n blockCompilation: true,\r\n });\r\n\r\n this.options.blockCompilation = blockCompilationFinal;\r\n\r\n if (direction !== undefined) {\r\n this.direction = direction;\r\n }\r\n if (kernel !== undefined) {\r\n this.kernel = kernel;\r\n }\r\n }\r\n\r\n /**\r\n * Width of the texture to apply the blur on\r\n */\r\n public textureWidth: number = 0;\r\n\r\n /**\r\n * Height of the texture to apply the blur on\r\n */\r\n public textureHeight: number = 0;\r\n\r\n /** The direction in which to blur the image. */\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.options.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.options.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 public override bind() {\r\n super.bind();\r\n this._drawWrapper.effect!.setFloat2(\"delta\", (1 / this.textureWidth) * this.direction.x, (1 / this.textureHeight) * this.direction.y);\r\n }\r\n\r\n /** @internal */\r\n public _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.options.engine.getCaps().maxVaryingVectors - (this.options.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.options.blockCompilation = false;\r\n\r\n this.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"]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Nullable, AbstractEngine, EffectWrapperCreationOptions } from "../index.js";
|
|
2
|
+
import { EffectWrapper } from "../Materials/effectRenderer";
|
|
3
|
+
import type { Camera } from "../Cameras/camera.js";
|
|
4
|
+
/**
|
|
5
|
+
* Options used to create a ThinCircleOfConfusionPostProcess.
|
|
6
|
+
*/
|
|
7
|
+
export interface ThinCircleOfConfusionPostProcessOptions extends EffectWrapperCreationOptions {
|
|
8
|
+
/**
|
|
9
|
+
* If the (view) depth is normalized (0.0 to 1.0 from near to far) or not (0 to camera max distance)
|
|
10
|
+
*/
|
|
11
|
+
depthNotNormalized?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Post process used to calculate the circle of confusion (used for depth of field, for example)
|
|
15
|
+
*/
|
|
16
|
+
export declare class ThinCircleOfConfusionPostProcess extends EffectWrapper {
|
|
17
|
+
/**
|
|
18
|
+
* The fragment shader url
|
|
19
|
+
*/
|
|
20
|
+
static readonly FragmentUrl = "circleOfConfusion";
|
|
21
|
+
/**
|
|
22
|
+
* The list of uniforms used by the effect
|
|
23
|
+
*/
|
|
24
|
+
static readonly Uniforms: string[];
|
|
25
|
+
/**
|
|
26
|
+
* The list of samplers used by the effect
|
|
27
|
+
*/
|
|
28
|
+
static readonly Samplers: string[];
|
|
29
|
+
/**
|
|
30
|
+
* Defines if the depth is normalized or not
|
|
31
|
+
*/
|
|
32
|
+
static readonly DefinesDepthNotNormalized = "#define COC_DEPTH_NOT_NORMALIZED";
|
|
33
|
+
protected _gatherImports(useWebGPU: boolean, list: Promise<any>[]): void;
|
|
34
|
+
/**
|
|
35
|
+
* Constructs a new circle of confusion post process
|
|
36
|
+
* @param name Name of the effect
|
|
37
|
+
* @param engine Engine to use to render the effect. If not provided, the last created engine will be used
|
|
38
|
+
* @param options Options to configure the effect
|
|
39
|
+
*/
|
|
40
|
+
constructor(name: string, engine?: Nullable<AbstractEngine>, options?: ThinCircleOfConfusionPostProcessOptions);
|
|
41
|
+
/**
|
|
42
|
+
* The camera to use to calculate the circle of confusion
|
|
43
|
+
*/
|
|
44
|
+
camera: Camera;
|
|
45
|
+
/**
|
|
46
|
+
* 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.
|
|
47
|
+
*/
|
|
48
|
+
lensSize: number;
|
|
49
|
+
/**
|
|
50
|
+
* F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
|
|
51
|
+
*/
|
|
52
|
+
fStop: number;
|
|
53
|
+
/**
|
|
54
|
+
* Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
|
|
55
|
+
*/
|
|
56
|
+
focusDistance: number;
|
|
57
|
+
/**
|
|
58
|
+
* Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
|
|
59
|
+
*/
|
|
60
|
+
focalLength: number;
|
|
61
|
+
bind(): void;
|
|
62
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { EffectWrapper } from "../Materials/effectRenderer.js";
|
|
2
|
+
import { Engine } from "../Engines/engine.js";
|
|
3
|
+
/**
|
|
4
|
+
* Post process used to calculate the circle of confusion (used for depth of field, for example)
|
|
5
|
+
*/
|
|
6
|
+
export class ThinCircleOfConfusionPostProcess extends EffectWrapper {
|
|
7
|
+
_gatherImports(useWebGPU, list) {
|
|
8
|
+
if (useWebGPU) {
|
|
9
|
+
this._webGPUReady = true;
|
|
10
|
+
list.push(import("../ShadersWGSL/circleOfConfusion.fragment.js"));
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
list.push(import("../Shaders/circleOfConfusion.fragment.js"));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Constructs a new circle of confusion post process
|
|
18
|
+
* @param name Name of the effect
|
|
19
|
+
* @param engine Engine to use to render the effect. If not provided, the last created engine will be used
|
|
20
|
+
* @param options Options to configure the effect
|
|
21
|
+
*/
|
|
22
|
+
constructor(name, engine = null, options) {
|
|
23
|
+
super({
|
|
24
|
+
...options,
|
|
25
|
+
name,
|
|
26
|
+
engine: engine || Engine.LastCreatedEngine,
|
|
27
|
+
useShaderStore: true,
|
|
28
|
+
useAsPostProcess: true,
|
|
29
|
+
fragmentShader: ThinCircleOfConfusionPostProcess.FragmentUrl,
|
|
30
|
+
uniforms: ThinCircleOfConfusionPostProcess.Uniforms,
|
|
31
|
+
samplers: ThinCircleOfConfusionPostProcess.Samplers,
|
|
32
|
+
defines: options?.depthNotNormalized ? ThinCircleOfConfusionPostProcess.DefinesDepthNotNormalized : undefined,
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* 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.
|
|
36
|
+
*/
|
|
37
|
+
this.lensSize = 50;
|
|
38
|
+
/**
|
|
39
|
+
* F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
|
|
40
|
+
*/
|
|
41
|
+
this.fStop = 1.4;
|
|
42
|
+
/**
|
|
43
|
+
* Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
|
|
44
|
+
*/
|
|
45
|
+
this.focusDistance = 2000;
|
|
46
|
+
/**
|
|
47
|
+
* Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
|
|
48
|
+
*/
|
|
49
|
+
this.focalLength = 50;
|
|
50
|
+
}
|
|
51
|
+
bind() {
|
|
52
|
+
super.bind();
|
|
53
|
+
const options = this.options;
|
|
54
|
+
const effect = this._drawWrapper.effect;
|
|
55
|
+
if (!options.depthNotNormalized) {
|
|
56
|
+
effect.setFloat2("cameraMinMaxZ", this.camera.minZ, this.camera.maxZ - this.camera.minZ);
|
|
57
|
+
}
|
|
58
|
+
// Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html
|
|
59
|
+
const aperture = this.lensSize / this.fStop;
|
|
60
|
+
const cocPrecalculation = (aperture * this.focalLength) / (this.focusDistance - this.focalLength); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]
|
|
61
|
+
effect.setFloat("focusDistance", this.focusDistance);
|
|
62
|
+
effect.setFloat("cocPrecalculation", cocPrecalculation);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The fragment shader url
|
|
67
|
+
*/
|
|
68
|
+
ThinCircleOfConfusionPostProcess.FragmentUrl = "circleOfConfusion";
|
|
69
|
+
/**
|
|
70
|
+
* The list of uniforms used by the effect
|
|
71
|
+
*/
|
|
72
|
+
ThinCircleOfConfusionPostProcess.Uniforms = ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"];
|
|
73
|
+
/**
|
|
74
|
+
* The list of samplers used by the effect
|
|
75
|
+
*/
|
|
76
|
+
ThinCircleOfConfusionPostProcess.Samplers = ["depthSampler"];
|
|
77
|
+
/**
|
|
78
|
+
* Defines if the depth is normalized or not
|
|
79
|
+
*/
|
|
80
|
+
ThinCircleOfConfusionPostProcess.DefinesDepthNotNormalized = "#define COC_DEPTH_NOT_NORMALIZED";
|
|
81
|
+
//# sourceMappingURL=thinCircleOfConfusionPostProcess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thinCircleOfConfusionPostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/thinCircleOfConfusionPostProcess.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAY3C;;GAEG;AACH,MAAM,OAAO,gCAAiC,SAAQ,aAAa;IAqB5C,cAAc,CAAC,SAAkB,EAAE,IAAoB;QACtE,IAAI,SAAS,EAAE;YACX,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,2CAA2C,CAAC,CAAC,CAAC;SAClE;aAAM;YACH,IAAI,CAAC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AAW,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,uFAAuF;QAE1L,MAAM,CAAC,QAAQ,CAAC,eAAe,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QACrD,MAAM,CAAC,QAAQ,CAAC,mBAAmB,EAAE,iBAAiB,CAAC,CAAC;IAC5D,CAAC;;AA3FD;;GAEG;AACoB,4CAAW,GAAG,mBAAmB,AAAtB,CAAuB;AAEzD;;GAEG;AACoB,yCAAQ,GAAG,CAAC,eAAe,EAAE,eAAe,EAAE,mBAAmB,CAAC,AAA1D,CAA2D;AAE1F;;GAEG;AACoB,yCAAQ,GAAG,CAAC,cAAc,CAAC,AAAnB,CAAoB;AAEnD;;GAEG;AACoB,0DAAyB,GAAG,kCAAkC,AAArC,CAAsC","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { Nullable, AbstractEngine, EffectWrapperCreationOptions } from \"core/index\";\r\nimport { EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport type { Camera } from \"core/Cameras/camera\";\r\nimport { Engine } from \"../Engines/engine\";\r\n\r\n/**\r\n * Options used to create a ThinCircleOfConfusionPostProcess.\r\n */\r\nexport interface ThinCircleOfConfusionPostProcessOptions extends EffectWrapperCreationOptions {\r\n /**\r\n * If the (view) depth is normalized (0.0 to 1.0 from near to far) or not (0 to camera max distance)\r\n */\r\n depthNotNormalized?: boolean;\r\n}\r\n\r\n/**\r\n * Post process used to calculate the circle of confusion (used for depth of field, for example)\r\n */\r\nexport class ThinCircleOfConfusionPostProcess extends EffectWrapper {\r\n /**\r\n * The fragment shader url\r\n */\r\n public static readonly FragmentUrl = \"circleOfConfusion\";\r\n\r\n /**\r\n * The list of uniforms used by the effect\r\n */\r\n public static readonly Uniforms = [\"cameraMinMaxZ\", \"focusDistance\", \"cocPrecalculation\"];\r\n\r\n /**\r\n * The list of samplers used by the effect\r\n */\r\n public static readonly Samplers = [\"depthSampler\"];\r\n\r\n /**\r\n * Defines if the depth is normalized or not\r\n */\r\n public static readonly DefinesDepthNotNormalized = \"#define COC_DEPTH_NOT_NORMALIZED\";\r\n\r\n protected override _gatherImports(useWebGPU: boolean, list: Promise<any>[]) {\r\n if (useWebGPU) {\r\n this._webGPUReady = true;\r\n list.push(import(\"../ShadersWGSL/circleOfConfusion.fragment\"));\r\n } else {\r\n list.push(import(\"../Shaders/circleOfConfusion.fragment\"));\r\n }\r\n }\r\n\r\n /**\r\n * Constructs a new circle of confusion post process\r\n * @param name Name of the effect\r\n * @param engine Engine to use to render the effect. If not provided, the last created engine will be used\r\n * @param options Options to configure the effect\r\n */\r\n constructor(name: string, engine: Nullable<AbstractEngine> = null, options?: ThinCircleOfConfusionPostProcessOptions) {\r\n super({\r\n ...options,\r\n name,\r\n engine: engine || Engine.LastCreatedEngine!,\r\n useShaderStore: true,\r\n useAsPostProcess: true,\r\n fragmentShader: ThinCircleOfConfusionPostProcess.FragmentUrl,\r\n uniforms: ThinCircleOfConfusionPostProcess.Uniforms,\r\n samplers: ThinCircleOfConfusionPostProcess.Samplers,\r\n defines: options?.depthNotNormalized ? ThinCircleOfConfusionPostProcess.DefinesDepthNotNormalized : undefined,\r\n });\r\n }\r\n\r\n /**\r\n * The camera to use to calculate the circle of confusion\r\n */\r\n public camera: Camera;\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 lensSize = 50;\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 fStop = 1.4;\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 focusDistance = 2000;\r\n\r\n /**\r\n * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)\r\n */\r\n public focalLength = 50;\r\n\r\n public override bind() {\r\n super.bind();\r\n\r\n const options = this.options as ThinCircleOfConfusionPostProcessOptions;\r\n\r\n const effect = this._drawWrapper.effect!;\r\n\r\n if (!options.depthNotNormalized) {\r\n effect.setFloat2(\"cameraMinMaxZ\", this.camera.minZ, this.camera.maxZ - this.camera.minZ);\r\n }\r\n\r\n // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html\r\n const aperture = this.lensSize / this.fStop;\r\n const cocPrecalculation = (aperture * this.focalLength) / (this.focusDistance - this.focalLength); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]\r\n\r\n effect.setFloat(\"focusDistance\", this.focusDistance);\r\n effect.setFloat(\"cocPrecalculation\", cocPrecalculation);\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Nullable, AbstractEngine, EffectWrapperCreationOptions, Vector2 } from "../index.js";
|
|
2
|
+
import { ThinBlurPostProcess } from "./thinBlurPostProcess";
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare class ThinDepthOfFieldBlurPostProcess extends ThinBlurPostProcess {
|
|
7
|
+
constructor(name: string, engine: Nullable<AbstractEngine> | undefined, direction: Vector2, kernel: number, options?: EffectWrapperCreationOptions);
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ThinBlurPostProcess } from "./thinBlurPostProcess.js";
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export class ThinDepthOfFieldBlurPostProcess extends ThinBlurPostProcess {
|
|
6
|
+
constructor(name, engine = null, direction, kernel, options) {
|
|
7
|
+
super(name, engine, direction, kernel, {
|
|
8
|
+
...options,
|
|
9
|
+
defines: `#define DOF 1\n`,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=thinDepthOfFieldBlurPostProcess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thinDepthOfFieldBlurPostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/thinDepthOfFieldBlurPostProcess.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;GAEG;AACH,MAAM,OAAO,+BAAgC,SAAQ,mBAAmB;IACpE,YAAY,IAAY,EAAE,SAAmC,IAAI,EAAE,SAAkB,EAAE,MAAc,EAAE,OAAsC;QACzI,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE;YACnC,GAAG,OAAO;YACV,OAAO,EAAE,iBAAiB;SAC7B,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { Nullable, AbstractEngine, EffectWrapperCreationOptions, Vector2 } from \"core/index\";\r\nimport { ThinBlurPostProcess } from \"./thinBlurPostProcess\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class ThinDepthOfFieldBlurPostProcess extends ThinBlurPostProcess {\r\n constructor(name: string, engine: Nullable<AbstractEngine> = null, direction: Vector2, kernel: number, options?: EffectWrapperCreationOptions) {\r\n super(name, engine, direction, kernel, {\r\n ...options,\r\n defines: `#define DOF 1\\n`,\r\n });\r\n }\r\n}\r\n"]}
|