@meimu/mutracer 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/LICENSES/Apache-2.0.txt +202 -0
- package/LICENSES/GLSL-PathTracer-MIT.txt +21 -0
- package/LICENSES/GlMatrix-MIT.txt +19 -0
- package/LICENSES/KinoBloom-MIT.txt +21 -0
- package/LICENSES/OIDNWeb-MIT.txt +21 -0
- package/LICENSES/Octicons-MIT.txt +21 -0
- package/LICENSES/RayTracingRenderer-MIT.txt +21 -0
- package/LICENSES/TinyBVH-MIT.txt +21 -0
- package/LICENSES/WebGPUUtils-MIT.txt +21 -0
- package/LICENSES/ZetaRay-MIT.txt +21 -0
- package/README.md +240 -2
- package/THIRD_PARTY_NOTICES.md +160 -0
- package/dist/assets/bvh.worker.js +1 -0
- package/dist/mutracer.umd.js +14360 -0
- package/docs/api.md +394 -0
- package/docs/bvh.md +141 -0
- package/docs/denoising.md +301 -0
- package/docs/getting-started.md +308 -0
- package/docs/materials.md +281 -0
- package/docs/performance.md +85 -0
- package/docs/post-processing.md +87 -0
- package/docs/progressive-rendering.md +160 -0
- package/docs/sampling.md +40 -0
- package/docs/threejs.md +274 -0
- package/docs/todo.md +61 -0
- package/docs/updates.md +208 -0
- package/lib/Display.d.ts +72 -0
- package/lib/Display.js +123 -0
- package/lib/Display.js.map +1 -0
- package/lib/Engine.d.ts +161 -0
- package/lib/Engine.js +681 -0
- package/lib/Engine.js.map +1 -0
- package/lib/Render.d.ts +265 -0
- package/lib/Render.js +742 -0
- package/lib/Render.js.map +1 -0
- package/lib/RenderLoop.d.ts +79 -0
- package/lib/RenderLoop.js +236 -0
- package/lib/RenderLoop.js.map +1 -0
- package/lib/Sync.d.ts +19 -0
- package/lib/Sync.js +19 -0
- package/lib/Sync.js.map +1 -0
- package/lib/constants.d.ts +2 -0
- package/lib/constants.js +3 -0
- package/lib/constants.js.map +1 -0
- package/lib/main.d.ts +56 -0
- package/lib/main.js +43 -0
- package/lib/main.js.map +1 -0
- package/lib/math.d.ts +23 -0
- package/lib/math.js +56 -0
- package/lib/math.js.map +1 -0
- package/lib/oidn.d.ts +45 -0
- package/lib/oidn.js +42 -0
- package/lib/oidn.js.map +1 -0
- package/lib/oidnBundledWeights.cdn.d.ts +2 -0
- package/lib/oidnBundledWeights.cdn.js +5 -0
- package/lib/oidnBundledWeights.cdn.js.map +1 -0
- package/lib/oidnBundledWeights.d.ts +2 -0
- package/lib/oidnBundledWeights.js +4 -0
- package/lib/oidnBundledWeights.js.map +1 -0
- package/lib/renderer/DisplayPostProcess.d.ts +14 -0
- package/lib/renderer/DisplayPostProcess.js +41 -0
- package/lib/renderer/DisplayPostProcess.js.map +1 -0
- package/lib/renderer/MaterialTable.d.ts +119 -0
- package/lib/renderer/MaterialTable.js +550 -0
- package/lib/renderer/MaterialTable.js.map +1 -0
- package/lib/renderer/OfflineAdaptiveSampling.d.ts +47 -0
- package/lib/renderer/OfflineAdaptiveSampling.js +36 -0
- package/lib/renderer/OfflineAdaptiveSampling.js.map +1 -0
- package/lib/renderer/RenderingPipeline.d.ts +232 -0
- package/lib/renderer/RenderingPipeline.js +18 -0
- package/lib/renderer/RenderingPipeline.js.map +1 -0
- package/lib/renderer/ScratchPool.d.ts +13 -0
- package/lib/renderer/ScratchPool.js +21 -0
- package/lib/renderer/ScratchPool.js.map +1 -0
- package/lib/renderer/TileRender.d.ts +44 -0
- package/lib/renderer/TileRender.js +283 -0
- package/lib/renderer/TileRender.js.map +1 -0
- package/lib/renderer/WGPUBloomPass.d.ts +17 -0
- package/lib/renderer/WGPUBloomPass.js +243 -0
- package/lib/renderer/WGPUBloomPass.js.map +1 -0
- package/lib/renderer/WGPUCanvasSurface.d.ts +21 -0
- package/lib/renderer/WGPUCanvasSurface.js +48 -0
- package/lib/renderer/WGPUCanvasSurface.js.map +1 -0
- package/lib/renderer/WGPUComputePass.d.ts +73 -0
- package/lib/renderer/WGPUComputePass.js +317 -0
- package/lib/renderer/WGPUComputePass.js.map +1 -0
- package/lib/renderer/WGPUFullQuadPass.d.ts +73 -0
- package/lib/renderer/WGPUFullQuadPass.js +389 -0
- package/lib/renderer/WGPUFullQuadPass.js.map +1 -0
- package/lib/renderer/WGPUHDRPeakMeter.d.ts +19 -0
- package/lib/renderer/WGPUHDRPeakMeter.js +112 -0
- package/lib/renderer/WGPUHDRPeakMeter.js.map +1 -0
- package/lib/renderer/WGPUJNLMDenoiser.d.ts +61 -0
- package/lib/renderer/WGPUJNLMDenoiser.js +412 -0
- package/lib/renderer/WGPUJNLMDenoiser.js.map +1 -0
- package/lib/renderer/WGPURayTraceOutput.d.ts +44 -0
- package/lib/renderer/WGPURayTraceOutput.js +368 -0
- package/lib/renderer/WGPURayTraceOutput.js.map +1 -0
- package/lib/renderer/WGPURayTracePass.d.ts +284 -0
- package/lib/renderer/WGPURayTracePass.js +2323 -0
- package/lib/renderer/WGPURayTracePass.js.map +1 -0
- package/lib/renderer/WGPURenderingPipeline.d.ts +9 -0
- package/lib/renderer/WGPURenderingPipeline.js +1448 -0
- package/lib/renderer/WGPURenderingPipeline.js.map +1 -0
- package/lib/renderer/WGPUSceneFeatures.d.ts +3 -0
- package/lib/renderer/WGPUSceneFeatures.js +20 -0
- package/lib/renderer/WGPUSceneFeatures.js.map +1 -0
- package/lib/renderer/WGPUScratchBuffer.d.ts +9 -0
- package/lib/renderer/WGPUScratchBuffer.js +21 -0
- package/lib/renderer/WGPUScratchBuffer.js.map +1 -0
- package/lib/renderer/WGPUScratchTexture.d.ts +10 -0
- package/lib/renderer/WGPUScratchTexture.js +27 -0
- package/lib/renderer/WGPUScratchTexture.js.map +1 -0
- package/lib/renderer/WGPUShaderCache.d.ts +26 -0
- package/lib/renderer/WGPUShaderCache.js +103 -0
- package/lib/renderer/WGPUShaderCache.js.map +1 -0
- package/lib/renderer/WebGLBloomPass.d.ts +18 -0
- package/lib/renderer/WebGLBloomPass.js +113 -0
- package/lib/renderer/WebGLBloomPass.js.map +1 -0
- package/lib/renderer/WebGLFullQuadPass.d.ts +65 -0
- package/lib/renderer/WebGLFullQuadPass.js +208 -0
- package/lib/renderer/WebGLFullQuadPass.js.map +1 -0
- package/lib/renderer/WebGLJNLMDenoiser.d.ts +32 -0
- package/lib/renderer/WebGLJNLMDenoiser.js +328 -0
- package/lib/renderer/WebGLJNLMDenoiser.js.map +1 -0
- package/lib/renderer/WebGLRayTraceOutputPass.d.ts +20 -0
- package/lib/renderer/WebGLRayTraceOutputPass.js +106 -0
- package/lib/renderer/WebGLRayTraceOutputPass.js.map +1 -0
- package/lib/renderer/WebGLRayTracePass.d.ts +142 -0
- package/lib/renderer/WebGLRayTracePass.js +845 -0
- package/lib/renderer/WebGLRayTracePass.js.map +1 -0
- package/lib/renderer/WebGLReadback.d.ts +4 -0
- package/lib/renderer/WebGLReadback.js +75 -0
- package/lib/renderer/WebGLReadback.js.map +1 -0
- package/lib/renderer/WebGLRenderingPipeline.d.ts +4 -0
- package/lib/renderer/WebGLRenderingPipeline.js +510 -0
- package/lib/renderer/WebGLRenderingPipeline.js.map +1 -0
- package/lib/renderer/WebGLScratchCopy.d.ts +10 -0
- package/lib/renderer/WebGLScratchCopy.js +27 -0
- package/lib/renderer/WebGLScratchCopy.js.map +1 -0
- package/lib/renderer/accumulationTarget.d.ts +26 -0
- package/lib/renderer/accumulationTarget.js +2 -0
- package/lib/renderer/accumulationTarget.js.map +1 -0
- package/lib/renderer/binnedSahBvh.d.ts +31 -0
- package/lib/renderer/binnedSahBvh.js +263 -0
- package/lib/renderer/binnedSahBvh.js.map +1 -0
- package/lib/renderer/bvh.worker.d.ts +1 -0
- package/lib/renderer/bvh.worker.js +16 -0
- package/lib/renderer/bvh.worker.js.map +1 -0
- package/lib/renderer/bvhAccel.d.ts +81 -0
- package/lib/renderer/bvhAccel.js +621 -0
- package/lib/renderer/bvhAccel.js.map +1 -0
- package/lib/renderer/bvhWorkerBuild.d.ts +12 -0
- package/lib/renderer/bvhWorkerBuild.js +17 -0
- package/lib/renderer/bvhWorkerBuild.js.map +1 -0
- package/lib/renderer/bvhWorkerClient.d.ts +57 -0
- package/lib/renderer/bvhWorkerClient.js +166 -0
- package/lib/renderer/bvhWorkerClient.js.map +1 -0
- package/lib/renderer/cameraLens.d.ts +5 -0
- package/lib/renderer/cameraLens.js +15 -0
- package/lib/renderer/cameraLens.js.map +1 -0
- package/lib/renderer/cameraSnapshot.d.ts +3 -0
- package/lib/renderer/cameraSnapshot.js +7 -0
- package/lib/renderer/cameraSnapshot.js.map +1 -0
- package/lib/renderer/committedScene.d.ts +13 -0
- package/lib/renderer/committedScene.js +126 -0
- package/lib/renderer/committedScene.js.map +1 -0
- package/lib/renderer/dataTextureUtil.d.ts +32 -0
- package/lib/renderer/dataTextureUtil.js +46 -0
- package/lib/renderer/dataTextureUtil.js.map +1 -0
- package/lib/renderer/denoiser.d.ts +65 -0
- package/lib/renderer/denoiser.js +2 -0
- package/lib/renderer/denoiser.js.map +1 -0
- package/lib/renderer/depthQuery.d.ts +14 -0
- package/lib/renderer/depthQuery.js +14 -0
- package/lib/renderer/depthQuery.js.map +1 -0
- package/lib/renderer/deviceRequirements.d.ts +23 -0
- package/lib/renderer/deviceRequirements.js +50 -0
- package/lib/renderer/deviceRequirements.js.map +1 -0
- package/lib/renderer/envMapCreation.d.ts +10 -0
- package/lib/renderer/envMapCreation.js +96 -0
- package/lib/renderer/envMapCreation.js.map +1 -0
- package/lib/renderer/envMapDistribution.d.ts +9 -0
- package/lib/renderer/envMapDistribution.js +107 -0
- package/lib/renderer/envMapDistribution.js.map +1 -0
- package/lib/renderer/float16.d.ts +1 -0
- package/lib/renderer/float16.js +19 -0
- package/lib/renderer/float16.js.map +1 -0
- package/lib/renderer/geometryBvh.d.ts +11 -0
- package/lib/renderer/geometryBvh.js +24 -0
- package/lib/renderer/geometryBvh.js.map +1 -0
- package/lib/renderer/geometryUpdates.d.ts +28 -0
- package/lib/renderer/geometryUpdates.js +131 -0
- package/lib/renderer/geometryUpdates.js.map +1 -0
- package/lib/renderer/glsl/chunks/cameraRay.glsl.d.ts +2 -0
- package/lib/renderer/glsl/chunks/cameraRay.glsl.js +37 -0
- package/lib/renderer/glsl/chunks/cameraRay.glsl.js.map +1 -0
- package/lib/renderer/glsl/chunks/common.glsl.d.ts +2 -0
- package/lib/renderer/glsl/chunks/common.glsl.js +17 -0
- package/lib/renderer/glsl/chunks/common.glsl.js.map +1 -0
- package/lib/renderer/glsl/chunks/envMap.glsl.d.ts +2 -0
- package/lib/renderer/glsl/chunks/envMap.glsl.js +192 -0
- package/lib/renderer/glsl/chunks/envMap.glsl.js.map +1 -0
- package/lib/renderer/glsl/chunks/intersect.glsl.d.ts +2 -0
- package/lib/renderer/glsl/chunks/intersect.glsl.js +1091 -0
- package/lib/renderer/glsl/chunks/intersect.glsl.js.map +1 -0
- package/lib/renderer/glsl/chunks/materialBuffer.glsl.d.ts +2 -0
- package/lib/renderer/glsl/chunks/materialBuffer.glsl.js +371 -0
- package/lib/renderer/glsl/chunks/materialBuffer.glsl.js.map +1 -0
- package/lib/renderer/glsl/chunks/openPbrBsdf.glsl.d.ts +2 -0
- package/lib/renderer/glsl/chunks/openPbrBsdf.glsl.js +1767 -0
- package/lib/renderer/glsl/chunks/openPbrBsdf.glsl.js.map +1 -0
- package/lib/renderer/glsl/chunks/rand.glsl.d.ts +2 -0
- package/lib/renderer/glsl/chunks/rand.glsl.js +26 -0
- package/lib/renderer/glsl/chunks/rand.glsl.js.map +1 -0
- package/lib/renderer/glsl/chunks/random.glsl.d.ts +2 -0
- package/lib/renderer/glsl/chunks/random.glsl.js +27 -0
- package/lib/renderer/glsl/chunks/random.glsl.js.map +1 -0
- package/lib/renderer/glsl/chunks/rayTraceCore.glsl.d.ts +2 -0
- package/lib/renderer/glsl/chunks/rayTraceCore.glsl.js +287 -0
- package/lib/renderer/glsl/chunks/rayTraceCore.glsl.js.map +1 -0
- package/lib/renderer/glsl/chunks/sampleLight.glsl.d.ts +2 -0
- package/lib/renderer/glsl/chunks/sampleLight.glsl.js +254 -0
- package/lib/renderer/glsl/chunks/sampleLight.glsl.js.map +1 -0
- package/lib/renderer/glsl/chunks/sampleMaterial.glsl.d.ts +2 -0
- package/lib/renderer/glsl/chunks/sampleMaterial.glsl.js +279 -0
- package/lib/renderer/glsl/chunks/sampleMaterial.glsl.js.map +1 -0
- package/lib/renderer/glsl/chunks/sampleShadowCatcher.glsl.d.ts +2 -0
- package/lib/renderer/glsl/chunks/sampleShadowCatcher.glsl.js +48 -0
- package/lib/renderer/glsl/chunks/sampleShadowCatcher.glsl.js.map +1 -0
- package/lib/renderer/glsl/chunks/sampling.glsl.d.ts +2 -0
- package/lib/renderer/glsl/chunks/sampling.glsl.js +194 -0
- package/lib/renderer/glsl/chunks/sampling.glsl.js.map +1 -0
- package/lib/renderer/glsl/chunks/sobol.glsl.d.ts +2 -0
- package/lib/renderer/glsl/chunks/sobol.glsl.js +170 -0
- package/lib/renderer/glsl/chunks/sobol.glsl.js.map +1 -0
- package/lib/renderer/glsl/chunks/textureLinear.glsl.d.ts +2 -0
- package/lib/renderer/glsl/chunks/textureLinear.glsl.js +27 -0
- package/lib/renderer/glsl/chunks/textureLinear.glsl.js.map +1 -0
- package/lib/renderer/glsl/chunks/uvProjection.glsl.d.ts +2 -0
- package/lib/renderer/glsl/chunks/uvProjection.glsl.js +72 -0
- package/lib/renderer/glsl/chunks/uvProjection.glsl.js.map +1 -0
- package/lib/renderer/glsl/depthQuery.frag.d.ts +3 -0
- package/lib/renderer/glsl/depthQuery.frag.js +55 -0
- package/lib/renderer/glsl/depthQuery.frag.js.map +1 -0
- package/lib/renderer/glsl/normalizeRayTraceOutput.frag.d.ts +6 -0
- package/lib/renderer/glsl/normalizeRayTraceOutput.frag.js +46 -0
- package/lib/renderer/glsl/normalizeRayTraceOutput.frag.js.map +1 -0
- package/lib/renderer/glsl/rayTrace.frag.d.ts +2 -0
- package/lib/renderer/glsl/rayTrace.frag.js +623 -0
- package/lib/renderer/glsl/rayTrace.frag.js.map +1 -0
- package/lib/renderer/glsl/shadowCatcher.frag.d.ts +3 -0
- package/lib/renderer/glsl/shadowCatcher.frag.js +119 -0
- package/lib/renderer/glsl/shadowCatcher.frag.js.map +1 -0
- package/lib/renderer/glsl/webglPipeline.frag.d.ts +4 -0
- package/lib/renderer/glsl/webglPipeline.frag.js +208 -0
- package/lib/renderer/glsl/webglPipeline.frag.js.map +1 -0
- package/lib/renderer/gpuMemory.d.ts +2 -0
- package/lib/renderer/gpuMemory.js +10 -0
- package/lib/renderer/gpuMemory.js.map +1 -0
- package/lib/renderer/halton.d.ts +1 -0
- package/lib/renderer/halton.js +15 -0
- package/lib/renderer/halton.js.map +1 -0
- package/lib/renderer/jnlm.d.ts +85 -0
- package/lib/renderer/jnlm.js +87 -0
- package/lib/renderer/jnlm.js.map +1 -0
- package/lib/renderer/lightSampling.d.ts +75 -0
- package/lib/renderer/lightSampling.js +305 -0
- package/lib/renderer/lightSampling.js.map +1 -0
- package/lib/renderer/lightsUtil.d.ts +26 -0
- package/lib/renderer/lightsUtil.js +154 -0
- package/lib/renderer/lightsUtil.js.map +1 -0
- package/lib/renderer/materialChanges.d.ts +13 -0
- package/lib/renderer/materialChanges.js +59 -0
- package/lib/renderer/materialChanges.js.map +1 -0
- package/lib/renderer/materialComparison.generated.d.ts +5 -0
- package/lib/renderer/materialComparison.generated.js +655 -0
- package/lib/renderer/materialComparison.generated.js.map +1 -0
- package/lib/renderer/materialConstants.d.ts +6 -0
- package/lib/renderer/materialConstants.js +3 -0
- package/lib/renderer/materialConstants.js.map +1 -0
- package/lib/renderer/materialEmission.d.ts +9 -0
- package/lib/renderer/materialEmission.js +21 -0
- package/lib/renderer/materialEmission.js.map +1 -0
- package/lib/renderer/materialIndices.d.ts +7 -0
- package/lib/renderer/materialIndices.js +34 -0
- package/lib/renderer/materialIndices.js.map +1 -0
- package/lib/renderer/materialLayout.d.ts +102 -0
- package/lib/renderer/materialLayout.js +189 -0
- package/lib/renderer/materialLayout.js.map +1 -0
- package/lib/renderer/materialTextureSlots.d.ts +537 -0
- package/lib/renderer/materialTextureSlots.js +219 -0
- package/lib/renderer/materialTextureSlots.js.map +1 -0
- package/lib/renderer/mergeMeshesToGeometry.d.ts +8 -0
- package/lib/renderer/mergeMeshesToGeometry.js +236 -0
- package/lib/renderer/mergeMeshesToGeometry.js.map +1 -0
- package/lib/renderer/meshInstances.d.ts +23 -0
- package/lib/renderer/meshInstances.js +66 -0
- package/lib/renderer/meshInstances.js.map +1 -0
- package/lib/renderer/meshMembership.d.ts +10 -0
- package/lib/renderer/meshMembership.js +72 -0
- package/lib/renderer/meshMembership.js.map +1 -0
- package/lib/renderer/oidnNetwork.d.ts +20 -0
- package/lib/renderer/oidnNetwork.js +123 -0
- package/lib/renderer/oidnNetwork.js.map +1 -0
- package/lib/renderer/openPbrEnergyLut.d.ts +32 -0
- package/lib/renderer/openPbrEnergyLut.js +965 -0
- package/lib/renderer/openPbrEnergyLut.js.map +1 -0
- package/lib/renderer/pathLimits.d.ts +4 -0
- package/lib/renderer/pathLimits.js +7 -0
- package/lib/renderer/pathLimits.js.map +1 -0
- package/lib/renderer/prepareMeshBVH.d.ts +110 -0
- package/lib/renderer/prepareMeshBVH.js +857 -0
- package/lib/renderer/prepareMeshBVH.js.map +1 -0
- package/lib/renderer/progressiveScheduler.d.ts +11 -0
- package/lib/renderer/progressiveScheduler.js +19 -0
- package/lib/renderer/progressiveScheduler.js.map +1 -0
- package/lib/renderer/renderPipeline.d.ts +57 -0
- package/lib/renderer/renderPipeline.js +49 -0
- package/lib/renderer/renderPipeline.js.map +1 -0
- package/lib/renderer/sampling.d.ts +10 -0
- package/lib/renderer/sampling.js +28 -0
- package/lib/renderer/sampling.js.map +1 -0
- package/lib/renderer/sceneChangeDetector.d.ts +29 -0
- package/lib/renderer/sceneChangeDetector.js +232 -0
- package/lib/renderer/sceneChangeDetector.js.map +1 -0
- package/lib/renderer/sceneLightChanges.d.ts +14 -0
- package/lib/renderer/sceneLightChanges.js +34 -0
- package/lib/renderer/sceneLightChanges.js.map +1 -0
- package/lib/renderer/scratchSampling.d.ts +3 -0
- package/lib/renderer/scratchSampling.js +39 -0
- package/lib/renderer/scratchSampling.js.map +1 -0
- package/lib/renderer/shader.d.ts +37 -0
- package/lib/renderer/shader.js +41 -0
- package/lib/renderer/shader.js.map +1 -0
- package/lib/renderer/staticBvhPreparation.d.ts +24 -0
- package/lib/renderer/staticBvhPreparation.js +116 -0
- package/lib/renderer/staticBvhPreparation.js.map +1 -0
- package/lib/renderer/textureRegion.d.ts +8 -0
- package/lib/renderer/textureRegion.js +9 -0
- package/lib/renderer/textureRegion.js.map +1 -0
- package/lib/renderer/texturesFromMaterials.d.ts +6 -0
- package/lib/renderer/texturesFromMaterials.js +37 -0
- package/lib/renderer/texturesFromMaterials.js.map +1 -0
- package/lib/renderer/util.d.ts +17 -0
- package/lib/renderer/util.js +56 -0
- package/lib/renderer/util.js.map +1 -0
- package/lib/renderer/webgl.d.ts +131 -0
- package/lib/renderer/webgl.js +586 -0
- package/lib/renderer/webgl.js.map +1 -0
- package/lib/renderer/webglShaders.d.ts +4 -0
- package/lib/renderer/webglShaders.js +41 -0
- package/lib/renderer/webglShaders.js.map +1 -0
- package/lib/renderer/wgsl/chunks/common.wgsl.d.ts +2 -0
- package/lib/renderer/wgsl/chunks/common.wgsl.js +23 -0
- package/lib/renderer/wgsl/chunks/common.wgsl.js.map +1 -0
- package/lib/renderer/wgsl/chunks/envMap.wgsl.d.ts +2 -0
- package/lib/renderer/wgsl/chunks/envMap.wgsl.js +128 -0
- package/lib/renderer/wgsl/chunks/envMap.wgsl.js.map +1 -0
- package/lib/renderer/wgsl/chunks/intersect.wgsl.d.ts +6 -0
- package/lib/renderer/wgsl/chunks/intersect.wgsl.js +1441 -0
- package/lib/renderer/wgsl/chunks/intersect.wgsl.js.map +1 -0
- package/lib/renderer/wgsl/chunks/intersectionAlpha.wgsl.d.ts +8 -0
- package/lib/renderer/wgsl/chunks/intersectionAlpha.wgsl.js +85 -0
- package/lib/renderer/wgsl/chunks/intersectionAlpha.wgsl.js.map +1 -0
- package/lib/renderer/wgsl/chunks/materialBuffer.wgsl.d.ts +7 -0
- package/lib/renderer/wgsl/chunks/materialBuffer.wgsl.js +315 -0
- package/lib/renderer/wgsl/chunks/materialBuffer.wgsl.js.map +1 -0
- package/lib/renderer/wgsl/chunks/openPbrBsdf.wgsl.d.ts +3 -0
- package/lib/renderer/wgsl/chunks/openPbrBsdf.wgsl.js +1737 -0
- package/lib/renderer/wgsl/chunks/openPbrBsdf.wgsl.js.map +1 -0
- package/lib/renderer/wgsl/chunks/pdm_displacement.wgsl.d.ts +4 -0
- package/lib/renderer/wgsl/chunks/pdm_displacement.wgsl.js +352 -0
- package/lib/renderer/wgsl/chunks/pdm_displacement.wgsl.js.map +1 -0
- package/lib/renderer/wgsl/chunks/rand.wgsl.d.ts +2 -0
- package/lib/renderer/wgsl/chunks/rand.wgsl.js +25 -0
- package/lib/renderer/wgsl/chunks/rand.wgsl.js.map +1 -0
- package/lib/renderer/wgsl/chunks/random.wgsl.d.ts +1 -0
- package/lib/renderer/wgsl/chunks/random.wgsl.js +2 -0
- package/lib/renderer/wgsl/chunks/random.wgsl.js.map +1 -0
- package/lib/renderer/wgsl/chunks/rayTraceCore.wgsl.d.ts +5 -0
- package/lib/renderer/wgsl/chunks/rayTraceCore.wgsl.js +328 -0
- package/lib/renderer/wgsl/chunks/rayTraceCore.wgsl.js.map +1 -0
- package/lib/renderer/wgsl/chunks/sampleLight.wgsl.d.ts +2 -0
- package/lib/renderer/wgsl/chunks/sampleLight.wgsl.js +400 -0
- package/lib/renderer/wgsl/chunks/sampleLight.wgsl.js.map +1 -0
- package/lib/renderer/wgsl/chunks/sampleMaterial.wgsl.d.ts +3 -0
- package/lib/renderer/wgsl/chunks/sampleMaterial.wgsl.js +439 -0
- package/lib/renderer/wgsl/chunks/sampleMaterial.wgsl.js.map +1 -0
- package/lib/renderer/wgsl/chunks/sampleShadowCatcher.wgsl.d.ts +2 -0
- package/lib/renderer/wgsl/chunks/sampleShadowCatcher.wgsl.js +40 -0
- package/lib/renderer/wgsl/chunks/sampleShadowCatcher.wgsl.js.map +1 -0
- package/lib/renderer/wgsl/chunks/sampling.wgsl.d.ts +2 -0
- package/lib/renderer/wgsl/chunks/sampling.wgsl.js +198 -0
- package/lib/renderer/wgsl/chunks/sampling.wgsl.js.map +1 -0
- package/lib/renderer/wgsl/chunks/shadowCatcherAccumulation.wgsl.d.ts +8 -0
- package/lib/renderer/wgsl/chunks/shadowCatcherAccumulation.wgsl.js +16 -0
- package/lib/renderer/wgsl/chunks/shadowCatcherAccumulation.wgsl.js.map +1 -0
- package/lib/renderer/wgsl/chunks/sobol.wgsl.d.ts +2 -0
- package/lib/renderer/wgsl/chunks/sobol.wgsl.js +170 -0
- package/lib/renderer/wgsl/chunks/sobol.wgsl.js.map +1 -0
- package/lib/renderer/wgsl/chunks/uvProjection.wgsl.d.ts +2 -0
- package/lib/renderer/wgsl/chunks/uvProjection.wgsl.js +42 -0
- package/lib/renderer/wgsl/chunks/uvProjection.wgsl.js.map +1 -0
- package/lib/renderer/wgsl/compose.frag.wgsl.d.ts +5 -0
- package/lib/renderer/wgsl/compose.frag.wgsl.js +218 -0
- package/lib/renderer/wgsl/compose.frag.wgsl.js.map +1 -0
- package/lib/renderer/wgsl/customDenoise.wgsl.d.ts +4 -0
- package/lib/renderer/wgsl/customDenoise.wgsl.js +28 -0
- package/lib/renderer/wgsl/customDenoise.wgsl.js.map +1 -0
- package/lib/renderer/wgsl/depthQuery.wgsl.d.ts +3 -0
- package/lib/renderer/wgsl/depthQuery.wgsl.js +34 -0
- package/lib/renderer/wgsl/depthQuery.wgsl.js.map +1 -0
- package/lib/renderer/wgsl/offlineAdaptive.compute.d.ts +2 -0
- package/lib/renderer/wgsl/offlineAdaptive.compute.js +108 -0
- package/lib/renderer/wgsl/offlineAdaptive.compute.js.map +1 -0
- package/lib/renderer/wgsl/rayTrace.compute.d.ts +16 -0
- package/lib/renderer/wgsl/rayTrace.compute.js +927 -0
- package/lib/renderer/wgsl/rayTrace.compute.js.map +1 -0
- package/lib/scene/AmbientLight.d.ts +17 -0
- package/lib/scene/AmbientLight.js +15 -0
- package/lib/scene/AmbientLight.js.map +1 -0
- package/lib/scene/Camera.d.ts +78 -0
- package/lib/scene/Camera.js +111 -0
- package/lib/scene/Camera.js.map +1 -0
- package/lib/scene/DirectionalLight.d.ts +18 -0
- package/lib/scene/DirectionalLight.js +17 -0
- package/lib/scene/DirectionalLight.js.map +1 -0
- package/lib/scene/EnvironmentLight.d.ts +14 -0
- package/lib/scene/EnvironmentLight.js +14 -0
- package/lib/scene/EnvironmentLight.js.map +1 -0
- package/lib/scene/Geometry.d.ts +87 -0
- package/lib/scene/Geometry.js +108 -0
- package/lib/scene/Geometry.js.map +1 -0
- package/lib/scene/IESProfile.d.ts +19 -0
- package/lib/scene/IESProfile.js +165 -0
- package/lib/scene/IESProfile.js.map +1 -0
- package/lib/scene/InstancedMesh.d.ts +43 -0
- package/lib/scene/InstancedMesh.js +79 -0
- package/lib/scene/InstancedMesh.js.map +1 -0
- package/lib/scene/Mesh.d.ts +14 -0
- package/lib/scene/Mesh.js +17 -0
- package/lib/scene/Mesh.js.map +1 -0
- package/lib/scene/OpenPBRMaterial.d.ts +224 -0
- package/lib/scene/OpenPBRMaterial.js +240 -0
- package/lib/scene/OpenPBRMaterial.js.map +1 -0
- package/lib/scene/RectLight.d.ts +31 -0
- package/lib/scene/RectLight.js +26 -0
- package/lib/scene/RectLight.js.map +1 -0
- package/lib/scene/Scene.d.ts +55 -0
- package/lib/scene/Scene.js +2 -0
- package/lib/scene/Scene.js.map +1 -0
- package/lib/scene/SceneNode.d.ts +16 -0
- package/lib/scene/SceneNode.js +33 -0
- package/lib/scene/SceneNode.js.map +1 -0
- package/lib/scene/SphereLight.d.ts +22 -0
- package/lib/scene/SphereLight.js +20 -0
- package/lib/scene/SphereLight.js.map +1 -0
- package/lib/scene/SpotLight.d.ts +35 -0
- package/lib/scene/SpotLight.js +29 -0
- package/lib/scene/SpotLight.js.map +1 -0
- package/lib/scene/Texture.d.ts +38 -0
- package/lib/scene/Texture.js +37 -0
- package/lib/scene/Texture.js.map +1 -0
- package/lib/scene/anisotropyParameters.d.ts +1 -0
- package/lib/scene/anisotropyParameters.js +13 -0
- package/lib/scene/anisotropyParameters.js.map +1 -0
- package/lib/scene/geometryChanges.d.ts +5 -0
- package/lib/scene/geometryChanges.js +18 -0
- package/lib/scene/geometryChanges.js.map +1 -0
- package/lib/scene/materialTextureNames.d.ts +2 -0
- package/lib/scene/materialTextureNames.js +9 -0
- package/lib/scene/materialTextureNames.js.map +1 -0
- package/lib/scene/openPbrSchema.d.ts +400 -0
- package/lib/scene/openPbrSchema.js +149 -0
- package/lib/scene/openPbrSchema.js.map +1 -0
- package/lib/scene/thinFilmParameters.d.ts +4 -0
- package/lib/scene/thinFilmParameters.js +12 -0
- package/lib/scene/thinFilmParameters.js.map +1 -0
- package/lib/settings/display.d.ts +118 -0
- package/lib/settings/display.js +34 -0
- package/lib/settings/display.js.map +1 -0
- package/lib/settings/engine.d.ts +37 -0
- package/lib/settings/engine.js +26 -0
- package/lib/settings/engine.js.map +1 -0
- package/lib/settings/render.d.ts +178 -0
- package/lib/settings/render.js +36 -0
- package/lib/settings/render.js.map +1 -0
- package/lib/tinybvh/LICENSE +21 -0
- package/lib/tinybvh/TinyBvhBuilder.d.ts +17 -0
- package/lib/tinybvh/TinyBvhBuilder.js +211 -0
- package/lib/tinybvh/TinyBvhBuilder.js.map +1 -0
- package/lib/tinybvh/tinybvh.wasm +0 -0
- package/lib/types.d.ts +13 -0
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -0
- package/lib/util/canvas.d.ts +2 -0
- package/lib/util/canvas.js +13 -0
- package/lib/util/canvas.js.map +1 -0
- package/lib/util/commonGeometry.d.ts +15 -0
- package/lib/util/commonGeometry.js +240 -0
- package/lib/util/commonGeometry.js.map +1 -0
- package/lib/util/events.d.ts +7 -0
- package/lib/util/events.js +23 -0
- package/lib/util/events.js.map +1 -0
- package/lib/util/frame.d.ts +2 -0
- package/lib/util/frame.js +10 -0
- package/lib/util/frame.js.map +1 -0
- package/lib/util/fromTHREE.d.ts +105 -0
- package/lib/util/fromTHREE.js +1111 -0
- package/lib/util/fromTHREE.js.map +1 -0
- package/lib/util/geometry.d.ts +13 -0
- package/lib/util/geometry.js +292 -0
- package/lib/util/geometry.js.map +1 -0
- package/lib/util/loadRGBE.d.ts +7 -0
- package/lib/util/loadRGBE.js +168 -0
- package/lib/util/loadRGBE.js.map +1 -0
- package/lib/util/math.d.ts +8 -0
- package/lib/util/math.js +64 -0
- package/lib/util/math.js.map +1 -0
- package/lib/util/mesh.d.ts +7 -0
- package/lib/util/mesh.js +20 -0
- package/lib/util/mesh.js.map +1 -0
- package/lib/util/threeDeformation.d.ts +20 -0
- package/lib/util/threeDeformation.js +218 -0
- package/lib/util/threeDeformation.js.map +1 -0
- package/lib/version.d.ts +2 -0
- package/lib/version.js +3 -0
- package/lib/version.js.map +1 -0
- package/llms.txt +62 -0
- package/oidn/weights/LICENSE.txt +202 -0
- package/oidn/weights/README.md +43 -0
- package/oidn/weights/rt_hdr_alb_nrm.tza +0 -0
- package/oidn/weights/rt_hdr_alb_nrm_small.tza +0 -0
- package/package.json +124 -4
package/docs/threejs.md
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
# Three.js integration
|
|
2
|
+
|
|
3
|
+
Build or load a Three.js scene, then bind it and its camera with THREESync.
|
|
4
|
+
RenderLoop calls the sync automatically. Three.js is an optional peer dependency
|
|
5
|
+
(`npm install three`).
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import * as THREE from 'three';
|
|
9
|
+
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
10
|
+
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
|
|
11
|
+
import { Engine, RenderLoop, THREESync } from '@meimu/mutracer';
|
|
12
|
+
const scene = new THREE.Scene();
|
|
13
|
+
scene.add((await new GLTFLoader().loadAsync('model.glb')).scene);
|
|
14
|
+
const camera = new THREE.PerspectiveCamera(40, canvas.width / canvas.height, .1, 100);
|
|
15
|
+
camera.position.set(0, 2, 6);
|
|
16
|
+
const controls = new OrbitControls(camera, canvas);
|
|
17
|
+
const engine = new Engine({canvas});
|
|
18
|
+
const sync = new THREESync(engine, {scene, camera, controls});
|
|
19
|
+
const loop = new RenderLoop(engine, {sync});
|
|
20
|
+
loop.start();
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Keeping scenes in sync
|
|
24
|
+
|
|
25
|
+
Edit Three.js transforms, membership, lights, backgrounds and materials directly.
|
|
26
|
+
Material edits are converted automatically; color and roughness
|
|
27
|
+
edits do not require `material.needsUpdate`. Buffer and pixel edits need the
|
|
28
|
+
usual flags:
|
|
29
|
+
|
|
30
|
+
| Edit | Flag |
|
|
31
|
+
| --- | --- |
|
|
32
|
+
| Attribute or index array elements | `attribute.needsUpdate = true` (`attribute.data.needsUpdate` for interleaved) |
|
|
33
|
+
| Texture pixels or canvas | `texture.needsUpdate = true` |
|
|
34
|
+
| Instance matrices / colors | `instanceMatrix.needsUpdate` / `instanceColor.needsUpdate = true` |
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
threeMesh.rotation.y += .01;
|
|
38
|
+
threeMaterial.roughness = .6;
|
|
39
|
+
geometry.attributes.position.setX(0, .5);
|
|
40
|
+
geometry.attributes.position.needsUpdate = true;
|
|
41
|
+
// The next loop tick synchronizes and commits these edits.
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
For an application-owned animation frame, update the animation mixer first,
|
|
45
|
+
then call `loop.tick()`. With first-layer frame control, call `sync.update()`,
|
|
46
|
+
`engine.update()`, `render.refine()` and `engine.display.present(render)` in order.
|
|
47
|
+
|
|
48
|
+
## What is converted
|
|
49
|
+
|
|
50
|
+
| Three.js | MuTracer |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| `Mesh` with `MeshStandardMaterial` / `MeshPhysicalMaterial` | `Mesh` + `OpenPBRMaterial` (color, metalness, roughness, maps, normal map, emissive, transmission, attenuation, IOR, clearcoat, sheen, iridescence, anisotropy, alpha) |
|
|
53
|
+
| `Mesh` with `MeshBasicMaterial` (glTF `KHR_materials_unlit`) | Unlit emissive material |
|
|
54
|
+
| `MeshPhysicalMaterial.clearcoat`, `.clearcoatRoughness` (glTF `KHR_materials_clearcoat`) | `coatWeight`, `coatRoughness`, with `coatIor = 1.5` and `coatDarkening = 0` for Three.js compatibility; explicit `userData.mutracerOpenPBR.coatDarkening` overrides the imported value |
|
|
55
|
+
| `MeshPhysicalMaterial.sheen`, `.sheenColor`, `.sheenRoughness` | `fuzzWeight`, `fuzzColor`, `fuzzRoughness`; explicit `userData.mutracerOpenPBR.fuzzRoughness` overrides imported roughness |
|
|
56
|
+
| `MeshPhysicalMaterial.iridescenceThicknessMap`, `.iridescenceThicknessRange` | `thinFilmMap` with `thinFilmMapChannel = 'g'`; both nm endpoints are divided by 1000 into `thinFilmThicknessMinimum` / `thinFilmThickness`; without a map only the maximum is used |
|
|
57
|
+
| `MeshPhysicalMaterial.clearcoatMap`, `.clearcoatRoughnessMap` | `coatWeightMap` (linear R), `coatRoughnessMap` (linear G) |
|
|
58
|
+
| `MeshPhysicalMaterial.clearcoatNormalMap`, `.clearcoatNormalScale` | `coatNormalMap` (linear RGB), independent `coatNormalScale`; see [coat normals](./materials.md#coat-normals) |
|
|
59
|
+
| `MeshPhysicalMaterial.sheenColorMap`, `.sheenRoughnessMap` | `fuzzColorMap` (sRGB RGB), `fuzzRoughnessMap` (linear A) |
|
|
60
|
+
| `MeshPhysicalMaterial.specularIntensityMap`, `.specularColorMap` | `specularWeightMap` (linear A), `specularColorMap` (sRGB RGB) |
|
|
61
|
+
| `MeshPhysicalMaterial.anisotropy`, `.anisotropyRotation`, `.anisotropyMap` | Source strength, rotation and direction texture; see [anisotropy source conversion](#anisotropy-source-conversion) |
|
|
62
|
+
| `SkinnedMesh` / mesh with morph targets | CPU-deformed dynamic geometry |
|
|
63
|
+
| `InstancedMesh` | One InstancedMesh per material group, with native colors, sharing geometry and BLAS |
|
|
64
|
+
| Multi-material groups | One MuTracer mesh per group |
|
|
65
|
+
| `DirectionalLight` | `DirectionalLight` |
|
|
66
|
+
| `PointLight` | `SphereLight` (radius `userData.mutracerRadius`, default 0.25) |
|
|
67
|
+
| `SpotLight` | `SpotLight` (radius `userData.mutracerRadius`, default 0.01; `penumbra` sets the inner angle) |
|
|
68
|
+
| `RectAreaLight` | `RectLight` |
|
|
69
|
+
| `AmbientLight` | `AmbientLight` |
|
|
70
|
+
| `scene.environment` (equirectangular float `DataTexture`, e.g. from `HDRLoader`/`RGBELoader`) | `EnvironmentLight` |
|
|
71
|
+
| `scene.background` color / texture | Background; the environment itself when `background === environment` |
|
|
72
|
+
|
|
73
|
+
Three.js `opacity` maps to `geometryOpacity`; thin-shell choices map to
|
|
74
|
+
`geometryThinWalled`. Metadata accepts the five [canonical and compatibility
|
|
75
|
+
names](./materials.md#compatibility-names), using the constructor's equal-value
|
|
76
|
+
or conflict rule. These overrides apply after standard conversion; alpha mode
|
|
77
|
+
still follows the source material flags and resolved coverage. Naming does not
|
|
78
|
+
change transmission, volume or anisotropy conversion semantics.
|
|
79
|
+
|
|
80
|
+
Thin-film ranges keep their endpoint order, including minimum greater than
|
|
81
|
+
maximum, and retain the converter's 0–20 µm endpoint clamp. The converter uses
|
|
82
|
+
Three.js's actual range defaults. `mutracerOpenPBR` may explicitly override the
|
|
83
|
+
range, channel and map after conversion; its map accepts a MuTracer `Texture`
|
|
84
|
+
or a source `THREE.Texture`. `THREESync` converts parameter edits without
|
|
85
|
+
rewriting texture pixels. The iridescence strength texture is not supported;
|
|
86
|
+
`thinFilmMap` represents thickness only.
|
|
87
|
+
|
|
88
|
+
The six layer maps reuse the texture conversion cache, source UV channel,
|
|
89
|
+
scale, offset and flipY. `mutracerOpenPBR` can override them with a MuTracer
|
|
90
|
+
`Texture` or `THREE.Texture`; explicit `null` clears an imported map, while
|
|
91
|
+
unknown JSON objects are ignored. `THREESync` follows texture edits without
|
|
92
|
+
copying pixels. General `KHR_texture_transform` rotation remains unsupported.
|
|
93
|
+
Clearcoat normals are deferred to the independent coat-frame implementation.
|
|
94
|
+
Anisotropy direction and source-model mapping are described [below](#anisotropy-source-conversion). The conversion preserves OpenPBR layering: glTF sheen
|
|
95
|
+
layer order differs, and specular weight/color also affect metals in OpenPBR;
|
|
96
|
+
these imports do not imply identical glTF BRDFs.
|
|
97
|
+
|
|
98
|
+
Invisible objects are skipped. Other material types are skipped with a console
|
|
99
|
+
warning unless `convertMaterial` supplies an OpenPBR material. `BatchedMesh`, instanced morph targets (`morphTexture`) and skinned
|
|
100
|
+
instancing are unsupported: each source object warns once per converter and is
|
|
101
|
+
converted as an ordinary mesh, without per-instance matrices or colors.
|
|
102
|
+
|
|
103
|
+
Meshes without UVs get automatic triplanar texture and displacement
|
|
104
|
+
projection; explicit
|
|
105
|
+
`mutracerUvProjection` settings take precedence.
|
|
106
|
+
|
|
107
|
+
## Skinning and morph targets
|
|
108
|
+
|
|
109
|
+
The initial conversion and each `sync.update()` evaluate morph targets and
|
|
110
|
+
skinning on the CPU. The sync calls `skeleton.update()` itself, so a preceding
|
|
111
|
+
Three.js render is unnecessary. Relative and absolute morph targets affect
|
|
112
|
+
positions and normals; skinning transforms positions, normals and supplied
|
|
113
|
+
tangents in local space. Missing tangents are generated from the deformed
|
|
114
|
+
positions, normals and UVs. The mesh's world transform remains an instance
|
|
115
|
+
transform.
|
|
116
|
+
|
|
117
|
+
Each deforming source mesh owns its MuTracer geometry, even when several
|
|
118
|
+
SkinnedMesh objects share a Three.js BufferGeometry; deformation is computed
|
|
119
|
+
once per source mesh and copied to each material group. These geometries are
|
|
120
|
+
[dynamic](./updates.md#dynamic-geometry).
|
|
121
|
+
|
|
122
|
+
An unchanged pose (bones, binding matrices, morph weights and attribute
|
|
123
|
+
versions) skips deformation. A changed pose updates the arrays in place, and
|
|
124
|
+
rendering refits only that geometry's BLAS and instances. CPU cost grows with
|
|
125
|
+
vertices, bone influences and material groups. Displaced deforming meshes need
|
|
126
|
+
a full mesh update on every pose change.
|
|
127
|
+
|
|
128
|
+
Try the procedural [animation example](../examples/animation.html). Pause the
|
|
129
|
+
animation to accumulate samples; changing a pose restarts accumulation.
|
|
130
|
+
|
|
131
|
+
## Instanced meshes
|
|
132
|
+
|
|
133
|
+
`THREE.InstancedMesh.count` converts to a MuTracer `InstancedMesh` per material
|
|
134
|
+
group. Local Float32 matrices and colors are copied in source
|
|
135
|
+
index order within each batch; the retained double-precision `source.matrixWorld`
|
|
136
|
+
is the batch transform. Each world matrix remains `source.matrixWorld * instanceMatrix[i]`.
|
|
137
|
+
|
|
138
|
+
- **Matrices**: set `instanceMatrix.needsUpdate = true` after edits. The converter
|
|
139
|
+
checks values and notifies changed batches; unchanged batches retain their
|
|
140
|
+
matrix arrays and versions. Both backends refit the instance hierarchy.
|
|
141
|
+
- **Count**: the surviving source prefix retains its transforms and batch
|
|
142
|
+
identities. Shrinking removes the tail; increasing reads it again from the
|
|
143
|
+
source buffer. Membership changes rebuild the top-level BVH and reuse vertices
|
|
144
|
+
and BLASes where packing permits ([scene updates](./updates.md#adding-removing-and-reassigning-meshes)).
|
|
145
|
+
- **Colors**: `instanceColor` is copied into the batch's native `colors` array in
|
|
146
|
+
source order; removing it restores undefined (white). Set
|
|
147
|
+
`instanceColor.needsUpdate = true` after edits. Only changed values notify the
|
|
148
|
+
batch, and colors do not create material variants or extra batches. See
|
|
149
|
+
[color semantics and updates](./updates.md#instanced-meshes).
|
|
150
|
+
- **Callbacks**: `onMeshConverted` runs once per visible group on each update.
|
|
151
|
+
It receives `Mesh | InstancedMesh`; edit shared materials as usual, or notify
|
|
152
|
+
batch array element edits as described in [scene updates](./updates.md).
|
|
153
|
+
|
|
154
|
+
Unsupported instanced deformation keeps the ordinary-mesh fallback described
|
|
155
|
+
above. [Native instancing](./updates.md#instanced-meshes) uses the same primitive
|
|
156
|
+
without Three.js.
|
|
157
|
+
|
|
158
|
+
## `userData` keys
|
|
159
|
+
|
|
160
|
+
Renderer-specific settings without a Three.js equivalent:
|
|
161
|
+
|
|
162
|
+
| Key | On | Description |
|
|
163
|
+
| --- | --- | --- |
|
|
164
|
+
| `mutracerShadowCatcher: true` | material | Shadow-catcher ground |
|
|
165
|
+
| `mutracerOpenPBR: { ... }` | material | OpenPBR inputs without a Three.js equivalent: `baseWeight`, `baseDiffuseRoughness`, `specularWeight`, `specularColor`, `coat*`, `fuzz*`, `thinFilm*`, `thinWalled`, `subsurface*`, `transmissionScatter*`, `transmissionDispersion*` |
|
|
166
|
+
| `mutracerBevelSize` | material | Shader bevel radius |
|
|
167
|
+
| `mutracerUvProjection`, `mutracerUvProjectionScale`, `mutracerUvReferenceLength` | material | Procedural UV projection |
|
|
168
|
+
| `mutracerDisplacement*` | material | Displacement settings, same names as the `OpenPBRMaterial` fields; projection scale is `mutracerDisplacementUvProjectionScale` |
|
|
169
|
+
| `mutracerThinFilmMap` | material | Native R thickness texture with minimum 0; takes precedence over `iridescenceThicknessMap` |
|
|
170
|
+
| `mutracerRadius` | point / spot light | Emitter radius |
|
|
171
|
+
| `mutracerIesProfile`, `mutracerIesRotation` | spot light | `IESProfile` instance; rotation becomes local-Z transform rotation |
|
|
172
|
+
| `mutracerGroundedSkybox: { texture, height, radius, groundHeight?, center? }` | scene | Grounded skybox background |
|
|
173
|
+
| `mutracerHiddenBackground: true` | scene | Transparent background while keeping environment lighting |
|
|
174
|
+
|
|
175
|
+
Directional and spot lights use their world position and target to build a
|
|
176
|
+
MuTracer transform; source rotation alone does not specify their direction.
|
|
177
|
+
|
|
178
|
+
## Options
|
|
179
|
+
|
|
180
|
+
`new THREESync(engine, options?)` accepts these optional sources and settings:
|
|
181
|
+
|
|
182
|
+
| Option | Default | Meaning |
|
|
183
|
+
| --- | --- | --- |
|
|
184
|
+
| `scene` | undefined | Three.js scene; omitted leaves engine.scene untouched |
|
|
185
|
+
| `camera` | undefined | Perspective or orthographic camera; omitted leaves engine.camera untouched |
|
|
186
|
+
| `controls` | undefined | Controls with update and start/end events, such as OrbitControls |
|
|
187
|
+
| `updateControls` | true | Calls controls.update; false leaves updating to the application |
|
|
188
|
+
| `convertMaterial` | undefined | `(sourceMaterial)` → OpenPBRMaterial, null to skip every mesh using it, undefined for built-in conversion |
|
|
189
|
+
| `convertLight` | undefined | `(sourceLight)` → SceneLight, null to skip the light, undefined for built-in conversion |
|
|
190
|
+
| `onMeshConverted` | undefined | `(mesh, source, group, groupIndex)` on every visible mesh/group during update |
|
|
191
|
+
|
|
192
|
+
Construction subscribes to control events. The first update converts and writes
|
|
193
|
+
sources to the engine. `scene` exposes the retained converted scene, or undefined
|
|
194
|
+
when no source was supplied. A camera-only sync preserves a MuTracer-built scene.
|
|
195
|
+
`active` covers start/end interaction, camera movement, damping and changing
|
|
196
|
+
skinned/morph poses. OrbitControls damping stays consistent across render frame
|
|
197
|
+
rates, and final refinement resumes when motion settles. Use
|
|
198
|
+
`updateControls: false` when your application already updates the controls.
|
|
199
|
+
|
|
200
|
+
`fromTHREEScene(scene, options?)` and `fromTHREECamera(camera, options?)` remain
|
|
201
|
+
available for one-shot conversions. Each call reruns conversion hooks and creates fresh default objects; custom
|
|
202
|
+
objects are kept by identity.
|
|
203
|
+
Call `camera.updateProjectionMatrix()` after changing aspect or fov. A perspective
|
|
204
|
+
camera's focus and film height become MuTracer focus distance and sensor height;
|
|
205
|
+
pass `{fStop: 2.8}` to `fromTHREECamera` to enable depth of field.
|
|
206
|
+
|
|
207
|
+
### Custom conversion
|
|
208
|
+
|
|
209
|
+
Both `fromTHREEScene` and `THREESync` accept the conversion hooks:
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
import { OpenPBRMaterial, SphereLight } from '@meimu/mutracer';
|
|
213
|
+
const customMaterial = new OpenPBRMaterial({baseColor: [0.2, 0.4, 0.8]});
|
|
214
|
+
const customLight = new SphereLight({radius: 0.1, intensity: 3});
|
|
215
|
+
const sync = new THREESync(engine, {
|
|
216
|
+
scene,
|
|
217
|
+
convertMaterial(source) {
|
|
218
|
+
if (source.type === 'ShaderMaterial') return customMaterial;
|
|
219
|
+
if (source.userData.skipPathTracing) return null;
|
|
220
|
+
return undefined;
|
|
221
|
+
},
|
|
222
|
+
convertLight(source) {
|
|
223
|
+
if (source.userData.customEmitter) return customLight;
|
|
224
|
+
return undefined;
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
// Edit the returned MuTracer material directly after initial conversion.
|
|
228
|
+
customMaterial.baseColor = [0.8, 0.4, 0.2];
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
The sync caches each hook result (including null and undefined) by source
|
|
232
|
+
identity and `version`. The material hook receives only the source material,
|
|
233
|
+
so a shared material converts once for every mesh using it; use distinct
|
|
234
|
+
source materials for per-mesh conversion. Set `threeMaterial.needsUpdate = true` to advance its version and
|
|
235
|
+
rerun the hook. Returned objects are used by identity and are caller-owned;
|
|
236
|
+
`engine.update()` detects edits to them. Automatic UV
|
|
237
|
+
projection derives retained variants from the returned material; these refresh
|
|
238
|
+
when its identity or parameters change.
|
|
239
|
+
|
|
240
|
+
Three.js lights have no built-in `version`, so the light hook runs once. To
|
|
241
|
+
rerun it, set a numeric `light.userData.mutracerVersion` and increment it. An undefined hook result keeps normal built-in material/light
|
|
242
|
+
synchronization, including parameter edits that do not change the source
|
|
243
|
+
version. A null material result skips every group/instance of its mesh.
|
|
244
|
+
The environment texture follows the built-in conversion and is not a
|
|
245
|
+
`THREE.Light` hook source.
|
|
246
|
+
|
|
247
|
+
## Coat normal conversion
|
|
248
|
+
|
|
249
|
+
`clearcoatNormalMap` uses the shared texture conversion cache and preserves its UV channel, scale, offset and `flipY`; `clearcoatNormalScale` is copied separately from `normalScale`. Explicit `mutracerOpenPBR.coatNormalMap` accepts a MuTracer Texture or Three.js Texture, and `null` clears the imported map. `coatNormalScale` metadata overrides the imported pair; unrelated metadata retains the imported anisotropy source convention. Arbitrary JSON objects are not interpreted as texture images. `THREESync` propagates map and scale edits.
|
|
250
|
+
|
|
251
|
+
## Caveats
|
|
252
|
+
|
|
253
|
+
THREESync updates world/bone matrices and retains unchanged meshes, materials,
|
|
254
|
+
textures, lights, backgrounds and membership arrays. MuTracer transforms use
|
|
255
|
+
Three.js matrixWorld, preserving double precision. Skinning and morphs run on the
|
|
256
|
+
CPU, updating retained geometry in place. Other changed buffers replace geometry
|
|
257
|
+
and require a [full mesh update](./updates.md#full-mesh-updates).
|
|
258
|
+
|
|
259
|
+
`sync.dispose()` removes control subscriptions and conversion caches; it leaves
|
|
260
|
+
the last converted scene usable. Updating a disposed sync throws. RenderLoop does
|
|
261
|
+
not dispose supplied syncs or renders; see [ownership](./progressive-rendering.md#options-and-ownership).
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
Native `mutracerOpenPBR` metadata can set `anisotropyMap` (a MuTracer or Three.js Texture, or null to clear), `specularAnisotropyRotation` and `coatAnisotropyRotation` (radians, default zero). Imported geometry preserves a tangent's optional W handedness.
|
|
265
|
+
|
|
266
|
+
## Anisotropy source conversion
|
|
267
|
+
|
|
268
|
+
`MeshPhysicalMaterial.anisotropy`, `anisotropyRotation` and `anisotropyMap` import as source strength, base rotation (radians) and the linear RG/B direction map, with `specularAnisotropyModel = 'gltf'`. Roughness and its maps retain source values. `GLTFLoader` supplies the extension defaults and texture coordinates; `THREESync` propagates later strength, rotation, texture and metadata edits without rewriting pixels. Nonphysical materials retain native semantics.
|
|
269
|
+
|
|
270
|
+
For sampled source roughness r and strength a, u = r², A = u + (1 - u)a² and B = u. The native anisotropy is 1 - B/A (clamped to [0, 1] against Float32 roundoff) and native roughness is ((A² + B²)/2)^(1/4). A = B = 0 resolves to zero. Strength zero returns the original roughness directly. Conversion occurs after roughness/metallic-roughness sampling and the anisotropy blue multiplier, followed by the existing OpenPBR coat roughening. CPU conversion before multiplying maps would give different alpha axes and is not used. The coat's anisotropy is independent.
|
|
271
|
+
|
|
272
|
+
Metadata overriding `specularAnisotropy` or `specularRoughnessAnisotropy` defaults back to `'openpbr'` and clears the automatically imported direction map/rotation to undefined/zero. Explicit metadata direction values can replace or restore them; explicit `specularAnisotropyModel: 'gltf'` retains source semantics and the imported directions. An unrelated override such as baseColor preserves the imported model. Texture overrides accept MuTracer/Three.js textures, and null clears a texture. Invalid model names throw.
|
|
273
|
+
|
|
274
|
+
This is an alpha-parameter match, with approximation differences from the renderer's Fresnel, masking, energy compensation and layer model. Zero roughness with nonzero strength reaches the existing alpha minimum; this numerical endpoint does not reproduce a singular zero-width distribution. General KHR texture-transform rotation remains the adapter limitation documented above.
|
package/docs/todo.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# TODO
|
|
2
|
+
|
|
3
|
+
Follow-ups deferred during the Engine / Display / Render API redesign. Each
|
|
4
|
+
item says why it was deferred. None of them changes the current public API;
|
|
5
|
+
the ones marked additive would only add to it.
|
|
6
|
+
|
|
7
|
+
## Rendering and denoising
|
|
8
|
+
|
|
9
|
+
- **HDR-stage post-process hooks.** `display.addPostProcess` runs after display
|
|
10
|
+
composition only. The built-in JNLM and OIDN filters denoise the composed
|
|
11
|
+
display-linear image and cache the result, so an HDR-stage hook would feed
|
|
12
|
+
the denoiser input and leave stale results whenever the hook changes. This
|
|
13
|
+
needs an invalidation rule first, for example restarting denoising when the
|
|
14
|
+
hook list or a hook revision changes.
|
|
15
|
+
- **Shadow-catcher shadows with custom denoisers.** `DenoiseInput` provides only
|
|
16
|
+
color, albedo and normal. Catcher shadow masks are composited after filtering
|
|
17
|
+
and keep their noise. The built-in filters do filter these shadows. One option
|
|
18
|
+
is an optional mask buffer on `DenoiseInput` (additive).
|
|
19
|
+
- **`readPixels('denoised')` depends on the filter.** Built-in filters return
|
|
20
|
+
display-linear values because they filter after tone mapping. Custom filters
|
|
21
|
+
return linear HDR. This is documented in TSDoc; consider a single contract.
|
|
22
|
+
- **Unused alpha post-filter.** `WGPURenderingPipeline` keeps an OIDN alpha
|
|
23
|
+
post-filter (the `alphaDenoiser` parameter), but `Render` always passes
|
|
24
|
+
`undefined`. Expose it or remove it; removing an image-quality mechanism is
|
|
25
|
+
a maintainer decision.
|
|
26
|
+
|
|
27
|
+
## Performance and memory
|
|
28
|
+
|
|
29
|
+
- **Dirty ranges for `InstancedMesh`.** `markTransformsUpdated(start, count)` / `markColorsUpdated(start, count)`
|
|
30
|
+
validates its range, but a commit still copies the whole changed `transforms`
|
|
31
|
+
or `colors` array. Transform edits refit the whole TLAS; color edits only
|
|
32
|
+
upload instance records. Unchanged updates are already cheap (100,000
|
|
33
|
+
instances: about 10.6 ms down to 0.0025 ms per `engine.update()`); frames
|
|
34
|
+
that change transforms are not optimized.
|
|
35
|
+
- **Camera allocation in `THREESync`.** Every `update()` creates a temporary
|
|
36
|
+
`Camera` with `fromTHREECamera` and copies it into the retained camera
|
|
37
|
+
(`src/util/fromTHREE.ts`). Update the retained camera in place instead.
|
|
38
|
+
- **Render target memory.** A WebGPU render target uses about 110 bytes per
|
|
39
|
+
pixel. Check which buffers can be shared between renders or use narrower
|
|
40
|
+
formats.
|
|
41
|
+
|
|
42
|
+
## Additive capabilities
|
|
43
|
+
|
|
44
|
+
- **Multiple canvases.** `engine.createDisplay(canvas)` on WebGPU. WebGL
|
|
45
|
+
contexts cannot share resources, so WebGL keeps a single display.
|
|
46
|
+
- **Several resident scenes.** `new Render(engine, {scene, camera})` would
|
|
47
|
+
override the engine's scene and camera per render. Today one scene is
|
|
48
|
+
resident on the GPU, and `engine.prepare(otherScene)` prepares CPU data only.
|
|
49
|
+
|
|
50
|
+
## Viewer
|
|
51
|
+
|
|
52
|
+
- **Device loss status.** Show device loss and recovery in the status bar,
|
|
53
|
+
using the engine's `devicelost` event. The library already recovers.
|
|
54
|
+
|
|
55
|
+
## Decided against
|
|
56
|
+
|
|
57
|
+
- **A scene graph.** Path tracing consumes a flat instance list. Hierarchy stays
|
|
58
|
+
in Three.js or the application, which computes each world `transform`.
|
|
59
|
+
- **Open material or light type extension.** Every new type needs shader support
|
|
60
|
+
in both backends. Keep a closed set and maintain it through the internal
|
|
61
|
+
field tables.
|
package/docs/updates.md
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# Scene updates and animation
|
|
2
|
+
|
|
3
|
+
This page is the reference for editing a scene that is already rendering.
|
|
4
|
+
Keep the same scene, arrays and resources and edit them in place. Call
|
|
5
|
+
`engine.update()` once per frame to detect and commit changes. Every Render
|
|
6
|
+
uses that committed snapshot until the next update; editing or replacing the
|
|
7
|
+
external scene/camera without calling update has no effect on tracing.
|
|
8
|
+
Changes restart each render at its next refine. See
|
|
9
|
+
[progressive rendering](./progressive-rendering.md) for preview selection.
|
|
10
|
+
|
|
11
|
+
## What to do after a change
|
|
12
|
+
|
|
13
|
+
`engine.update()` compares the scene with its last commit. It detects every
|
|
14
|
+
property assignment, membership change and small value such as matrices,
|
|
15
|
+
material parameters, light parameters and background fields. It does not read
|
|
16
|
+
the contents of large arrays or images, so in-place edits to them need a
|
|
17
|
+
notification first:
|
|
18
|
+
|
|
19
|
+
| Edited in place | Notification |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| Texture pixels or UV-array elements | `texture.markUpdated()` |
|
|
22
|
+
| Vertex attributes; indices and `materialIndex` unchanged | `geometry.markVerticesUpdated()` |
|
|
23
|
+
| Indices, `materialIndex` or other geometry data | `geometry.markUpdated()` |
|
|
24
|
+
| `instancedMesh.transforms` elements | `instancedMesh.markTransformsUpdated(start?, count?)` |
|
|
25
|
+
| `instancedMesh.colors` elements | `instancedMesh.markColorsUpdated(start?, count?)` |
|
|
26
|
+
| Both instance matrices and colors | `instancedMesh.markUpdated()` |
|
|
27
|
+
|
|
28
|
+
Everything else, including the camera, `scene.meshes`, `mesh.transform`,
|
|
29
|
+
replaced geometry, materials, textures or arrays, and `instancedMesh.count`,
|
|
30
|
+
needs only `engine.update()`. Engine BVH settings also take effect at the next
|
|
31
|
+
update; see [BVH](./bvh.md).
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
mesh.transform[12] += 0.1; // detected
|
|
35
|
+
material.specularRoughness = 0.6; // detected
|
|
36
|
+
// ...edit texture pixels...
|
|
37
|
+
texture.markUpdated(); // pixels: notify
|
|
38
|
+
engine.update(); final.refine(); engine.display.present(final);
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
With RenderLoop, edit sources before the next tick; the loop calls sync.update
|
|
42
|
+
and engine.update. THREESync sends resource notifications for you. See
|
|
43
|
+
[Three.js](./threejs.md#keeping-scenes-in-sync).
|
|
44
|
+
|
|
45
|
+
## Transforms
|
|
46
|
+
|
|
47
|
+
Edit `mesh.transform` in place while retaining the mesh objects and the
|
|
48
|
+
`scene.meshes` array. Both WebGPU and WebGL 2 refit the top-level BVH over the
|
|
49
|
+
changed instances and upload only the affected ranges.
|
|
50
|
+
|
|
51
|
+
## Instanced meshes
|
|
52
|
+
|
|
53
|
+
Use `InstancedMesh` for many copies of the same geometry and materials:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
const batch = new InstancedMesh(geometry, material, {count: 1000});
|
|
57
|
+
// Omitted transforms initialize every local matrix to identity.
|
|
58
|
+
for (let i = 0; i < batch.count; i++) batch.transforms[i * 16 + 12] = i * 2;
|
|
59
|
+
batch.markTransformsUpdated();
|
|
60
|
+
scene.meshes.push(batch);
|
|
61
|
+
engine.update();
|
|
62
|
+
|
|
63
|
+
batch.transforms[16 + 12] += 1;
|
|
64
|
+
batch.markTransformsUpdated(1, 1); // start/count are in instances, not floats
|
|
65
|
+
engine.update();
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
`transforms` contains column-major Float32 matrices; the constructor retains a
|
|
69
|
+
supplied array. Each world matrix is `batch.transform * transforms[i]`, so the
|
|
70
|
+
inherited `position` and `lookAt` move the whole batch. Every instance uses the
|
|
71
|
+
same material list, selected by the geometry's `materialIndex` exactly as for Mesh.
|
|
72
|
+
|
|
73
|
+
`count` selects an active prefix and must be a nonnegative integer within the
|
|
74
|
+
transforms and colors array capacity. Shrinking it retains the stored matrices; increase it again to
|
|
75
|
+
reactivate that prefix. To grow beyond capacity, assign a larger Float32Array
|
|
76
|
+
with the previous prefix copied. The default count and capacity come from the
|
|
77
|
+
constructor. Empty batches are supported.
|
|
78
|
+
|
|
79
|
+
Optional `colors` contains linear RGB multipliers, three Float32 values per
|
|
80
|
+
instance; omitted colors are white. The array is retained and must hold at least
|
|
81
|
+
`3 * count` values. All materials of an instance share its color. Colors multiply
|
|
82
|
+
baseColor after texture sampling, and emissionColor only for unlit materials.
|
|
83
|
+
They do not affect alpha, other layer colors, non-unlit emission or light sampling.
|
|
84
|
+
Values are not clamped; results for nonfinite colors are undefined.
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
batch.colors = new Float32Array(batch.count * 3).fill(1); // replacement: detected
|
|
88
|
+
batch.colors.set([0.2, 0.6, 1], 3);
|
|
89
|
+
batch.markColorsUpdated(1, 1);
|
|
90
|
+
engine.update();
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
After editing both matrices and colors, call `batch.markUpdated()` to notify
|
|
94
|
+
both for all active instances. This does not notify geometry or material edits.
|
|
95
|
+
For edits to just one array, use the dedicated notification (default range: all
|
|
96
|
+
active instances):
|
|
97
|
+
|
|
98
|
+
| Notification | Work avoided compared with `markUpdated()` |
|
|
99
|
+
| --- | --- |
|
|
100
|
+
| `markTransformsUpdated(start?, count?)` | Copying unchanged instance colors |
|
|
101
|
+
| `markColorsUpdated(start?, count?)` | Copying instance matrices and refitting or rebuilding BVHs; only instance colors are uploaded |
|
|
102
|
+
|
|
103
|
+
Each notification advances the read-only `version` once, initially zero.
|
|
104
|
+
Replacing either array, removing colors, and changing count are detected automatically.
|
|
105
|
+
Arrays are copied into the engine snapshot on their own version or storage change;
|
|
106
|
+
unnotified edits remain uncommitted even when another scene resource changes. Call
|
|
107
|
+
`engine.update()` before refining or converging.
|
|
108
|
+
|
|
109
|
+
Caveats: individual instances have no names, transforms or materials as JS
|
|
110
|
+
objects. Use separate batches for distinct material sets. Nonfinite world
|
|
111
|
+
matrices are excluded, as with Mesh.
|
|
112
|
+
The notification range is validated.
|
|
113
|
+
|
|
114
|
+
## Materials, textures and lights
|
|
115
|
+
|
|
116
|
+
Material parameter edits repack material parameters without touching geometry
|
|
117
|
+
or BVHs. Emission edits also refresh light-sampling state, and texture edits
|
|
118
|
+
rebuild the texture atlas. Displacement settings that move geometry require a
|
|
119
|
+
[full mesh update](#full-mesh-updates).
|
|
120
|
+
|
|
121
|
+
Analytic-light edits keep the environment map. Ambient and environment edits
|
|
122
|
+
rebuild it. Rect-light texture edits require a full mesh update, because those
|
|
123
|
+
textures live in the material atlas.
|
|
124
|
+
|
|
125
|
+
## Geometry
|
|
126
|
+
|
|
127
|
+
Choose the notification that matches the edit:
|
|
128
|
+
|
|
129
|
+
| Edit | Notification | Effect |
|
|
130
|
+
| --- | --- | --- |
|
|
131
|
+
| Vertex attributes only; indices and `materialIndex` unchanged | `geometry.markVerticesUpdated()` | Advances `version`; keeps `topologyVersion`. Allows vertex updates and BLAS refits |
|
|
132
|
+
| Indices, `materialIndex`, or any other geometry change | `geometry.markUpdated()` | Advances `version` and `topologyVersion`. Rebuilds the affected BLAS |
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
geometry.dynamic = true; // for frequent deformation
|
|
136
|
+
geometry.position.array[0] += 0.1;
|
|
137
|
+
geometry.markVerticesUpdated();
|
|
138
|
+
// The next engine.update commits this geometry and every mesh that uses it.
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
- Neither method recalculates normals or tangents. Update them before
|
|
142
|
+
notifying the renderer.
|
|
143
|
+
- `markUpdated()` is valid for vertex edits too, but it can rebuild the BLAS
|
|
144
|
+
unnecessarily.
|
|
145
|
+
- Keep the attribute arrays, their lengths and item sizes. Then both backends
|
|
146
|
+
update only the edited geometry's ranges and BLAS, and refit every instance
|
|
147
|
+
that shares it. Vertex, transform and material edits can be combined in one
|
|
148
|
+
frame.
|
|
149
|
+
- Replaced arrays, changed lengths or item sizes, and displaced geometry
|
|
150
|
+
require a [full mesh update](#full-mesh-updates), whichever method you call.
|
|
151
|
+
|
|
152
|
+
### Dynamic geometry
|
|
153
|
+
|
|
154
|
+
Set `geometry.dynamic = true` (default `false`) for geometry that deforms
|
|
155
|
+
every frame. Dynamic geometry always uses the built-in builder and the binary
|
|
156
|
+
`'bvh2'` layout, whatever `engine.bvhBuilder` and `engine.bvhLayout` say,
|
|
157
|
+
so its BLAS can be refitted. A refitted BLAS is rebuilt once its total node
|
|
158
|
+
surface area exceeds twice the total of its last build, which limits quality
|
|
159
|
+
loss during long deformations. Non-dynamic geometry refits layouts that
|
|
160
|
+
support it and rebuilds the others.
|
|
161
|
+
|
|
162
|
+
Refits and rebuilds run synchronously during committed GPU uploads. Three.js skinning
|
|
163
|
+
and morph targets set `dynamic` automatically; try the
|
|
164
|
+
[animation example](../examples/animation.html).
|
|
165
|
+
|
|
166
|
+
## Adding, removing and reassigning meshes
|
|
167
|
+
|
|
168
|
+
Adding, removing or reordering meshes, or replacing a mesh's material, is
|
|
169
|
+
cheap when every mesh uses a single material and geometry that is already on
|
|
170
|
+
the GPU: the renderer rebuilds the top-level BVH and instance data and reuses
|
|
171
|
+
vertex data and BLASes. Otherwise, for example with new geometry, displacement
|
|
172
|
+
or a `materialIndex` attribute, it needs a full mesh update.
|
|
173
|
+
|
|
174
|
+
## Full mesh updates
|
|
175
|
+
|
|
176
|
+
A full mesh update repacks and uploads all mesh data, and its cost grows with
|
|
177
|
+
the whole scene rather than with the edit. It happens when:
|
|
178
|
+
|
|
179
|
+
- attribute or index arrays are replaced, or their lengths or item sizes change;
|
|
180
|
+
- displaced geometry or its displacement settings change;
|
|
181
|
+
- a rect-light texture changes;
|
|
182
|
+
- a mesh gets geometry that is not yet on the GPU, or meshes with displaced
|
|
183
|
+
or multi-material geometry are added, removed or reassigned.
|
|
184
|
+
|
|
185
|
+
Avoid these in per-frame animation.
|
|
186
|
+
|
|
187
|
+
## Preview and animation
|
|
188
|
+
|
|
189
|
+
Create a cheaper preview Render and use it during motion. Give the final render
|
|
190
|
+
`fallback: preview`; it transitions when its first complete sample is ready.
|
|
191
|
+
Selection and coalescing of continuous animation changes belong to the
|
|
192
|
+
application. Render.refine only executes the chosen settings, and samples
|
|
193
|
+
always count that render's complete samples. For fixed-quality animation, use
|
|
194
|
+
converge on each frame with disjoint sequence offsets.
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
## Implementation notes
|
|
198
|
+
|
|
199
|
+
Material detection compares each distinct material once per engine.update,
|
|
200
|
+
however many meshes share it; cost grows with the number of distinct materials.
|
|
201
|
+
|
|
202
|
+
On a version or storage change, the engine copies the full transforms or colors
|
|
203
|
+
array; start/count validation does not limit the copied elements. In scenes
|
|
204
|
+
containing batches, a transform update regenerates all instance records and
|
|
205
|
+
refits the top-level BVH. World matrices keep double precision until GPU
|
|
206
|
+
packing, matching Three.js world-matrix and inverse calculations. Instances
|
|
207
|
+
share BLAS and vertices unless explicit materialIndex packing or displacement
|
|
208
|
+
requires a distinct vertex region.
|
package/lib/Display.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type Render from './Render.js';
|
|
2
|
+
import type { ToneMapping, DisplayChannel } from './renderer/RenderingPipeline.js';
|
|
3
|
+
import type { ColorRGB } from './types.js';
|
|
4
|
+
/** Display image channels. Default final. */
|
|
5
|
+
export type { DisplayChannel } from './renderer/RenderingPipeline.js';
|
|
6
|
+
/** Image encoding options for Display.toBlob. */
|
|
7
|
+
export interface BlobOptions {
|
|
8
|
+
/** Browser image MIME type. Default image/png. */ type?: string;
|
|
9
|
+
/** Encoder quality in 0–1. Default undefined uses the browser default. */ quality?: number;
|
|
10
|
+
}
|
|
11
|
+
/** Optional shared display settings; defaults match Display. */
|
|
12
|
+
export interface DisplaySettings {
|
|
13
|
+
/** Tone mapping transform. Default agx. */ toneMapping?: ToneMapping;
|
|
14
|
+
/** Linear exposure multiplier. Default 1. */ toneMappingExposure?: number;
|
|
15
|
+
/** Contrast multiplier. Default 1. */ contrast?: number;
|
|
16
|
+
/** Saturation multiplier. Default 1. */ saturation?: number;
|
|
17
|
+
/** White balance temperature shift in -1–1. Default 0. */ temperature?: number;
|
|
18
|
+
/** Green/magenta tint in -1–1. Default 0. */ tint?: number;
|
|
19
|
+
/** Vignette strength in 0–1. Default 0. */ vignette?: number;
|
|
20
|
+
/** Bloom intensity; 0 disables it. Default 0. */ bloomIntensity?: number;
|
|
21
|
+
/** Bloom luminance threshold. Default 1. */ bloomThreshold?: number;
|
|
22
|
+
/** Bloom radius in 0–1. Default 0.6. */ bloomRadius?: number;
|
|
23
|
+
/** Extended-range WebGPU presentation, ignored on WebGL. Default false. */ hdrOutputEnabled?: boolean;
|
|
24
|
+
/** Display image channel. Default final. */ channel?: DisplayChannel;
|
|
25
|
+
/** Linear shadow-catcher color. Default black. */ shadowCatcherColor?: ColorRGB;
|
|
26
|
+
/** Shadow-catcher opacity multiplier. Default 1. */ shadowCatcherAlpha?: number;
|
|
27
|
+
}
|
|
28
|
+
/** Borrowed WebGPU images for one synchronous display pass. */
|
|
29
|
+
export interface PostProcessContext {
|
|
30
|
+
/** Engine device; may change after recovery. */ device: GPUDevice;
|
|
31
|
+
/** Record commands here; the library finishes and submits it. */ encoder: GPUCommandEncoder;
|
|
32
|
+
/** Read-only composed display image, top row first; no additional color conversion. */ input: GPUTexture;
|
|
33
|
+
/** Fully write this image. Same format and dimensions as input; supports render, storage and copy writes. */ output: GPUTexture;
|
|
34
|
+
/** Actual render width. */ width: number;
|
|
35
|
+
/** Actual render height. */ height: number;
|
|
36
|
+
/** Selected complete render, including a selected fallback. */ render: Render;
|
|
37
|
+
}
|
|
38
|
+
/** Synchronous display pass. Images and encoder are borrowed only during the call; do not retain or destroy them. */
|
|
39
|
+
export type PostProcess = (context: PostProcessContext) => void;
|
|
40
|
+
/** Canvas presentation and shared display settings; obtained from engine.display. */
|
|
41
|
+
export default class Display {
|
|
42
|
+
private readonly engine;
|
|
43
|
+
/** Display canvas. Default the supplied Engine canvas, or a new canvas (OffscreenCanvas without document). */ readonly canvas: HTMLCanvasElement | OffscreenCanvas;
|
|
44
|
+
/** Tone mapping transform. Default agx. */ toneMapping: ToneMapping;
|
|
45
|
+
/** Linear exposure multiplier. Default 1. */ toneMappingExposure: number;
|
|
46
|
+
/** Contrast multiplier. Default 1. */ contrast: number;
|
|
47
|
+
/** Saturation multiplier. Default 1. */ saturation: number;
|
|
48
|
+
/** White balance temperature shift in -1–1. Default 0. */ temperature: number;
|
|
49
|
+
/** Green/magenta tint in -1–1. Default 0. */ tint: number;
|
|
50
|
+
/** Vignette strength in 0–1. Default 0. */ vignette: number;
|
|
51
|
+
/** Bloom intensity; 0 disables it. Default 0. */ bloomIntensity: number;
|
|
52
|
+
/** Bloom luminance threshold. Default 1. */ bloomThreshold: number;
|
|
53
|
+
/** Bloom radius in 0–1. Default 0.6. */ bloomRadius: number;
|
|
54
|
+
/** Extended-range WebGPU presentation, ignored on WebGL. Default false. */ hdrOutputEnabled: boolean;
|
|
55
|
+
/** Display image channel. Default final. */ channel: DisplayChannel;
|
|
56
|
+
/** Linear shadow-catcher color. Default black. */ shadowCatcherColor: ColorRGB;
|
|
57
|
+
/** Shadow-catcher opacity multiplier. Default 1. */ shadowCatcherAlpha: number;
|
|
58
|
+
private constructor();
|
|
59
|
+
/** Resizes the drawing buffer; scale-based renders resize at their next refine. */
|
|
60
|
+
setSize(width: number, height: number): void;
|
|
61
|
+
private readonly settings;
|
|
62
|
+
private readonly _postProcesses;
|
|
63
|
+
private _warnedPostProcess;
|
|
64
|
+
/** Registers a display pass in order and returns an idempotent removal function. Default no passes. WebGPU only; WebGL skips passes with one warning. Runs after composition on every present/toBlob, without tracing or invalidating denoising. A thrown error discards the whole chain, presents the original image and emits engine error. */
|
|
65
|
+
addPostProcess(pass: PostProcess): () => void;
|
|
66
|
+
private warnPostProcess;
|
|
67
|
+
private compose;
|
|
68
|
+
/** Presents a complete image or fallback. Keeps fallback visible until the first intermediate filter finishes. Does not trace. */
|
|
69
|
+
present(render: Render): Render | undefined;
|
|
70
|
+
/** Encodes this render at its actual dimensions using these settings; leaves the display canvas unchanged. */
|
|
71
|
+
toBlob(render: Render, options?: BlobOptions): Promise<Blob>;
|
|
72
|
+
}
|