@meimu/mutracer 0.0.0-stage → 0.1.0
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 +195 -2
- package/THIRD_PARTY_NOTICES.md +160 -0
- package/dist/assets/bvh.worker.js +1 -0
- package/dist/mutracer.umd.js +14352 -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 +144 -0
- package/docs/sampling.md +40 -0
- package/docs/threejs.md +273 -0
- package/docs/todo.md +61 -0
- package/docs/updates.md +208 -0
- package/lib/Display.d.ts +72 -0
- package/lib/Display.js +121 -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 +256 -0
- package/lib/Render.js +671 -0
- package/lib/Render.js.map +1 -0
- package/lib/RenderLoop.d.ts +76 -0
- package/lib/RenderLoop.js +204 -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 +1446 -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 +121 -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 +619 -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 +923 -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 +100 -0
- package/lib/util/fromTHREE.js +1063 -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
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { glsl } from '../../shader.js';
|
|
2
|
+
export default glsl `
|
|
3
|
+
#ifdef NUM_LIGHTS
|
|
4
|
+
void eJ(
|
|
5
|
+
in Light light,
|
|
6
|
+
in vec3 shadingPoint,
|
|
7
|
+
in vec2 samplePoint,
|
|
8
|
+
inout LightSampleRec result
|
|
9
|
+
) {
|
|
10
|
+
vec3 nE = light.position - shadingPoint;
|
|
11
|
+
float aj = length(nE);
|
|
12
|
+
if (light.radius <= 0.0) {
|
|
13
|
+
if (aj <= 1e-6) {
|
|
14
|
+
result.direction = vec3(0.0, 0.0, 1.0);
|
|
15
|
+
result.normal = vec3(0.0, 0.0, -1.0);
|
|
16
|
+
result.dist = 0.0;
|
|
17
|
+
result.pdf = 1.0;
|
|
18
|
+
result.emission = vec3(0.0);
|
|
19
|
+
result.isDelta = true;
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
result.direction = nE / aj;
|
|
23
|
+
result.normal = -result.direction;
|
|
24
|
+
result.dist = aj;
|
|
25
|
+
result.pdf = 1.0;
|
|
26
|
+
result.emission = light.emission / max(aj * aj, 1e-8);
|
|
27
|
+
result.isDelta = true;
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
float radius = max(light.radius, 1e-6);
|
|
31
|
+
result.isDelta = false;
|
|
32
|
+
vec3 direction;
|
|
33
|
+
|
|
34
|
+
if (aj <= radius) {
|
|
35
|
+
float z = 1.0 - 2.0 * samplePoint.x;
|
|
36
|
+
float fi = sqrt(max(0.0, 1.0 - z * z));
|
|
37
|
+
float br = TWOPI * samplePoint.y;
|
|
38
|
+
direction = vec3(fi * cos(br), fi * sin(br), z);
|
|
39
|
+
result.pdf = INV4PI;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
vec3 axis = nE / aj;
|
|
43
|
+
float rG = min(
|
|
44
|
+
1.0,
|
|
45
|
+
radius * radius / (aj * aj)
|
|
46
|
+
);
|
|
47
|
+
float rJ = sqrt(max(0.0, 1.0 - rG));
|
|
48
|
+
float au = mix(1.0, rJ, samplePoint.x);
|
|
49
|
+
float tR = sqrt(max(0.0, 1.0 - au * au));
|
|
50
|
+
float br = TWOPI * samplePoint.y;
|
|
51
|
+
vec3 tangent;
|
|
52
|
+
vec3 bitangent;
|
|
53
|
+
aK(axis, tangent, bitangent);
|
|
54
|
+
direction = axis * au
|
|
55
|
+
+ tangent * (tR * cos(br))
|
|
56
|
+
+ bitangent * (tR * sin(br));
|
|
57
|
+
result.pdf = 1.0 / max(TWOPI * (1.0 - rJ), 1e-8);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
float iZ = dot(direction, nE);
|
|
61
|
+
float ej = iZ * iZ
|
|
62
|
+
- dot(nE, nE) + radius * radius;
|
|
63
|
+
float wt = sqrt(max(0.0, ej));
|
|
64
|
+
float cN = iZ - wt;
|
|
65
|
+
float cB = iZ + wt;
|
|
66
|
+
result.dist = cN > 1e-6 ? cN : cB;
|
|
67
|
+
result.direction = direction;
|
|
68
|
+
vec3 surfacePoint = shadingPoint + direction * result.dist;
|
|
69
|
+
result.normal = normalize(surfacePoint - light.position);
|
|
70
|
+
result.emission = light.emission;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
void cZ(
|
|
74
|
+
in Light light,
|
|
75
|
+
in vec3 surfacePoint,
|
|
76
|
+
in vec3 lowerLeft,
|
|
77
|
+
inout LightSampleRec result
|
|
78
|
+
) {
|
|
79
|
+
#ifdef NUM_MAPS
|
|
80
|
+
if (light.textureIndex >= 0) {
|
|
81
|
+
float width = length(light.u);
|
|
82
|
+
float height = length(light.v);
|
|
83
|
+
vec3 hY = surfacePoint - lowerLeft;
|
|
84
|
+
vec2 uv = vec2(
|
|
85
|
+
dot(hY, light.u / width) / width,
|
|
86
|
+
dot(hY, light.v / height) / height
|
|
87
|
+
);
|
|
88
|
+
result.emission *= sampleMap(light.textureIndex, uv).rgb;
|
|
89
|
+
}
|
|
90
|
+
#endif
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
void jJ(
|
|
94
|
+
in Light light,
|
|
95
|
+
in vec3 shadingPoint,
|
|
96
|
+
in vec2 samplePoint,
|
|
97
|
+
inout LightSampleRec result
|
|
98
|
+
) {
|
|
99
|
+
vec3 normal = normalize(cross(light.u, light.v));
|
|
100
|
+
vec3 lowerLeft = light.position - 0.5 * (light.u + light.v);
|
|
101
|
+
float spread = clamp(light.spread, 0.0, 1.0);
|
|
102
|
+
|
|
103
|
+
if (spread <= 0.001) {
|
|
104
|
+
float ga = dot(normal, shadingPoint - light.position);
|
|
105
|
+
vec3 surfacePoint = shadingPoint - normal * ga;
|
|
106
|
+
vec3 hY = surfacePoint - lowerLeft;
|
|
107
|
+
float width = length(light.u);
|
|
108
|
+
float height = length(light.v);
|
|
109
|
+
vec2 uv = vec2(
|
|
110
|
+
dot(hY, light.u / width) / width,
|
|
111
|
+
dot(hY, light.v / height) / height
|
|
112
|
+
);
|
|
113
|
+
if (ga <= 0.0 || any(lessThan(uv, vec2(0.0)))
|
|
114
|
+
|| any(greaterThan(uv, vec2(1.0)))) {
|
|
115
|
+
result.emission = vec3(0.0);
|
|
116
|
+
result.pdf = 0.0;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
result.direction = -normal;
|
|
120
|
+
result.dist = ga;
|
|
121
|
+
result.normal = normal;
|
|
122
|
+
result.emission = light.emission;
|
|
123
|
+
result.pdf = 1.0;
|
|
124
|
+
result.isDelta = true;
|
|
125
|
+
cZ(light, surfacePoint, lowerLeft, result);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
vec3 surfacePoint = lowerLeft
|
|
130
|
+
+ light.u * samplePoint.x
|
|
131
|
+
+ light.v * samplePoint.y;
|
|
132
|
+
vec3 offset = surfacePoint - shadingPoint;
|
|
133
|
+
float hl = dot(offset, offset);
|
|
134
|
+
result.dist = sqrt(hl);
|
|
135
|
+
result.direction = offset / result.dist;
|
|
136
|
+
result.normal = normal;
|
|
137
|
+
float fV = dot(-result.direction, normal);
|
|
138
|
+
float oC = cos(0.5 * PI * spread);
|
|
139
|
+
if (fV <= 0.0 || fV < oC) {
|
|
140
|
+
result.emission = vec3(0.0);
|
|
141
|
+
result.pdf = 0.0;
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
result.emission = light.emission;
|
|
145
|
+
result.pdf = hl / max(light.area * fV, 1e-8);
|
|
146
|
+
cZ(light, surfacePoint, lowerLeft, result);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
void fX(
|
|
150
|
+
in Light light,
|
|
151
|
+
in vec3 shadingPoint,
|
|
152
|
+
inout LightSampleRec result
|
|
153
|
+
) {
|
|
154
|
+
result.direction = normalize(-light.u);
|
|
155
|
+
result.normal = -result.direction;
|
|
156
|
+
result.emission = light.emission;
|
|
157
|
+
result.dist = INF;
|
|
158
|
+
result.pdf = 1.0;
|
|
159
|
+
result.isDelta = true;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
void jK(
|
|
163
|
+
in Light light,
|
|
164
|
+
in vec3 shadingPoint,
|
|
165
|
+
in vec2 samplePoint,
|
|
166
|
+
inout LightSampleRec result
|
|
167
|
+
) {
|
|
168
|
+
eJ(light, shadingPoint, samplePoint, result);
|
|
169
|
+
vec3 surfacePoint = shadingPoint + result.direction * result.dist;
|
|
170
|
+
result.emission *= bL(
|
|
171
|
+
light,
|
|
172
|
+
normalize(shadingPoint - surfacePoint)
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
void iK(
|
|
177
|
+
in Light light,
|
|
178
|
+
in vec3 shadingPoint,
|
|
179
|
+
in vec2 samplePoint,
|
|
180
|
+
inout LightSampleRec result
|
|
181
|
+
) {
|
|
182
|
+
int dO = int(light.type);
|
|
183
|
+
#ifdef HAS_RECT_LIGHTS
|
|
184
|
+
if (dO == RECT_LIGHT) {
|
|
185
|
+
jJ(light, shadingPoint, samplePoint, result);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
#endif
|
|
189
|
+
#ifdef HAS_SPHERE_LIGHTS
|
|
190
|
+
if (dO == SPHERE_LIGHT) {
|
|
191
|
+
eJ(light, shadingPoint, samplePoint, result);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
#endif
|
|
195
|
+
#ifdef HAS_SPOT_LIGHTS
|
|
196
|
+
if (dO == SPOT_LIGHT) {
|
|
197
|
+
jK(light, shadingPoint, samplePoint, result);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
#endif
|
|
201
|
+
#ifdef HAS_DIRECTIONAL_LIGHTS
|
|
202
|
+
if (dO == DIRECTIONAL_LIGHT) {
|
|
203
|
+
fX(light, shadingPoint, result);
|
|
204
|
+
}
|
|
205
|
+
#endif
|
|
206
|
+
}
|
|
207
|
+
#endif
|
|
208
|
+
|
|
209
|
+
void mu(in vec2 samplePoint, inout LightSampleRec result) {
|
|
210
|
+
vec2 uv;
|
|
211
|
+
result.direction = oA(samplePoint, uv, result.pdf);
|
|
212
|
+
result.emission = textureLinear(envMap, uv).rgb;
|
|
213
|
+
result.dist = INF;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
void sampleLight(
|
|
217
|
+
in vec3 shadingPoint,
|
|
218
|
+
in vec3 randomSampleValue,
|
|
219
|
+
inout LightSampleRec result,
|
|
220
|
+
bool rP
|
|
221
|
+
) {
|
|
222
|
+
result.isDelta = false;
|
|
223
|
+
float tQ = randomSampleValue.z;
|
|
224
|
+
bool ko = false;
|
|
225
|
+
#ifdef USE_ENVMAP
|
|
226
|
+
ko = tQ < envLightSelectionPmf;
|
|
227
|
+
if (ko) {
|
|
228
|
+
mu(randomSampleValue.xy, result);
|
|
229
|
+
result.pdf *= envLightSelectionPmf;
|
|
230
|
+
}
|
|
231
|
+
#endif
|
|
232
|
+
|
|
233
|
+
#ifdef NUM_LIGHTS
|
|
234
|
+
if (!ko) {
|
|
235
|
+
int kQ = NUM_LIGHTS - 1;
|
|
236
|
+
for (int index = 0; index < NUM_LIGHTS; index++) {
|
|
237
|
+
if (tQ < ql(index).selectionCdf) {
|
|
238
|
+
kQ = index;
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
Light qb = ql(kQ);
|
|
243
|
+
iK(
|
|
244
|
+
qb,
|
|
245
|
+
shadingPoint,
|
|
246
|
+
randomSampleValue.xy,
|
|
247
|
+
result
|
|
248
|
+
);
|
|
249
|
+
result.pdf *= qb.selectionPmf;
|
|
250
|
+
}
|
|
251
|
+
#endif
|
|
252
|
+
}
|
|
253
|
+
`;
|
|
254
|
+
//# sourceMappingURL=sampleLight.glsl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sampleLight.glsl.js","sourceRoot":"","sources":["../../../../src/renderer/glsl/chunks/sampleLight.glsl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,eAAe,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2PlB,CAAC","sourcesContent":["import { glsl } from '../../shader.js';\n\nexport default glsl`\n#ifdef NUM_LIGHTS\nvoid light_sample_sphere(\n in Light light,\n in vec3 shadingPoint,\n in vec2 samplePoint,\n inout LightSampleRec result\n) {\n vec3 toCenter = light.position - shadingPoint;\n float centerDistance = length(toCenter);\n if (light.radius <= 0.0) {\n if (centerDistance <= 1e-6) {\n result.direction = vec3(0.0, 0.0, 1.0);\n result.normal = vec3(0.0, 0.0, -1.0);\n result.dist = 0.0;\n result.pdf = 1.0;\n result.emission = vec3(0.0);\n result.isDelta = true;\n return;\n }\n result.direction = toCenter / centerDistance;\n result.normal = -result.direction;\n result.dist = centerDistance;\n result.pdf = 1.0;\n result.emission = light.emission / max(centerDistance * centerDistance, 1e-8);\n result.isDelta = true;\n return;\n }\n float radius = max(light.radius, 1e-6);\n result.isDelta = false;\n vec3 direction;\n\n if (centerDistance <= radius) {\n float z = 1.0 - 2.0 * samplePoint.x;\n float radial = sqrt(max(0.0, 1.0 - z * z));\n float azimuth = TWOPI * samplePoint.y;\n direction = vec3(radial * cos(azimuth), radial * sin(azimuth), z);\n result.pdf = INV4PI;\n }\n else {\n vec3 axis = toCenter / centerDistance;\n float sineLimitSquared = min(\n 1.0,\n radius * radius / (centerDistance * centerDistance)\n );\n float cosineLimit = sqrt(max(0.0, 1.0 - sineLimitSquared));\n float cosine = mix(1.0, cosineLimit, samplePoint.x);\n float sine = sqrt(max(0.0, 1.0 - cosine * cosine));\n float azimuth = TWOPI * samplePoint.y;\n vec3 tangent;\n vec3 bitangent;\n sampling_orthonormal_basis(axis, tangent, bitangent);\n direction = axis * cosine\n + tangent * (sine * cos(azimuth))\n + bitangent * (sine * sin(azimuth));\n result.pdf = 1.0 / max(TWOPI * (1.0 - cosineLimit), 1e-8);\n }\n\n float projectedCenter = dot(direction, toCenter);\n float discriminant = projectedCenter * projectedCenter\n - dot(toCenter, toCenter) + radius * radius;\n float root = sqrt(max(0.0, discriminant));\n float nearDistance = projectedCenter - root;\n float farDistance = projectedCenter + root;\n result.dist = nearDistance > 1e-6 ? nearDistance : farDistance;\n result.direction = direction;\n vec3 surfacePoint = shadingPoint + direction * result.dist;\n result.normal = normalize(surfacePoint - light.position);\n result.emission = light.emission;\n}\n\nvoid light_apply_rect_texture(\n in Light light,\n in vec3 surfacePoint,\n in vec3 lowerLeft,\n inout LightSampleRec result\n) {\n#ifdef NUM_MAPS\n if (light.textureIndex >= 0) {\n float width = length(light.u);\n float height = length(light.v);\n vec3 relative = surfacePoint - lowerLeft;\n vec2 uv = vec2(\n dot(relative, light.u / width) / width,\n dot(relative, light.v / height) / height\n );\n result.emission *= sampleMap(light.textureIndex, uv).rgb;\n }\n#endif\n}\n\nvoid light_sample_rect(\n in Light light,\n in vec3 shadingPoint,\n in vec2 samplePoint,\n inout LightSampleRec result\n) {\n vec3 normal = normalize(cross(light.u, light.v));\n vec3 lowerLeft = light.position - 0.5 * (light.u + light.v);\n float spread = clamp(light.spread, 0.0, 1.0);\n\n if (spread <= 0.001) {\n float planeDistance = dot(normal, shadingPoint - light.position);\n vec3 surfacePoint = shadingPoint - normal * planeDistance;\n vec3 relative = surfacePoint - lowerLeft;\n float width = length(light.u);\n float height = length(light.v);\n vec2 uv = vec2(\n dot(relative, light.u / width) / width,\n dot(relative, light.v / height) / height\n );\n if (planeDistance <= 0.0 || any(lessThan(uv, vec2(0.0)))\n || any(greaterThan(uv, vec2(1.0)))) {\n result.emission = vec3(0.0);\n result.pdf = 0.0;\n return;\n }\n result.direction = -normal;\n result.dist = planeDistance;\n result.normal = normal;\n result.emission = light.emission;\n result.pdf = 1.0;\n result.isDelta = true;\n light_apply_rect_texture(light, surfacePoint, lowerLeft, result);\n return;\n }\n\n vec3 surfacePoint = lowerLeft\n + light.u * samplePoint.x\n + light.v * samplePoint.y;\n vec3 offset = surfacePoint - shadingPoint;\n float distanceSquared = dot(offset, offset);\n result.dist = sqrt(distanceSquared);\n result.direction = offset / result.dist;\n result.normal = normal;\n float emitterCosine = dot(-result.direction, normal);\n float spreadCosine = cos(0.5 * PI * spread);\n if (emitterCosine <= 0.0 || emitterCosine < spreadCosine) {\n result.emission = vec3(0.0);\n result.pdf = 0.0;\n return;\n }\n result.emission = light.emission;\n result.pdf = distanceSquared / max(light.area * emitterCosine, 1e-8);\n light_apply_rect_texture(light, surfacePoint, lowerLeft, result);\n}\n\nvoid light_sample_directional(\n in Light light,\n in vec3 shadingPoint,\n inout LightSampleRec result\n) {\n result.direction = normalize(-light.u);\n result.normal = -result.direction;\n result.emission = light.emission;\n result.dist = INF;\n result.pdf = 1.0;\n result.isDelta = true;\n}\n\nvoid light_sample_spot(\n in Light light,\n in vec3 shadingPoint,\n in vec2 samplePoint,\n inout LightSampleRec result\n) {\n light_sample_sphere(light, shadingPoint, samplePoint, result);\n vec3 surfacePoint = shadingPoint + result.direction * result.dist;\n result.emission *= evaluateSpotEmissionMultiplier(\n light,\n normalize(shadingPoint - surfacePoint)\n );\n}\n\nvoid sampleAnalyticLight(\n in Light light,\n in vec3 shadingPoint,\n in vec2 samplePoint,\n inout LightSampleRec result\n) {\n int lightType = int(light.type);\n#ifdef HAS_RECT_LIGHTS\n if (lightType == RECT_LIGHT) {\n light_sample_rect(light, shadingPoint, samplePoint, result);\n return;\n }\n#endif\n#ifdef HAS_SPHERE_LIGHTS\n if (lightType == SPHERE_LIGHT) {\n light_sample_sphere(light, shadingPoint, samplePoint, result);\n return;\n }\n#endif\n#ifdef HAS_SPOT_LIGHTS\n if (lightType == SPOT_LIGHT) {\n light_sample_spot(light, shadingPoint, samplePoint, result);\n return;\n }\n#endif\n#ifdef HAS_DIRECTIONAL_LIGHTS\n if (lightType == DIRECTIONAL_LIGHT) {\n light_sample_directional(light, shadingPoint, result);\n }\n#endif\n}\n#endif\n\nvoid sampleEnvLight(in vec2 samplePoint, inout LightSampleRec result) {\n vec2 uv;\n result.direction = sampleEnvmap(samplePoint, uv, result.pdf);\n result.emission = textureLinear(envMap, uv).rgb;\n result.dist = INF;\n}\n\nvoid sampleLight(\n in vec3 shadingPoint,\n in vec3 randomSampleValue,\n inout LightSampleRec result,\n bool distByIntensity\n) {\n result.isDelta = false;\n float selector = randomSampleValue.z;\n bool choseEnvironment = false;\n#ifdef USE_ENVMAP\n choseEnvironment = selector < envLightSelectionPmf;\n if (choseEnvironment) {\n sampleEnvLight(randomSampleValue.xy, result);\n result.pdf *= envLightSelectionPmf;\n }\n#endif\n\n#ifdef NUM_LIGHTS\n if (!choseEnvironment) {\n int selectedIndex = NUM_LIGHTS - 1;\n for (int index = 0; index < NUM_LIGHTS; index++) {\n if (selector < fetchLight(index).selectionCdf) {\n selectedIndex = index;\n break;\n }\n }\n Light selectedLight = fetchLight(selectedIndex);\n sampleAnalyticLight(\n selectedLight,\n shadingPoint,\n randomSampleValue.xy,\n result\n );\n result.pdf *= selectedLight.selectionPmf;\n }\n#endif\n}\n`;\n"]}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
// Estimate the direct lighting integral using multiple importance sampling
|
|
2
|
+
// http://www.pbr-book.org/3ed-2018/Light_Transport_I_Surface_Reflection/Direct_Lighting.html#EstimatingtheDirectLightingIntegral
|
|
3
|
+
import { glsl } from '../../shader.js';
|
|
4
|
+
export default glsl `
|
|
5
|
+
vec3 mG(ad si, J mat, ag prepared, inout Path aa, vec3 ffnormal, bool gw) {
|
|
6
|
+
float mp = 1.0;
|
|
7
|
+
vec3 kZ = vec3(fk(cv(LIGHT_POSITION)), dz(cv(LIGHT_SELECT)));
|
|
8
|
+
|
|
9
|
+
LightSampleRec lightSample;
|
|
10
|
+
sampleLight(si.position, kZ, lightSample, false);
|
|
11
|
+
lightSample.emission = ai(lightSample.emission, bf);
|
|
12
|
+
|
|
13
|
+
vec3 lightDir = lightSample.direction;
|
|
14
|
+
vec3 oH = -aa.ray.d;
|
|
15
|
+
float fd = lightSample.pdf;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
float cosThetaL = dot(ffnormal, lightDir);
|
|
21
|
+
#ifdef NUM_COAT_NORMAL_MAPS
|
|
22
|
+
if (gw && mat.coatNormalEnabled) { cosThetaL = dot(mat.geometricNormal, lightDir); }
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
if (fd <= 0.0 || max(max(lightSample.emission.x, lightSample.emission.y), lightSample.emission.z) <= 0.0) {
|
|
26
|
+
return vec3(0.0);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
float scatteringPdf = 0.0;
|
|
30
|
+
vec3 f = vec3(0.0);
|
|
31
|
+
if (gw) {
|
|
32
|
+
if (cosThetaL <= 0.0 && mat.transmissionWeight <= 0.0 && mat.subsurfaceWeight <= 0.0) {
|
|
33
|
+
return vec3(0.0);
|
|
34
|
+
}
|
|
35
|
+
f = bI(prepared, lightDir, scatteringPdf);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
scatteringPdf = bD(
|
|
39
|
+
dot(oH, lightDir),
|
|
40
|
+
si.mediumAnisotropy
|
|
41
|
+
);
|
|
42
|
+
f = vec3(scatteringPdf);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (scatteringPdf <= 0.0 || max(max(f.x, f.y), f.z) <= 0.0) {
|
|
46
|
+
return vec3(0.0);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
Ray ml;
|
|
50
|
+
vec3 hc = si.position + EPS * lightDir;
|
|
51
|
+
if (gw) {
|
|
52
|
+
const float bZ = 0.1;
|
|
53
|
+
float dr = dot(si.normal, lightDir);
|
|
54
|
+
#ifdef NUM_COAT_NORMAL_MAPS
|
|
55
|
+
if (mat.coatNormalEnabled) { dr = dot(si.faceNormal, lightDir); }
|
|
56
|
+
#endif
|
|
57
|
+
vec3 geometricNormal = dr < 0.0 ? -si.faceNormal : si.faceNormal;
|
|
58
|
+
dr = abs(dr);
|
|
59
|
+
float hP = dot(geometricNormal, lightDir);
|
|
60
|
+
float oo = dr < bZ
|
|
61
|
+
? clamp(
|
|
62
|
+
2.0 - (hP + dr) / bZ,
|
|
63
|
+
0.0,
|
|
64
|
+
1.0
|
|
65
|
+
)
|
|
66
|
+
: clamp(1.0 - hP / bZ, 0.0, 1.0);
|
|
67
|
+
hc += si.shadowOffset * oo;
|
|
68
|
+
}
|
|
69
|
+
iw(ml, hc, lightDir);
|
|
70
|
+
if (ex(ml, lightSample.dist - EPS, si.triangleIndex)) {
|
|
71
|
+
return vec3(0.0);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
#ifdef USE_ENVMAP
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
if (gw && cosThetaL < 0.0 && kZ.z < envLightSelectionPmf) {
|
|
78
|
+
vec4 background = cw(ml.o, lightDir);
|
|
79
|
+
lightSample.emission = ai(background.rgb * background.a, bf);
|
|
80
|
+
}
|
|
81
|
+
#endif
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
float eW = lightSample.isDelta
|
|
86
|
+
? 1.0
|
|
87
|
+
: aF(fd, scatteringPdf);
|
|
88
|
+
return eW > 0.0
|
|
89
|
+
? eW * lightSample.emission * f / fd
|
|
90
|
+
: vec3(0.0);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
#ifdef NUM_COAT_NORMAL_MAPS
|
|
94
|
+
vec3 fB(vec3 pk, vec3 tc, vec3 view) {
|
|
95
|
+
bool qL = dot(tc, view) >= 0.0;
|
|
96
|
+
vec3 ub = qL ? tc : -tc;
|
|
97
|
+
vec3 qK = qL ? pk : -pk;
|
|
98
|
+
if (dot(pk, tc) <= 0.0 || dot(qK, view) <= 1e-6) { return ub; }
|
|
99
|
+
return qK;
|
|
100
|
+
}
|
|
101
|
+
#endif
|
|
102
|
+
void lO(inout ad si, J mat, inout Path aa) {
|
|
103
|
+
vec3 ud = vec3(fk(cv(BSDF_DIRECTION)), dz(cv(BSDF_LOBE)));
|
|
104
|
+
#ifdef NUM_COAT_NORMAL_MAPS
|
|
105
|
+
vec3 bC = si.faceNormal;
|
|
106
|
+
vec3 mr = si.normal;
|
|
107
|
+
#endif
|
|
108
|
+
float rA = -dot(si.faceNormal, aa.ray.d);
|
|
109
|
+
float sq = -dot(si.normal, aa.ray.d);
|
|
110
|
+
if ((mat.transmissionWeight > 0.0 || mat.subsurfaceWeight > 0.0) && mat.thinWalled) {
|
|
111
|
+
|
|
112
|
+
if (rA < 0.0) {
|
|
113
|
+
si.faceNormal = -si.faceNormal;
|
|
114
|
+
rA = -rA;
|
|
115
|
+
}
|
|
116
|
+
if (sq < 0.0) {
|
|
117
|
+
si.normal = -si.normal;
|
|
118
|
+
sq = -sq;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
bool pI = rA >= 0.0 && sq < 0.0;
|
|
124
|
+
float ndv = pI ? rA : sq;
|
|
125
|
+
vec3 normal = pI ? si.faceNormal : si.normal;
|
|
126
|
+
|
|
127
|
+
mat.inside = ndv <= 0.0 && !mat.thinWalled;
|
|
128
|
+
|
|
129
|
+
mat.relativeIor = ndv > 0.0 ? (1.0 / mat.specularIor) : mat.specularIor;
|
|
130
|
+
vec3 ffnormal = ndv >= 0.0 ? normal : -normal;
|
|
131
|
+
#ifdef NUM_COAT_NORMAL_MAPS
|
|
132
|
+
if (mat.coatNormalEnabled) {
|
|
133
|
+
vec3 view = -aa.ray.d;
|
|
134
|
+
float fW = dot(bC, view);
|
|
135
|
+
mat.geometricNormal = fW >= 0.0 ? bC : -bC;
|
|
136
|
+
ffnormal = fB(mr, bC, view);
|
|
137
|
+
mat.coatNormal = fB(si.coatNormal, bC, view);
|
|
138
|
+
mat.inside = fW <= 0.0 && !mat.thinWalled;
|
|
139
|
+
mat.relativeIor = (fW > 0.0 || mat.thinWalled) ? 1.0 / mat.specularIor : mat.specularIor;
|
|
140
|
+
}
|
|
141
|
+
#endif
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
float scatteringPdf;
|
|
145
|
+
vec3 cF;
|
|
146
|
+
aa.scatteringIsDelta = false;
|
|
147
|
+
bool bl = false;
|
|
148
|
+
bool hj = false;
|
|
149
|
+
ag prepared;
|
|
150
|
+
|
|
151
|
+
#ifdef HAS_MEDIUM
|
|
152
|
+
int mediumType = si.mediumType;
|
|
153
|
+
float d = distance(si.position, aa.ray.o);
|
|
154
|
+
vec3 ne = aa.ray.o;
|
|
155
|
+
vec3 extinction = si.mediumExtinction;
|
|
156
|
+
vec3 scattering = min(si.mediumScattering, extinction);
|
|
157
|
+
float sl = max(max(extinction.x, extinction.y), extinction.z);
|
|
158
|
+
if (mediumType > 0 && sl > 0.0) {
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
int mT = min(int(dz(cv(MEDIUM_CHANNEL)) * 3.0), 2);
|
|
164
|
+
float fA = extinction[mT];
|
|
165
|
+
float ic = fA > 0.0
|
|
166
|
+
? min(-log(max(dz(cv(MEDIUM_DISTANCE)), 1e-7)) / fA, d)
|
|
167
|
+
: d;
|
|
168
|
+
bl = ic < d;
|
|
169
|
+
vec3 ew = exp(-extinction * ic);
|
|
170
|
+
vec3 nM = bl
|
|
171
|
+
? extinction * ew
|
|
172
|
+
: ew;
|
|
173
|
+
float nt = max(
|
|
174
|
+
(nM.x + nM.y + nM.z) / 3.0,
|
|
175
|
+
1e-8
|
|
176
|
+
);
|
|
177
|
+
if (bl) {
|
|
178
|
+
aa.beta *= ew * scattering / nt;
|
|
179
|
+
|
|
180
|
+
aa.ray.o = ne + ic * aa.ray.d;
|
|
181
|
+
si.position = aa.ray.o;
|
|
182
|
+
aa.li += mG(si, mat, prepared, aa, ffnormal, false) * aa.beta;
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
cF = fl(
|
|
186
|
+
-aa.ray.d,
|
|
187
|
+
si.mediumAnisotropy,
|
|
188
|
+
fk(cv(PHASE_DIRECTION))
|
|
189
|
+
);
|
|
190
|
+
scatteringPdf = bD(
|
|
191
|
+
dot(cF, -aa.ray.d),
|
|
192
|
+
si.mediumAnisotropy
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
aa.beta *= ew / nt;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
#endif
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
if (!bl) {
|
|
203
|
+
aa.li += mat.emission * aa.beta;
|
|
204
|
+
if (mat.materialType == UNLIT) {
|
|
205
|
+
aa.abort = true;
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
vec3 pG = vec3(0.0);
|
|
209
|
+
#ifdef USE_TANGENT
|
|
210
|
+
pG = si.tangent;
|
|
211
|
+
#endif
|
|
212
|
+
mat.directionTangent = si.directionTangent;
|
|
213
|
+
mat.directionBitangent = si.directionBitangent;
|
|
214
|
+
mat.geometryTangent = si.geometryTangent;
|
|
215
|
+
mat.geometryBitangent = si.geometryBitangent;
|
|
216
|
+
prepared = eG(pG, mat, -aa.ray.d, ffnormal);
|
|
217
|
+
aa.li += mG(si, mat, prepared, aa, ffnormal, true) * aa.beta;
|
|
218
|
+
|
|
219
|
+
bool isNextRefraction;
|
|
220
|
+
vec3 f = dv(
|
|
221
|
+
prepared,
|
|
222
|
+
ud,
|
|
223
|
+
cF,
|
|
224
|
+
scatteringPdf,
|
|
225
|
+
isNextRefraction
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
aa.scatteringIsDelta = !prepared.material.thinWalled &&
|
|
229
|
+
abs(prepared.material.relativeIor - 1.0) <= 1e-6 &&
|
|
230
|
+
prepared.probabilities[OPENPBR_LOBE_TRANSMISSION] >= 1.0 - 1e-6;
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
if (!(scatteringPdf > 0.0) || any(isnan(f)) || any(isinf(f)) ||
|
|
235
|
+
dot(cF, cF) < 0.5) {
|
|
236
|
+
aa.scatteringPdf = 0.0;
|
|
237
|
+
aa.abort = true;
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
aa.beta *= f / scatteringPdf;
|
|
241
|
+
hj = !mat.thinWalled &&
|
|
242
|
+
isNextRefraction;
|
|
243
|
+
aa.isNextRefraction = isNextRefraction;
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
aa.ray.o = si.position + EPS * cF;
|
|
247
|
+
#ifdef NUM_COAT_NORMAL_MAPS
|
|
248
|
+
if (mat.coatNormalEnabled) { aa.ray.o = si.position + EPS * (dot(bC, cF) >= 0.0 ? bC : -bC); }
|
|
249
|
+
#endif
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
aa.scatteringPdf = scatteringPdf;
|
|
253
|
+
iw(aa.ray, aa.ray.o, cF);
|
|
254
|
+
if (bl) {
|
|
255
|
+
aa.isNextRefraction = false;
|
|
256
|
+
}
|
|
257
|
+
aa.fromEye = false;
|
|
258
|
+
|
|
259
|
+
#ifdef HAS_MEDIUM
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
if (!bl && hj && mat.mediumType > 0) {
|
|
263
|
+
if (rA >= 0.0) {
|
|
264
|
+
si.mediumType = mat.mediumType;
|
|
265
|
+
si.mediumExtinction = mat.mediumExtinction;
|
|
266
|
+
si.mediumScattering = mat.mediumScattering;
|
|
267
|
+
si.mediumAnisotropy = mat.mediumAnisotropy;
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
si.mediumType = 0;
|
|
271
|
+
si.mediumExtinction = vec3(0.0);
|
|
272
|
+
si.mediumScattering = vec3(0.0);
|
|
273
|
+
si.mediumAnisotropy = 0.0;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
#endif
|
|
277
|
+
}
|
|
278
|
+
`;
|
|
279
|
+
//# sourceMappingURL=sampleMaterial.glsl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sampleMaterial.glsl.js","sourceRoot":"","sources":["../../../../src/renderer/glsl/chunks/sampleMaterial.glsl.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,iIAAiI;AAEjI,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,eAAe,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkRlB,CAAC","sourcesContent":["// Estimate the direct lighting integral using multiple importance sampling\n// http://www.pbr-book.org/3ed-2018/Light_Transport_I_Surface_Reflection/Direct_Lighting.html#EstimatingtheDirectLightingIntegral\n\nimport { glsl } from '../../shader.js';\nexport default glsl`\nvec3 DirectLight(SurfaceInteraction si, OpenPbrResolvedMaterial mat, OpenPbrPreparedBsdf prepared, inout Path path, vec3 ffnormal, bool isSurface) {\n float occluded = 1.0;\n vec3 lightRnd = vec3(sample2D(bounceDim(LIGHT_POSITION)), sample1D(bounceDim(LIGHT_SELECT)));\n\n LightSampleRec lightSample;\n sampleLight(si.position, lightRnd, lightSample, false);\n lightSample.emission = sampling_spectral_rgb_filter(lightSample.emission, pathWavelength);\n\n vec3 lightDir = lightSample.direction;\n vec3 viewDir = -path.ray.d;\n float lightPdf = lightSample.pdf;\n // Opaque surfaces are rendered two-sided by the core renderer. Use the\n // face-forward shading normal here as well, otherwise the early-out rejects\n // every direct-light sample seen from the back of a triangle (for example\n // the inside of an imported room wall).\n float cosThetaL = dot(ffnormal, lightDir);\n#ifdef NUM_COAT_NORMAL_MAPS\n if (isSurface && mat.coatNormalEnabled) { cosThetaL = dot(mat.geometricNormal, lightDir); }\n#endif\n\n if (lightPdf <= 0.0 || max(max(lightSample.emission.x, lightSample.emission.y), lightSample.emission.z) <= 0.0) {\n return vec3(0.0);\n }\n\n float scatteringPdf = 0.0;\n vec3 f = vec3(0.0);\n if (isSurface) {\n if (cosThetaL <= 0.0 && mat.transmissionWeight <= 0.0 && mat.subsurfaceWeight <= 0.0) {\n return vec3(0.0);\n }\n f = openpbr_eval_prepared(prepared, lightDir, scatteringPdf);\n }\n else {\n scatteringPdf = sampling_henyey_greenstein_phase(\n dot(viewDir, lightDir),\n si.mediumAnisotropy\n );\n f = vec3(scatteringPdf);\n }\n\n if (scatteringPdf <= 0.0 || max(max(f.x, f.y), f.z) <= 0.0) {\n return vec3(0.0);\n }\n\n Ray lightRay;\n vec3 shadowOrigin = si.position + EPS * lightDir;\n if (isSurface) {\n const float shadowTerminatorCutoff = 0.1;\n float normalLight = dot(si.normal, lightDir);\n#ifdef NUM_COAT_NORMAL_MAPS\n if (mat.coatNormalEnabled) { normalLight = dot(si.faceNormal, lightDir); }\n#endif\n vec3 geometricNormal = normalLight < 0.0 ? -si.faceNormal : si.faceNormal;\n normalLight = abs(normalLight);\n float geometricLight = dot(geometricNormal, lightDir);\n float offsetAmount = normalLight < shadowTerminatorCutoff\n ? clamp(\n 2.0 - (geometricLight + normalLight) / shadowTerminatorCutoff,\n 0.0,\n 1.0\n )\n : clamp(1.0 - geometricLight / shadowTerminatorCutoff, 0.0, 1.0);\n shadowOrigin += si.shadowOffset * offsetAmount;\n }\n initRay(lightRay, shadowOrigin, lightDir);\n if (intersectSceneShadow(lightRay, lightSample.dist - EPS, si.triangleIndex)) {\n return vec3(0.0);\n }\n\n#ifdef USE_ENVMAP\n // Match the endpoint used by a BSDF-sampled surface transmission, including\n // a separately displayed or grounded background and its coverage.\n if (isSurface && cosThetaL < 0.0 && lightRnd.z < envLightSelectionPmf) {\n vec4 background = sampleBackgroundFromRay(lightRay.o, lightDir);\n lightSample.emission = sampling_spectral_rgb_filter(background.rgb * background.a, pathWavelength);\n }\n#endif\n\n // Delta lights cannot be sampled by the BSDF strategy, so their MIS weight\n // is exactly one even when their light-selection PMF is small.\n float misWeight = lightSample.isDelta\n ? 1.0\n : sampling_power_heuristic(lightPdf, scatteringPdf);\n return misWeight > 0.0\n ? misWeight * lightSample.emission * f / lightPdf\n : vec3(0.0);\n}\n\n#ifdef NUM_COAT_NORMAL_MAPS\nvec3 coat_frame_normal(vec3 inputNormal, vec3 face, vec3 view) {\n bool front = dot(face, view) >= 0.0;\n vec3 ffFace = front ? face : -face;\n vec3 ffInput = front ? inputNormal : -inputNormal;\n if (dot(inputNormal, face) <= 0.0 || dot(ffInput, view) <= 1e-6) { return ffFace; }\n return ffInput;\n}\n#endif\nvoid SampleMaterial(inout SurfaceInteraction si, OpenPbrResolvedMaterial mat, inout Path path) {\n vec3 matRnd = vec3(sample2D(bounceDim(BSDF_DIRECTION)), sample1D(bounceDim(BSDF_LOBE)));\n#ifdef NUM_COAT_NORMAL_MAPS\n vec3 originalFace = si.faceNormal;\n vec3 originalNormal = si.normal;\n#endif\n float ndv1 = -dot(si.faceNormal, path.ray.d);\n float ndv2 = -dot(si.normal, path.ray.d);\n if ((mat.transmissionWeight > 0.0 || mat.subsurfaceWeight > 0.0) && mat.thinWalled) {\n // Always treat thin material as entering medium\n if (ndv1 < 0.0) {\n si.faceNormal = -si.faceNormal;\n ndv1 = -ndv1;\n }\n if (ndv2 < 0.0) {\n si.normal = -si.normal;\n ndv2 = -ndv2;\n }\n }\n // In same edge cases normal is not torwards the camera while we can still see the face.\n // We need to choose faceNormal in this case.\n bool useFaceN = ndv1 >= 0.0 && ndv2 < 0.0;\n float ndv = useFaceN ? ndv1 : ndv2;\n vec3 normal = useFaceN ? si.faceNormal : si.normal;\n\n mat.inside = ndv <= 0.0 && !mat.thinWalled;\n // In or out\n mat.relativeIor = ndv > 0.0 ? (1.0 / mat.specularIor) : mat.specularIor;\n vec3 ffnormal = ndv >= 0.0 ? normal : -normal;\n#ifdef NUM_COAT_NORMAL_MAPS\n if (mat.coatNormalEnabled) {\n vec3 view = -path.ray.d;\n float geometricView = dot(originalFace, view);\n mat.geometricNormal = geometricView >= 0.0 ? originalFace : -originalFace;\n ffnormal = coat_frame_normal(originalNormal, originalFace, view);\n mat.coatNormal = coat_frame_normal(si.coatNormal, originalFace, view);\n mat.inside = geometricView <= 0.0 && !mat.thinWalled;\n mat.relativeIor = (geometricView > 0.0 || mat.thinWalled) ? 1.0 / mat.specularIor : mat.specularIor;\n }\n#endif\n\n\n float scatteringPdf;\n vec3 scatterDir;\n path.scatteringIsDelta = false;\n bool mediumSampled = false;\n bool crossedBoundary = false;\n OpenPbrPreparedBsdf prepared;\n\n#ifdef HAS_MEDIUM\n int mediumType = si.mediumType;\n float d = distance(si.position, path.ray.o);\n vec3 segmentOrigin = path.ray.o;\n vec3 extinction = si.mediumExtinction;\n vec3 scattering = min(si.mediumScattering, extinction);\n float majorant = max(max(extinction.x, extinction.y), extinction.z);\n if (mediumType > 0 && majorant > 0.0) {\n // Sample one RGB extinction channel and divide by the mixture PDF. This\n // is the homogeneous-medium estimator used by PBRT and avoids the very\n // large exp((majorant - extinction) * distance) weights produced by\n // majorant tracking when OpenPBR SSS radii differ strongly by channel.\n int mediumChannel = min(int(sample1D(bounceDim(MEDIUM_CHANNEL)) * 3.0), 2);\n float channelExtinction = extinction[mediumChannel];\n float scatterDist = channelExtinction > 0.0\n ? min(-log(max(sample1D(bounceDim(MEDIUM_DISTANCE)), 1e-7)) / channelExtinction, d)\n : d;\n mediumSampled = scatterDist < d;\n vec3 transmittance = exp(-extinction * scatterDist);\n vec3 density = mediumSampled\n ? extinction * transmittance\n : transmittance;\n float mediumPdf = max(\n (density.x + density.y + density.z) / 3.0,\n 1e-8\n );\n if (mediumSampled) {\n path.beta *= transmittance * scattering / mediumPdf;\n // Move from the start of the segment, not from its end surface.\n path.ray.o = segmentOrigin + scatterDist * path.ray.d;\n si.position = path.ray.o;\n path.li += DirectLight(si, mat, prepared, path, ffnormal, false) * path.beta;\n\n // Pick a new direction based on the phase function\n scatterDir = sampling_henyey_greenstein(\n -path.ray.d,\n si.mediumAnisotropy,\n sample2D(bounceDim(PHASE_DIRECTION))\n );\n scatteringPdf = sampling_henyey_greenstein_phase(\n dot(scatterDir, -path.ray.d),\n si.mediumAnisotropy\n );\n }\n else {\n path.beta *= transmittance / mediumPdf;\n }\n }\n#endif\n\n // Direct lighting\n if (!mediumSampled) {\n path.li += mat.emission * path.beta;\n if (mat.materialType == UNLIT) {\n path.abort = true;\n return;\n }\n vec3 surfaceTangent = vec3(0.0);\n#ifdef USE_TANGENT\n surfaceTangent = si.tangent;\n#endif\n mat.directionTangent = si.directionTangent;\n mat.directionBitangent = si.directionBitangent;\n mat.geometryTangent = si.geometryTangent;\n mat.geometryBitangent = si.geometryBitangent;\n prepared = openpbr_prepare(surfaceTangent, mat, -path.ray.d, ffnormal);\n path.li += DirectLight(si, mat, prepared, path, ffnormal, true) * path.beta;\n // Sample BSDF for color and outgoing direction\n bool isNextRefraction;\n vec3 f = openpbr_sample_prepared(\n prepared,\n matRnd,\n scatterDir,\n scatteringPdf,\n isNextRefraction\n );\n // Null-boundary transmission is discrete and has no NEE competitor.\n path.scatteringIsDelta = !prepared.material.thinWalled &&\n abs(prepared.material.relativeIor - 1.0) <= 1e-6 &&\n prepared.probabilities[OPENPBR_LOBE_TRANSMISSION] >= 1.0 - 1e-6;\n // Match WebGPU: rejected VNDF/refraction proposals have no continuation.\n // Tracing their fallback direction with the incoming throughput invents\n // light paths, especially after total internal reflection inside glass.\n if (!(scatteringPdf > 0.0) || any(isnan(f)) || any(isinf(f)) ||\n dot(scatterDir, scatterDir) < 0.5) {\n path.scatteringPdf = 0.0;\n path.abort = true;\n return;\n }\n path.beta *= f / scatteringPdf;\n crossedBoundary = !mat.thinWalled &&\n isNextRefraction;\n path.isNextRefraction = isNextRefraction;\n // TODO prefer the opaque surface when transmission surface and opaque surface are overlapped.\n // Or the ray go out from transmission material will miss the opque surface.\n path.ray.o = si.position + EPS * scatterDir;\n#ifdef NUM_COAT_NORMAL_MAPS\n if (mat.coatNormalEnabled) { path.ray.o = si.position + EPS * (dot(originalFace, scatterDir) >= 0.0 ? originalFace : -originalFace); }\n#endif\n }\n\n path.scatteringPdf = scatteringPdf;\n initRay(path.ray, path.ray.o, scatterDir);\n if (mediumSampled) {\n path.isNextRefraction = false;\n }\n path.fromEye = false;\n\n#ifdef HAS_MEDIUM\n // A reflected ray stays in its current medium. Only a sampled transmission\n // event crosses the boundary of a medium-bearing closed mesh.\n if (!mediumSampled && crossedBoundary && mat.mediumType > 0) {\n if (ndv1 >= 0.0) {\n si.mediumType = mat.mediumType;\n si.mediumExtinction = mat.mediumExtinction;\n si.mediumScattering = mat.mediumScattering;\n si.mediumAnisotropy = mat.mediumAnisotropy;\n }\n else {\n si.mediumType = 0;\n si.mediumExtinction = vec3(0.0);\n si.mediumScattering = vec3(0.0);\n si.mediumAnisotropy = 0.0;\n }\n }\n#endif\n}\n`;\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Portions adapted from ray-tracing-renderer@0.10.15
|
|
2
|
+
// (https://github.com/hoverinc/ray-tracing-renderer).
|
|
3
|
+
// Copyright (c) 2019 HOVER, MIT license; see LICENSES/RayTracingRenderer-MIT.txt.
|
|
4
|
+
// Estimate the direct lighting integral using multiple importance sampling
|
|
5
|
+
// http://www.pbr-book.org/3ed-2018/Light_Transport_I_Surface_Reflection/Direct_Lighting.html#EstimatingtheDirectLightingIntegral
|
|
6
|
+
import { glsl } from '../../shader.js';
|
|
7
|
+
export default glsl `
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
const uint SHADOW_CATCHER_LIGHT_SAMPLES = 4u;
|
|
13
|
+
|
|
14
|
+
uint km(uint candidate, uint slot) {
|
|
15
|
+
return candidate == 0u ? cv(slot) : cv(9u + (candidate - 1u) * 3u + slot);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
void sampleShadowCatcher(ad si, int bounce, inout Path aa) {
|
|
19
|
+
vec3 oH = -aa.ray.d;
|
|
20
|
+
|
|
21
|
+
#if defined(NUM_LIGHTS) || defined(USE_ENVMAP)
|
|
22
|
+
float visibility = 0.0;
|
|
23
|
+
for (uint candidate = 0u; candidate < SHADOW_CATCHER_LIGHT_SAMPLES; candidate++) {
|
|
24
|
+
LightSampleRec lightSample;
|
|
25
|
+
vec3 kZ = vec3(
|
|
26
|
+
fk(km(candidate, LIGHT_POSITION)),
|
|
27
|
+
dz(km(candidate, LIGHT_SELECT))
|
|
28
|
+
);
|
|
29
|
+
sampleLight(si.position, kZ, lightSample, false);
|
|
30
|
+
|
|
31
|
+
vec3 lightDir = lightSample.direction;
|
|
32
|
+
float cosThetaL = dot(si.normal, lightDir);
|
|
33
|
+
float pq = dot(si.normal, oH) * cosThetaL;
|
|
34
|
+
bool mp = false;
|
|
35
|
+
if (pq >= 0.0) {
|
|
36
|
+
Ray ray;
|
|
37
|
+
iw(ray, si.position + EPS * lightDir, lightDir);
|
|
38
|
+
mp = ex(ray, lightSample.dist - EPS, si.triangleIndex);
|
|
39
|
+
}
|
|
40
|
+
visibility += mp ? 0.0 : 1.0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
aa.alpha = visibility / float(SHADOW_CATCHER_LIGHT_SAMPLES);
|
|
44
|
+
#endif
|
|
45
|
+
aa.fromEye = false;
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
//# sourceMappingURL=sampleShadowCatcher.glsl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sampleShadowCatcher.glsl.js","sourceRoot":"","sources":["../../../../src/renderer/glsl/chunks/sampleShadowCatcher.glsl.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,sDAAsD;AACtD,kFAAkF;AAElF,2EAA2E;AAC3E,iIAAiI;AAEjI,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,eAAe,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwClB,CAAC","sourcesContent":["// Portions adapted from ray-tracing-renderer@0.10.15\n// (https://github.com/hoverinc/ray-tracing-renderer).\n// Copyright (c) 2019 HOVER, MIT license; see LICENSES/RayTracingRenderer-MIT.txt.\n\n// Estimate the direct lighting integral using multiple importance sampling\n// http://www.pbr-book.org/3ed-2018/Light_Transport_I_Surface_Reflection/Direct_Lighting.html#EstimatingtheDirectLightingIntegral\n\nimport { glsl } from '../../shader.js';\n\nexport default glsl`\n// A one-sample binary shadow test leaves scattered fully dark pixels far\n// from the occluder at low sample counts. Averaging a few light samples per\n// primary hit costs only shadow rays and lets the mask settle much sooner.\n// Candidate dimensions match WGSL lightDim().\nconst uint SHADOW_CATCHER_LIGHT_SAMPLES = 4u;\n\nuint shadowCatcherLightDim(uint candidate, uint slot) {\n return candidate == 0u ? bounceDim(slot) : bounceDim(9u + (candidate - 1u) * 3u + slot);\n}\n\nvoid sampleShadowCatcher(SurfaceInteraction si, int bounce, inout Path path) {\n vec3 viewDir = -path.ray.d;\n\n#if defined(NUM_LIGHTS) || defined(USE_ENVMAP)\n float visibility = 0.0;\n for (uint candidate = 0u; candidate < SHADOW_CATCHER_LIGHT_SAMPLES; candidate++) {\n LightSampleRec lightSample;\n vec3 lightRnd = vec3(\n sample2D(shadowCatcherLightDim(candidate, LIGHT_POSITION)),\n sample1D(shadowCatcherLightDim(candidate, LIGHT_SELECT))\n );\n sampleLight(si.position, lightRnd, lightSample, false);\n\n vec3 lightDir = lightSample.direction;\n float cosThetaL = dot(si.normal, lightDir);\n float orientation = dot(si.normal, viewDir) * cosThetaL;\n bool occluded = false;\n if (orientation >= 0.0) {\n Ray ray;\n initRay(ray, si.position + EPS * lightDir, lightDir);\n occluded = intersectSceneShadow(ray, lightSample.dist - EPS, si.triangleIndex);\n }\n visibility += occluded ? 0.0 : 1.0;\n }\n // WebGL's compose pass converts visibility to shadow opacity.\n path.alpha = visibility / float(SHADOW_CATCHER_LIGHT_SAMPLES);\n#endif\n path.fromEye = false;\n}\n`;\n"]}
|