@onerjs/core 9.0.2 → 9.0.4
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.pure.js +4 -0
- package/Buffers/buffer.pure.js.map +1 -1
- package/Cameras/camera.pure.d.ts +14 -0
- package/Cameras/camera.pure.js +15 -0
- package/Cameras/camera.pure.js.map +1 -1
- package/Compute/computeShader.pure.d.ts +2 -1
- package/Compute/computeShader.pure.js +29 -10
- package/Compute/computeShader.pure.js.map +1 -1
- package/Culling/ray.core.js +22 -9
- package/Culling/ray.core.js.map +1 -1
- package/Engines/IDrawContext.d.ts +2 -0
- package/Engines/IDrawContext.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +55 -4
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/Native/nativeRenderTargetWrapper.d.ts +1 -0
- package/Engines/Native/nativeRenderTargetWrapper.js +5 -1
- package/Engines/Native/nativeRenderTargetWrapper.js.map +1 -1
- package/Engines/Processors/shaderCodeInliner.d.ts +2 -0
- package/Engines/Processors/shaderCodeInliner.js +251 -6
- package/Engines/Processors/shaderCodeInliner.js.map +1 -1
- package/Engines/Processors/shaderProcessor.js +10 -1
- package/Engines/Processors/shaderProcessor.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.debugging.pure.js +12 -0
- package/Engines/WebGPU/Extensions/engine.debugging.pure.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.pure.js +0 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.pure.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.query.pure.js +5 -0
- package/Engines/WebGPU/Extensions/engine.query.pure.js.map +1 -1
- package/Engines/WebGPU/webgpuBufferManager.js +7 -0
- package/Engines/WebGPU/webgpuBufferManager.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheTextureView.d.ts +1 -1
- package/Engines/WebGPU/webgpuCacheTextureView.js +20 -8
- package/Engines/WebGPU/webgpuCacheTextureView.js.map +1 -1
- package/Engines/WebGPU/webgpuDrawContext.d.ts +2 -0
- package/Engines/WebGPU/webgpuDrawContext.js +6 -0
- package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
- package/Engines/WebGPU/webgpuQuerySet.d.ts +3 -3
- package/Engines/WebGPU/webgpuQuerySet.js +23 -9
- package/Engines/WebGPU/webgpuQuerySet.js.map +1 -1
- package/Engines/WebGPU/webgpuRenderPassCommandStream.d.ts +156 -0
- package/Engines/WebGPU/webgpuRenderPassCommandStream.js +323 -0
- package/Engines/WebGPU/webgpuRenderPassCommandStream.js.map +1 -0
- package/Engines/WebGPU/webgpuTextureManager.d.ts +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +4 -3
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/WebGPU/webgpuTimestampQuery.d.ts +3 -1
- package/Engines/WebGPU/webgpuTimestampQuery.js +9 -6
- package/Engines/WebGPU/webgpuTimestampQuery.js.map +1 -1
- package/Engines/abstractEngine.pure.d.ts +2 -0
- package/Engines/abstractEngine.pure.js +14 -5
- package/Engines/abstractEngine.pure.js.map +1 -1
- package/Engines/constants.d.ts +6 -0
- package/Engines/constants.js +6 -0
- package/Engines/constants.js.map +1 -1
- package/Engines/engine.d.ts +198 -24
- package/Engines/pure.d.ts +1 -0
- package/Engines/pure.js +1 -0
- package/Engines/pure.js.map +1 -1
- package/Engines/renderCommandBatcher.pure.d.ts +16 -0
- package/Engines/renderCommandBatcher.pure.js +24 -0
- package/Engines/renderCommandBatcher.pure.js.map +1 -0
- package/Engines/thinEngine.functions.js +3 -2
- package/Engines/thinEngine.functions.js.map +1 -1
- package/Engines/thinEngine.pure.js +18 -2
- package/Engines/thinEngine.pure.js.map +1 -1
- package/Engines/thinNativeEngine.pure.d.ts +10 -7
- package/Engines/thinNativeEngine.pure.js +117 -46
- package/Engines/thinNativeEngine.pure.js.map +1 -1
- package/Engines/thinWebGPUEngine.d.ts +8 -0
- package/Engines/thinWebGPUEngine.js +11 -0
- package/Engines/thinWebGPUEngine.js.map +1 -1
- package/Engines/webgpuEngine.pure.d.ts +60 -1
- package/Engines/webgpuEngine.pure.js +238 -42
- package/Engines/webgpuEngine.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Audio/flowGraphGetSoundVolumeBlock.pure.d.ts +3 -3
- package/FlowGraph/Blocks/Data/Audio/flowGraphGetSoundVolumeBlock.pure.js +2 -1
- package/FlowGraph/Blocks/Data/Audio/flowGraphGetSoundVolumeBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Audio/flowGraphIsSoundPlayingBlock.pure.d.ts +3 -3
- package/FlowGraph/Blocks/Data/Audio/flowGraphIsSoundPlayingBlock.pure.js +2 -1
- package/FlowGraph/Blocks/Data/Audio/flowGraphIsSoundPlayingBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.d.ts +5 -0
- package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.js +8 -0
- package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.js.map +1 -0
- package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.pure.d.ts +77 -0
- package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.pure.js +141 -0
- package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.pure.js.map +1 -0
- package/FlowGraph/Blocks/Event/flowGraphSoundEndedEventBlock.pure.d.ts +5 -3
- package/FlowGraph/Blocks/Event/flowGraphSoundEndedEventBlock.pure.js +38 -7
- package/FlowGraph/Blocks/Event/flowGraphSoundEndedEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/index.d.ts +1 -0
- package/FlowGraph/Blocks/Event/index.js +1 -0
- package/FlowGraph/Blocks/Event/index.js.map +1 -1
- package/FlowGraph/Blocks/Event/pure.d.ts +1 -0
- package/FlowGraph/Blocks/Event/pure.js +1 -0
- package/FlowGraph/Blocks/Event/pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPauseSoundBlock.pure.d.ts +3 -3
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPauseSoundBlock.pure.js +2 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPauseSoundBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlaySoundBlock.pure.d.ts +3 -3
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlaySoundBlock.pure.js +2 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlaySoundBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphSetSoundVolumeBlock.pure.d.ts +3 -3
- package/FlowGraph/Blocks/Execution/Audio/flowGraphSetSoundVolumeBlock.pure.js +2 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphSetSoundVolumeBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopSoundBlock.pure.d.ts +3 -3
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopSoundBlock.pure.js +2 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopSoundBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/allBlocks.pure.js +2 -0
- package/FlowGraph/Blocks/allBlocks.pure.js.map +1 -1
- package/FlowGraph/Blocks/flowGraphBlockFactory.js +2 -0
- package/FlowGraph/Blocks/flowGraphBlockFactory.js.map +1 -1
- package/FlowGraph/Blocks/flowGraphBlockNames.d.ts +1 -0
- package/FlowGraph/Blocks/flowGraphBlockNames.js +1 -0
- package/FlowGraph/Blocks/flowGraphBlockNames.js.map +1 -1
- package/FlowGraph/flowGraph.d.ts +12 -1
- package/FlowGraph/flowGraph.js +38 -0
- package/FlowGraph/flowGraph.js.map +1 -1
- package/FlowGraph/flowGraphCoordinator.d.ts +44 -0
- package/FlowGraph/flowGraphCoordinator.js +141 -0
- package/FlowGraph/flowGraphCoordinator.js.map +1 -1
- package/FlowGraph/flowGraphDataConnection.pure.js +41 -14
- package/FlowGraph/flowGraphDataConnection.pure.js.map +1 -1
- package/FlowGraph/flowGraphParser.js +105 -5
- package/FlowGraph/flowGraphParser.js.map +1 -1
- package/FlowGraph/flowGraphSoundAssets.d.ts +40 -0
- package/FlowGraph/flowGraphSoundAssets.js +33 -0
- package/FlowGraph/flowGraphSoundAssets.js.map +1 -0
- package/FlowGraph/index.d.ts +1 -0
- package/FlowGraph/index.js +1 -0
- package/FlowGraph/index.js.map +1 -1
- package/FlowGraph/pure.d.ts +1 -0
- package/FlowGraph/pure.js +1 -0
- package/FlowGraph/pure.js.map +1 -1
- package/FlowGraph/serialization.d.ts +8 -0
- package/FlowGraph/serialization.js +31 -12
- package/FlowGraph/serialization.js.map +1 -1
- package/FlowGraph/typeDefinitions.d.ts +25 -0
- package/FlowGraph/typeDefinitions.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/taaTask.js +2 -0
- package/FrameGraph/Tasks/PostProcesses/taaTask.js.map +1 -1
- package/Instrumentation/engineInstrumentation.d.ts +1 -0
- package/Instrumentation/engineInstrumentation.js +25 -6
- package/Instrumentation/engineInstrumentation.js.map +1 -1
- package/Lights/Clustered/clusteredLightContainer.pure.js +2 -0
- package/Lights/Clustered/clusteredLightContainer.pure.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.pure.d.ts +36 -1
- package/Lights/Shadows/cascadedShadowGenerator.pure.js +202 -27
- package/Lights/Shadows/cascadedShadowGenerator.pure.js.map +1 -1
- package/Lights/directionalLight.pure.d.ts +24 -10
- package/Lights/directionalLight.pure.js +29 -11
- package/Lights/directionalLight.pure.js.map +1 -1
- package/Loading/sceneLoader.d.ts +1 -1
- package/Loading/sceneLoader.js +1 -1
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js +4 -4
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js.map +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.pure.js +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.pure.js.map +1 -1
- package/Materials/Node/Blocks/Input/inputBlock.pure.js +4 -0
- package/Materials/Node/Blocks/Input/inputBlock.pure.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.d.ts +9 -0
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js +23 -3
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js.map +1 -1
- package/Materials/PBR/openpbrMaterial.pure.js +1 -1
- package/Materials/PBR/openpbrMaterial.pure.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.pure.d.ts +9 -0
- package/Materials/PBR/pbrBaseMaterial.pure.js +60 -1
- package/Materials/PBR/pbrBaseMaterial.pure.js.map +1 -1
- package/Materials/PBR/pbrBaseSimpleMaterial.d.ts +11 -0
- package/Materials/PBR/pbrBaseSimpleMaterial.js +21 -2
- package/Materials/PBR/pbrBaseSimpleMaterial.js.map +1 -1
- package/Materials/PBR/pbrMaterial.pure.d.ts +12 -0
- package/Materials/PBR/pbrMaterial.pure.js +23 -3
- package/Materials/PBR/pbrMaterial.pure.js.map +1 -1
- package/Materials/Textures/Filtering/hdrIrradianceFiltering.d.ts +1 -0
- package/Materials/Textures/Filtering/hdrIrradianceFiltering.js +10 -0
- package/Materials/Textures/Filtering/hdrIrradianceFiltering.js.map +1 -1
- package/Materials/Textures/HTML/htmlInCanvasPolyfill.d.ts +5 -0
- package/Materials/Textures/HTML/htmlInCanvasPolyfill.js +7 -0
- package/Materials/Textures/HTML/htmlInCanvasPolyfill.js.map +1 -1
- package/Materials/Textures/HTML/htmlInteractionManager.d.ts +9 -3
- package/Materials/Textures/HTML/htmlInteractionManager.js +64 -5
- package/Materials/Textures/HTML/htmlInteractionManager.js.map +1 -1
- package/Materials/Textures/HTML/htmlTexture.d.ts +11 -11
- package/Materials/Textures/HTML/htmlTexture.js +106 -65
- package/Materials/Textures/HTML/htmlTexture.js.map +1 -1
- package/Materials/Textures/Loaders/internalTextureLoader.d.ts +2 -1
- package/Materials/Textures/Loaders/internalTextureLoader.js.map +1 -1
- package/Materials/Textures/Loaders/ktxTextureLoader.d.ts +2 -1
- package/Materials/Textures/Loaders/ktxTextureLoader.js +4 -50
- package/Materials/Textures/Loaders/ktxTextureLoader.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.pure.js +10 -0
- package/Materials/Textures/Procedurals/proceduralTexture.pure.js.map +1 -1
- package/Materials/Textures/dynamicTexture.pure.js +6 -0
- package/Materials/Textures/dynamicTexture.pure.js.map +1 -1
- package/Materials/Textures/ktx2encoderTypes.d.ts +51 -0
- package/Materials/Textures/ktx2encoderTypes.js +2 -0
- package/Materials/Textures/ktx2encoderTypes.js.map +1 -0
- package/Materials/Textures/renderTargetTexture.pure.js +10 -2
- package/Materials/Textures/renderTargetTexture.pure.js.map +1 -1
- package/Materials/Textures/textureMerger.d.ts +11 -0
- package/Materials/Textures/textureMerger.js +34 -19
- package/Materials/Textures/textureMerger.js.map +1 -1
- package/Materials/Textures/textureProcessor.d.ts +145 -0
- package/Materials/Textures/textureProcessor.js +445 -45
- package/Materials/Textures/textureProcessor.js.map +1 -1
- package/Materials/Textures/textureSampling.functions.d.ts +41 -0
- package/Materials/Textures/textureSampling.functions.js +82 -0
- package/Materials/Textures/textureSampling.functions.js.map +1 -0
- package/Materials/drawWrapper.d.ts +8 -0
- package/Materials/drawWrapper.js +19 -0
- package/Materials/drawWrapper.js.map +1 -1
- package/Materials/effect.pure.d.ts +6 -0
- package/Materials/effect.pure.js +28 -6
- package/Materials/effect.pure.js.map +1 -1
- package/Materials/effect.webgl.functions.pure.js +1 -1
- package/Materials/effect.webgl.functions.pure.js.map +1 -1
- package/Materials/material.pure.d.ts +5 -0
- package/Materials/material.pure.js +9 -2
- package/Materials/material.pure.js.map +1 -1
- package/Materials/materialFlags.d.ts +6 -0
- package/Materials/materialFlags.js +14 -0
- package/Materials/materialFlags.js.map +1 -1
- package/Materials/materialHelper.functions.d.ts +2 -1
- package/Materials/materialHelper.functions.js +36 -2
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/materialHelper.geometryrendering.js +19 -16
- package/Materials/materialHelper.geometryrendering.js.map +1 -1
- package/Materials/materialPluginManager.pure.js +12 -8
- package/Materials/materialPluginManager.pure.js.map +1 -1
- package/Materials/prePassConfiguration.js +19 -16
- package/Materials/prePassConfiguration.js.map +1 -1
- package/Materials/shaderMaterial.pure.js +19 -6
- package/Materials/shaderMaterial.pure.js.map +1 -1
- package/Materials/shadowDepthWrapper.d.ts +6 -0
- package/Materials/shadowDepthWrapper.js +17 -0
- package/Materials/shadowDepthWrapper.js.map +1 -1
- package/Meshes/Compression/dracoCodec.d.ts +14 -0
- package/Meshes/Compression/dracoCodec.js +22 -0
- package/Meshes/Compression/dracoCodec.js.map +1 -1
- package/Meshes/Compression/dracoDecoder.d.ts +1 -0
- package/Meshes/Compression/dracoDecoder.js +27 -0
- package/Meshes/Compression/dracoDecoder.js.map +1 -1
- package/Meshes/Compression/dracoEncoder.d.ts +1 -0
- package/Meshes/Compression/dracoEncoder.js +8 -0
- package/Meshes/Compression/dracoEncoder.js.map +1 -1
- package/Meshes/Compression/meshoptCompression.d.ts +1 -0
- package/Meshes/Compression/meshoptCompression.js +9 -0
- package/Meshes/Compression/meshoptCompression.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingGpuSorter.d.ts +415 -0
- package/Meshes/GaussianSplatting/gaussianSplattingGpuSorter.js +912 -0
- package/Meshes/GaussianSplatting/gaussianSplattingGpuSorter.js.map +1 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.d.ts +3 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js +40 -9
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.d.ts +112 -8
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +696 -74
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
- package/Meshes/abstractMesh.pure.js +12 -4
- package/Meshes/abstractMesh.pure.js.map +1 -1
- package/Meshes/geometry.d.ts +5 -0
- package/Meshes/geometry.js +25 -0
- package/Meshes/geometry.js.map +1 -1
- package/Meshes/index.d.ts +1 -0
- package/Meshes/index.js +1 -0
- package/Meshes/index.js.map +1 -1
- package/Meshes/mesh.pure.d.ts +7 -0
- package/Meshes/mesh.pure.js +18 -13
- package/Meshes/mesh.pure.js.map +1 -1
- package/Meshes/pure.d.ts +1 -0
- package/Meshes/pure.js +1 -0
- package/Meshes/pure.js.map +1 -1
- package/Meshes/subMesh.pure.d.ts +3 -0
- package/Meshes/subMesh.pure.js +26 -0
- package/Meshes/subMesh.pure.js.map +1 -1
- package/Meshes/thinInstanceMesh.pure.js +5 -3
- package/Meshes/thinInstanceMesh.pure.js.map +1 -1
- package/Misc/index.d.ts +1 -0
- package/Misc/index.js +1 -0
- package/Misc/index.js.map +1 -1
- package/Misc/khronosTextureContainer2.d.ts +3 -2
- package/Misc/khronosTextureContainer2.js +24 -6
- package/Misc/khronosTextureContainer2.js.map +1 -1
- package/Misc/khronosTextureContainer2Encoder.d.ts +166 -0
- package/Misc/khronosTextureContainer2Encoder.js +556 -0
- package/Misc/khronosTextureContainer2Encoder.js.map +1 -0
- package/Misc/khronosTextureContainer2EncoderWorker.d.ts +61 -0
- package/Misc/khronosTextureContainer2EncoderWorker.js +55 -0
- package/Misc/khronosTextureContainer2EncoderWorker.js.map +1 -0
- package/Misc/pure.d.ts +1 -0
- package/Misc/pure.js +1 -0
- package/Misc/pure.js.map +1 -1
- package/Misc/textureFormat.functions.d.ts +6 -0
- package/Misc/textureFormat.functions.js +54 -0
- package/Misc/textureFormat.functions.js.map +1 -0
- package/Misc/textureTools.d.ts +6 -2
- package/Misc/textureTools.js +100 -42
- package/Misc/textureTools.js.map +1 -1
- package/Misc/tools.pure.js +1 -1
- package/Misc/tools.pure.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.pure.d.ts +1 -1
- package/Particles/Node/Blocks/systemBlock.pure.js +6 -3
- package/Particles/Node/Blocks/systemBlock.pure.js.map +1 -1
- package/Particles/computeShaderParticleSystem.pure.js +5 -0
- package/Particles/computeShaderParticleSystem.pure.js.map +1 -1
- package/Particles/gpuParticleSystem.pure.d.ts +2 -0
- package/Particles/gpuParticleSystem.pure.js +25 -1
- package/Particles/gpuParticleSystem.pure.js.map +1 -1
- package/Particles/solidParticle.d.ts +5 -0
- package/Particles/solidParticle.js +5 -0
- package/Particles/solidParticle.js.map +1 -1
- package/Particles/solidParticleSystem.d.ts +10 -0
- package/Particles/solidParticleSystem.js +72 -13
- package/Particles/solidParticleSystem.js.map +1 -1
- package/Particles/thinParticleSystem.pure.js +4 -0
- package/Particles/thinParticleSystem.pure.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/taaMaterialManager.pure.d.ts +27 -6
- package/PostProcesses/RenderPipeline/Pipelines/taaMaterialManager.pure.js +60 -5
- package/PostProcesses/RenderPipeline/Pipelines/taaMaterialManager.pure.js.map +1 -1
- package/PostProcesses/thinTAAPostProcess.d.ts +1 -0
- package/PostProcesses/thinTAAPostProcess.js +17 -1
- package/PostProcesses/thinTAAPostProcess.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.pure.d.ts +2 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.pure.js +6 -5
- package/PostProcesses/volumetricLightScatteringPostProcess.pure.js.map +1 -1
- package/Rendering/boundingBoxRenderer.pure.js +2 -3
- package/Rendering/boundingBoxRenderer.pure.js.map +1 -1
- package/Rendering/geometryBufferRenderer.pure.js +8 -2
- package/Rendering/geometryBufferRenderer.pure.js.map +1 -1
- package/Rendering/objectRenderer.d.ts +1 -0
- package/Rendering/objectRenderer.js +14 -0
- package/Rendering/objectRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/bumpFragmentMainFunctions.js +2 -2
- package/Shaders/ShadersInclude/bumpFragmentMainFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/bumpVertex.js +1 -1
- package/Shaders/ShadersInclude/bumpVertex.js.map +1 -1
- package/Shaders/ShadersInclude/bumpVertexDeclaration.js +1 -1
- package/Shaders/ShadersInclude/bumpVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js +5 -1
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/helperFunctions.js +2 -2
- package/Shaders/ShadersInclude/helperFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrBackgroundTransmission.js +1 -1
- package/Shaders/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrVertexDeclaration.js +6 -0
- package/Shaders/ShadersInclude/openpbrVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockFinalLitComponents.js +11 -1
- package/Shaders/ShadersInclude/pbrBlockFinalLitComponents.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockNormalFinal.js +9 -0
- package/Shaders/ShadersInclude/pbrBlockNormalFinal.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflectance.js +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflectance.js.map +1 -1
- package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.js +1 -1
- package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentDeclaration.js +7 -1
- package/Shaders/ShadersInclude/pbrFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +1 -0
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrIBLFunctions.js +12 -0
- package/Shaders/ShadersInclude/pbrIBLFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrUboDeclaration.js +1 -1
- package/Shaders/ShadersInclude/pbrUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrVertexDeclaration.js +3 -0
- package/Shaders/ShadersInclude/pbrVertexDeclaration.js.map +1 -1
- package/Shaders/geometry.vertex.js +6 -6
- package/Shaders/geometry.vertex.js.map +1 -1
- package/Shaders/gpuUpdateParticles.vertex.js +1 -1
- package/Shaders/gpuUpdateParticles.vertex.js.map +1 -1
- package/Shaders/lod.fragment.js +15 -2
- package/Shaders/lod.fragment.js.map +1 -1
- package/Shaders/lod3D.fragment.js +15 -2
- package/Shaders/lod3D.fragment.js.map +1 -1
- package/Shaders/lodCube.fragment.js +15 -2
- package/Shaders/lodCube.fragment.js.map +1 -1
- package/Shaders/openpbr.vertex.js +2 -0
- package/Shaders/openpbr.vertex.js.map +1 -1
- package/Shaders/pbr.fragment.js +12 -1
- package/Shaders/pbr.fragment.js.map +1 -1
- package/Shaders/pbr.vertex.js +2 -0
- package/Shaders/pbr.vertex.js.map +1 -1
- package/Shaders/textureMerger.fragment.js +28 -0
- package/Shaders/textureMerger.fragment.js.map +1 -1
- package/Shaders/textureProcessor.fragment.js +26 -4
- package/Shaders/textureProcessor.fragment.js.map +1 -1
- package/Shaders/volumetricLightScattering.fragment.js +1 -1
- package/Shaders/volumetricLightScattering.fragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bumpFragmentMainFunctions.js +2 -2
- package/ShadersWGSL/ShadersInclude/bumpFragmentMainFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bumpVertex.js +1 -1
- package/ShadersWGSL/ShadersInclude/bumpVertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bumpVertexDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/bumpVertexDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/helperFunctions.js +2 -2
- package/ShadersWGSL/ShadersInclude/helperFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js +44 -2
- package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js +17 -3
- package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js +12 -1
- package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalLitComponents.js +11 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalLitComponents.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockNormalFinal.js +9 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockNormalFinal.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectance.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectance.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrClusteredLightingFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrClusteredLightingFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js +1 -0
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrIBLFunctions.js +8 -0
- package/ShadersWGSL/ShadersInclude/pbrIBLFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrUboDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/prePassVertex.js +2 -2
- package/ShadersWGSL/ShadersInclude/prePassVertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/prePassVertexDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/prePassVertexDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/sceneUboDeclaration.js +3 -1
- package/ShadersWGSL/ShadersInclude/sceneUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/shadowsVertex.js +16 -0
- package/ShadersWGSL/ShadersInclude/shadowsVertex.js.map +1 -1
- package/ShadersWGSL/default.fragment.js +4 -4
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/default.vertex.js +1 -1
- package/ShadersWGSL/default.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +3 -3
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/gpuUpdateParticles.compute.js +1 -1
- package/ShadersWGSL/gpuUpdateParticles.compute.js.map +1 -1
- package/ShadersWGSL/gsSortCount.compute.d.ts +5 -0
- package/ShadersWGSL/gsSortCount.compute.js +19 -0
- package/ShadersWGSL/gsSortCount.compute.js.map +1 -0
- package/ShadersWGSL/gsSortKeys.compute.d.ts +5 -0
- package/ShadersWGSL/gsSortKeys.compute.js +49 -0
- package/ShadersWGSL/gsSortKeys.compute.js.map +1 -0
- package/ShadersWGSL/gsSortOutput.compute.d.ts +5 -0
- package/ShadersWGSL/gsSortOutput.compute.js +28 -0
- package/ShadersWGSL/gsSortOutput.compute.js.map +1 -0
- package/ShadersWGSL/gsSortScanLocal.compute.d.ts +5 -0
- package/ShadersWGSL/gsSortScanLocal.compute.js +23 -0
- package/ShadersWGSL/gsSortScanLocal.compute.js.map +1 -0
- package/ShadersWGSL/gsSortScanSums.compute.d.ts +5 -0
- package/ShadersWGSL/gsSortScanSums.compute.js +19 -0
- package/ShadersWGSL/gsSortScanSums.compute.js.map +1 -0
- package/ShadersWGSL/gsSortScatter.compute.d.ts +5 -0
- package/ShadersWGSL/gsSortScatter.compute.js +33 -0
- package/ShadersWGSL/gsSortScatter.compute.js.map +1 -0
- package/ShadersWGSL/lod.fragment.js +14 -2
- package/ShadersWGSL/lod.fragment.js.map +1 -1
- package/ShadersWGSL/lod3D.fragment.js +14 -2
- package/ShadersWGSL/lod3D.fragment.js.map +1 -1
- package/ShadersWGSL/lodCube.fragment.js +14 -2
- package/ShadersWGSL/lodCube.fragment.js.map +1 -1
- package/ShadersWGSL/openpbr.vertex.js +3 -1
- package/ShadersWGSL/openpbr.vertex.js.map +1 -1
- package/ShadersWGSL/pbr.fragment.js +11 -0
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/ShadersWGSL/pbr.vertex.js +3 -1
- package/ShadersWGSL/pbr.vertex.js.map +1 -1
- package/ShadersWGSL/textureMerger.fragment.js +40 -4
- package/ShadersWGSL/textureMerger.fragment.js.map +1 -1
- package/ShadersWGSL/textureProcessor.fragment.js +26 -4
- package/ShadersWGSL/textureProcessor.fragment.js.map +1 -1
- package/Sprites/spriteRenderer.js +15 -5
- package/Sprites/spriteRenderer.js.map +1 -1
- package/package.json +1 -1
- package/scene.pure.d.ts +23 -1
- package/scene.pure.js +83 -1
- package/scene.pure.js.map +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ProceduralTexture } from "./Procedurals/proceduralTexture.pure.js";
|
|
2
2
|
|
|
3
3
|
import { Color4 } from "../../Maths/math.color.pure.js";
|
|
4
|
+
import { _AllTransformsMatch, _CopyTextureMetadata, _HasNonIdentityTransform, _KeepMatchingCoordinates } from "./textureSampling.functions.js";
|
|
4
5
|
const _ShaderName = "textureProcessor";
|
|
5
6
|
/**
|
|
6
7
|
* Specifies the color space of a texture operand.
|
|
@@ -136,9 +137,43 @@ function _MaxConstants(a, b) {
|
|
|
136
137
|
return new Color4(Math.max(a.r, b.r), Math.max(a.g, b.g), Math.max(a.b, b.b), Math.max(a.a, b.a));
|
|
137
138
|
}
|
|
138
139
|
/** @internal */
|
|
140
|
+
function _DivideConstants(a, b) {
|
|
141
|
+
const eps = 0.00001;
|
|
142
|
+
return new Color4(a.r / Math.max(b.r, eps), a.g / Math.max(b.g, eps), a.b / Math.max(b.b, eps), a.a / Math.max(b.a, eps));
|
|
143
|
+
}
|
|
144
|
+
/** @internal */
|
|
139
145
|
function _LerpConstants(a, b, t) {
|
|
140
146
|
return new Color4(a.r + (b.r - a.r) * t.r, a.g + (b.g - a.g) * t.g, a.b + (b.b - a.b) * t.b, a.a + (b.a - a.a) * t.a);
|
|
141
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Clamps a scatter anisotropy the same way the renderer does before converting between single- and
|
|
150
|
+
* multi-scatter albedo, so that |aniso| = 1 doesn't collapse the conversion.
|
|
151
|
+
* @internal
|
|
152
|
+
*/
|
|
153
|
+
function _EffectiveScatterAnisotropy(aniso) {
|
|
154
|
+
return Math.min(Math.max(aniso, -0.9999), 0.9999);
|
|
155
|
+
}
|
|
156
|
+
/** @internal */
|
|
157
|
+
function _MultiScatterToSingleScatterAlbedoConstant(multiScatter, aniso) {
|
|
158
|
+
const convert = (value) => {
|
|
159
|
+
const rhoMs = Math.min(Math.max(value, 0), 1);
|
|
160
|
+
let s = 4.09712 + 4.20863 * rhoMs - Math.sqrt(9.59217 + 41.6808 * rhoMs + 17.7126 * rhoMs * rhoMs);
|
|
161
|
+
if (rhoMs === 0) {
|
|
162
|
+
s = 1;
|
|
163
|
+
}
|
|
164
|
+
return (1 - s * s) / Math.max(1 - aniso * s * s, 0.0000001);
|
|
165
|
+
};
|
|
166
|
+
return new Color4(convert(multiScatter.r), convert(multiScatter.g), convert(multiScatter.b), multiScatter.a);
|
|
167
|
+
}
|
|
168
|
+
/** @internal */
|
|
169
|
+
function _SingleScatterToMultiScatterAlbedoConstant(singleScatter, aniso) {
|
|
170
|
+
const convert = (value) => {
|
|
171
|
+
const ssAlbedo = Math.min(Math.max(value, 0), 1);
|
|
172
|
+
const s = Math.sqrt(Math.max((1 - ssAlbedo) / Math.max(1 - aniso * ssAlbedo, 0.0000001), 0));
|
|
173
|
+
return ((1 - s) * (1 - 0.139 * s)) / (1 + 1.17 * s);
|
|
174
|
+
};
|
|
175
|
+
return new Color4(convert(singleScatter.r), convert(singleScatter.g), convert(singleScatter.b), singleScatter.a);
|
|
176
|
+
}
|
|
142
177
|
/**
|
|
143
178
|
* @internal
|
|
144
179
|
* Determine the output texture size from a list of operands, using the largest input texture.
|
|
@@ -158,49 +193,8 @@ function _ResolveOutputSize(operands) {
|
|
|
158
193
|
}
|
|
159
194
|
return result;
|
|
160
195
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
* Returns true when the texture has a non-identity UV transform (offset, scale, or rotation).
|
|
164
|
-
*/
|
|
165
|
-
function _HasNonIdentityTransform(texture) {
|
|
166
|
-
return !texture.getTextureMatrix().isIdentity();
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* @internal
|
|
170
|
-
* Returns true when every texture in the list shares the same UV transform matrix.
|
|
171
|
-
* A single texture (or empty list) trivially satisfies this.
|
|
172
|
-
*/
|
|
173
|
-
function _AllTransformsMatch(textures) {
|
|
174
|
-
if (textures.length <= 1) {
|
|
175
|
-
return true;
|
|
176
|
-
}
|
|
177
|
-
const ref = textures[0].getTextureMatrix();
|
|
178
|
-
for (let i = 1; i < textures.length; i++) {
|
|
179
|
-
if (!ref.equals(textures[i].getTextureMatrix())) {
|
|
180
|
-
return false;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return true;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* @internal
|
|
187
|
-
* Copy sampling metadata from a source texture onto the output ProceduralTexture.
|
|
188
|
-
* `coordinatesIndex` and wrap modes are always copied.
|
|
189
|
-
* When `includeTransform` is true the UV offset/scale/rotation are also copied
|
|
190
|
-
* (used when all inputs share the same transform and it is propagated rather than baked).
|
|
191
|
-
*/
|
|
192
|
-
function _CopyTextureMetadata(from, to, includeTransform) {
|
|
193
|
-
to.coordinatesIndex = from.coordinatesIndex;
|
|
194
|
-
to.wrapU = from.wrapU;
|
|
195
|
-
to.wrapV = from.wrapV;
|
|
196
|
-
if (includeTransform) {
|
|
197
|
-
const src = from;
|
|
198
|
-
to.uOffset = src.uOffset ?? 0;
|
|
199
|
-
to.vOffset = src.vOffset ?? 0;
|
|
200
|
-
to.uScale = src.uScale ?? 1;
|
|
201
|
-
to.vScale = src.vScale ?? 1;
|
|
202
|
-
to.wAng = src.wAng ?? 0;
|
|
203
|
-
}
|
|
196
|
+
function _KeepMatchingOperandCoordinates(name, operands) {
|
|
197
|
+
return _KeepMatchingCoordinates(`Texture processor '${name}'`, operands, (operand) => operand.texture, (operand) => ({ ...operand, texture: null }));
|
|
204
198
|
}
|
|
205
199
|
/**
|
|
206
200
|
* @internal
|
|
@@ -458,6 +452,7 @@ export async function MultiplyTexturesAsync(name, a, b, scene, outputColorSpace,
|
|
|
458
452
|
const factor = _MultiplyConstants(_EvalConstant(a), _EvalConstant(b));
|
|
459
453
|
return { texture: null, factor: outputChannelMask ? _ApplyOutputChannelMask(factor, outputChannelMask) : factor };
|
|
460
454
|
}
|
|
455
|
+
[a, b] = _KeepMatchingOperandCoordinates(name, [a, b]);
|
|
461
456
|
const allTextures = [];
|
|
462
457
|
if (a.texture) {
|
|
463
458
|
allTextures.push(a.texture);
|
|
@@ -524,6 +519,7 @@ export async function MaxTexturesAsync(name, a, b, scene, outputColorSpace, outp
|
|
|
524
519
|
const factor = _MaxConstants(_EvalConstant(a), _EvalConstant(b));
|
|
525
520
|
return { texture: null, factor: outputChannelMask ? _ApplyOutputChannelMask(factor, outputChannelMask) : factor };
|
|
526
521
|
}
|
|
522
|
+
[a, b] = _KeepMatchingOperandCoordinates(name, [a, b]);
|
|
527
523
|
const allTextures = [];
|
|
528
524
|
if (a.texture) {
|
|
529
525
|
allTextures.push(a.texture);
|
|
@@ -562,6 +558,218 @@ export async function MaxTexturesAsync(name, a, b, scene, outputColorSpace, outp
|
|
|
562
558
|
}
|
|
563
559
|
return result;
|
|
564
560
|
}
|
|
561
|
+
/**
|
|
562
|
+
* Component-wise safe division of two texture operands: `result = a / max(b, 0.00001)`.
|
|
563
|
+
*
|
|
564
|
+
* Each operand can be a texture, a constant factor, or a texture scaled by a factor.
|
|
565
|
+
* Division by zero is guarded with a small epsilon so the result is always finite.
|
|
566
|
+
*
|
|
567
|
+
* If both operands are constant (no textures), the operation is performed on the CPU and
|
|
568
|
+
* the result is returned as a factor-only operand with no texture allocated.
|
|
569
|
+
*
|
|
570
|
+
* When operands are results of previous operations (i.e. they carry a `dispose` function),
|
|
571
|
+
* their intermediate textures are automatically released after the GPU pass completes.
|
|
572
|
+
*
|
|
573
|
+
* @param name - Name for the resulting procedural texture (used only when a GPU pass is needed)
|
|
574
|
+
* @param a - Numerator operand
|
|
575
|
+
* @param b - Denominator operand
|
|
576
|
+
* @param scene - Scene to create the texture in (used only when a GPU pass is needed)
|
|
577
|
+
* @param outputColorSpace - Optional output color space.
|
|
578
|
+
* @param outputChannelMask - Optional bitmask of channels to write.
|
|
579
|
+
* @param outputOptions - Optional render-target type, sampling, and mipmap settings.
|
|
580
|
+
* @returns An operand whose `texture` holds the GPU result, or whose `factor` holds the CPU-folded constant
|
|
581
|
+
*/
|
|
582
|
+
export async function DivideTexturesAsync(name, a, b, scene, outputColorSpace, outputChannelMask, outputOptions) {
|
|
583
|
+
if (!a.texture && !b.texture) {
|
|
584
|
+
const factor = _DivideConstants(_EvalConstant(a), _EvalConstant(b));
|
|
585
|
+
return { texture: null, factor: outputChannelMask ? _ApplyOutputChannelMask(factor, outputChannelMask) : factor };
|
|
586
|
+
}
|
|
587
|
+
[a, b] = _KeepMatchingOperandCoordinates(name, [a, b]);
|
|
588
|
+
const allTextures = [];
|
|
589
|
+
if (a.texture) {
|
|
590
|
+
allTextures.push(a.texture);
|
|
591
|
+
}
|
|
592
|
+
if (b.texture) {
|
|
593
|
+
allTextures.push(b.texture);
|
|
594
|
+
}
|
|
595
|
+
const canPropagate = _AllTransformsMatch(allTextures);
|
|
596
|
+
const bakeTransform = !canPropagate;
|
|
597
|
+
const defines = [
|
|
598
|
+
"OP_DIVIDE",
|
|
599
|
+
..._BuildOperandDefines(a, "A", bakeTransform),
|
|
600
|
+
..._BuildOperandDefines(b, "B", bakeTransform),
|
|
601
|
+
...(outputChannelMask ? _BuildOutputChannelMaskDefines(outputChannelMask) : []),
|
|
602
|
+
];
|
|
603
|
+
if (outputColorSpace) {
|
|
604
|
+
defines.push("OUTPUT_SRGB");
|
|
605
|
+
}
|
|
606
|
+
const pt = _CreateProcessorTexture(name, defines, _ResolveOutputSize([a, b]), scene, outputColorSpace, outputOptions);
|
|
607
|
+
_SetOperandUniforms(pt, a, "textureA", "factorA", bakeTransform);
|
|
608
|
+
_SetOperandUniforms(pt, b, "textureB", "factorB", bakeTransform);
|
|
609
|
+
try {
|
|
610
|
+
await _RenderAsync(pt);
|
|
611
|
+
}
|
|
612
|
+
catch (error) {
|
|
613
|
+
a.dispose?.();
|
|
614
|
+
b.dispose?.();
|
|
615
|
+
throw error;
|
|
616
|
+
}
|
|
617
|
+
a.dispose?.();
|
|
618
|
+
b.dispose?.();
|
|
619
|
+
_CopyTextureMetadata(allTextures[0], pt, canPropagate);
|
|
620
|
+
const result = { texture: pt, dispose: () => pt.dispose() };
|
|
621
|
+
if (outputColorSpace) {
|
|
622
|
+
result.colorSpace = outputColorSpace;
|
|
623
|
+
}
|
|
624
|
+
return result;
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* Compute the component-wise fraction `result = a / (a + b * (1 - a))` in a single GPU pass.
|
|
628
|
+
*
|
|
629
|
+
* For OpenPBR this is the transmission fraction of the dielectric's transmitted light, where `a` is
|
|
630
|
+
* the transmission weight T and `b` the subsurface weight S (subsurface covers only the remaining
|
|
631
|
+
* `1 - T`). The subsurface fraction is `1 - result`. The denominator `T + S(1 - T)` equals
|
|
632
|
+
* `1 - (1 - T)(1 - S)` but avoids subtracting values near one, and fusing the whole expression into
|
|
633
|
+
* one pass means no intermediate is quantized; only the final output is. The denominator is guarded
|
|
634
|
+
* with `max(..., 0.00001)`, so the result is 0 where both inputs are 0.
|
|
635
|
+
*
|
|
636
|
+
* If both operands are constant (no textures), the operation is performed on the CPU and
|
|
637
|
+
* the result is returned as a factor-only operand with no texture allocated.
|
|
638
|
+
*
|
|
639
|
+
* When operands are results of previous operations (i.e. they carry a `dispose` function),
|
|
640
|
+
* their intermediate textures are automatically released after the GPU pass completes.
|
|
641
|
+
*
|
|
642
|
+
* @param name - Name for the resulting procedural texture (used only when a GPU pass is needed)
|
|
643
|
+
* @param a - Transmission weight operand (T)
|
|
644
|
+
* @param b - Subsurface weight operand (S)
|
|
645
|
+
* @param scene - Scene to create the texture in (used only when a GPU pass is needed)
|
|
646
|
+
* @param outputColorSpace - Optional output color space.
|
|
647
|
+
* @param outputChannelMask - Optional bitmask of channels to write.
|
|
648
|
+
* @param outputOptions - Optional render-target type, sampling, and mipmap settings.
|
|
649
|
+
* @returns An operand whose `texture` holds the GPU result, or whose `factor` holds the CPU-folded constant
|
|
650
|
+
*/
|
|
651
|
+
export async function TransmissionFractionAsync(name, a, b, scene, outputColorSpace, outputChannelMask, outputOptions) {
|
|
652
|
+
if (!a.texture && !b.texture) {
|
|
653
|
+
const ca = _EvalConstant(a);
|
|
654
|
+
const cb = _EvalConstant(b);
|
|
655
|
+
const fraction = (x, y) => x / Math.max(x + y * (1 - x), 0.00001);
|
|
656
|
+
const factor = new Color4(fraction(ca.r, cb.r), fraction(ca.g, cb.g), fraction(ca.b, cb.b), fraction(ca.a, cb.a));
|
|
657
|
+
return { texture: null, factor: outputChannelMask ? _ApplyOutputChannelMask(factor, outputChannelMask) : factor };
|
|
658
|
+
}
|
|
659
|
+
[a, b] = _KeepMatchingOperandCoordinates(name, [a, b]);
|
|
660
|
+
const allTextures = [];
|
|
661
|
+
if (a.texture) {
|
|
662
|
+
allTextures.push(a.texture);
|
|
663
|
+
}
|
|
664
|
+
if (b.texture) {
|
|
665
|
+
allTextures.push(b.texture);
|
|
666
|
+
}
|
|
667
|
+
const canPropagate = _AllTransformsMatch(allTextures);
|
|
668
|
+
const bakeTransform = !canPropagate;
|
|
669
|
+
const defines = [
|
|
670
|
+
"OP_TRANSMISSION_FRACTION",
|
|
671
|
+
..._BuildOperandDefines(a, "A", bakeTransform),
|
|
672
|
+
..._BuildOperandDefines(b, "B", bakeTransform),
|
|
673
|
+
...(outputChannelMask ? _BuildOutputChannelMaskDefines(outputChannelMask) : []),
|
|
674
|
+
];
|
|
675
|
+
if (outputColorSpace) {
|
|
676
|
+
defines.push("OUTPUT_SRGB");
|
|
677
|
+
}
|
|
678
|
+
const pt = _CreateProcessorTexture(name, defines, _ResolveOutputSize([a, b]), scene, outputColorSpace, outputOptions);
|
|
679
|
+
_SetOperandUniforms(pt, a, "textureA", "factorA", bakeTransform);
|
|
680
|
+
_SetOperandUniforms(pt, b, "textureB", "factorB", bakeTransform);
|
|
681
|
+
try {
|
|
682
|
+
await _RenderAsync(pt);
|
|
683
|
+
}
|
|
684
|
+
catch (error) {
|
|
685
|
+
a.dispose?.();
|
|
686
|
+
b.dispose?.();
|
|
687
|
+
throw error;
|
|
688
|
+
}
|
|
689
|
+
a.dispose?.();
|
|
690
|
+
b.dispose?.();
|
|
691
|
+
_CopyTextureMetadata(allTextures[0], pt, canPropagate);
|
|
692
|
+
const result = { texture: pt, dispose: () => pt.dispose() };
|
|
693
|
+
if (outputColorSpace) {
|
|
694
|
+
result.colorSpace = outputColorSpace;
|
|
695
|
+
}
|
|
696
|
+
return result;
|
|
697
|
+
}
|
|
698
|
+
/** @internal */
|
|
699
|
+
function _TransmissionScatterAlbedoConstant(transmissionColor, transmissionScatter) {
|
|
700
|
+
const extinction = [transmissionColor.r, transmissionColor.g, transmissionColor.b].map((value) => -Math.log(Math.max(value, 0.0000001)));
|
|
701
|
+
const scatter = [transmissionScatter.r, transmissionScatter.g, transmissionScatter.b];
|
|
702
|
+
const shift = Math.min(0, ...extinction.map((value, i) => value - scatter[i]));
|
|
703
|
+
const albedo = scatter.map((value, i) => value / Math.max(extinction[i] - shift, 0.00001));
|
|
704
|
+
return new Color4(albedo[0], albedo[1], albedo[2], transmissionScatter.a);
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Recover the single-scatter albedo of an OpenPBR 1.1 transmission volume, `scatter / extinction`, using the
|
|
708
|
+
* renderer's extinction: the absorption `-log(transmissionColor) - transmissionScatter` is shifted so its
|
|
709
|
+
* smallest channel is non-negative, and the extinction is recomputed from it. The transmission depth cancels
|
|
710
|
+
* out of the ratio, so both operands are given per unit depth. The result alpha is taken from the scatter operand.
|
|
711
|
+
*
|
|
712
|
+
* If both operands are constant (no textures), the operation is performed on the CPU and
|
|
713
|
+
* the result is returned as a factor-only operand with no texture allocated.
|
|
714
|
+
*
|
|
715
|
+
* When operands are results of previous operations (i.e. they carry a `dispose` function),
|
|
716
|
+
* their intermediate textures are automatically released after the GPU pass completes.
|
|
717
|
+
*
|
|
718
|
+
* @param name - Name for the resulting procedural texture (used only when a GPU pass is needed)
|
|
719
|
+
* @param transmissionColor - Linear transmission color operand
|
|
720
|
+
* @param transmissionScatter - Transmission scatter operand
|
|
721
|
+
* @param scene - Scene to create the texture in (used only when a GPU pass is needed)
|
|
722
|
+
* @param outputColorSpace - Optional output color space.
|
|
723
|
+
* @param outputChannelMask - Optional bitmask of channels to write.
|
|
724
|
+
* @param outputOptions - Optional render-target type, sampling, and mipmap settings.
|
|
725
|
+
* @returns An operand whose `texture` holds the GPU result, or whose `factor` holds the CPU-folded constant
|
|
726
|
+
*/
|
|
727
|
+
export async function TransmissionScatterToSingleScatterAlbedoAsync(name, transmissionColor, transmissionScatter, scene, outputColorSpace, outputChannelMask, outputOptions) {
|
|
728
|
+
let a = transmissionColor;
|
|
729
|
+
let b = transmissionScatter;
|
|
730
|
+
if (!a.texture && !b.texture) {
|
|
731
|
+
const factor = _TransmissionScatterAlbedoConstant(_EvalConstant(a), _EvalConstant(b));
|
|
732
|
+
return { texture: null, factor: outputChannelMask ? _ApplyOutputChannelMask(factor, outputChannelMask) : factor };
|
|
733
|
+
}
|
|
734
|
+
[a, b] = _KeepMatchingOperandCoordinates(name, [a, b]);
|
|
735
|
+
const allTextures = [];
|
|
736
|
+
if (a.texture) {
|
|
737
|
+
allTextures.push(a.texture);
|
|
738
|
+
}
|
|
739
|
+
if (b.texture) {
|
|
740
|
+
allTextures.push(b.texture);
|
|
741
|
+
}
|
|
742
|
+
const canPropagate = _AllTransformsMatch(allTextures);
|
|
743
|
+
const bakeTransform = !canPropagate;
|
|
744
|
+
const defines = [
|
|
745
|
+
"OP_TRANSMISSION_SCATTER_ALBEDO",
|
|
746
|
+
..._BuildOperandDefines(a, "A", bakeTransform),
|
|
747
|
+
..._BuildOperandDefines(b, "B", bakeTransform),
|
|
748
|
+
...(outputChannelMask ? _BuildOutputChannelMaskDefines(outputChannelMask) : []),
|
|
749
|
+
];
|
|
750
|
+
if (outputColorSpace) {
|
|
751
|
+
defines.push("OUTPUT_SRGB");
|
|
752
|
+
}
|
|
753
|
+
const pt = _CreateProcessorTexture(name, defines, _ResolveOutputSize([a, b]), scene, outputColorSpace, outputOptions);
|
|
754
|
+
_SetOperandUniforms(pt, a, "textureA", "factorA", bakeTransform);
|
|
755
|
+
_SetOperandUniforms(pt, b, "textureB", "factorB", bakeTransform);
|
|
756
|
+
try {
|
|
757
|
+
await _RenderAsync(pt);
|
|
758
|
+
}
|
|
759
|
+
catch (error) {
|
|
760
|
+
a.dispose?.();
|
|
761
|
+
b.dispose?.();
|
|
762
|
+
throw error;
|
|
763
|
+
}
|
|
764
|
+
a.dispose?.();
|
|
765
|
+
b.dispose?.();
|
|
766
|
+
_CopyTextureMetadata(allTextures[0], pt, canPropagate);
|
|
767
|
+
const result = { texture: pt, dispose: () => pt.dispose() };
|
|
768
|
+
if (outputColorSpace) {
|
|
769
|
+
result.colorSpace = outputColorSpace;
|
|
770
|
+
}
|
|
771
|
+
return result;
|
|
772
|
+
}
|
|
565
773
|
/**
|
|
566
774
|
* Linearly interpolate between two texture operands: `result = mix(a, b, t)`.
|
|
567
775
|
*
|
|
@@ -588,11 +796,12 @@ export async function MaxTexturesAsync(name, a, b, scene, outputColorSpace, outp
|
|
|
588
796
|
* @param outputOptions - Optional render-target type, sampling, and mipmap settings.
|
|
589
797
|
* @returns An operand whose `texture` holds the GPU result, or whose `factor` holds the CPU-folded constant
|
|
590
798
|
*/
|
|
591
|
-
export async function LerpTexturesAsync(name, a, b, t, scene, outputColorSpace, outputChannelMask, outputOptions) {
|
|
799
|
+
export async function LerpTexturesAsync(name, a, b, t, scene, outputColorSpace = TextureColorSpace.Linear, outputChannelMask, outputOptions) {
|
|
592
800
|
if (!a.texture && !b.texture && !t.texture) {
|
|
593
801
|
const factor = _LerpConstants(_EvalConstant(a), _EvalConstant(b), _EvalConstant(t));
|
|
594
802
|
return { texture: null, factor: outputChannelMask ? _ApplyOutputChannelMask(factor, outputChannelMask) : factor };
|
|
595
803
|
}
|
|
804
|
+
[a, b, t] = _KeepMatchingOperandCoordinates(name, [a, b, t]);
|
|
596
805
|
const allTextures = [];
|
|
597
806
|
if (a.texture) {
|
|
598
807
|
allTextures.push(a.texture);
|
|
@@ -612,7 +821,7 @@ export async function LerpTexturesAsync(name, a, b, t, scene, outputColorSpace,
|
|
|
612
821
|
..._BuildLerpBlendDefines(t, bakeTransform),
|
|
613
822
|
...(outputChannelMask ? _BuildOutputChannelMaskDefines(outputChannelMask) : []),
|
|
614
823
|
];
|
|
615
|
-
if (outputColorSpace) {
|
|
824
|
+
if (outputColorSpace == TextureColorSpace.SRGB) {
|
|
616
825
|
defines.push("OUTPUT_SRGB");
|
|
617
826
|
}
|
|
618
827
|
const pt = _CreateProcessorTexture(name, defines, _ResolveOutputSize([a, b, t]), scene, outputColorSpace, outputOptions);
|
|
@@ -795,4 +1004,195 @@ export async function ExtractChannelAsync(name, input, channel, scene, outputCol
|
|
|
795
1004
|
}
|
|
796
1005
|
return await MultiplyTexturesAsync(name, { ...input, channel }, CreateFactorOperand(new Color4(1, 1, 1, 1)), scene, outputColorSpace, outputChannelMask, outputOptions);
|
|
797
1006
|
}
|
|
1007
|
+
/**
|
|
1008
|
+
* Convert a multi-scatter albedo operand to single-scatter albedo using the OpenPBR/KHR
|
|
1009
|
+
* approximation. RGB is clamped to `[0, 1]` before conversion and alpha is preserved.
|
|
1010
|
+
*
|
|
1011
|
+
* If the operand is constant, the conversion is performed on the CPU. Otherwise it is baked
|
|
1012
|
+
* into a linear procedural texture. Input color-space conversion, channel selection, factors,
|
|
1013
|
+
* UV transforms, metadata propagation, and intermediate disposal follow the other unary texture
|
|
1014
|
+
* processor operations.
|
|
1015
|
+
*
|
|
1016
|
+
* @param name - Name for the resulting procedural texture (used only when a GPU pass is needed)
|
|
1017
|
+
* @param input - Multi-scatter albedo operand to convert
|
|
1018
|
+
* @param scene - Scene to create the texture in (used only when a GPU pass is needed)
|
|
1019
|
+
* @param aniso - Scattering anisotropy in `[-1, 1]`. `0` (default) is isotropic; positive values are
|
|
1020
|
+
* forward-scattering. Matches `multiScatterToSingleScatterAlbedo(rho_ms, aniso)` in helperFunctions.
|
|
1021
|
+
* Clamped to `[-0.9999, 0.9999]`, as in the renderer.
|
|
1022
|
+
* @param scale - Optional operand multiplied into `input` (RGBA) before conversion, in the same pass. Use it
|
|
1023
|
+
* instead of a separate {@link MultiplyTexturesAsync} so that the product (e.g. scatter strength times
|
|
1024
|
+
* multi-scatter color) isn't quantized before the nonlinear conversion.
|
|
1025
|
+
* @returns An operand containing the converted single-scatter albedo
|
|
1026
|
+
*/
|
|
1027
|
+
export async function MultiScatterToSingleScatterAlbedoAsync(name, input, scene, aniso = 0, scale) {
|
|
1028
|
+
aniso = _EffectiveScatterAnisotropy(aniso);
|
|
1029
|
+
if (!input.texture && !scale?.texture) {
|
|
1030
|
+
const multiScatter = scale ? _MultiplyConstants(_EvalConstant(input), _EvalConstant(scale)) : _EvalConstant(input);
|
|
1031
|
+
return { texture: null, factor: _MultiScatterToSingleScatterAlbedoConstant(multiScatter, aniso) };
|
|
1032
|
+
}
|
|
1033
|
+
const operands = scale ? _KeepMatchingOperandCoordinates(name, [input, scale]) : [input];
|
|
1034
|
+
const allTextures = operands.map((operand) => operand.texture).filter((texture) => !!texture);
|
|
1035
|
+
const canPropagate = _AllTransformsMatch(allTextures);
|
|
1036
|
+
const bakeTransform = !canPropagate;
|
|
1037
|
+
const defines = [..._BuildOperandDefines(operands[0], "A", bakeTransform), "OP_MULTI_SCATTER_TO_SINGLE_SCATTER"];
|
|
1038
|
+
if (operands[1]) {
|
|
1039
|
+
defines.push(..._BuildOperandDefines(operands[1], "B", bakeTransform), "MULTI_SCATTER_SCALE_B");
|
|
1040
|
+
}
|
|
1041
|
+
const pt = _CreateProcessorTexture(name, defines, _ResolveOutputSize(operands), scene);
|
|
1042
|
+
_SetOperandUniforms(pt, operands[0], "textureA", "factorA", bakeTransform);
|
|
1043
|
+
if (operands[1]) {
|
|
1044
|
+
_SetOperandUniforms(pt, operands[1], "textureB", "factorB", bakeTransform);
|
|
1045
|
+
}
|
|
1046
|
+
pt.setFloat("scatterAniso", aniso);
|
|
1047
|
+
const disposeOperands = () => operands.forEach((operand) => operand.dispose?.());
|
|
1048
|
+
try {
|
|
1049
|
+
await _RenderAsync(pt);
|
|
1050
|
+
}
|
|
1051
|
+
catch (error) {
|
|
1052
|
+
disposeOperands();
|
|
1053
|
+
throw error;
|
|
1054
|
+
}
|
|
1055
|
+
disposeOperands();
|
|
1056
|
+
_CopyTextureMetadata(allTextures[0], pt, canPropagate);
|
|
1057
|
+
return { texture: pt, dispose: () => pt.dispose() };
|
|
1058
|
+
}
|
|
1059
|
+
/**
|
|
1060
|
+
* Convert a single-scatter albedo operand to multi-scatter albedo using the OpenPBR/KHR
|
|
1061
|
+
* approximation. This is the inverse of {@link MultiScatterToSingleScatterAlbedoAsync}.
|
|
1062
|
+
* RGB is clamped to `[0, 1]` before conversion and alpha is preserved.
|
|
1063
|
+
*
|
|
1064
|
+
* If the operand is constant, the conversion is performed on the CPU. Otherwise it is baked
|
|
1065
|
+
* into a linear procedural texture. Input color-space conversion, channel selection, factors,
|
|
1066
|
+
* UV transforms, metadata propagation, and intermediate disposal follow the other unary texture
|
|
1067
|
+
* processor operations.
|
|
1068
|
+
*
|
|
1069
|
+
* @param name - Name for the resulting procedural texture (used only when a GPU pass is needed)
|
|
1070
|
+
* @param input - Single-scatter albedo operand to convert
|
|
1071
|
+
* @param scene - Scene to create the texture in (used only when a GPU pass is needed)
|
|
1072
|
+
* @param aniso - Scattering anisotropy in `[-1, 1]`. `0` (default) is isotropic; positive values are
|
|
1073
|
+
* forward-scattering. This inverts the anisotropic multi→single mapping: `s^2 = (1 - rho_ss) /
|
|
1074
|
+
* (1 - aniso * rho_ss)`, then `rho_ms = (1 - s)(1 - 0.139 s)/(1 + 1.17 s)`. Clamped to
|
|
1075
|
+
* `[-0.9999, 0.9999]`, as in the renderer.
|
|
1076
|
+
* @param outputOptions - Optional render-target type, sampling, and mipmap settings.
|
|
1077
|
+
* @returns An operand containing the converted multi-scatter albedo
|
|
1078
|
+
*/
|
|
1079
|
+
export async function SingleScatterToMultiScatterAlbedoAsync(name, input, scene, aniso = 0, outputOptions) {
|
|
1080
|
+
aniso = _EffectiveScatterAnisotropy(aniso);
|
|
1081
|
+
if (!input.texture) {
|
|
1082
|
+
return { texture: null, factor: _SingleScatterToMultiScatterAlbedoConstant(_EvalConstant(input), aniso) };
|
|
1083
|
+
}
|
|
1084
|
+
const defines = [..._BuildOperandDefines(input, "A", false), "OP_SINGLE_SCATTER_TO_MULTI_SCATTER"];
|
|
1085
|
+
const pt = _CreateProcessorTexture(name, defines, _ResolveOutputSize([input]), scene, undefined, outputOptions);
|
|
1086
|
+
_SetOperandUniforms(pt, input, "textureA", "factorA", false);
|
|
1087
|
+
pt.setFloat("scatterAniso", aniso);
|
|
1088
|
+
try {
|
|
1089
|
+
await _RenderAsync(pt);
|
|
1090
|
+
}
|
|
1091
|
+
catch (error) {
|
|
1092
|
+
input.dispose?.();
|
|
1093
|
+
throw error;
|
|
1094
|
+
}
|
|
1095
|
+
input.dispose?.();
|
|
1096
|
+
_CopyTextureMetadata(input.texture, pt, true);
|
|
1097
|
+
return { texture: pt, dispose: () => pt.dispose() };
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* Compute the OpenPBR thin-walled scatter weights from a transmission operand (T) and a
|
|
1101
|
+
* scatter-strength operand (S). Both operands are read from their R channel (after the operand's
|
|
1102
|
+
* channel swizzle and factor), and each weight is broadcast to all four output channels.
|
|
1103
|
+
*
|
|
1104
|
+
* For each texel:
|
|
1105
|
+
* ```
|
|
1106
|
+
* transmission_weight = T * (1 - S)
|
|
1107
|
+
* subsurface_weight = T * S / (1 - T*(1-S))
|
|
1108
|
+
* ```
|
|
1109
|
+
*
|
|
1110
|
+
* These are the OpenPBR weight values when a thin-walled glTF material combines
|
|
1111
|
+
* KHR_materials_transmission (T = transmissionFactor * transmissionTexture) and
|
|
1112
|
+
* KHR_materials_scatter (S = scatterStrengthFactor * scatterStrengthTexture):
|
|
1113
|
+
* `scatterStrengthFactor` converts a fraction of the coherent transmission budget into
|
|
1114
|
+
* scattered (subsurface) transmission while keeping the total translucency constant.
|
|
1115
|
+
*
|
|
1116
|
+
* When both operands are constants the computation is performed entirely on the CPU.
|
|
1117
|
+
* When either operand has a texture, each weight is computed from T and S in a single GPU pass, so
|
|
1118
|
+
* only the two outputs are quantized. Near T = 1 the subsurface weight divides two small values, and
|
|
1119
|
+
* quantizing intermediates (e.g. T * S or 1 - S to 8 bits) would change it drastically.
|
|
1120
|
+
*
|
|
1121
|
+
* @param name - Base name for any procedural textures created
|
|
1122
|
+
* @param transmission - T operand (transmissionFactor × optional transmissionTexture, R channel)
|
|
1123
|
+
* @param scatter - S operand (scatterStrengthFactor × optional scatterStrengthTexture, R channel)
|
|
1124
|
+
* @param scene - Scene used for GPU passes when textures are involved
|
|
1125
|
+
* @returns `{ transmission, subsurface }` – two operands ready to assign to
|
|
1126
|
+
* `transmissionWeightTexture` / `subsurfaceWeightTexture` (and the corresponding scalar factors)
|
|
1127
|
+
*/
|
|
1128
|
+
export async function ThinWalledScatterWeightsAsync(name, transmission, scatter, scene) {
|
|
1129
|
+
[transmission, scatter] = _KeepMatchingOperandCoordinates(name, [transmission, scatter]);
|
|
1130
|
+
// Constant-only fast path — compute entirely on the CPU.
|
|
1131
|
+
if (!transmission.texture && !scatter.texture) {
|
|
1132
|
+
const transmissionFactor = _EvalConstant(transmission).r;
|
|
1133
|
+
const scatterStrength = _EvalConstant(scatter).r;
|
|
1134
|
+
const transW = transmissionFactor * (1.0 - scatterStrength);
|
|
1135
|
+
const transmittedScatter = transmissionFactor * scatterStrength;
|
|
1136
|
+
// 1 - T(1 - S), written to avoid cancellation near T = 1.
|
|
1137
|
+
const denom = 1.0 - transmissionFactor + transmittedScatter;
|
|
1138
|
+
const ssW = denom > 0.00001 ? transmittedScatter / denom : 0.0;
|
|
1139
|
+
transmission.dispose?.();
|
|
1140
|
+
scatter.dispose?.();
|
|
1141
|
+
return {
|
|
1142
|
+
transmission: { texture: null, factor: new Color4(transW, transW, transW, transW) },
|
|
1143
|
+
subsurface: { texture: null, factor: new Color4(ssW, ssW, ssW, ssW) },
|
|
1144
|
+
};
|
|
1145
|
+
}
|
|
1146
|
+
// GPU path. Each weight is computed from T and S in one pass, so there are no intermediate textures to
|
|
1147
|
+
// quantize. T and S are consumed by both passes and released only after both have run.
|
|
1148
|
+
try {
|
|
1149
|
+
const transW = await _RenderThinWalledWeightAsync(`${name}_transWeight`, "OP_THIN_WALLED_TRANSMISSION_WEIGHT", transmission, scatter, scene);
|
|
1150
|
+
try {
|
|
1151
|
+
const ssW = await _RenderThinWalledWeightAsync(`${name}_subWeight`, "OP_THIN_WALLED_SUBSURFACE_WEIGHT", transmission, scatter, scene);
|
|
1152
|
+
return { transmission: transW, subsurface: ssW };
|
|
1153
|
+
}
|
|
1154
|
+
catch (error) {
|
|
1155
|
+
transW.dispose?.();
|
|
1156
|
+
throw error;
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
finally {
|
|
1160
|
+
transmission.dispose?.();
|
|
1161
|
+
scatter.dispose?.();
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
/**
|
|
1165
|
+
* Renders one thin-walled scatter weight from the transmission and scatter strength operands. The operands
|
|
1166
|
+
* are not disposed, since both weights are computed from them.
|
|
1167
|
+
* @param name - Name for the resulting procedural texture
|
|
1168
|
+
* @param op - Shader operation define
|
|
1169
|
+
* @param transmission - T operand
|
|
1170
|
+
* @param scatter - S operand
|
|
1171
|
+
* @param scene - Scene to create the texture in
|
|
1172
|
+
* @returns An operand whose `texture` holds the weight
|
|
1173
|
+
*/
|
|
1174
|
+
async function _RenderThinWalledWeightAsync(name, op, transmission, scatter, scene) {
|
|
1175
|
+
const allTextures = [];
|
|
1176
|
+
if (transmission.texture) {
|
|
1177
|
+
allTextures.push(transmission.texture);
|
|
1178
|
+
}
|
|
1179
|
+
if (scatter.texture) {
|
|
1180
|
+
allTextures.push(scatter.texture);
|
|
1181
|
+
}
|
|
1182
|
+
const canPropagate = _AllTransformsMatch(allTextures);
|
|
1183
|
+
const bakeTransform = !canPropagate;
|
|
1184
|
+
const defines = [op, ..._BuildOperandDefines(transmission, "A", bakeTransform), ..._BuildOperandDefines(scatter, "B", bakeTransform)];
|
|
1185
|
+
const pt = _CreateProcessorTexture(name, defines, _ResolveOutputSize([transmission, scatter]), scene);
|
|
1186
|
+
_SetOperandUniforms(pt, transmission, "textureA", "factorA", bakeTransform);
|
|
1187
|
+
_SetOperandUniforms(pt, scatter, "textureB", "factorB", bakeTransform);
|
|
1188
|
+
try {
|
|
1189
|
+
await _RenderAsync(pt);
|
|
1190
|
+
}
|
|
1191
|
+
catch (error) {
|
|
1192
|
+
pt.dispose();
|
|
1193
|
+
throw error;
|
|
1194
|
+
}
|
|
1195
|
+
_CopyTextureMetadata(allTextures[0], pt, canPropagate);
|
|
1196
|
+
return { texture: pt, dispose: () => pt.dispose() };
|
|
1197
|
+
}
|
|
798
1198
|
//# sourceMappingURL=textureProcessor.js.map
|