@babylonjs/core 7.37.0 → 7.37.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Buffers/buffer.d.ts +3 -1
- package/Buffers/buffer.js +20 -122
- package/Buffers/buffer.js.map +1 -1
- package/Buffers/bufferUtils.d.ts +32 -1
- package/Buffers/bufferUtils.js +221 -10
- package/Buffers/bufferUtils.js.map +1 -1
- package/Cameras/arcRotateCamera.d.ts +3 -1
- package/Cameras/arcRotateCamera.js +14 -3
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/engine.js +0 -4
- package/Engines/engine.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraphBlock.js +1 -0
- package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.d.ts +2 -0
- package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js +3 -1
- package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js.map +1 -1
- package/Inputs/scene.inputManager.js +2 -0
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Lights/IES/iesLoader.d.ts +19 -0
- package/Lights/IES/iesLoader.js +150 -0
- package/Lights/IES/iesLoader.js.map +1 -0
- package/Lights/index.d.ts +1 -0
- package/Lights/index.js +1 -0
- package/Lights/index.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +12 -2
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/GreasedLine/greasedLineMaterialInterfaces.d.ts +5 -0
- package/Materials/GreasedLine/greasedLineMaterialInterfaces.js.map +1 -1
- package/Materials/GreasedLine/greasedLinePluginMaterial.d.ts +21 -5
- package/Materials/GreasedLine/greasedLinePluginMaterial.js +52 -176
- package/Materials/GreasedLine/greasedLinePluginMaterial.js.map +1 -1
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.d.ts +11 -0
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.js +158 -0
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.js.map +1 -0
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.d.ts +11 -0
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js +177 -0
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js.map +1 -0
- package/Materials/GreasedLine/greasedLineSimpleMaterial.d.ts +4 -2
- package/Materials/GreasedLine/greasedLineSimpleMaterial.js +45 -25
- package/Materials/GreasedLine/greasedLineSimpleMaterial.js.map +1 -1
- package/Materials/Node/Blocks/PBR/reflectionBlock.js +6 -0
- package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/index.d.ts +1 -0
- package/Materials/Node/Blocks/index.js +1 -0
- package/Materials/Node/Blocks/index.js.map +1 -1
- package/Materials/Node/Blocks/matrixSplitterBlock.d.ts +56 -0
- package/Materials/Node/Blocks/matrixSplitterBlock.js +130 -0
- package/Materials/Node/Blocks/matrixSplitterBlock.js.map +1 -0
- package/Materials/Node/nodeMaterialBlock.js +1 -0
- package/Materials/Node/nodeMaterialBlock.js.map +1 -1
- package/Materials/Node/nodeMaterialBlockConnectionPoint.d.ts +2 -0
- package/Materials/Node/nodeMaterialBlockConnectionPoint.js +4 -1
- package/Materials/Node/nodeMaterialBlockConnectionPoint.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.d.ts +1 -0
- package/Materials/PBR/pbrBaseMaterial.js +12 -0
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/Loaders/iesTextureLoader.d.ts +23 -0
- package/Materials/Textures/Loaders/iesTextureLoader.js +40 -0
- package/Materials/Textures/Loaders/iesTextureLoader.js.map +1 -0
- package/Materials/Textures/Loaders/index.d.ts +1 -0
- package/Materials/Textures/Loaders/index.js +1 -0
- package/Materials/Textures/Loaders/index.js.map +1 -1
- package/Materials/Textures/Loaders/textureLoaderManager.js +3 -0
- package/Materials/Textures/Loaders/textureLoaderManager.js.map +1 -1
- package/Materials/effectRenderer.js +1 -1
- package/Materials/effectRenderer.js.map +1 -1
- package/Materials/index.d.ts +4 -0
- package/Materials/index.js +5 -0
- package/Materials/index.js.map +1 -1
- package/Maths/math.scalar.d.ts +0 -1
- package/Maths/math.scalar.js +1 -2
- package/Maths/math.scalar.js.map +1 -1
- package/Meshes/Builders/greasedLineBuilder.js +2 -2
- package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +15 -2
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +68 -20
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/Node/Blocks/geometryInputBlock.d.ts +4 -0
- package/Meshes/Node/Blocks/geometryInputBlock.js +8 -0
- package/Meshes/Node/Blocks/geometryInputBlock.js.map +1 -1
- package/Meshes/Node/nodeGeometryBlock.js +1 -0
- package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.d.ts +2 -0
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.js +3 -1
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.js.map +1 -1
- package/Meshes/abstractMesh.hotSpot.d.ts +8 -1
- package/Meshes/abstractMesh.hotSpot.js +17 -0
- package/Meshes/abstractMesh.hotSpot.js.map +1 -1
- package/Meshes/linesMesh.js +1 -1
- package/Meshes/linesMesh.js.map +1 -1
- package/Misc/deepMerger.d.ts +6 -0
- package/Misc/deepMerger.js +26 -0
- package/Misc/deepMerger.js.map +1 -0
- package/Misc/index.d.ts +1 -0
- package/Misc/index.js +1 -0
- package/Misc/index.js.map +1 -1
- package/Misc/virtualJoystick.js +2 -0
- package/Misc/virtualJoystick.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +3 -23
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +30 -67
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.d.ts +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js +8 -4
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js.map +1 -1
- package/Rendering/boundingBoxRenderer.d.ts +63 -1
- package/Rendering/boundingBoxRenderer.js +224 -3
- package/Rendering/boundingBoxRenderer.js.map +1 -1
- package/Rendering/edgesRenderer.js +4 -1
- package/Rendering/edgesRenderer.js.map +1 -1
- package/Rendering/{IBLShadows/iblShadowsImportanceSamplingRenderer.d.ts → iblCdfGenerator.d.ts} +15 -12
- package/Rendering/{IBLShadows/iblShadowsImportanceSamplingRenderer.js → iblCdfGenerator.js} +37 -27
- package/Rendering/iblCdfGenerator.js.map +1 -0
- package/Rendering/iblCdfGeneratorSceneComponent.d.ts +59 -0
- package/Rendering/iblCdfGeneratorSceneComponent.js +83 -0
- package/Rendering/iblCdfGeneratorSceneComponent.js.map +1 -0
- package/Rendering/index.d.ts +12 -10
- package/Rendering/index.js +12 -10
- package/Rendering/index.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js +72 -2
- package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js +1 -1
- package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js +29 -4
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflection.js +9 -1
- package/Shaders/ShadersInclude/pbrBlockReflection.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js +9 -1
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +3 -0
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/Shaders/boundingBoxRenderer.vertex.js +7 -0
- package/Shaders/boundingBoxRenderer.vertex.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +16 -2
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/Shaders/{iblShadowsCdfy.fragment.d.ts → iblCdfx.fragment.d.ts} +1 -1
- package/Shaders/{iblShadowsCdfx.fragment.js → iblCdfx.fragment.js} +3 -3
- package/Shaders/iblCdfx.fragment.js.map +1 -0
- package/Shaders/{iblShadowsCdfx.fragment.d.ts → iblCdfy.fragment.d.ts} +1 -1
- package/Shaders/{iblShadowsCdfy.fragment.js → iblCdfy.fragment.js} +3 -3
- package/Shaders/iblCdfy.fragment.js.map +1 -0
- package/Shaders/{iblShadowsIcdfx.fragment.d.ts → iblIcdfx.fragment.d.ts} +1 -1
- package/Shaders/{iblShadowsIcdfx.fragment.js → iblIcdfx.fragment.js} +3 -3
- package/Shaders/iblIcdfx.fragment.js.map +1 -0
- package/Shaders/{iblShadowsIcdfy.fragment.d.ts → iblIcdfy.fragment.d.ts} +1 -1
- package/Shaders/{iblShadowsIcdfy.fragment.js → iblIcdfy.fragment.js} +3 -3
- package/Shaders/iblIcdfy.fragment.js.map +1 -0
- package/Shaders/importanceSamplingDebug.fragment.d.ts +5 -0
- package/Shaders/{iblShadowsImportanceSamplingDebug.fragment.js → importanceSamplingDebug.fragment.js} +3 -3
- package/Shaders/importanceSamplingDebug.fragment.js.map +1 -0
- package/Shaders/pbr.fragment.js +8 -0
- package/Shaders/pbr.fragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +77 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js +28 -4
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js +1 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/oitFragment.js +1 -1
- package/ShadersWGSL/ShadersInclude/oitFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflection.js +14 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflection.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockSubSurface.js +14 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js +3 -0
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/shadowsFragmentFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/shadowsFragmentFunctions.js.map +1 -1
- package/ShadersWGSL/boundingBoxRenderer.vertex.js +9 -1
- package/ShadersWGSL/boundingBoxRenderer.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +18 -2
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/greasedLine.fragment.d.ts +5 -0
- package/ShadersWGSL/greasedLine.fragment.js +25 -0
- package/ShadersWGSL/greasedLine.fragment.js.map +1 -0
- package/ShadersWGSL/greasedLine.vertex.d.ts +9 -0
- package/ShadersWGSL/greasedLine.vertex.js +43 -0
- package/ShadersWGSL/greasedLine.vertex.js.map +1 -0
- package/ShadersWGSL/iblCdfx.fragment.d.ts +5 -0
- package/ShadersWGSL/{iblShadowsCdfx.fragment.js → iblCdfx.fragment.js} +3 -3
- package/ShadersWGSL/iblCdfx.fragment.js.map +1 -0
- package/ShadersWGSL/iblCdfy.fragment.d.ts +5 -0
- package/ShadersWGSL/{iblShadowsCdfy.fragment.js → iblCdfy.fragment.js} +3 -3
- package/ShadersWGSL/iblCdfy.fragment.js.map +1 -0
- package/ShadersWGSL/iblIcdfx.fragment.d.ts +5 -0
- package/ShadersWGSL/{iblShadowsIcdfx.fragment.js → iblIcdfx.fragment.js} +3 -3
- package/ShadersWGSL/iblIcdfx.fragment.js.map +1 -0
- package/ShadersWGSL/iblIcdfy.fragment.d.ts +5 -0
- package/ShadersWGSL/{iblShadowsIcdfy.fragment.js → iblIcdfy.fragment.js} +3 -3
- package/ShadersWGSL/iblIcdfy.fragment.js.map +1 -0
- package/ShadersWGSL/importanceSamplingDebug.fragment.d.ts +5 -0
- package/ShadersWGSL/{iblShadowsImportanceSamplingDebug.fragment.js → importanceSamplingDebug.fragment.js} +3 -3
- package/ShadersWGSL/importanceSamplingDebug.fragment.js.map +1 -0
- package/ShadersWGSL/pbr.fragment.js +12 -0
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +4 -0
- package/scene.js +6 -0
- package/scene.js.map +1 -1
- package/sceneComponent.d.ts +1 -1
- package/sceneComponent.js +1 -1
- package/sceneComponent.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsImportanceSamplingRenderer.js.map +0 -1
- package/Shaders/iblShadowsCdfx.fragment.js.map +0 -1
- package/Shaders/iblShadowsCdfy.fragment.js.map +0 -1
- package/Shaders/iblShadowsIcdfx.fragment.js.map +0 -1
- package/Shaders/iblShadowsIcdfy.fragment.js.map +0 -1
- package/Shaders/iblShadowsImportanceSamplingDebug.fragment.d.ts +0 -5
- package/Shaders/iblShadowsImportanceSamplingDebug.fragment.js.map +0 -1
- package/ShadersWGSL/iblShadowsCdfx.fragment.d.ts +0 -5
- package/ShadersWGSL/iblShadowsCdfx.fragment.js.map +0 -1
- package/ShadersWGSL/iblShadowsCdfy.fragment.d.ts +0 -5
- package/ShadersWGSL/iblShadowsCdfy.fragment.js.map +0 -1
- package/ShadersWGSL/iblShadowsIcdfx.fragment.d.ts +0 -5
- package/ShadersWGSL/iblShadowsIcdfx.fragment.js.map +0 -1
- package/ShadersWGSL/iblShadowsIcdfy.fragment.d.ts +0 -5
- package/ShadersWGSL/iblShadowsIcdfy.fragment.js.map +0 -1
- package/ShadersWGSL/iblShadowsImportanceSamplingDebug.fragment.d.ts +0 -5
- package/ShadersWGSL/iblShadowsImportanceSamplingDebug.fragment.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iblCdfGenerator.js","sourceRoot":"","sources":["../../../../dev/core/src/Rendering/iblCdfGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIjD,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AAExF,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;GAEG;AACH,MAAM,OAAO,eAAe;IAUxB;;OAEG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,IAAW,SAAS,CAAC,MAAmB;QACpC,IAAI,IAAI,CAAC,UAAU,KAAK,MAAM,EAAE,CAAC;YAC7B,OAAO;QACX,CAAC;QACD,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC;QACzB,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAChB,IAAI,MAAM,CAAC,oBAAoB,EAAE,EAAE,CAAC;gBAChC,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC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AAC,CAAC;QACvI,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;OAGG;IACI,OAAO;QACV,OAAO,CACH,IAAI,CAAC,UAAU;YACf,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,wBAAwB;YACjD,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE;YACzB,IAAI,CAAC,OAAO;YACZ,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACtB,IAAI,CAAC,QAAQ;YACb,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;YACvB,IAAI,CAAC,OAAO;YACZ,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACtB,IAAI,CAAC,QAAQ;YACb,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAC1B,CAAC;IACN,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;QAC7B,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC9B,CAAC;QACD,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;IACvC,CAAC;;AAlLD;;GAEG;AACW,6CAA6B,GAA2B,CAAC,CAAC,EAAE,EAAE;IACxE,MAAM,WAAW,CAAC,6CAA6C,CAAC,CAAC;AACrE,CAAC,AAF0C,CAEzC","sourcesContent":["import { Constants } from \"../Engines/constants\";\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\n\r\nimport type { Scene } from \"../scene\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport type { TextureSize } from \"../Materials/Textures/textureCreationOptions\";\r\nimport { ProceduralTexture } from \"../Materials/Textures/Procedurals/proceduralTexture\";\r\nimport type { IProceduralTextureCreationOptions } from \"../Materials/Textures/Procedurals/proceduralTexture\";\r\nimport { PostProcess } from \"../PostProcesses/postProcess\";\r\nimport type { PostProcessOptions } from \"../PostProcesses/postProcess\";\r\nimport { Vector4 } from \"../Maths/math.vector\";\r\nimport { RawTexture } from \"../Materials/Textures/rawTexture\";\r\nimport type { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { CubeTexture } from \"../Materials/Textures/cubeTexture\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\nimport { Engine } from \"../Engines/engine\";\r\nimport { _WarnImport } from \"../Misc/devTools\";\r\n\r\n/**\r\n * Build cdf maps to be used for IBL importance sampling.\r\n */\r\nexport class IblCdfGenerator {\r\n private _scene: Scene;\r\n private _engine: AbstractEngine;\r\n\r\n private _cdfyPT: ProceduralTexture;\r\n private _icdfyPT: ProceduralTexture;\r\n private _cdfxPT: ProceduralTexture;\r\n private _icdfxPT: ProceduralTexture;\r\n private _iblSource: BaseTexture;\r\n private _dummyTexture: RawTexture;\r\n /**\r\n * Gets the IBL source texture being used by the importance sampling renderer\r\n */\r\n public get iblSource(): BaseTexture {\r\n return this._iblSource;\r\n }\r\n\r\n /**\r\n * Sets the IBL source texture to be used by the importance sampling renderer.\r\n * This will trigger recreation of the importance sampling assets.\r\n */\r\n public set iblSource(source: BaseTexture) {\r\n if (this._iblSource === source) {\r\n return;\r\n }\r\n this._disposeTextures();\r\n this._iblSource = source;\r\n if (source.isCube) {\r\n if (source.isReadyOrNotBlocking()) {\r\n this._recreateAssetsFromNewIbl(source);\r\n } else {\r\n (source as CubeTexture).onLoadObservable.addOnce(this._recreateAssetsFromNewIbl.bind(this, source));\r\n }\r\n } else {\r\n if (source.isReadyOrNotBlocking()) {\r\n this._recreateAssetsFromNewIbl(source);\r\n } else {\r\n (source as Texture).onLoadObservable.addOnce(this._recreateAssetsFromNewIbl.bind(this, source));\r\n }\r\n }\r\n }\r\n\r\n private _recreateAssetsFromNewIbl(source: BaseTexture) {\r\n if (this._debugPass) {\r\n this._debugPass.dispose();\r\n }\r\n\r\n this._createTextures();\r\n\r\n if (this._debugPass) {\r\n // Recreate the debug pass because of the new textures\r\n this._createDebugPass();\r\n }\r\n\r\n // Once the textures are generated, notify that they are ready to use.\r\n this._icdfxPT.onGeneratedObservable.addOnce(() => {\r\n this.onGeneratedObservable.notifyObservers();\r\n });\r\n }\r\n\r\n /**\r\n * Return the cumulative distribution function (CDF) Y texture\r\n * @returns Return the cumulative distribution function (CDF) Y texture\r\n */\r\n public getIcdfyTexture(): Texture {\r\n return this._icdfyPT ? this._icdfyPT : this._dummyTexture;\r\n }\r\n\r\n /**\r\n * Return the cumulative distribution function (CDF) X texture\r\n * @returns Return the cumulative distribution function (CDF) X texture\r\n */\r\n public getIcdfxTexture(): Texture {\r\n return this._icdfxPT ? this._icdfxPT : this._dummyTexture;\r\n }\r\n\r\n /** Enable the debug view for this pass */\r\n public debugEnabled: boolean = false;\r\n private _debugPass: PostProcess;\r\n private _debugSizeParams: Vector4 = new Vector4(0.0, 0.0, 0.0, 0.0);\r\n\r\n /**\r\n * Sets params that control the position and scaling of the debug display on the screen.\r\n * @param x Screen X offset of the debug display (0-1)\r\n * @param y Screen Y offset of the debug display (0-1)\r\n * @param widthScale X scale of the debug display (0-1)\r\n * @param heightScale Y scale of the debug display (0-1)\r\n */\r\n public setDebugDisplayParams(x: number, y: number, widthScale: number, heightScale: number) {\r\n this._debugSizeParams.set(x, y, widthScale, heightScale);\r\n }\r\n\r\n /**\r\n * The name of the debug pass post process\r\n */\r\n public get debugPassName(): string {\r\n return this._debugPassName;\r\n }\r\n private _debugPassName: string = \"Importance Sample Debug\";\r\n\r\n /**\r\n * Gets the debug pass post process\r\n * @returns The post process\r\n */\r\n public getDebugPassPP(): PostProcess {\r\n if (!this._debugPass) {\r\n this._createDebugPass();\r\n }\r\n return this._debugPass;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _SceneComponentInitialization: (scene: Scene) => void = (_) => {\r\n throw _WarnImport(\"IblCdfGeneratorSceneComponentSceneComponent\");\r\n };\r\n\r\n /**\r\n * Instanciates the importance sampling renderer\r\n * @param scene Scene to attach to\r\n * @returns The importance sampling renderer\r\n */\r\n constructor(scene: Scene) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n const blackPixels = new Uint8Array([0, 0, 0, 255]);\r\n this._dummyTexture = new RawTexture(blackPixels, 1, 1, Engine.TEXTUREFORMAT_RGBA, scene, false);\r\n IblCdfGenerator._SceneComponentInitialization(this._scene);\r\n }\r\n\r\n /**\r\n * Observable that triggers when the importance sampling renderer is ready\r\n */\r\n public onGeneratedObservable: Observable<void> = new Observable<void>();\r\n\r\n private _createTextures() {\r\n const size: TextureSize = this._iblSource ? this._iblSource.getSize() : { width: 1, height: 1 };\r\n if (!this._iblSource) {\r\n this._iblSource = RawTexture.CreateRTexture(\r\n new Uint8Array([255]),\r\n 1,\r\n 1,\r\n this._scene,\r\n false,\r\n false,\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n Constants.TEXTURETYPE_UNSIGNED_BYTE\r\n );\r\n this._iblSource.name = \"Placeholder IBL Source\";\r\n }\r\n\r\n if (this._iblSource!.isCube) {\r\n size.width *= 4;\r\n size.height *= 2;\r\n }\r\n\r\n const isWebGPU = this._engine.isWebGPU;\r\n // Create CDF maps (Cumulative Distribution Function) to assist in importance sampling\r\n const cdfOptions: IProceduralTextureCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n format: Constants.TEXTUREFORMAT_R,\r\n type: Constants.TEXTURETYPE_FLOAT,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../ShadersWGSL/iblCdfx.fragment\"), import(\"../ShadersWGSL/iblCdfy.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../Shaders/iblCdfx.fragment\"), import(\"../Shaders/iblCdfy.fragment\")]);\r\n }\r\n },\r\n };\r\n const icdfOptions: IProceduralTextureCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n format: Constants.TEXTUREFORMAT_R,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../ShadersWGSL/iblIcdfx.fragment\"), import(\"../ShadersWGSL/iblIcdfy.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../Shaders/iblIcdfx.fragment\"), import(\"../Shaders/iblIcdfy.fragment\")]);\r\n }\r\n },\r\n };\r\n this._cdfyPT = new ProceduralTexture(\"cdfyTexture\", { width: size.width, height: size.height + 1 }, \"iblCdfy\", this._scene, cdfOptions, false, false);\r\n this._cdfyPT.autoClear = false;\r\n this._cdfyPT.setTexture(\"iblSource\", this._iblSource as Texture);\r\n this._cdfyPT.setInt(\"iblHeight\", size.height);\r\n if (this._iblSource.isCube) {\r\n this._cdfyPT.defines = \"#define IBL_USE_CUBE_MAP\\n\";\r\n }\r\n this._cdfyPT.refreshRate = 0;\r\n this._icdfyPT = new ProceduralTexture(\"icdfyTexture\", { width: size.width, height: size.height }, \"iblIcdfy\", this._scene, icdfOptions, false, false);\r\n this._icdfyPT.autoClear = false;\r\n this._icdfyPT.setTexture(\"cdfy\", this._cdfyPT);\r\n this._icdfyPT.refreshRate = 0;\r\n this._cdfxPT = new ProceduralTexture(\"cdfxTexture\", { width: size.width + 1, height: 1 }, \"iblCdfx\", this._scene, cdfOptions, false, false);\r\n this._cdfxPT.autoClear = false;\r\n this._cdfxPT.setTexture(\"cdfy\", this._cdfyPT);\r\n this._cdfxPT.refreshRate = 0;\r\n this._icdfxPT = new ProceduralTexture(\"icdfxTexture\", { width: size.width, height: 1 }, \"iblIcdfx\", this._scene, icdfOptions, false, false);\r\n this._icdfxPT.autoClear = false;\r\n this._icdfxPT.setTexture(\"cdfx\", this._cdfxPT);\r\n this._icdfxPT.refreshRate = 0;\r\n }\r\n\r\n private _disposeTextures() {\r\n this._cdfyPT?.dispose();\r\n this._icdfyPT?.dispose();\r\n this._cdfxPT?.dispose();\r\n this._icdfxPT?.dispose();\r\n }\r\n\r\n private _createDebugPass() {\r\n if (this._debugPass) {\r\n this._debugPass.dispose();\r\n }\r\n const isWebGPU = this._engine.isWebGPU;\r\n const debugOptions: PostProcessOptions = {\r\n width: this._scene.getEngine().getRenderWidth(),\r\n height: this._scene.getEngine().getRenderHeight(),\r\n samplingMode: Texture.BILINEAR_SAMPLINGMODE,\r\n engine: this._engine,\r\n textureType: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n uniforms: [\"sizeParams\"],\r\n samplers: [\"cdfy\", \"icdfy\", \"cdfx\", \"icdfx\", \"iblSource\"],\r\n defines: this._iblSource?.isCube ? \"#define IBL_USE_CUBE_MAP\\n\" : \"\",\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializations: (useWebGPU: boolean, list: Promise<any>[]) => {\r\n if (useWebGPU) {\r\n list.push(import(\"../ShadersWGSL/importanceSamplingDebug.fragment\"));\r\n } else {\r\n list.push(import(\"../Shaders/importanceSamplingDebug.fragment\"));\r\n }\r\n },\r\n };\r\n this._debugPass = new PostProcess(this._debugPassName, \"importanceSamplingDebug\", debugOptions);\r\n const debugEffect = this._debugPass.getEffect();\r\n if (debugEffect) {\r\n debugEffect.defines = this._iblSource?.isCube ? \"#define IBL_USE_CUBE_MAP\\n\" : \"\";\r\n }\r\n if (this._iblSource?.isCube) {\r\n this._debugPass.updateEffect(\"#define IBL_USE_CUBE_MAP\\n\");\r\n }\r\n this._debugPass.onApplyObservable.add((effect) => {\r\n effect.setTexture(\"cdfy\", this._cdfyPT);\r\n effect.setTexture(\"icdfy\", this._icdfyPT);\r\n effect.setTexture(\"cdfx\", this._cdfxPT);\r\n effect.setTexture(\"icdfx\", this._icdfxPT);\r\n effect.setTexture(\"iblSource\", this._iblSource);\r\n effect.setFloat4(\"sizeParams\", this._debugSizeParams.x, this._debugSizeParams.y, this._debugSizeParams.z, this._debugSizeParams.w);\r\n });\r\n }\r\n\r\n /**\r\n * Checks if the importance sampling renderer is ready\r\n * @returns true if the importance sampling renderer is ready\r\n */\r\n public isReady() {\r\n return (\r\n this._iblSource &&\r\n this._iblSource.name !== \"Placeholder IBL Source\" &&\r\n this._iblSource.isReady() &&\r\n this._cdfyPT &&\r\n this._cdfyPT.isReady() &&\r\n this._icdfyPT &&\r\n this._icdfyPT.isReady() &&\r\n this._cdfxPT &&\r\n this._cdfxPT.isReady() &&\r\n this._icdfxPT &&\r\n this._icdfxPT.isReady()\r\n );\r\n }\r\n\r\n /**\r\n * Disposes the importance sampling renderer and associated resources\r\n */\r\n public dispose() {\r\n this._disposeTextures();\r\n this._dummyTexture.dispose();\r\n if (this._debugPass) {\r\n this._debugPass.dispose();\r\n }\r\n this.onGeneratedObservable.clear();\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Nullable } from "../types";
|
|
2
|
+
import { Scene } from "../scene";
|
|
3
|
+
import type { ISceneComponent } from "../sceneComponent";
|
|
4
|
+
import { IblCdfGenerator } from "./iblCdfGenerator";
|
|
5
|
+
declare module "../scene" {
|
|
6
|
+
interface Scene {
|
|
7
|
+
/** @internal (Backing field) */
|
|
8
|
+
_iblCdfGenerator: Nullable<IblCdfGenerator>;
|
|
9
|
+
/**
|
|
10
|
+
* Gets or Sets the current CDF generator associated to the scene.
|
|
11
|
+
* The CDF (cumulative distribution function) generator creates CDF maps
|
|
12
|
+
* for a given IBL texture that can then be used for more efficient
|
|
13
|
+
* importance sampling.
|
|
14
|
+
*/
|
|
15
|
+
iblCdfGenerator: Nullable<IblCdfGenerator>;
|
|
16
|
+
/**
|
|
17
|
+
* Enables a IblCdfGenerator and associates it with the scene.
|
|
18
|
+
* @returns the IblCdfGenerator
|
|
19
|
+
*/
|
|
20
|
+
enableIblCdfGenerator(): Nullable<IblCdfGenerator>;
|
|
21
|
+
/**
|
|
22
|
+
* Disables the GeometryBufferRender associated with the scene
|
|
23
|
+
*/
|
|
24
|
+
disableIblCdfGenerator(): void;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Defines the IBL CDF Generator scene component responsible for generating CDF maps for a given IBL.
|
|
29
|
+
*/
|
|
30
|
+
export declare class IblCdfGeneratorSceneComponent implements ISceneComponent {
|
|
31
|
+
/**
|
|
32
|
+
* The component name helpful to identify the component in the list of scene components.
|
|
33
|
+
*/
|
|
34
|
+
readonly name = "iblCDFGenerator";
|
|
35
|
+
/**
|
|
36
|
+
* The scene the component belongs to.
|
|
37
|
+
*/
|
|
38
|
+
scene: Scene;
|
|
39
|
+
/**
|
|
40
|
+
* Creates a new instance of the component for the given scene
|
|
41
|
+
* @param scene Defines the scene to register the component in
|
|
42
|
+
*/
|
|
43
|
+
constructor(scene: Scene);
|
|
44
|
+
/**
|
|
45
|
+
* Registers the component in a given scene
|
|
46
|
+
*/
|
|
47
|
+
register(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Rebuilds the elements related to this component in case of
|
|
50
|
+
* context lost for instance.
|
|
51
|
+
*/
|
|
52
|
+
rebuild(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Disposes the component and the associated resources
|
|
55
|
+
*/
|
|
56
|
+
dispose(): void;
|
|
57
|
+
private _updateIblSource;
|
|
58
|
+
private _newIblObserver;
|
|
59
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Scene } from "../scene.js";
|
|
2
|
+
import { SceneComponentConstants } from "../sceneComponent.js";
|
|
3
|
+
import { IblCdfGenerator } from "./iblCdfGenerator.js";
|
|
4
|
+
Object.defineProperty(Scene.prototype, "iblCdfGenerator", {
|
|
5
|
+
get: function () {
|
|
6
|
+
return this._iblCdfGenerator;
|
|
7
|
+
},
|
|
8
|
+
set: function (value) {
|
|
9
|
+
if (value) {
|
|
10
|
+
this._iblCdfGenerator = value;
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
});
|
|
16
|
+
Scene.prototype.enableIblCdfGenerator = function () {
|
|
17
|
+
if (this._iblCdfGenerator) {
|
|
18
|
+
return this._iblCdfGenerator;
|
|
19
|
+
}
|
|
20
|
+
this._iblCdfGenerator = new IblCdfGenerator(this);
|
|
21
|
+
if (this.environmentTexture) {
|
|
22
|
+
this._iblCdfGenerator.iblSource = this.environmentTexture;
|
|
23
|
+
}
|
|
24
|
+
return this._iblCdfGenerator;
|
|
25
|
+
};
|
|
26
|
+
Scene.prototype.disableIblCdfGenerator = function () {
|
|
27
|
+
if (!this._iblCdfGenerator) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
this._iblCdfGenerator.dispose();
|
|
31
|
+
this._iblCdfGenerator = null;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Defines the IBL CDF Generator scene component responsible for generating CDF maps for a given IBL.
|
|
35
|
+
*/
|
|
36
|
+
export class IblCdfGeneratorSceneComponent {
|
|
37
|
+
/**
|
|
38
|
+
* Creates a new instance of the component for the given scene
|
|
39
|
+
* @param scene Defines the scene to register the component in
|
|
40
|
+
*/
|
|
41
|
+
constructor(scene) {
|
|
42
|
+
/**
|
|
43
|
+
* The component name helpful to identify the component in the list of scene components.
|
|
44
|
+
*/
|
|
45
|
+
this.name = SceneComponentConstants.NAME_IBLCDFGENERATOR;
|
|
46
|
+
this._newIblObserver = null;
|
|
47
|
+
this.scene = scene;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Registers the component in a given scene
|
|
51
|
+
*/
|
|
52
|
+
register() {
|
|
53
|
+
this._updateIblSource();
|
|
54
|
+
this._newIblObserver = this.scene.onEnvironmentTextureChangedObservable.add(this._updateIblSource.bind(this));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Rebuilds the elements related to this component in case of
|
|
58
|
+
* context lost for instance.
|
|
59
|
+
*/
|
|
60
|
+
rebuild() {
|
|
61
|
+
// Nothing to do for this component
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Disposes the component and the associated resources
|
|
65
|
+
*/
|
|
66
|
+
dispose() {
|
|
67
|
+
this.scene.onEnvironmentTextureChangedObservable.remove(this._newIblObserver);
|
|
68
|
+
}
|
|
69
|
+
_updateIblSource() {
|
|
70
|
+
if (this.scene.iblCdfGenerator && this.scene.environmentTexture) {
|
|
71
|
+
this.scene.iblCdfGenerator.iblSource = this.scene.environmentTexture;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
IblCdfGenerator._SceneComponentInitialization = (scene) => {
|
|
76
|
+
// Register the CDF generator component to the scene.
|
|
77
|
+
let component = scene._getComponent(SceneComponentConstants.NAME_IBLCDFGENERATOR);
|
|
78
|
+
if (!component) {
|
|
79
|
+
component = new IblCdfGeneratorSceneComponent(scene);
|
|
80
|
+
scene._addComponent(component);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=iblCdfGeneratorSceneComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iblCdfGeneratorSceneComponent.js","sourceRoot":"","sources":["../../../../dev/core/src/Rendering/iblCdfGeneratorSceneComponent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AA8BpD,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,SAAS,EAAE,iBAAiB,EAAE;IACtD,GAAG,EAAE;QACD,OAAO,IAAI,CAAC,gBAAgB,CAAC;IACjC,CAAC;IACD,GAAG,EAAE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CAAC;IAED;;;OAGG;IACI,OAAO;QACV,mCAAmC;IACvC,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,KAAK,CAAC,qCAAqC,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAClF,CAAC;IAEO,gBAAgB;QACpB,IAAI,IAAI,CAAC,KAAK,CAAC,eAAe,IAAI,IAAI,CAAC,KAAK,CAAC,kBAAkB,EAAE,CAAC;YAC9D,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC;QACzE,CAAC;IACL,CAAC;CAGJ;AAED,eAAe,CAAC,6BAA6B,GAAG,CAAC,KAAY,EAAE,EAAE;IAC7D,qDAAqD;IACrD,IAAI,SAAS,GAAG,KAAK,CAAC,aAAa,CAAC,uBAAuB,CAAC,oBAAoB,CAAkC,CAAC;IACnH,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,SAAS,GAAG,IAAI,6BAA6B,CAAC,KAAK,CAAC,CAAC;QACrD,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport { Scene } from \"../scene\";\r\nimport type { ISceneComponent } from \"../sceneComponent\";\r\nimport { SceneComponentConstants } from \"../sceneComponent\";\r\nimport { IblCdfGenerator } from \"./iblCdfGenerator\";\r\nimport type { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport type { Observer } from \"../Misc/observable\";\r\n\r\ndeclare module \"../scene\" {\r\n export interface Scene {\r\n /** @internal (Backing field) */\r\n _iblCdfGenerator: Nullable<IblCdfGenerator>;\r\n\r\n /**\r\n * Gets or Sets the current CDF generator associated to the scene.\r\n * The CDF (cumulative distribution function) generator creates CDF maps\r\n * for a given IBL texture that can then be used for more efficient\r\n * importance sampling.\r\n */\r\n iblCdfGenerator: Nullable<IblCdfGenerator>;\r\n\r\n /**\r\n * Enables a IblCdfGenerator and associates it with the scene.\r\n * @returns the IblCdfGenerator\r\n */\r\n enableIblCdfGenerator(): Nullable<IblCdfGenerator>;\r\n\r\n /**\r\n * Disables the GeometryBufferRender associated with the scene\r\n */\r\n disableIblCdfGenerator(): void;\r\n }\r\n}\r\n\r\nObject.defineProperty(Scene.prototype, \"iblCdfGenerator\", {\r\n get: function (this: Scene) {\r\n return this._iblCdfGenerator;\r\n },\r\n set: function (this: Scene, value: Nullable<IblCdfGenerator>) {\r\n if (value) {\r\n this._iblCdfGenerator = value;\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nScene.prototype.enableIblCdfGenerator = function (): Nullable<IblCdfGenerator> {\r\n if (this._iblCdfGenerator) {\r\n return this._iblCdfGenerator;\r\n }\r\n\r\n this._iblCdfGenerator = new IblCdfGenerator(this);\r\n if (this.environmentTexture) {\r\n this._iblCdfGenerator.iblSource = this.environmentTexture;\r\n }\r\n return this._iblCdfGenerator;\r\n};\r\n\r\nScene.prototype.disableIblCdfGenerator = function (): void {\r\n if (!this._iblCdfGenerator) {\r\n return;\r\n }\r\n\r\n this._iblCdfGenerator.dispose();\r\n this._iblCdfGenerator = null;\r\n};\r\n\r\n/**\r\n * Defines the IBL CDF Generator scene component responsible for generating CDF maps for a given IBL.\r\n */\r\nexport class IblCdfGeneratorSceneComponent implements ISceneComponent {\r\n /**\r\n * The component name helpful to identify the component in the list of scene components.\r\n */\r\n public readonly name = SceneComponentConstants.NAME_IBLCDFGENERATOR;\r\n\r\n /**\r\n * The scene the component belongs to.\r\n */\r\n public scene: Scene;\r\n\r\n /**\r\n * Creates a new instance of the component for the given scene\r\n * @param scene Defines the scene to register the component in\r\n */\r\n constructor(scene: Scene) {\r\n this.scene = scene;\r\n }\r\n\r\n /**\r\n * Registers the component in a given scene\r\n */\r\n public register(): void {\r\n this._updateIblSource();\r\n this._newIblObserver = this.scene.onEnvironmentTextureChangedObservable.add(this._updateIblSource.bind(this));\r\n }\r\n\r\n /**\r\n * Rebuilds the elements related to this component in case of\r\n * context lost for instance.\r\n */\r\n public rebuild(): void {\r\n // Nothing to do for this component\r\n }\r\n\r\n /**\r\n * Disposes the component and the associated resources\r\n */\r\n public dispose(): void {\r\n this.scene.onEnvironmentTextureChangedObservable.remove(this._newIblObserver);\r\n }\r\n\r\n private _updateIblSource(): void {\r\n if (this.scene.iblCdfGenerator && this.scene.environmentTexture) {\r\n this.scene.iblCdfGenerator.iblSource = this.scene.environmentTexture;\r\n }\r\n }\r\n\r\n private _newIblObserver: Nullable<Observer<Nullable<BaseTexture>>> = null;\r\n}\r\n\r\nIblCdfGenerator._SceneComponentInitialization = (scene: Scene) => {\r\n // Register the CDF generator component to the scene.\r\n let component = scene._getComponent(SceneComponentConstants.NAME_IBLCDFGENERATOR) as IblCdfGeneratorSceneComponent;\r\n if (!component) {\r\n component = new IblCdfGeneratorSceneComponent(scene);\r\n scene._addComponent(component);\r\n }\r\n};\r\n"]}
|
package/Rendering/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export * from "./depthPeelingSceneComponent";
|
|
|
6
6
|
export * from "./edgesRenderer";
|
|
7
7
|
export * from "./geometryBufferRenderer";
|
|
8
8
|
export * from "./geometryBufferRendererSceneComponent";
|
|
9
|
+
export * from "./iblCdfGenerator";
|
|
10
|
+
export * from "./iblCdfGeneratorSceneComponent";
|
|
9
11
|
export * from "./IBLShadows/iblShadowsRenderPipeline";
|
|
10
12
|
export * from "./prePassRenderer";
|
|
11
13
|
export * from "./prePassRendererSceneComponent";
|
|
@@ -56,16 +58,16 @@ export * from "../Shaders/iblGenerateVoxelMip.fragment";
|
|
|
56
58
|
export * from "../ShadersWGSL/iblGenerateVoxelMip.fragment";
|
|
57
59
|
export * from "../Shaders/iblShadowGBufferDebug.fragment";
|
|
58
60
|
export * from "../ShadersWGSL/iblShadowGBufferDebug.fragment";
|
|
59
|
-
export * from "../ShadersWGSL/
|
|
60
|
-
export * from "../Shaders/
|
|
61
|
-
export * from "../ShadersWGSL/
|
|
62
|
-
export * from "../Shaders/
|
|
63
|
-
export * from "../ShadersWGSL/
|
|
64
|
-
export * from "../Shaders/
|
|
65
|
-
export * from "../ShadersWGSL/
|
|
66
|
-
export * from "../Shaders/
|
|
67
|
-
export * from "../ShadersWGSL/
|
|
68
|
-
export * from "../Shaders/
|
|
61
|
+
export * from "../ShadersWGSL/iblCdfx.fragment";
|
|
62
|
+
export * from "../Shaders/iblCdfx.fragment";
|
|
63
|
+
export * from "../ShadersWGSL/iblCdfy.fragment";
|
|
64
|
+
export * from "../Shaders/iblCdfy.fragment";
|
|
65
|
+
export * from "../ShadersWGSL/iblIcdfx.fragment";
|
|
66
|
+
export * from "../Shaders/iblIcdfx.fragment";
|
|
67
|
+
export * from "../ShadersWGSL/iblIcdfy.fragment";
|
|
68
|
+
export * from "../Shaders/iblIcdfy.fragment";
|
|
69
|
+
export * from "../ShadersWGSL/importanceSamplingDebug.fragment";
|
|
70
|
+
export * from "../Shaders/importanceSamplingDebug.fragment";
|
|
69
71
|
export * from "../Shaders/iblVoxelGrid2dArrayDebug.fragment";
|
|
70
72
|
export * from "../ShadersWGSL/iblVoxelGrid2dArrayDebug.fragment";
|
|
71
73
|
export * from "../Shaders/iblVoxelGrid.fragment";
|
package/Rendering/index.js
CHANGED
|
@@ -7,6 +7,8 @@ export * from "./depthPeelingSceneComponent.js";
|
|
|
7
7
|
export * from "./edgesRenderer.js";
|
|
8
8
|
export * from "./geometryBufferRenderer.js";
|
|
9
9
|
export * from "./geometryBufferRendererSceneComponent.js";
|
|
10
|
+
export * from "./iblCdfGenerator.js";
|
|
11
|
+
export * from "./iblCdfGeneratorSceneComponent.js";
|
|
10
12
|
export * from "./IBLShadows/iblShadowsRenderPipeline.js";
|
|
11
13
|
export * from "./prePassRenderer.js";
|
|
12
14
|
export * from "./prePassRendererSceneComponent.js";
|
|
@@ -63,16 +65,16 @@ export * from "../Shaders/iblGenerateVoxelMip.fragment.js";
|
|
|
63
65
|
export * from "../ShadersWGSL/iblGenerateVoxelMip.fragment.js";
|
|
64
66
|
export * from "../Shaders/iblShadowGBufferDebug.fragment.js";
|
|
65
67
|
export * from "../ShadersWGSL/iblShadowGBufferDebug.fragment.js";
|
|
66
|
-
export * from "../ShadersWGSL/
|
|
67
|
-
export * from "../Shaders/
|
|
68
|
-
export * from "../ShadersWGSL/
|
|
69
|
-
export * from "../Shaders/
|
|
70
|
-
export * from "../ShadersWGSL/
|
|
71
|
-
export * from "../Shaders/
|
|
72
|
-
export * from "../ShadersWGSL/
|
|
73
|
-
export * from "../Shaders/
|
|
74
|
-
export * from "../ShadersWGSL/
|
|
75
|
-
export * from "../Shaders/
|
|
68
|
+
export * from "../ShadersWGSL/iblCdfx.fragment.js";
|
|
69
|
+
export * from "../Shaders/iblCdfx.fragment.js";
|
|
70
|
+
export * from "../ShadersWGSL/iblCdfy.fragment.js";
|
|
71
|
+
export * from "../Shaders/iblCdfy.fragment.js";
|
|
72
|
+
export * from "../ShadersWGSL/iblIcdfx.fragment.js";
|
|
73
|
+
export * from "../Shaders/iblIcdfx.fragment.js";
|
|
74
|
+
export * from "../ShadersWGSL/iblIcdfy.fragment.js";
|
|
75
|
+
export * from "../Shaders/iblIcdfy.fragment.js";
|
|
76
|
+
export * from "../ShadersWGSL/importanceSamplingDebug.fragment.js";
|
|
77
|
+
export * from "../Shaders/importanceSamplingDebug.fragment.js";
|
|
76
78
|
export * from "../Shaders/iblVoxelGrid2dArrayDebug.fragment.js";
|
|
77
79
|
export * from "../ShadersWGSL/iblVoxelGrid2dArrayDebug.fragment.js";
|
|
78
80
|
export * from "../Shaders/iblVoxelGrid.fragment.js";
|
package/Rendering/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Rendering/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,+BAA+B,CA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D,CAAC;AACjE,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;AACnD,cAAc,yCAAyC,CAAC;AACxD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,qCAAqC,CAAC;AACpD,cAAc,uCAAuC,CAAC;AACtD,cAAc,yCAAyC,CAAC;AACxD,cAAc,2CAA2C,CAAC;AAE1D,yBAAyB;AACzB,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sCAAsC,CAAC;AACrD,cAAc,kCAAkC,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./boundingBoxRenderer\";\r\nexport * from \"./depthRenderer\";\r\nexport * from \"./depthRendererSceneComponent\";\r\nexport * from \"./depthPeelingRenderer\";\r\nexport * from \"./depthPeelingSceneComponent\";\r\nexport * from \"./edgesRenderer\";\r\nexport * from \"./geometryBufferRenderer\";\r\nexport * from \"./geometryBufferRendererSceneComponent\";\r\nexport * from \"./iblCdfGenerator\";\r\nexport * from \"./iblCdfGeneratorSceneComponent\";\r\nexport * from \"./IBLShadows/iblShadowsRenderPipeline\";\r\nexport * from \"./prePassRenderer\";\r\nexport * from \"./prePassRendererSceneComponent\";\r\nexport * from \"./subSurfaceSceneComponent\";\r\nexport * from \"./outlineRenderer\";\r\nexport * from \"./renderingGroup\";\r\nexport * from \"./renderingManager\";\r\nexport * from \"./utilityLayerRenderer\";\r\nexport * from \"./fluidRenderer/index\";\r\nexport * from \"./reflectiveShadowMap\";\r\nexport * from \"./objectRenderer\";\r\nexport * from \"./GlobalIllumination/index\";\r\n\r\n// Depth\r\nexport * from \"../Shaders/depth.fragment\";\r\nexport * from \"../Shaders/depth.vertex\";\r\nexport * from \"../ShadersWGSL/depth.fragment\";\r\nexport * from \"../ShadersWGSL/depth.vertex\";\r\n\r\n// Geometry\r\nexport * from \"../Shaders/geometry.fragment\";\r\nexport * from \"../Shaders/geometry.vertex\";\r\nexport * from \"../ShadersWGSL/geometry.fragment\";\r\nexport * from \"../ShadersWGSL/geometry.vertex\";\r\n\r\n// Bounding Box Renderer\r\nexport * from \"../Shaders/boundingBoxRenderer.fragment\";\r\nexport * from \"../Shaders/boundingBoxRenderer.vertex\";\r\nexport * from \"../ShadersWGSL/boundingBoxRenderer.fragment\";\r\nexport * from \"../ShadersWGSL/boundingBoxRenderer.vertex\";\r\n\r\n// Edges Renderer\r\nexport * from \"../Shaders/line.fragment\";\r\nexport * from \"../Shaders/line.vertex\";\r\nexport * from \"../ShadersWGSL/line.fragment\";\r\nexport * from \"../ShadersWGSL/line.vertex\";\r\n\r\n// Outline Renderer\r\nexport * from \"../Shaders/outline.fragment\";\r\nexport * from \"../Shaders/outline.vertex\";\r\nexport * from \"../ShadersWGSL/outline.fragment\";\r\nexport * from \"../ShadersWGSL/outline.vertex\";\r\n\r\n// IBL Shadows\r\nexport * from \"../Shaders/copyTexture3DLayerToTexture.fragment\";\r\nexport * from \"../ShadersWGSL/copyTexture3DLayerToTexture.fragment\";\r\nexport * from \"../Shaders/iblShadowVoxelTracing.fragment\";\r\nexport * from \"../ShadersWGSL/iblShadowVoxelTracing.fragment\";\r\nexport * from \"../Shaders/iblShadowDebug.fragment\";\r\nexport * from \"../ShadersWGSL/iblShadowDebug.fragment\";\r\nexport * from \"../ShadersWGSL/iblShadowSpatialBlur.fragment\";\r\nexport * from \"../Shaders/iblShadowSpatialBlur.fragment\";\r\nexport * from \"../ShadersWGSL/iblShadowAccumulation.fragment\";\r\nexport * from \"../Shaders/iblShadowAccumulation.fragment\";\r\nexport * from \"../Shaders/iblShadowsCombine.fragment\";\r\nexport * from \"../ShadersWGSL/iblShadowsCombine.fragment\";\r\nexport * from \"../ShadersWGSL/iblCombineVoxelGrids.fragment\";\r\nexport * from \"../Shaders/iblCombineVoxelGrids.fragment\";\r\nexport * from \"../Shaders/iblGenerateVoxelMip.fragment\";\r\nexport * from \"../ShadersWGSL/iblGenerateVoxelMip.fragment\";\r\nexport * from \"../Shaders/iblShadowGBufferDebug.fragment\";\r\nexport * from \"../ShadersWGSL/iblShadowGBufferDebug.fragment\";\r\nexport * from \"../ShadersWGSL/iblCdfx.fragment\";\r\nexport * from \"../Shaders/iblCdfx.fragment\";\r\nexport * from \"../ShadersWGSL/iblCdfy.fragment\";\r\nexport * from \"../Shaders/iblCdfy.fragment\";\r\nexport * from \"../ShadersWGSL/iblIcdfx.fragment\";\r\nexport * from \"../Shaders/iblIcdfx.fragment\";\r\nexport * from \"../ShadersWGSL/iblIcdfy.fragment\";\r\nexport * from \"../Shaders/iblIcdfy.fragment\";\r\nexport * from \"../ShadersWGSL/importanceSamplingDebug.fragment\";\r\nexport * from \"../Shaders/importanceSamplingDebug.fragment\";\r\nexport * from \"../Shaders/iblVoxelGrid2dArrayDebug.fragment\";\r\nexport * from \"../ShadersWGSL/iblVoxelGrid2dArrayDebug.fragment\";\r\nexport * from \"../Shaders/iblVoxelGrid.fragment\";\r\nexport * from \"../Shaders/iblVoxelGrid.vertex\";\r\nexport * from \"../ShadersWGSL/iblVoxelGrid.fragment\";\r\nexport * from \"../ShadersWGSL/iblVoxelGrid.vertex\";\r\nexport * from \"../Shaders/iblVoxelGrid3dDebug.fragment\";\r\nexport * from \"../ShadersWGSL/iblVoxelGrid3dDebug.fragment\";\r\nexport * from \"../Shaders/iblVoxelSlabDebug.vertex\";\r\nexport * from \"../Shaders/iblVoxelSlabDebug.fragment\";\r\nexport * from \"../ShadersWGSL/iblVoxelSlabDebug.vertex\";\r\nexport * from \"../ShadersWGSL/iblVoxelSlabDebug.fragment\";\r\n\r\n// Depth Peeling Renderer\r\nexport * from \"../Shaders/oitBackBlend.fragment\";\r\nexport * from \"../Shaders/oitFinal.fragment\";\r\nexport * from \"../ShadersWGSL/oitBackBlend.fragment\";\r\nexport * from \"../ShadersWGSL/oitFinal.fragment\";\r\n"]}
|
|
@@ -7,8 +7,78 @@ matrix[0][1],matrix[1][1],matrix[2][1],
|
|
|
7
7
|
matrix[0][2],matrix[1][2],matrix[2][2]);}
|
|
8
8
|
#endif
|
|
9
9
|
vec2 getDataUV(float index,vec2 textureSize) {float y=floor(index/textureSize.x);float x=index-y*textureSize.x;return vec2((x+0.5)/textureSize.x,(y+0.5)/textureSize.y);}
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
#if SH_DEGREE>0
|
|
11
|
+
ivec2 getDataUVint(float index,vec2 textureSize) {float y=floor(index/textureSize.x);float x=index-y*textureSize.x;return ivec2(uint(x+0.5),uint(y+0.5));}
|
|
12
|
+
#endif
|
|
13
|
+
struct Splat {vec4 center;vec4 color;vec4 covA;vec4 covB;
|
|
14
|
+
#if SH_DEGREE>0
|
|
15
|
+
uvec4 sh0;
|
|
16
|
+
#endif
|
|
17
|
+
#if SH_DEGREE>1
|
|
18
|
+
uvec4 sh1;
|
|
19
|
+
#endif
|
|
20
|
+
#if SH_DEGREE>2
|
|
21
|
+
uvec4 sh2;
|
|
22
|
+
#endif
|
|
23
|
+
};Splat readSplat(float splatIndex)
|
|
24
|
+
{Splat splat;vec2 splatUV=getDataUV(splatIndex,dataTextureSize);splat.center=texture2D(centersTexture,splatUV);splat.color=texture2D(colorsTexture,splatUV);splat.covA=texture2D(covariancesATexture,splatUV)*splat.center.w;splat.covB=texture2D(covariancesBTexture,splatUV)*splat.center.w;
|
|
25
|
+
#if SH_DEGREE>0
|
|
26
|
+
ivec2 splatUVint=getDataUVint(splatIndex,dataTextureSize);splat.sh0=texelFetch(shTexture0,splatUVint,0);
|
|
27
|
+
#endif
|
|
28
|
+
#if SH_DEGREE>1
|
|
29
|
+
splat.sh1=texelFetch(shTexture1,splatUVint,0);
|
|
30
|
+
#endif
|
|
31
|
+
#if SH_DEGREE>2
|
|
32
|
+
splat.sh2=texelFetch(shTexture2,splatUVint,0);
|
|
33
|
+
#endif
|
|
34
|
+
return splat;}
|
|
35
|
+
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
|
36
|
+
vec3 computeColorFromSHDegree(vec3 dir,const vec3 sh[16])
|
|
37
|
+
{const float SH_C0=0.28209479;const float SH_C1=0.48860251;float SH_C2[5];SH_C2[0]=1.092548430;SH_C2[1]=-1.09254843;SH_C2[2]=0.315391565;SH_C2[3]=-1.09254843;SH_C2[4]=0.546274215;float SH_C3[7];SH_C3[0]=-0.59004358;SH_C3[1]=2.890611442;SH_C3[2]=-0.45704579;SH_C3[3]=0.373176332;SH_C3[4]=-0.45704579;SH_C3[5]=1.445305721;SH_C3[6]=-0.59004358;vec3 result=/*SH_C0**/sh[0];
|
|
38
|
+
#if SH_DEGREE>0
|
|
39
|
+
float x=dir.x;float y=dir.y;float z=dir.z;result+=- SH_C1*y*sh[1]+SH_C1*z*sh[2]-SH_C1*x*sh[3];
|
|
40
|
+
#if SH_DEGREE>1
|
|
41
|
+
float xx=x*x,yy=y*y,zz=z*z;float xy=x*y,yz=y*z,xz=x*z;result+=
|
|
42
|
+
SH_C2[0]*xy*sh[4] +
|
|
43
|
+
SH_C2[1]*yz*sh[5] +
|
|
44
|
+
SH_C2[2]*(2.0f*zz-xx-yy)*sh[6] +
|
|
45
|
+
SH_C2[3]*xz*sh[7] +
|
|
46
|
+
SH_C2[4]*(xx-yy)*sh[8];
|
|
47
|
+
#if SH_DEGREE>2
|
|
48
|
+
result+=
|
|
49
|
+
SH_C3[0]*y*(3.0f*xx-yy)*sh[9] +
|
|
50
|
+
SH_C3[1]*xy*z*sh[10] +
|
|
51
|
+
SH_C3[2]*y*(4.0f*zz-xx-yy)*sh[11] +
|
|
52
|
+
SH_C3[3]*z*(2.0f*zz-3.0f*xx-3.0f*yy)*sh[12] +
|
|
53
|
+
SH_C3[4]*x*(4.0f*zz-xx-yy)*sh[13] +
|
|
54
|
+
SH_C3[5]*z*(xx-yy)*sh[14] +
|
|
55
|
+
SH_C3[6]*x*(xx-3.0f*yy)*sh[15];
|
|
56
|
+
#endif
|
|
57
|
+
#endif
|
|
58
|
+
#endif
|
|
59
|
+
return result;}
|
|
60
|
+
vec4 decompose(uint value)
|
|
61
|
+
{vec4 components=vec4(
|
|
62
|
+
float((value ) & 255u),
|
|
63
|
+
float((value>>uint( 8)) & 255u),
|
|
64
|
+
float((value>>uint(16)) & 255u),
|
|
65
|
+
float((value>>uint(24)) & 255u));return components*vec4(2./255.)-vec4(1.);}
|
|
66
|
+
vec3 computeSH(Splat splat,vec3 color,vec3 dir)
|
|
67
|
+
{vec3 sh[16];sh[0]=color;
|
|
68
|
+
#if SH_DEGREE>0
|
|
69
|
+
vec4 sh00=decompose(splat.sh0.x);vec4 sh01=decompose(splat.sh0.y);vec4 sh02=decompose(splat.sh0.z);sh[1]=vec3(sh00.x,sh00.y,sh00.z);sh[2]=vec3(sh00.w,sh01.x,sh01.y);sh[3]=vec3(sh01.z,sh01.w,sh02.x);
|
|
70
|
+
#endif
|
|
71
|
+
#if SH_DEGREE>1
|
|
72
|
+
vec4 sh03=decompose(splat.sh0.w);vec4 sh04=decompose(splat.sh1.x);vec4 sh05=decompose(splat.sh1.y);sh[4]=vec3(sh02.y,sh02.z,sh02.w);sh[5]=vec3(sh03.x,sh03.y,sh03.z);sh[6]=vec3(sh03.w,sh04.x,sh04.y);sh[7]=vec3(sh04.z,sh04.w,sh05.x);sh[8]=vec3(sh05.y,sh05.z,sh05.w);
|
|
73
|
+
#endif
|
|
74
|
+
#if SH_DEGREE>2
|
|
75
|
+
vec4 sh06=decompose(splat.sh1.z);vec4 sh07=decompose(splat.sh1.w);vec4 sh08=decompose(splat.sh2.x);vec4 sh09=decompose(splat.sh2.y);vec4 sh10=decompose(splat.sh2.z);vec4 sh11=decompose(splat.sh2.w);sh[9]=vec3(sh06.x,sh06.y,sh06.z);sh[10]=vec3(sh06.w,sh07.x,sh07.y);sh[11]=vec3(sh07.z,sh07.w,sh08.x);sh[12]=vec3(sh08.y,sh08.z,sh08.w);sh[13]=vec3(sh09.x,sh09.y,sh09.z);sh[14]=vec3(sh09.w,sh10.x,sh10.y);sh[15]=vec3(sh10.z,sh10.w,sh11.x);
|
|
76
|
+
#endif
|
|
77
|
+
return computeColorFromSHDegree(dir,sh);}
|
|
78
|
+
#else
|
|
79
|
+
vec3 computeSH(Splat splat,vec3 color,vec3 dir)
|
|
80
|
+
{return color;}
|
|
81
|
+
#endif
|
|
12
82
|
vec4 gaussianSplatting(vec2 meshPos,vec3 worldPos,vec2 scale,vec3 covA,vec3 covB,mat4 worldMatrix,mat4 viewMatrix,mat4 projectionMatrix)
|
|
13
83
|
{mat4 modelView=viewMatrix*worldMatrix;vec4 camspace=viewMatrix*vec4(worldPos,1.);vec4 pos2d=projectionMatrix*camspace;float bounds=1.2*pos2d.w;if (pos2d.z<-pos2d.w || pos2d.x<-bounds || pos2d.x>bounds
|
|
14
84
|
|| pos2d.y<-bounds || pos2d.y>bounds) {return vec4(0.0,0.0,2.0,1.0);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gaussianSplatting.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/gaussianSplatting.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,mBAAmB,CAAC;AACjC,MAAM,MAAM,GAAG
|
|
1
|
+
{"version":3,"file":"gaussianSplatting.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/gaussianSplatting.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,mBAAmB,CAAC;AACjC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8DA8F+C,CAAC;AAC/D,aAAa;AACb,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,gBAAgB;AAChB,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"gaussianSplatting\";\nconst shader = `#if !defined(WEBGL2) && !defined(WEBGPU) && !defined(NATIVE)\nmat3 transpose(mat3 matrix) {return mat3(matrix[0][0],matrix[1][0],matrix[2][0],\nmatrix[0][1],matrix[1][1],matrix[2][1],\nmatrix[0][2],matrix[1][2],matrix[2][2]);}\n#endif\nvec2 getDataUV(float index,vec2 textureSize) {float y=floor(index/textureSize.x);float x=index-y*textureSize.x;return vec2((x+0.5)/textureSize.x,(y+0.5)/textureSize.y);}\n#if SH_DEGREE>0\nivec2 getDataUVint(float index,vec2 textureSize) {float y=floor(index/textureSize.x);float x=index-y*textureSize.x;return ivec2(uint(x+0.5),uint(y+0.5));}\n#endif\nstruct Splat {vec4 center;vec4 color;vec4 covA;vec4 covB;\n#if SH_DEGREE>0\nuvec4 sh0; \n#endif\n#if SH_DEGREE>1\nuvec4 sh1;\n#endif\n#if SH_DEGREE>2\nuvec4 sh2;\n#endif\n};Splat readSplat(float splatIndex)\n{Splat splat;vec2 splatUV=getDataUV(splatIndex,dataTextureSize);splat.center=texture2D(centersTexture,splatUV);splat.color=texture2D(colorsTexture,splatUV);splat.covA=texture2D(covariancesATexture,splatUV)*splat.center.w;splat.covB=texture2D(covariancesBTexture,splatUV)*splat.center.w;\n#if SH_DEGREE>0\nivec2 splatUVint=getDataUVint(splatIndex,dataTextureSize);splat.sh0=texelFetch(shTexture0,splatUVint,0);\n#endif\n#if SH_DEGREE>1\nsplat.sh1=texelFetch(shTexture1,splatUVint,0);\n#endif\n#if SH_DEGREE>2\nsplat.sh2=texelFetch(shTexture2,splatUVint,0);\n#endif\nreturn splat;}\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nvec3 computeColorFromSHDegree(vec3 dir,const vec3 sh[16])\n{const float SH_C0=0.28209479;const float SH_C1=0.48860251;float SH_C2[5];SH_C2[0]=1.092548430;SH_C2[1]=-1.09254843;SH_C2[2]=0.315391565;SH_C2[3]=-1.09254843;SH_C2[4]=0.546274215;float SH_C3[7];SH_C3[0]=-0.59004358;SH_C3[1]=2.890611442;SH_C3[2]=-0.45704579;SH_C3[3]=0.373176332;SH_C3[4]=-0.45704579;SH_C3[5]=1.445305721;SH_C3[6]=-0.59004358;vec3 result=/*SH_C0**/sh[0];\n#if SH_DEGREE>0\nfloat x=dir.x;float y=dir.y;float z=dir.z;result+=- SH_C1*y*sh[1]+SH_C1*z*sh[2]-SH_C1*x*sh[3];\n#if SH_DEGREE>1\nfloat xx=x*x,yy=y*y,zz=z*z;float xy=x*y,yz=y*z,xz=x*z;result+=\nSH_C2[0]*xy*sh[4] +\nSH_C2[1]*yz*sh[5] +\nSH_C2[2]*(2.0f*zz-xx-yy)*sh[6] +\nSH_C2[3]*xz*sh[7] +\nSH_C2[4]*(xx-yy)*sh[8];\n#if SH_DEGREE>2\nresult+=\nSH_C3[0]*y*(3.0f*xx-yy)*sh[9] +\nSH_C3[1]*xy*z*sh[10] +\nSH_C3[2]*y*(4.0f*zz-xx-yy)*sh[11] +\nSH_C3[3]*z*(2.0f*zz-3.0f*xx-3.0f*yy)*sh[12] +\nSH_C3[4]*x*(4.0f*zz-xx-yy)*sh[13] +\nSH_C3[5]*z*(xx-yy)*sh[14] +\nSH_C3[6]*x*(xx-3.0f*yy)*sh[15];\n#endif\n#endif\n#endif\nreturn result;}\nvec4 decompose(uint value)\n{vec4 components=vec4(\nfloat((value ) & 255u),\nfloat((value>>uint( 8)) & 255u),\nfloat((value>>uint(16)) & 255u),\nfloat((value>>uint(24)) & 255u));return components*vec4(2./255.)-vec4(1.);}\nvec3 computeSH(Splat splat,vec3 color,vec3 dir)\n{vec3 sh[16];sh[0]=color;\n#if SH_DEGREE>0\nvec4 sh00=decompose(splat.sh0.x);vec4 sh01=decompose(splat.sh0.y);vec4 sh02=decompose(splat.sh0.z);sh[1]=vec3(sh00.x,sh00.y,sh00.z);sh[2]=vec3(sh00.w,sh01.x,sh01.y);sh[3]=vec3(sh01.z,sh01.w,sh02.x);\n#endif\n#if SH_DEGREE>1\nvec4 sh03=decompose(splat.sh0.w);vec4 sh04=decompose(splat.sh1.x);vec4 sh05=decompose(splat.sh1.y);sh[4]=vec3(sh02.y,sh02.z,sh02.w);sh[5]=vec3(sh03.x,sh03.y,sh03.z);sh[6]=vec3(sh03.w,sh04.x,sh04.y);sh[7]=vec3(sh04.z,sh04.w,sh05.x);sh[8]=vec3(sh05.y,sh05.z,sh05.w);\n#endif\n#if SH_DEGREE>2\nvec4 sh06=decompose(splat.sh1.z);vec4 sh07=decompose(splat.sh1.w);vec4 sh08=decompose(splat.sh2.x);vec4 sh09=decompose(splat.sh2.y);vec4 sh10=decompose(splat.sh2.z);vec4 sh11=decompose(splat.sh2.w);sh[9]=vec3(sh06.x,sh06.y,sh06.z);sh[10]=vec3(sh06.w,sh07.x,sh07.y);sh[11]=vec3(sh07.z,sh07.w,sh08.x);sh[12]=vec3(sh08.y,sh08.z,sh08.w);sh[13]=vec3(sh09.x,sh09.y,sh09.z);sh[14]=vec3(sh09.w,sh10.x,sh10.y);sh[15]=vec3(sh10.z,sh10.w,sh11.x); \n#endif\nreturn computeColorFromSHDegree(dir,sh);}\n#else\nvec3 computeSH(Splat splat,vec3 color,vec3 dir)\n{return color;}\n#endif\nvec4 gaussianSplatting(vec2 meshPos,vec3 worldPos,vec2 scale,vec3 covA,vec3 covB,mat4 worldMatrix,mat4 viewMatrix,mat4 projectionMatrix)\n{mat4 modelView=viewMatrix*worldMatrix;vec4 camspace=viewMatrix*vec4(worldPos,1.);vec4 pos2d=projectionMatrix*camspace;float bounds=1.2*pos2d.w;if (pos2d.z<-pos2d.w || pos2d.x<-bounds || pos2d.x>bounds\n|| pos2d.y<-bounds || pos2d.y>bounds) {return vec4(0.0,0.0,2.0,1.0);}\nmat3 Vrk=mat3(\ncovA.x,covA.y,covA.z,\ncovA.y,covB.x,covB.y,\ncovA.z,covB.y,covB.z\n);mat3 J=mat3(\nfocal.x/camspace.z,0.,-(focal.x*camspace.x)/(camspace.z*camspace.z),\n0.,focal.y/camspace.z,-(focal.y*camspace.y)/(camspace.z*camspace.z),\n0.,0.,0.\n);mat3 invy=mat3(1,0,0,0,-1,0,0,0,1);mat3 T=invy*transpose(mat3(modelView))*J;mat3 cov2d=transpose(T)*Vrk*T;float mid=(cov2d[0][0]+cov2d[1][1])/2.0;float radius=length(vec2((cov2d[0][0]-cov2d[1][1])/2.0,cov2d[0][1]));float lambda1=mid+radius,lambda2=mid-radius;if (lambda2<0.0)\n{return vec4(0.0,0.0,2.0,1.0);}\nvec2 diagonalVector=normalize(vec2(cov2d[0][1],lambda1-cov2d[0][0]));vec2 majorAxis=min(sqrt(2.0*lambda1),1024.0)*diagonalVector;vec2 minorAxis=min(sqrt(2.0*lambda2),1024.0)*vec2(diagonalVector.y,-diagonalVector.x);vec2 vCenter=vec2(pos2d);return vec4(\nvCenter \n+ ((meshPos.x*majorAxis\n+ meshPos.y*minorAxis)*invViewport*pos2d.w)*scale,pos2d.zw);}`;\n// Sideeffect\nShaderStore.IncludesShadersStore[name] = shader;\n/** @internal */\nexport const gaussianSplatting = { name, shader };\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Do not edit.
|
|
2
2
|
import { ShaderStore } from "../../Engines/shaderStore.js";
|
|
3
3
|
const name = "gaussianSplattingVertexDeclaration";
|
|
4
|
-
const shader = `attribute vec2 position;uniform mat4 view;uniform mat4 projection;uniform mat4 world;`;
|
|
4
|
+
const shader = `attribute vec2 position;uniform mat4 view;uniform mat4 projection;uniform mat4 world;uniform vec4 vEyePosition;`;
|
|
5
5
|
// Sideeffect
|
|
6
6
|
ShaderStore.IncludesShadersStore[name] = shader;
|
|
7
7
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gaussianSplattingVertexDeclaration.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,oCAAoC,CAAC;AAClD,MAAM,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"gaussianSplattingVertexDeclaration.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,oCAAoC,CAAC;AAClD,MAAM,MAAM,GAAG,iHAAiH,CAAC;AACjI,aAAa;AACb,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,gBAAgB;AAChB,MAAM,CAAC,MAAM,kCAAkC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"gaussianSplattingVertexDeclaration\";\nconst shader = `attribute vec2 position;uniform mat4 view;uniform mat4 projection;uniform mat4 world;uniform vec4 vEyePosition;`;\n// Sideeffect\nShaderStore.IncludesShadersStore[name] = shader;\n/** @internal */\nexport const gaussianSplattingVertexDeclaration = { name, shader };\n"]}
|
|
@@ -18,20 +18,45 @@ vec2 hammersley(int i,int N)
|
|
|
18
18
|
{return vec2(float(i)/float(N),vanDerCorpus(i,2));}
|
|
19
19
|
#endif
|
|
20
20
|
float log4(float x) {return log2(x)/2.;}
|
|
21
|
+
vec3 uv_to_normal(vec2 uv) {vec3 N;vec2 uvRange=uv;float theta=uvRange.x*2.0*PI;float phi=uvRange.y*PI;N.x=cos(theta)*sin(phi);N.z=sin(theta)*sin(phi);N.y=cos(phi);return N;}
|
|
21
22
|
const float NUM_SAMPLES_FLOAT=float(NUM_SAMPLES);const float NUM_SAMPLES_FLOAT_INVERSED=1./NUM_SAMPLES_FLOAT;const float K=4.;
|
|
22
23
|
#define inline
|
|
23
|
-
vec3 irradiance(samplerCube inputTexture,vec3 inputN,vec2 filteringInfo
|
|
24
|
-
|
|
24
|
+
vec3 irradiance(samplerCube inputTexture,vec3 inputN,vec2 filteringInfo
|
|
25
|
+
#ifdef IBL_CDF_FILTERING
|
|
26
|
+
,sampler2D icdfxSampler,sampler2D icdfySampler
|
|
27
|
+
#endif
|
|
28
|
+
)
|
|
29
|
+
{vec3 n=normalize(inputN);vec3 result=vec3(0.0);
|
|
30
|
+
#ifndef IBL_CDF_FILTERING
|
|
31
|
+
vec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);tangent=normalize(cross(tangent,n));vec3 bitangent=cross(n,tangent);mat3 tbn=mat3(tangent,bitangent,n);
|
|
32
|
+
#endif
|
|
33
|
+
float maxLevel=filteringInfo.y;float dim0=filteringInfo.x;float omegaP=(4.*PI)/(6.*dim0*dim0);
|
|
25
34
|
#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
|
26
35
|
for(uint i=0u; i<NUM_SAMPLES; ++i)
|
|
27
36
|
#else
|
|
28
37
|
for(int i=0; i<NUM_SAMPLES; ++i)
|
|
29
38
|
#endif
|
|
30
|
-
{vec2 Xi=hammersley(i,NUM_SAMPLES);
|
|
39
|
+
{vec2 Xi=hammersley(i,NUM_SAMPLES);
|
|
40
|
+
#ifdef IBL_CDF_FILTERING
|
|
41
|
+
vec2 T;T.x=textureCubeLodEXT(icdfxSampler,vec2(Xi.x,0.0),0.0).x;T.y=textureCubeLodEXT(icdfySampler,vec2(T.x,Xi.y),0.0).x;T.x=1.0-fract(T.x+0.25);vec3 Ls=uv_to_normal(T);float NoL=dot(n,Ls);
|
|
42
|
+
#else
|
|
43
|
+
vec3 Ls=hemisphereCosSample(Xi);Ls=normalize(Ls);vec3 Ns=vec3(0.,0.,1.);float NoL=dot(Ns,Ls);
|
|
44
|
+
#endif
|
|
45
|
+
if (NoL>0.) {float pdf_inversed=PI/NoL;float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;float l=log4(omegaS)-log4(omegaP)+log4(K);float mipLevel=clamp(l,0.0,maxLevel);
|
|
46
|
+
#ifdef IBL_CDF_FILTERING
|
|
47
|
+
vec3 c=textureCubeLodEXT(inputTexture,Ls,mipLevel).rgb;
|
|
48
|
+
#else
|
|
49
|
+
vec3 c=textureCubeLodEXT(inputTexture,tbn*Ls,mipLevel).rgb;
|
|
50
|
+
#endif
|
|
31
51
|
#ifdef GAMMA_INPUT
|
|
32
52
|
c=toLinearSpace(c);
|
|
33
53
|
#endif
|
|
34
|
-
|
|
54
|
+
#ifdef IBL_CDF_FILTERING
|
|
55
|
+
result+=c*NoL;
|
|
56
|
+
#else
|
|
57
|
+
result+=c;
|
|
58
|
+
#endif
|
|
59
|
+
}}
|
|
35
60
|
result=result*NUM_SAMPLES_FLOAT_INVERSED;return result;}
|
|
36
61
|
#define inline
|
|
37
62
|
vec3 radiance(float alphaG,samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hdrFilteringFunctions.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/hdrFilteringFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,uBAAuB,CAAC;AACrC,MAAM,MAAM,GAAG
|
|
1
|
+
{"version":3,"file":"hdrFilteringFunctions.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/hdrFilteringFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,uBAAuB,CAAC;AACrC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Ed,CAAC;AACF,aAAa;AACb,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,gBAAgB;AAChB,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"hdrFilteringFunctions\";\nconst shader = `#ifdef NUM_SAMPLES\n#if NUM_SAMPLES>0\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nfloat radicalInverse_VdC(uint bits) \n{bits=(bits<<16u) | (bits>>16u);bits=((bits & 0x55555555u)<<1u) | ((bits & 0xAAAAAAAAu)>>1u);bits=((bits & 0x33333333u)<<2u) | ((bits & 0xCCCCCCCCu)>>2u);bits=((bits & 0x0F0F0F0Fu)<<4u) | ((bits & 0xF0F0F0F0u)>>4u);bits=((bits & 0x00FF00FFu)<<8u) | ((bits & 0xFF00FF00u)>>8u);return float(bits)*2.3283064365386963e-10; }\nvec2 hammersley(uint i,uint N)\n{return vec2(float(i)/float(N),radicalInverse_VdC(i));}\n#else\nfloat vanDerCorpus(int n,int base)\n{float invBase=1.0/float(base);float denom =1.0;float result =0.0;for(int i=0; i<32; ++i)\n{if(n>0)\n{denom =mod(float(n),2.0);result+=denom*invBase;invBase=invBase/2.0;n =int(float(n)/2.0);}}\nreturn result;}\nvec2 hammersley(int i,int N)\n{return vec2(float(i)/float(N),vanDerCorpus(i,2));}\n#endif\nfloat log4(float x) {return log2(x)/2.;}\nvec3 uv_to_normal(vec2 uv) {vec3 N;vec2 uvRange=uv;float theta=uvRange.x*2.0*PI;float phi=uvRange.y*PI;N.x=cos(theta)*sin(phi);N.z=sin(theta)*sin(phi);N.y=cos(phi);return N;}\nconst float NUM_SAMPLES_FLOAT=float(NUM_SAMPLES);const float NUM_SAMPLES_FLOAT_INVERSED=1./NUM_SAMPLES_FLOAT;const float K=4.;\n#define inline\nvec3 irradiance(samplerCube inputTexture,vec3 inputN,vec2 filteringInfo\n#ifdef IBL_CDF_FILTERING\n,sampler2D icdfxSampler,sampler2D icdfySampler\n#endif\n)\n{vec3 n=normalize(inputN);vec3 result=vec3(0.0);\n#ifndef IBL_CDF_FILTERING\nvec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);tangent=normalize(cross(tangent,n));vec3 bitangent=cross(n,tangent);mat3 tbn=mat3(tangent,bitangent,n);\n#endif\nfloat maxLevel=filteringInfo.y;float dim0=filteringInfo.x;float omegaP=(4.*PI)/(6.*dim0*dim0);\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nfor(uint i=0u; i<NUM_SAMPLES; ++i)\n#else\nfor(int i=0; i<NUM_SAMPLES; ++i)\n#endif\n{vec2 Xi=hammersley(i,NUM_SAMPLES);\n#ifdef IBL_CDF_FILTERING\nvec2 T;T.x=textureCubeLodEXT(icdfxSampler,vec2(Xi.x,0.0),0.0).x;T.y=textureCubeLodEXT(icdfySampler,vec2(T.x,Xi.y),0.0).x;T.x=1.0-fract(T.x+0.25);vec3 Ls=uv_to_normal(T);float NoL=dot(n,Ls);\n#else\nvec3 Ls=hemisphereCosSample(Xi);Ls=normalize(Ls);vec3 Ns=vec3(0.,0.,1.);float NoL=dot(Ns,Ls);\n#endif\nif (NoL>0.) {float pdf_inversed=PI/NoL;float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;float l=log4(omegaS)-log4(omegaP)+log4(K);float mipLevel=clamp(l,0.0,maxLevel);\n#ifdef IBL_CDF_FILTERING\nvec3 c=textureCubeLodEXT(inputTexture,Ls,mipLevel).rgb;\n#else\nvec3 c=textureCubeLodEXT(inputTexture,tbn*Ls,mipLevel).rgb;\n#endif\n#ifdef GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\n#ifdef IBL_CDF_FILTERING\nresult+=c*NoL;\n#else\nresult+=c;\n#endif\n}}\nresult=result*NUM_SAMPLES_FLOAT_INVERSED;return result;}\n#define inline\nvec3 radiance(float alphaG,samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)\n{vec3 n=normalize(inputN);vec3 c=textureCube(inputTexture,n).rgb; \nif (alphaG==0.) {\n#ifdef GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\nreturn c;} else {vec3 result=vec3(0.);vec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);tangent=normalize(cross(tangent,n));vec3 bitangent=cross(n,tangent);mat3 tbn=mat3(tangent,bitangent,n);float maxLevel=filteringInfo.y;float dim0=filteringInfo.x;float omegaP=(4.*PI)/(6.*dim0*dim0);float weight=0.;\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nfor(uint i=0u; i<NUM_SAMPLES; ++i)\n#else\nfor(int i=0; i<NUM_SAMPLES; ++i)\n#endif\n{vec2 Xi=hammersley(i,NUM_SAMPLES);vec3 H=hemisphereImportanceSampleDggx(Xi,alphaG);float NoV=1.;float NoH=H.z;float NoH2=H.z*H.z;float NoL=2.*NoH2-1.;vec3 L=vec3(2.*NoH*H.x,2.*NoH*H.y,NoL);L=normalize(L);if (NoL>0.) {float pdf_inversed=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;float l=log4(omegaS)-log4(omegaP)+log4(K);float mipLevel=clamp(float(l),0.0,maxLevel);weight+=NoL;vec3 c=textureCubeLodEXT(inputTexture,tbn*L,mipLevel).rgb;\n#ifdef GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\nresult+=c*NoL;}}\nresult=result/weight;return result;}}\n#endif\n#endif\n`;\n// Sideeffect\nShaderStore.IncludesShadersStore[name] = shader;\n/** @internal */\nexport const hdrFilteringFunctions = { name, shader };\n"]}
|
|
@@ -170,6 +170,10 @@ in vec3 vPositionW
|
|
|
170
170
|
#endif
|
|
171
171
|
#ifdef REALTIME_FILTERING
|
|
172
172
|
,in vec2 vReflectionFilteringInfo
|
|
173
|
+
#ifdef IBL_CDF_FILTERING
|
|
174
|
+
,in sampler2D icdfxSampler
|
|
175
|
+
,in sampler2D icdfySampler
|
|
176
|
+
#endif
|
|
173
177
|
#endif
|
|
174
178
|
)
|
|
175
179
|
{reflectionOutParams outParams;vec4 environmentRadiance=vec4(0.,0.,0.,0.);
|
|
@@ -228,7 +232,11 @@ irradianceVector.z*=-1.0;
|
|
|
228
232
|
irradianceVector.y*=-1.0;
|
|
229
233
|
#endif
|
|
230
234
|
#if defined(REALTIME_FILTERING)
|
|
231
|
-
environmentIrradiance=irradiance(reflectionSampler,irradianceVector,vReflectionFilteringInfo
|
|
235
|
+
environmentIrradiance=irradiance(reflectionSampler,irradianceVector,vReflectionFilteringInfo
|
|
236
|
+
#ifdef IBL_CDF_FILTERING
|
|
237
|
+
,icdfxSampler,icdfySampler
|
|
238
|
+
#endif
|
|
239
|
+
);
|
|
232
240
|
#else
|
|
233
241
|
environmentIrradiance=computeEnvironmentIrradiance(irradianceVector);
|
|
234
242
|
#endif
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pbrBlockReflection.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/pbrBlockReflection.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,oBAAoB,CAAC;AAClC,MAAM,MAAM,GAAG
|
|
1
|
+
{"version":3,"file":"pbrBlockReflection.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/pbrBlockReflection.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,oBAAoB,CAAC;AAClC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Pd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,gBAAgB;AAChB,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"pbrBlockReflection\";\nconst shader = `#ifdef REFLECTION\nstruct reflectionOutParams\n{vec4 environmentRadiance;vec3 environmentIrradiance;\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords;\n#else\nvec2 reflectionCoords;\n#endif\n#ifdef SS_TRANSLUCENCY\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\nvec3 irradianceVector;\n#endif\n#endif\n#endif\n};\n#define pbr_inline\nvoid createReflectionCoords(\nin vec3 vPositionW,\nin vec3 normalW,\n#ifdef ANISOTROPIC\nin anisotropicOutParams anisotropicOut,\n#endif\n#ifdef REFLECTIONMAP_3D\nout vec3 reflectionCoords\n#else\nout vec2 reflectionCoords\n#endif\n)\n{\n#ifdef ANISOTROPIC\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),anisotropicOut.anisotropicNormal);\n#else\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#endif\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n#ifdef REFLECTIONMAP_3D\nreflectionCoords=reflectionVector;\n#else\nreflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n}\n#define pbr_inline\n#define inline\nvoid sampleReflectionTexture(\nin float alphaG,\nin vec3 vReflectionMicrosurfaceInfos,\nin vec2 vReflectionInfos,\nin vec3 vReflectionColor,\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nin float NdotVUnclamped,\n#endif\n#ifdef LINEARSPECULARREFLECTION\nin float roughness,\n#endif\n#ifdef REFLECTIONMAP_3D\nin samplerCube reflectionSampler,\nconst vec3 reflectionCoords,\n#else\nin sampler2D reflectionSampler,\nconst vec2 reflectionCoords,\n#endif\n#ifndef LODBASEDMICROSFURACE\n#ifdef REFLECTIONMAP_3D\nin samplerCube reflectionSamplerLow,\nin samplerCube reflectionSamplerHigh,\n#else\nin sampler2D reflectionSamplerLow,\nin sampler2D reflectionSamplerHigh,\n#endif\n#endif\n#ifdef REALTIME_FILTERING\nin vec2 vReflectionFilteringInfo,\n#endif\nout vec4 environmentRadiance\n)\n{\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#elif defined(LINEARSPECULARREFLECTION)\nfloat reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef LODINREFLECTIONALPHA\nfloat automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);float requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);\n#else\nfloat requestedReflectionLOD=reflectionLOD;\n#endif\n#ifdef REALTIME_FILTERING\nenvironmentRadiance=vec4(radiance(alphaG,reflectionSampler,reflectionCoords,vReflectionFilteringInfo),1.0);\n#else\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);\n#endif\n#else\nfloat lodReflectionNormalized=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));float lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;vec4 environmentMid=sampleReflection(reflectionSampler,reflectionCoords);if (lodReflectionNormalizedDoubled<1.0){environmentRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentMid,\nlodReflectionNormalizedDoubled\n);} else {environmentRadiance=mix(\nenvironmentMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentRadiance.rgb=fromRGBD(environmentRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);\n#endif\nenvironmentRadiance.rgb*=vReflectionInfos.x;environmentRadiance.rgb*=vReflectionColor.rgb;}\n#define pbr_inline\n#define inline\nreflectionOutParams reflectionBlock(\nin vec3 vPositionW\n,in vec3 normalW\n,in float alphaG\n,in vec3 vReflectionMicrosurfaceInfos\n,in vec2 vReflectionInfos\n,in vec3 vReflectionColor\n#ifdef ANISOTROPIC\n,in anisotropicOutParams anisotropicOut\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\n,in float NdotVUnclamped\n#endif\n#ifdef LINEARSPECULARREFLECTION\n,in float roughness\n#endif\n#ifdef REFLECTIONMAP_3D\n,in samplerCube reflectionSampler\n#else\n,in sampler2D reflectionSampler\n#endif\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\n,in vec3 vEnvironmentIrradiance\n#endif\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\n,in mat4 reflectionMatrix\n#endif\n#endif\n#ifdef USEIRRADIANCEMAP\n#ifdef REFLECTIONMAP_3D\n,in samplerCube irradianceSampler\n#else\n,in sampler2D irradianceSampler\n#endif\n#endif\n#ifndef LODBASEDMICROSFURACE\n#ifdef REFLECTIONMAP_3D\n,in samplerCube reflectionSamplerLow\n,in samplerCube reflectionSamplerHigh\n#else\n,in sampler2D reflectionSamplerLow\n,in sampler2D reflectionSamplerHigh\n#endif\n#endif\n#ifdef REALTIME_FILTERING\n,in vec2 vReflectionFilteringInfo\n#ifdef IBL_CDF_FILTERING\n,in sampler2D icdfxSampler\n,in sampler2D icdfySampler\n#endif\n#endif\n)\n{reflectionOutParams outParams;vec4 environmentRadiance=vec4(0.,0.,0.,0.);\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=vec3(0.);\n#else\nvec2 reflectionCoords=vec2(0.);\n#endif\ncreateReflectionCoords(\nvPositionW,\nnormalW,\n#ifdef ANISOTROPIC\nanisotropicOut,\n#endif\nreflectionCoords\n);sampleReflectionTexture(\nalphaG,\nvReflectionMicrosurfaceInfos,\nvReflectionInfos,\nvReflectionColor,\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nNdotVUnclamped,\n#endif\n#ifdef LINEARSPECULARREFLECTION\nroughness,\n#endif\n#ifdef REFLECTIONMAP_3D\nreflectionSampler,\nreflectionCoords,\n#else\nreflectionSampler,\nreflectionCoords,\n#endif\n#ifndef LODBASEDMICROSFURACE\nreflectionSamplerLow,\nreflectionSamplerHigh,\n#endif\n#ifdef REALTIME_FILTERING\nvReflectionFilteringInfo,\n#endif\nenvironmentRadiance\n);vec3 environmentIrradiance=vec3(0.,0.,0.);\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nenvironmentIrradiance=vEnvironmentIrradiance;\n#else\n#ifdef ANISOTROPIC\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(anisotropicOut.anisotropicNormal,0)).xyz;\n#else\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#endif\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\n#ifdef INVERTCUBICMAP\nirradianceVector.y*=-1.0;\n#endif\n#if defined(REALTIME_FILTERING)\nenvironmentIrradiance=irradiance(reflectionSampler,irradianceVector,vReflectionFilteringInfo\n#ifdef IBL_CDF_FILTERING\n,icdfxSampler,icdfySampler\n#endif\n);\n#else\nenvironmentIrradiance=computeEnvironmentIrradiance(irradianceVector);\n#endif\n#ifdef SS_TRANSLUCENCY\noutParams.irradianceVector=irradianceVector;\n#endif\n#endif\n#elif defined(USEIRRADIANCEMAP)\nvec4 environmentIrradiance4=sampleReflection(irradianceSampler,reflectionCoords);environmentIrradiance=environmentIrradiance4.rgb;\n#ifdef RGBDREFLECTION\nenvironmentIrradiance.rgb=fromRGBD(environmentIrradiance4);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb);\n#endif\n#endif\nenvironmentIrradiance*=vReflectionColor.rgb;outParams.environmentRadiance=environmentRadiance;outParams.environmentIrradiance=environmentIrradiance;outParams.reflectionCoords=reflectionCoords;return outParams;}\n#endif\n`;\n// Sideeffect\nShaderStore.IncludesShadersStore[name] = shader;\n/** @internal */\nexport const pbrBlockReflection = { name, shader };\n"]}
|