@meimu/mutracer 0.2.0 → 0.3.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.
Files changed (372) hide show
  1. package/CHANGELOG.md +222 -0
  2. package/LICENSES/FidelityFX-FSR.txt +19 -0
  3. package/LICENSES/pbrt-v4-Apache-2.0.txt +202 -0
  4. package/README.md +3 -0
  5. package/THIRD_PARTY_NOTICES.md +18 -4
  6. package/dist/assets/bvh.worker.js +1 -1
  7. package/dist/mutracer.umd.js +9328 -7614
  8. package/docs/api.md +83 -35
  9. package/docs/caustics.md +80 -0
  10. package/docs/materials.md +9 -6
  11. package/docs/performance.md +7 -0
  12. package/docs/post-processing.md +62 -9
  13. package/docs/progressive-rendering.md +53 -9
  14. package/docs/sampling.md +4 -0
  15. package/docs/technical/acceleration.md +52 -0
  16. package/docs/technical/aovs.md +79 -0
  17. package/docs/technical/caustics.md +109 -0
  18. package/docs/technical/continuous-spectrum.md +122 -0
  19. package/docs/technical/display-upscale.md +82 -0
  20. package/docs/technical/openpbr.md +99 -0
  21. package/docs/technical/pbrt-import.md +168 -0
  22. package/docs/technical/tiling.md +74 -0
  23. package/docs/technical/webgl.md +53 -0
  24. package/docs/updates.md +3 -1
  25. package/docs/viewer-checklist.md +65 -0
  26. package/docs/viewer.md +18 -6
  27. package/lib/Display.d.ts +19 -5
  28. package/lib/Display.js +10 -7
  29. package/lib/Display.js.map +1 -1
  30. package/lib/Engine.d.ts +4 -1
  31. package/lib/Engine.js +77 -14
  32. package/lib/Engine.js.map +1 -1
  33. package/lib/Render.d.ts +81 -24
  34. package/lib/Render.js +201 -26
  35. package/lib/Render.js.map +1 -1
  36. package/lib/RenderLoop.d.ts +7 -3
  37. package/lib/RenderLoop.js +68 -44
  38. package/lib/RenderLoop.js.map +1 -1
  39. package/lib/main.d.ts +4 -2
  40. package/lib/main.js +1 -0
  41. package/lib/main.js.map +1 -1
  42. package/lib/oidn.d.ts +1 -1
  43. package/lib/renderer/AovPrimitiveCache.js +39 -8
  44. package/lib/renderer/AovPrimitiveCache.js.map +1 -1
  45. package/lib/renderer/DisplayPostProcess.d.ts +8 -3
  46. package/lib/renderer/DisplayPostProcess.js +51 -18
  47. package/lib/renderer/DisplayPostProcess.js.map +1 -1
  48. package/lib/renderer/GPUTraceQueue.d.ts +2 -1
  49. package/lib/renderer/GPUTraceQueue.js +3 -1
  50. package/lib/renderer/GPUTraceQueue.js.map +1 -1
  51. package/lib/renderer/MaterialData.js +7 -2
  52. package/lib/renderer/MaterialData.js.map +1 -1
  53. package/lib/renderer/RenderingPipeline.d.ts +11 -1
  54. package/lib/renderer/RenderingPipeline.js.map +1 -1
  55. package/lib/renderer/TileRender.d.ts +2 -2
  56. package/lib/renderer/TileRender.js +128 -7
  57. package/lib/renderer/TileRender.js.map +1 -1
  58. package/lib/renderer/WGPUAov.d.ts +6 -1
  59. package/lib/renderer/WGPUAov.js +108 -14
  60. package/lib/renderer/WGPUAov.js.map +1 -1
  61. package/lib/renderer/WGPUCanvasSurface.js +12 -1
  62. package/lib/renderer/WGPUCanvasSurface.js.map +1 -1
  63. package/lib/renderer/WGPUCausticLightPass.d.ts +48 -0
  64. package/lib/renderer/WGPUCausticLightPass.js +217 -0
  65. package/lib/renderer/WGPUCausticLightPass.js.map +1 -0
  66. package/lib/renderer/WGPUEnvMapDistribution.js +19 -19
  67. package/lib/renderer/WGPUFullQuadPass.js +3 -3
  68. package/lib/renderer/WGPUPhotonMap.d.ts +37 -0
  69. package/lib/renderer/WGPUPhotonMap.js +191 -0
  70. package/lib/renderer/WGPUPhotonMap.js.map +1 -0
  71. package/lib/renderer/WGPURayTraceOutput.d.ts +13 -1
  72. package/lib/renderer/WGPURayTraceOutput.js +122 -28
  73. package/lib/renderer/WGPURayTraceOutput.js.map +1 -1
  74. package/lib/renderer/WGPURayTracePass.d.ts +65 -21
  75. package/lib/renderer/WGPURayTracePass.js +730 -409
  76. package/lib/renderer/WGPURayTracePass.js.map +1 -1
  77. package/lib/renderer/WGPURenderingPipeline.js +110 -68
  78. package/lib/renderer/WGPURenderingPipeline.js.map +1 -1
  79. package/lib/renderer/WebGLAov.js +3 -3
  80. package/lib/renderer/WebGLAov.js.map +1 -1
  81. package/lib/renderer/WebGLFullQuadPass.d.ts +2 -1
  82. package/lib/renderer/WebGLFullQuadPass.js +10 -0
  83. package/lib/renderer/WebGLFullQuadPass.js.map +1 -1
  84. package/lib/renderer/WebGLJNLMDenoiser.js +66 -66
  85. package/lib/renderer/WebGLJNLMDenoiser.js.map +1 -1
  86. package/lib/renderer/WebGLRayTraceOutputPass.js +4 -4
  87. package/lib/renderer/WebGLRayTracePass.d.ts +20 -11
  88. package/lib/renderer/WebGLRayTracePass.js +157 -116
  89. package/lib/renderer/WebGLRayTracePass.js.map +1 -1
  90. package/lib/renderer/WebGLRenderingPipeline.js +17 -14
  91. package/lib/renderer/WebGLRenderingPipeline.js.map +1 -1
  92. package/lib/renderer/WebGLSkyBaker.js +60 -60
  93. package/lib/renderer/accumulationTarget.d.ts +2 -1
  94. package/lib/renderer/accumulationTarget.js.map +1 -1
  95. package/lib/renderer/aov.d.ts +13 -1
  96. package/lib/renderer/aov.js +21 -2
  97. package/lib/renderer/aov.js.map +1 -1
  98. package/lib/renderer/aovDisplay.js +2 -2
  99. package/lib/renderer/aovDisplay.js.map +1 -1
  100. package/lib/renderer/binnedSahBvh.d.ts +2 -1
  101. package/lib/renderer/binnedSahBvh.js +24 -17
  102. package/lib/renderer/binnedSahBvh.js.map +1 -1
  103. package/lib/renderer/bvhAccel.d.ts +3 -1
  104. package/lib/renderer/bvhAccel.js +36 -6
  105. package/lib/renderer/bvhAccel.js.map +1 -1
  106. package/lib/renderer/cameraUniform.d.ts +1 -1
  107. package/lib/renderer/cameraUniform.js +6 -2
  108. package/lib/renderer/cameraUniform.js.map +1 -1
  109. package/lib/renderer/causticDiagnostics.d.ts +31 -0
  110. package/lib/renderer/causticDiagnostics.js +5 -0
  111. package/lib/renderer/causticDiagnostics.js.map +1 -0
  112. package/lib/renderer/causticEmission.d.ts +10 -0
  113. package/lib/renderer/causticEmission.js +40 -0
  114. package/lib/renderer/causticEmission.js.map +1 -0
  115. package/lib/renderer/causticUniform.d.ts +12 -0
  116. package/lib/renderer/causticUniform.js +22 -0
  117. package/lib/renderer/causticUniform.js.map +1 -0
  118. package/lib/renderer/caustics.d.ts +16 -0
  119. package/lib/renderer/caustics.js +93 -0
  120. package/lib/renderer/caustics.js.map +1 -0
  121. package/lib/renderer/compactVertices.d.ts +14 -0
  122. package/lib/renderer/compactVertices.js +124 -0
  123. package/lib/renderer/compactVertices.js.map +1 -0
  124. package/lib/renderer/easu.d.ts +11 -0
  125. package/lib/renderer/easu.js +156 -0
  126. package/lib/renderer/easu.js.map +1 -0
  127. package/lib/renderer/geometryUpdateState.d.ts +1 -0
  128. package/lib/renderer/geometryUpdateState.js.map +1 -1
  129. package/lib/renderer/geometryUpdates.js +3 -2
  130. package/lib/renderer/geometryUpdates.js.map +1 -1
  131. package/lib/renderer/glsl/aovDisplay.frag.js +5 -5
  132. package/lib/renderer/glsl/aovReflectance.glsl.js +53 -53
  133. package/lib/renderer/glsl/aovReflectanceSamples.glsl.js +1 -1
  134. package/lib/renderer/glsl/aovTrace.frag.js +45 -37
  135. package/lib/renderer/glsl/aovTrace.frag.js.map +1 -1
  136. package/lib/renderer/glsl/chunks/cameraProjection.glsl.d.ts +2 -0
  137. package/lib/renderer/glsl/chunks/cameraProjection.glsl.js +16 -0
  138. package/lib/renderer/glsl/chunks/cameraProjection.glsl.js.map +1 -0
  139. package/lib/renderer/glsl/chunks/cameraRay.glsl.d.ts +1 -1
  140. package/lib/renderer/glsl/chunks/cameraRay.glsl.js +9 -16
  141. package/lib/renderer/glsl/chunks/cameraRay.glsl.js.map +1 -1
  142. package/lib/renderer/glsl/chunks/emissiveLight.glsl.d.ts +2 -0
  143. package/lib/renderer/glsl/chunks/emissiveLight.glsl.js +35 -0
  144. package/lib/renderer/glsl/chunks/emissiveLight.glsl.js.map +1 -0
  145. package/lib/renderer/glsl/chunks/envMap.glsl.js +73 -73
  146. package/lib/renderer/glsl/chunks/intersect.glsl.js +478 -465
  147. package/lib/renderer/glsl/chunks/intersect.glsl.js.map +1 -1
  148. package/lib/renderer/glsl/chunks/materialBuffer.glsl.d.ts +1 -0
  149. package/lib/renderer/glsl/chunks/materialBuffer.glsl.js +156 -153
  150. package/lib/renderer/glsl/chunks/materialBuffer.glsl.js.map +1 -1
  151. package/lib/renderer/glsl/chunks/openPbrBsdf.glsl.js +771 -771
  152. package/lib/renderer/glsl/chunks/rand.glsl.js +3 -3
  153. package/lib/renderer/glsl/chunks/random.glsl.js +6 -6
  154. package/lib/renderer/glsl/chunks/rayTraceCore.glsl.d.ts +1 -0
  155. package/lib/renderer/glsl/chunks/rayTraceCore.glsl.js +70 -63
  156. package/lib/renderer/glsl/chunks/rayTraceCore.glsl.js.map +1 -1
  157. package/lib/renderer/glsl/chunks/sampleLight.glsl.js +89 -75
  158. package/lib/renderer/glsl/chunks/sampleLight.glsl.js.map +1 -1
  159. package/lib/renderer/glsl/chunks/sampleMaterial.glsl.d.ts +1 -0
  160. package/lib/renderer/glsl/chunks/sampleMaterial.glsl.js +160 -118
  161. package/lib/renderer/glsl/chunks/sampleMaterial.glsl.js.map +1 -1
  162. package/lib/renderer/glsl/chunks/sampleShadowCatcher.glsl.js +14 -14
  163. package/lib/renderer/glsl/chunks/sampling.glsl.js +88 -91
  164. package/lib/renderer/glsl/chunks/sampling.glsl.js.map +1 -1
  165. package/lib/renderer/glsl/chunks/sobol.glsl.js +79 -79
  166. package/lib/renderer/glsl/chunks/spectralPrefix.glsl.d.ts +6 -0
  167. package/lib/renderer/glsl/chunks/spectralPrefix.glsl.js +47 -0
  168. package/lib/renderer/glsl/chunks/spectralPrefix.glsl.js.map +1 -0
  169. package/lib/renderer/glsl/chunks/textureLinear.glsl.js +5 -5
  170. package/lib/renderer/glsl/chunks/uvProjection.glsl.js +11 -11
  171. package/lib/renderer/glsl/depthQuery.frag.js +13 -7
  172. package/lib/renderer/glsl/depthQuery.frag.js.map +1 -1
  173. package/lib/renderer/glsl/normalizeRayTraceOutput.frag.js +10 -10
  174. package/lib/renderer/glsl/rayTrace.frag.d.ts +1 -1
  175. package/lib/renderer/glsl/rayTrace.frag.js +338 -252
  176. package/lib/renderer/glsl/rayTrace.frag.js.map +1 -1
  177. package/lib/renderer/glsl/shadowCatcher.frag.js +27 -26
  178. package/lib/renderer/glsl/shadowCatcher.frag.js.map +1 -1
  179. package/lib/renderer/glsl/webglPipeline.frag.js +59 -59
  180. package/lib/renderer/gpuMemory.js +1 -1
  181. package/lib/renderer/gpuMemory.js.map +1 -1
  182. package/lib/renderer/lightSampling.d.ts +3 -2
  183. package/lib/renderer/lightSampling.js +14 -8
  184. package/lib/renderer/lightSampling.js.map +1 -1
  185. package/lib/renderer/openPbrEnergyLut.d.ts +2 -1
  186. package/lib/renderer/openPbrEnergyLut.js +18 -1
  187. package/lib/renderer/openPbrEnergyLut.js.map +1 -1
  188. package/lib/renderer/pathLimits.d.ts +5 -4
  189. package/lib/renderer/pathLimits.js +6 -5
  190. package/lib/renderer/pathLimits.js.map +1 -1
  191. package/lib/renderer/prepareMeshBVH.d.ts +2 -0
  192. package/lib/renderer/prepareMeshBVH.js +5 -3
  193. package/lib/renderer/prepareMeshBVH.js.map +1 -1
  194. package/lib/renderer/progressiveScheduler.js +5 -4
  195. package/lib/renderer/progressiveScheduler.js.map +1 -1
  196. package/lib/renderer/renderPipeline.d.ts +5 -0
  197. package/lib/renderer/renderPipeline.js +1 -0
  198. package/lib/renderer/renderPipeline.js.map +1 -1
  199. package/lib/renderer/researchTransport.d.ts +31 -0
  200. package/lib/renderer/researchTransport.js +5 -0
  201. package/lib/renderer/researchTransport.js.map +1 -0
  202. package/lib/renderer/sceneAssembly.d.ts +1 -1
  203. package/lib/renderer/sceneAssembly.js +4 -3
  204. package/lib/renderer/sceneAssembly.js.map +1 -1
  205. package/lib/renderer/sceneChangeDetector.d.ts +1 -1
  206. package/lib/renderer/sceneChangeDetector.js +3 -1
  207. package/lib/renderer/sceneChangeDetector.js.map +1 -1
  208. package/lib/renderer/sceneLayoutSchema.d.ts +2 -0
  209. package/lib/renderer/sceneLayoutSchema.js +3 -3
  210. package/lib/renderer/sceneLayoutSchema.js.map +1 -1
  211. package/lib/renderer/scenePreparation.d.ts +3 -2
  212. package/lib/renderer/scenePreparation.js +18 -2
  213. package/lib/renderer/scenePreparation.js.map +1 -1
  214. package/lib/renderer/scratchSampling.js +6 -6
  215. package/lib/renderer/spectrum.d.ts +21 -0
  216. package/lib/renderer/spectrum.js +154 -0
  217. package/lib/renderer/spectrum.js.map +1 -0
  218. package/lib/renderer/staticBvhPreparation.d.ts +9 -0
  219. package/lib/renderer/staticBvhPreparation.js +8 -2
  220. package/lib/renderer/staticBvhPreparation.js.map +1 -1
  221. package/lib/renderer/surfaceHit.d.ts +10 -0
  222. package/lib/renderer/surfaceHit.js +22 -0
  223. package/lib/renderer/surfaceHit.js.map +1 -0
  224. package/lib/renderer/tangentRequirements.d.ts +2 -0
  225. package/lib/renderer/tangentRequirements.js +7 -0
  226. package/lib/renderer/tangentRequirements.js.map +1 -0
  227. package/lib/renderer/textureAtlas.d.ts +4 -0
  228. package/lib/renderer/textureAtlas.js +48 -2
  229. package/lib/renderer/textureAtlas.js.map +1 -1
  230. package/lib/renderer/webgl.js +4 -0
  231. package/lib/renderer/webgl.js.map +1 -1
  232. package/lib/renderer/webglLightSampling.d.ts +39 -0
  233. package/lib/renderer/webglLightSampling.js +15 -0
  234. package/lib/renderer/webglLightSampling.js.map +1 -0
  235. package/lib/renderer/webglVertexAttributes.d.ts +17 -0
  236. package/lib/renderer/webglVertexAttributes.js +44 -0
  237. package/lib/renderer/webglVertexAttributes.js.map +1 -0
  238. package/lib/renderer/wgpuBindlessSource.js +3 -3
  239. package/lib/renderer/wgpuMaterialConstants.js +4 -3
  240. package/lib/renderer/wgpuMaterialConstants.js.map +1 -1
  241. package/lib/renderer/wgpuSceneUniform.js +2 -2
  242. package/lib/renderer/wgpuSceneUniform.js.map +1 -1
  243. package/lib/renderer/wgpuShaderSource.d.ts +22 -0
  244. package/lib/renderer/wgpuShaderSource.js +3 -1
  245. package/lib/renderer/wgpuShaderSource.js.map +1 -1
  246. package/lib/renderer/wgsl/aovCompact.wgsl.d.ts +4 -0
  247. package/lib/renderer/wgsl/aovCompact.wgsl.js +26 -0
  248. package/lib/renderer/wgsl/aovCompact.wgsl.js.map +1 -0
  249. package/lib/renderer/wgsl/aovDisplay.wgsl.js +9 -9
  250. package/lib/renderer/wgsl/aovReflectance.wgsl.js +55 -55
  251. package/lib/renderer/wgsl/aovReflectanceSamples.wgsl.js +1 -1
  252. package/lib/renderer/wgsl/aovResolve.wgsl.d.ts +4 -0
  253. package/lib/renderer/wgsl/aovResolve.wgsl.js +21 -2
  254. package/lib/renderer/wgsl/aovResolve.wgsl.js.map +1 -1
  255. package/lib/renderer/wgsl/aovSnapshot.wgsl.js +2 -2
  256. package/lib/renderer/wgsl/aovSnapshot.wgsl.js.map +1 -1
  257. package/lib/renderer/wgsl/aovTrace.wgsl.js +33 -33
  258. package/lib/renderer/wgsl/aovTraceDisplay.wgsl.d.ts +2 -0
  259. package/lib/renderer/wgsl/aovTraceDisplay.wgsl.js +56 -0
  260. package/lib/renderer/wgsl/aovTraceDisplay.wgsl.js.map +1 -0
  261. package/lib/renderer/wgsl/bloom.wgsl.js +18 -18
  262. package/lib/renderer/wgsl/causticLight.compute.d.ts +6 -0
  263. package/lib/renderer/wgsl/causticLight.compute.js +539 -0
  264. package/lib/renderer/wgsl/causticLight.compute.js.map +1 -0
  265. package/lib/renderer/wgsl/chunks/background.wgsl.d.ts +2 -0
  266. package/lib/renderer/wgsl/chunks/background.wgsl.js +102 -0
  267. package/lib/renderer/wgsl/chunks/background.wgsl.js.map +1 -0
  268. package/lib/renderer/wgsl/chunks/causticAdjoint.wgsl.d.ts +2 -0
  269. package/lib/renderer/wgsl/chunks/causticAdjoint.wgsl.js +12 -0
  270. package/lib/renderer/wgsl/chunks/causticAdjoint.wgsl.js.map +1 -0
  271. package/lib/renderer/wgsl/chunks/causticAtomic.wgsl.d.ts +2 -0
  272. package/lib/renderer/wgsl/chunks/causticAtomic.wgsl.js +16 -0
  273. package/lib/renderer/wgsl/chunks/causticAtomic.wgsl.js.map +1 -0
  274. package/lib/renderer/wgsl/chunks/caustics.wgsl.d.ts +1 -0
  275. package/lib/renderer/wgsl/chunks/caustics.wgsl.js +62 -0
  276. package/lib/renderer/wgsl/chunks/caustics.wgsl.js.map +1 -0
  277. package/lib/renderer/wgsl/chunks/common.wgsl.js +4 -4
  278. package/lib/renderer/wgsl/chunks/envMap.wgsl.js +37 -37
  279. package/lib/renderer/wgsl/chunks/intersect.wgsl.d.ts +6 -2
  280. package/lib/renderer/wgsl/chunks/intersect.wgsl.js +634 -620
  281. package/lib/renderer/wgsl/chunks/intersect.wgsl.js.map +1 -1
  282. package/lib/renderer/wgsl/chunks/intersectionAlpha.wgsl.d.ts +1 -1
  283. package/lib/renderer/wgsl/chunks/intersectionAlpha.wgsl.js +23 -21
  284. package/lib/renderer/wgsl/chunks/intersectionAlpha.wgsl.js.map +1 -1
  285. package/lib/renderer/wgsl/chunks/materialBuffer.wgsl.d.ts +3 -1
  286. package/lib/renderer/wgsl/chunks/materialBuffer.wgsl.js +77 -74
  287. package/lib/renderer/wgsl/chunks/materialBuffer.wgsl.js.map +1 -1
  288. package/lib/renderer/wgsl/chunks/openPbrBsdf.wgsl.js +795 -795
  289. package/lib/renderer/wgsl/chunks/pdm_displacement.wgsl.js +139 -139
  290. package/lib/renderer/wgsl/chunks/rand.wgsl.js +3 -3
  291. package/lib/renderer/wgsl/chunks/rayTraceCore.wgsl.d.ts +5 -1
  292. package/lib/renderer/wgsl/chunks/rayTraceCore.wgsl.js +45 -29
  293. package/lib/renderer/wgsl/chunks/rayTraceCore.wgsl.js.map +1 -1
  294. package/lib/renderer/wgsl/chunks/sampleLight.wgsl.d.ts +1 -1
  295. package/lib/renderer/wgsl/chunks/sampleLight.wgsl.js +142 -138
  296. package/lib/renderer/wgsl/chunks/sampleLight.wgsl.js.map +1 -1
  297. package/lib/renderer/wgsl/chunks/sampleMaterial.wgsl.d.ts +1 -1
  298. package/lib/renderer/wgsl/chunks/sampleMaterial.wgsl.js +228 -189
  299. package/lib/renderer/wgsl/chunks/sampleMaterial.wgsl.js.map +1 -1
  300. package/lib/renderer/wgsl/chunks/sampleShadowCatcher.wgsl.d.ts +1 -1
  301. package/lib/renderer/wgsl/chunks/sampleShadowCatcher.wgsl.js +11 -11
  302. package/lib/renderer/wgsl/chunks/sampleShadowCatcher.wgsl.js.map +1 -1
  303. package/lib/renderer/wgsl/chunks/sampling.wgsl.d.ts +1 -1
  304. package/lib/renderer/wgsl/chunks/sampling.wgsl.js +88 -92
  305. package/lib/renderer/wgsl/chunks/sampling.wgsl.js.map +1 -1
  306. package/lib/renderer/wgsl/chunks/sobol.wgsl.js +83 -83
  307. package/lib/renderer/wgsl/chunks/spectralPrefix.wgsl.d.ts +6 -0
  308. package/lib/renderer/wgsl/chunks/spectralPrefix.wgsl.js +66 -0
  309. package/lib/renderer/wgsl/chunks/spectralPrefix.wgsl.js.map +1 -0
  310. package/lib/renderer/wgsl/chunks/uvProjection.wgsl.js +11 -11
  311. package/lib/renderer/wgsl/chunks/vertexAttributes.wgsl.d.ts +2 -0
  312. package/lib/renderer/wgsl/chunks/vertexAttributes.wgsl.js +61 -0
  313. package/lib/renderer/wgsl/chunks/vertexAttributes.wgsl.js.map +1 -0
  314. package/lib/renderer/wgsl/compose.frag.wgsl.d.ts +2 -0
  315. package/lib/renderer/wgsl/compose.frag.wgsl.js +100 -98
  316. package/lib/renderer/wgsl/compose.frag.wgsl.js.map +1 -1
  317. package/lib/renderer/wgsl/customDenoise.wgsl.js +10 -10
  318. package/lib/renderer/wgsl/depthQuery.wgsl.d.ts +1 -1
  319. package/lib/renderer/wgsl/depthQuery.wgsl.js +12 -3
  320. package/lib/renderer/wgsl/depthQuery.wgsl.js.map +1 -1
  321. package/lib/renderer/wgsl/easu.wgsl.d.ts +2 -0
  322. package/lib/renderer/wgsl/easu.wgsl.js +80 -0
  323. package/lib/renderer/wgsl/easu.wgsl.js.map +1 -0
  324. package/lib/renderer/wgsl/easuDetail.wgsl.d.ts +21 -0
  325. package/lib/renderer/wgsl/easuDetail.wgsl.js +230 -0
  326. package/lib/renderer/wgsl/easuDetail.wgsl.js.map +1 -0
  327. package/lib/renderer/wgsl/jnlm.compute.js +74 -74
  328. package/lib/renderer/wgsl/jnlm.compute.js.map +1 -1
  329. package/lib/renderer/wgsl/offlineAdaptive.compute.js +26 -26
  330. package/lib/renderer/wgsl/oidnAuxiliary.wgsl.js +3 -3
  331. package/lib/renderer/wgsl/photonMap.compute.d.ts +29 -0
  332. package/lib/renderer/wgsl/photonMap.compute.js +352 -0
  333. package/lib/renderer/wgsl/photonMap.compute.js.map +1 -0
  334. package/lib/renderer/wgsl/proceduralSky.compute.js +64 -64
  335. package/lib/renderer/wgsl/rayTrace.compute.d.ts +23 -1
  336. package/lib/renderer/wgsl/rayTrace.compute.js +531 -543
  337. package/lib/renderer/wgsl/rayTrace.compute.js.map +1 -1
  338. package/lib/scene/MaterialState.d.ts +2 -2
  339. package/lib/scene/MaterialState.js +2 -2
  340. package/lib/scene/MaterialState.js.map +1 -1
  341. package/lib/scene/Scene.js.map +1 -1
  342. package/lib/settings/render.d.ts +22 -0
  343. package/lib/settings/render.js +2 -0
  344. package/lib/settings/render.js.map +1 -1
  345. package/lib/util/fromTHREE.js +23 -16
  346. package/lib/util/fromTHREE.js.map +1 -1
  347. package/lib/version.d.ts +1 -1
  348. package/lib/version.js +1 -1
  349. package/lib/version.js.map +1 -1
  350. package/llms.txt +2 -1
  351. package/package.json +7 -4
  352. package/lib/oidnBundledWeights.cdn.d.ts +0 -2
  353. package/lib/oidnBundledWeights.cdn.js +0 -5
  354. package/lib/oidnBundledWeights.cdn.js.map +0 -1
  355. package/lib/renderer/bvh.worker.d.ts +0 -1
  356. package/lib/renderer/bvh.worker.js +0 -16
  357. package/lib/renderer/bvh.worker.js.map +0 -1
  358. package/lib/renderer/bvhWorkerBuild.d.ts +0 -13
  359. package/lib/renderer/bvhWorkerBuild.js +0 -17
  360. package/lib/renderer/bvhWorkerBuild.js.map +0 -1
  361. package/lib/renderer/lightCore.d.ts +0 -12
  362. package/lib/renderer/lightCore.js +0 -13
  363. package/lib/renderer/lightCore.js.map +0 -1
  364. package/lib/renderer/materialCore.d.ts +0 -8
  365. package/lib/renderer/materialCore.js +0 -9
  366. package/lib/renderer/materialCore.js.map +0 -1
  367. package/lib/scene/PixelTexture.d.ts +0 -6
  368. package/lib/scene/PixelTexture.js +0 -10
  369. package/lib/scene/PixelTexture.js.map +0 -1
  370. package/lib/util/studioLighting.d.ts +0 -18
  371. package/lib/util/studioLighting.js +0 -36
  372. package/lib/util/studioLighting.js.map +0 -1
@@ -4,71 +4,71 @@ export default glsl `
4
4
 
5
5
 
6
6
 
7
- vec3 aD(vec3 view, vec2 alpha, vec2 samplePoint) {
8
- vec3 sv = vec3(alpha, 1.0);
9
- vec3 cr = normalize(sv * view);
10
- float qP = min(cr.z, 1.0);
11
- float kh = 1.0 + qP;
12
- float kC = (1.0 - samplePoint.y) * kh;
13
- float sU = samplePoint.y * kh;
14
- float tY = kC + (1.0 - qP);
15
- float ex = sqrt(max(0.0, tY * sU));
7
+ vec3 aA(vec3 view, vec2 alpha, vec2 samplePoint) {
8
+ vec3 qD = vec3(alpha, 1.0);
9
+ vec3 cf = normalize(qD * view);
10
+ float rU = min(cf.z, 1.0);
11
+ float ku = 1.0 + rU;
12
+ float kM = (1.0 - samplePoint.y) * ku;
13
+ float ur = samplePoint.y * ku;
14
+ float vK = kM + (1.0 - rU);
15
+ float dw = sqrt(max(0.0, vK * ur));
16
16
  float azimuth = TWOPI * samplePoint.x;
17
- vec3 mr = vec3(
18
- cr.x + ex * cos(azimuth),
19
- cr.y + ex * sin(azimuth),
20
- kC
17
+ vec3 mR = vec3(
18
+ cf.x + dw * cos(azimuth),
19
+ cf.y + dw * sin(azimuth),
20
+ kM
21
21
  );
22
- return normalize(sv * mr);
22
+ return normalize(qD * mR);
23
23
  }
24
24
 
25
- float cW(vec3 pf, vec2 alpha) {
26
- vec3 hF = vec3(
27
- pf.x / alpha.x,
28
- pf.y / alpha.y,
29
- pf.z
25
+ float sampling_ggx_ndf(vec3 qc, vec2 alpha) {
26
+ vec3 hG = vec3(
27
+ qc.x / alpha.x,
28
+ qc.y / alpha.y,
29
+ qc.z
30
30
  );
31
- float aq = dot(hF, hF);
31
+ float ah = dot(hG, hG);
32
32
  return 1.0 / (
33
- PI * alpha.x * alpha.y * aq * aq
33
+ PI * alpha.x * alpha.y * ah * ah
34
34
  );
35
35
  }
36
36
 
37
- float aF(vec3 direction, vec2 alpha) {
38
- float eQ = abs(direction.z);
39
- if (eQ <= 1e-8) {
37
+ float aD(vec3 direction, vec2 alpha) {
38
+ float eK = abs(direction.z);
39
+ if (eK <= 1e-8) {
40
40
  return 0.0;
41
41
  }
42
- vec2 iE = alpha * direction.xy;
43
- float mt = dot(iE, iE)
44
- / (eQ * eQ);
45
- return 2.0 / (1.0 + sqrt(1.0 + mt));
42
+ vec2 iK = alpha * direction.xy;
43
+ float mS = dot(iK, iK)
44
+ / (eK * eK);
45
+ return 2.0 / (1.0 + sqrt(1.0 + mS));
46
46
  }
47
47
 
48
48
  float aI(float cosine) {
49
- float dw = clamp(1.0 - cosine, 0.0, 1.0);
50
- return pow(dw, 5.0);
49
+ float da = clamp(1.0 - cosine, 0.0, 1.0);
50
+ return pow(da, 5.0);
51
51
  }
52
52
 
53
- float cC(float J, float cR) {
54
- float iS = clamp(abs(J), 0.0, 1.0);
55
- float kQ = cR * cR
56
- * max(0.0, 1.0 - iS * iS);
57
- if (kQ >= 1.0) {
53
+ float sampling_dielectric_fresnel(float J, float cH) {
54
+ float ja = clamp(abs(J), 0.0, 1.0);
55
+ float ld = cH * cH
56
+ * max(0.0, 1.0 - ja * ja);
57
+ if (ld >= 1.0) {
58
58
  return 1.0;
59
59
  }
60
60
 
61
- float mD = sqrt(max(0.0, 1.0 - kQ));
62
- float bk = (iS - cR * mD)
63
- / max(iS + cR * mD, 1e-8);
64
- float qC = (cR * iS - mD)
65
- / max(cR * iS + mD, 1e-8);
61
+ float nh = sqrt(max(0.0, 1.0 - ld));
62
+ float bf = (ja - cH * nh)
63
+ / max(ja + cH * nh, 1e-8);
64
+ float rH = (cH * ja - nh)
65
+ / max(cH * ja + nh, 1e-8);
66
66
  return 0.5 * (
67
- bk * bk + qC * qC
67
+ bf * bf + rH * rH
68
68
  );
69
69
  }
70
70
 
71
- vec2 gy(vec2 samplePoint) {
71
+ vec2 gA(vec2 samplePoint) {
72
72
  vec2 offset = 2.0 * samplePoint - vec2(1.0);
73
73
  if (offset.x == 0.0 && offset.y == 0.0) {
74
74
  return vec2(0.0);
@@ -87,78 +87,75 @@ angle = 0.5 * PI - 0.25 * PI * (offset.x / offset.y);
87
87
  return radius * vec2(cos(angle), sin(angle));
88
88
  }
89
89
 
90
- vec3 aO(vec2 samplePoint) {
91
- vec2 lk = gy(samplePoint);
90
+ vec3 aM(vec2 samplePoint) {
91
+ vec2 lL = gA(samplePoint);
92
92
  return vec3(
93
- lk,
94
- sqrt(max(0.0, 1.0 - dot(lk, lk)))
93
+ lL,
94
+ sqrt(max(0.0, 1.0 - dot(lL, lL)))
95
95
  );
96
96
  }
97
97
 
98
- float aK(float qo, float oJ) {
99
- float scale = max(qo, oJ);
98
+ float aG(float firstPdf, float secondPdf) {
99
+ float scale = max(firstPdf, secondPdf);
100
100
  if (scale <= 0.0) {
101
101
  return 0.0;
102
102
  }
103
- vec2 normalized = vec2(qo, oJ) / scale;
104
- vec2 pL = normalized * normalized;
105
- return pL.x / (pL.x + pL.y);
103
+ vec2 normalized = vec2(firstPdf, secondPdf) / scale;
104
+ vec2 qC = normalized * normalized;
105
+ return qC.x / (qC.x + qC.y);
106
106
  }
107
107
 
108
- void aP(in vec3 normal, out vec3 tangent, out vec3 bitangent) {
109
- float iI = normal.z >= 0.0 ? 1.0 : -1.0;
110
- float cL = -1.0 / (iI + normal.z);
111
- float xy = normal.x * normal.y * cL;
108
+ void sampling_orthonormal_basis(in vec3 normal, out vec3 tangent, out vec3 bitangent) {
109
+ float iP = normal.z >= 0.0 ? 1.0 : -1.0;
110
+ float cA = -1.0 / (iP + normal.z);
111
+ float xy = normal.x * normal.y * cA;
112
112
  tangent = vec3(
113
- 1.0 + iI * normal.x * normal.x * cL,
114
- iI * xy,
115
- -iI * normal.x
113
+ 1.0 + iP * normal.x * normal.x * cA,
114
+ iP * xy,
115
+ -iP * normal.x
116
116
  );
117
117
  bitangent = vec3(
118
118
  xy,
119
- iI + normal.y * normal.y * cL,
119
+ iP + normal.y * normal.y * cA,
120
120
  -normal.y
121
121
  );
122
122
  }
123
123
 
124
- vec3 aj(vec3 rgb, float wavelength) {
125
- if (wavelength == 0.0) {
124
+ vec3 sampling_spectral_rgb_filter(vec3 rgb, int channel) {
125
+ if (channel == 0) {
126
126
  return rgb;
127
127
  }
128
- vec3 vk = wavelength > 600.0
129
- ? vec3(1.0, 0.0, 0.0)
130
- : wavelength > 500.0
131
- ? vec3(0.0, 1.0, 0.0)
132
- : vec3(0.0, 0.0, 1.0);
133
- return rgb * vk;
128
+ vec3 uC = vec3(0.0);
129
+ uC[channel - 1] = 1.0;
130
+ return rgb * uC;
134
131
  }
135
132
 
136
- float ee(
133
+ float sampling_cauchy_ior(
137
134
  float wavelength,
138
- float hu,
139
- float hD,
140
- float rt
135
+ float hy,
136
+ float hF,
137
+ float sD
141
138
  ) {
142
- if (wavelength == 0.0 || hD <= 0.0) {
143
- return hu;
139
+ if (wavelength == 0.0 || hF <= 0.0) {
140
+ return hy;
144
141
  }
145
142
 
146
143
  const float FRAUNHOFER_C = 656.3;
147
144
  const float FRAUNHOFER_D = 587.6;
148
145
  const float FRAUNHOFER_F = 486.1;
149
- float kv = 1.0 / (
146
+ float kD = 1.0 / (
150
147
  1.0 / (FRAUNHOFER_F * FRAUNHOFER_F)
151
148
  - 1.0 / (FRAUNHOFER_C * FRAUNHOFER_C)
152
149
  );
153
- float oe = max(rt / hD, 1e-6);
154
- float rV = (hu - 1.0) * kv / oe;
155
- float uK = hu
156
- - rV / (FRAUNHOFER_D * FRAUNHOFER_D);
157
- return uK + rV / (wavelength * wavelength);
150
+ float oT = max(sD / hF, 1e-6);
151
+ float tj = (hy - 1.0) * kD / oT;
152
+ float wx = hy
153
+ - tj / (FRAUNHOFER_D * FRAUNHOFER_D);
154
+ return wx + tj / (wavelength * wavelength);
158
155
  }
159
156
 
160
- vec3 fH(
161
- vec3 gO,
157
+ vec3 dQ(
158
+ vec3 gQ,
162
159
  float anisotropy,
163
160
  vec2 samplePoint
164
161
  ) {
@@ -167,28 +164,28 @@ if (abs(anisotropy) < 0.001) {
167
164
  cosine = 1.0 - 2.0 * samplePoint.y;
168
165
  }
169
166
  else {
170
- float ju = (1.0 - anisotropy * anisotropy)
167
+ float fw = (1.0 - anisotropy * anisotropy)
171
168
  / (1.0 + anisotropy - 2.0 * anisotropy * samplePoint.y);
172
169
  cosine = (
173
- ju * ju - 1.0 - anisotropy * anisotropy
170
+ fw * fw - 1.0 - anisotropy * anisotropy
174
171
  ) / (2.0 * anisotropy);
175
172
  }
176
173
 
177
- float vF = sqrt(max(0.0, 1.0 - cosine * cosine));
174
+ float wk = sqrt(max(0.0, 1.0 - cosine * cosine));
178
175
  float azimuth = TWOPI * samplePoint.x;
179
176
  vec3 tangent;
180
177
  vec3 bitangent;
181
- aP(gO, tangent, bitangent);
182
- return tangent * (vF * cos(azimuth))
183
- + bitangent * (vF * sin(azimuth))
184
- + gO * cosine;
178
+ sampling_orthonormal_basis(gQ, tangent, bitangent);
179
+ return tangent * (wk * cos(azimuth))
180
+ + bitangent * (wk * sin(azimuth))
181
+ + gQ * cosine;
185
182
  }
186
183
 
187
- float bL(float cosine, float anisotropy) {
188
- float aq = 1.0 + anisotropy * anisotropy
184
+ float ba(float cosine, float anisotropy) {
185
+ float ah = 1.0 + anisotropy * anisotropy
189
186
  + 2.0 * anisotropy * cosine;
190
187
  return INV4PI * (1.0 - anisotropy * anisotropy)
191
- / (aq * sqrt(aq));
188
+ / (ah * sqrt(ah));
192
189
  }
193
190
  `;
194
191
  //# sourceMappingURL=sampling.glsl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sampling.glsl.js","sourceRoot":"","sources":["../../../../src/renderer/glsl/chunks/sampling.glsl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,eAAe,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+LlB,CAAC","sourcesContent":["import { glsl } from '../../shader.js';\n\nexport default glsl`\n// The GGX distribution and spherical-cap VNDF sampler are adapted from\n// adobe/openpbr-bsdf, Copyright 2026 Adobe, Apache-2.0. Other routines are\n// project implementations of their stated analytic distributions.\n\nvec3 sampling_ggx_visible_normal(vec3 view, vec2 alpha, vec2 samplePoint) {\n vec3 stretch = vec3(alpha, 1.0);\n vec3 sphericalView = normalize(stretch * view);\n float viewZ = min(sphericalView.z, 1.0);\n float capSpan = 1.0 + viewZ;\n float normalZ = (1.0 - samplePoint.y) * capSpan;\n float oneMinusZ = samplePoint.y * capSpan;\n float onePlusZ = normalZ + (1.0 - viewZ);\n float radial = sqrt(max(0.0, onePlusZ * oneMinusZ));\n float azimuth = TWOPI * samplePoint.x;\n vec3 sphericalNormal = vec3(\n sphericalView.x + radial * cos(azimuth),\n sphericalView.y + radial * sin(azimuth),\n normalZ\n );\n return normalize(stretch * sphericalNormal);\n}\n\nfloat sampling_ggx_ndf(vec3 halfway, vec2 alpha) {\n vec3 ellipsoidNormal = vec3(\n halfway.x / alpha.x,\n halfway.y / alpha.y,\n halfway.z\n );\n float denominator = dot(ellipsoidNormal, ellipsoidNormal);\n return 1.0 / (\n PI * alpha.x * alpha.y * denominator * denominator\n );\n}\n\nfloat sampling_ggx_smith_g1(vec3 direction, vec2 alpha) {\n float normalComponent = abs(direction.z);\n if (normalComponent <= 1e-8) {\n return 0.0;\n }\n vec2 roughDirection = alpha * direction.xy;\n float tanThetaSquared = dot(roughDirection, roughDirection)\n / (normalComponent * normalComponent);\n return 2.0 / (1.0 + sqrt(1.0 + tanThetaSquared));\n}\n\nfloat sampling_schlick_fifth_power(float cosine) {\n float complement = clamp(1.0 - cosine, 0.0, 1.0);\n return pow(complement, 5.0);\n}\n\nfloat sampling_dielectric_fresnel(float incidentCosine, float etaIOverEtaT) {\n float cosineI = clamp(abs(incidentCosine), 0.0, 1.0);\n float sineTSquared = etaIOverEtaT * etaIOverEtaT\n * max(0.0, 1.0 - cosineI * cosineI);\n if (sineTSquared >= 1.0) {\n return 1.0;\n }\n\n float cosineT = sqrt(max(0.0, 1.0 - sineTSquared));\n float perpendicular = (cosineI - etaIOverEtaT * cosineT)\n / max(cosineI + etaIOverEtaT * cosineT, 1e-8);\n float parallel = (etaIOverEtaT * cosineI - cosineT)\n / max(etaIOverEtaT * cosineI + cosineT, 1e-8);\n return 0.5 * (\n perpendicular * perpendicular + parallel * parallel\n );\n}\n\nvec2 sampling_concentric_disk(vec2 samplePoint) {\n vec2 offset = 2.0 * samplePoint - vec2(1.0);\n if (offset.x == 0.0 && offset.y == 0.0) {\n return vec2(0.0);\n }\n\n float radius;\n float angle;\n if (abs(offset.x) > abs(offset.y)) {\n radius = offset.x;\n angle = 0.25 * PI * (offset.y / offset.x);\n }\n else {\n radius = offset.y;\n angle = 0.5 * PI - 0.25 * PI * (offset.x / offset.y);\n }\n return radius * vec2(cos(angle), sin(angle));\n}\n\nvec3 sampling_cosine_hemisphere(vec2 samplePoint) {\n vec2 diskPoint = sampling_concentric_disk(samplePoint);\n return vec3(\n diskPoint,\n sqrt(max(0.0, 1.0 - dot(diskPoint, diskPoint)))\n );\n}\n\nfloat sampling_power_heuristic(float firstPdf, float secondPdf) {\n float scale = max(firstPdf, secondPdf);\n if (scale <= 0.0) {\n return 0.0;\n }\n vec2 normalized = vec2(firstPdf, secondPdf) / scale;\n vec2 squared = normalized * normalized;\n return squared.x / (squared.x + squared.y);\n}\n\nvoid sampling_orthonormal_basis(in vec3 normal, out vec3 tangent, out vec3 bitangent) {\n float signZ = normal.z >= 0.0 ? 1.0 : -1.0;\n float factor = -1.0 / (signZ + normal.z);\n float xy = normal.x * normal.y * factor;\n tangent = vec3(\n 1.0 + signZ * normal.x * normal.x * factor,\n signZ * xy,\n -signZ * normal.x\n );\n bitangent = vec3(\n xy,\n signZ + normal.y * normal.y * factor,\n -normal.y\n );\n}\n\nvec3 sampling_spectral_rgb_filter(vec3 rgb, float wavelength) {\n if (wavelength == 0.0) {\n return rgb;\n }\n vec3 channelMask = wavelength > 600.0\n ? vec3(1.0, 0.0, 0.0)\n : wavelength > 500.0\n ? vec3(0.0, 1.0, 0.0)\n : vec3(0.0, 0.0, 1.0);\n return rgb * channelMask;\n}\n\nfloat sampling_cauchy_ior(\n float wavelength,\n float referenceIor,\n float dispersionScale,\n float abbeNumber\n) {\n if (wavelength == 0.0 || dispersionScale <= 0.0) {\n return referenceIor;\n }\n\n const float FRAUNHOFER_C = 656.3;\n const float FRAUNHOFER_D = 587.6;\n const float FRAUNHOFER_F = 486.1;\n float inverseDifference = 1.0 / (\n 1.0 / (FRAUNHOFER_F * FRAUNHOFER_F)\n - 1.0 / (FRAUNHOFER_C * FRAUNHOFER_C)\n );\n float effectiveAbbe = max(abbeNumber / dispersionScale, 1e-6);\n float cauchyB = (referenceIor - 1.0) * inverseDifference / effectiveAbbe;\n float cauchyA = referenceIor\n - cauchyB / (FRAUNHOFER_D * FRAUNHOFER_D);\n return cauchyA + cauchyB / (wavelength * wavelength);\n}\n\nvec3 sampling_henyey_greenstein(\n vec3 forwardDirection,\n float anisotropy,\n vec2 samplePoint\n) {\n float cosine;\n if (abs(anisotropy) < 0.001) {\n cosine = 1.0 - 2.0 * samplePoint.y;\n }\n else {\n float ratio = (1.0 - anisotropy * anisotropy)\n / (1.0 + anisotropy - 2.0 * anisotropy * samplePoint.y);\n cosine = (\n ratio * ratio - 1.0 - anisotropy * anisotropy\n ) / (2.0 * anisotropy);\n }\n\n float sine = sqrt(max(0.0, 1.0 - cosine * cosine));\n float azimuth = TWOPI * samplePoint.x;\n vec3 tangent;\n vec3 bitangent;\n sampling_orthonormal_basis(forwardDirection, tangent, bitangent);\n return tangent * (sine * cos(azimuth))\n + bitangent * (sine * sin(azimuth))\n + forwardDirection * cosine;\n}\n\nfloat sampling_henyey_greenstein_phase(float cosine, float anisotropy) {\n float denominator = 1.0 + anisotropy * anisotropy\n + 2.0 * anisotropy * cosine;\n return INV4PI * (1.0 - anisotropy * anisotropy)\n / (denominator * sqrt(denominator));\n}\n`;\n"]}
1
+ {"version":3,"file":"sampling.glsl.js","sourceRoot":"","sources":["../../../../src/renderer/glsl/chunks/sampling.glsl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,eAAe,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4LlB,CAAC","sourcesContent":["import { glsl } from '../../shader.js';\n\nexport default glsl`\n// The GGX distribution and spherical-cap VNDF sampler are adapted from\n// adobe/openpbr-bsdf, Copyright 2026 Adobe, Apache-2.0. Other routines are\n// project implementations of their stated analytic distributions.\n\nvec3 sampling_ggx_visible_normal(vec3 view, vec2 alpha, vec2 samplePoint) {\n vec3 stretch = vec3(alpha, 1.0);\n vec3 sphericalView = normalize(stretch * view);\n float viewZ = min(sphericalView.z, 1.0);\n float capSpan = 1.0 + viewZ;\n float normalZ = (1.0 - samplePoint.y) * capSpan;\n float oneMinusZ = samplePoint.y * capSpan;\n float onePlusZ = normalZ + (1.0 - viewZ);\n float radial = sqrt(max(0.0, onePlusZ * oneMinusZ));\n float azimuth = TWOPI * samplePoint.x;\n vec3 sphericalNormal = vec3(\n sphericalView.x + radial * cos(azimuth),\n sphericalView.y + radial * sin(azimuth),\n normalZ\n );\n return normalize(stretch * sphericalNormal);\n}\n\nfloat sampling_ggx_ndf(vec3 halfway, vec2 alpha) {\n vec3 ellipsoidNormal = vec3(\n halfway.x / alpha.x,\n halfway.y / alpha.y,\n halfway.z\n );\n float denominator = dot(ellipsoidNormal, ellipsoidNormal);\n return 1.0 / (\n PI * alpha.x * alpha.y * denominator * denominator\n );\n}\n\nfloat sampling_ggx_smith_g1(vec3 direction, vec2 alpha) {\n float normalComponent = abs(direction.z);\n if (normalComponent <= 1e-8) {\n return 0.0;\n }\n vec2 roughDirection = alpha * direction.xy;\n float tanThetaSquared = dot(roughDirection, roughDirection)\n / (normalComponent * normalComponent);\n return 2.0 / (1.0 + sqrt(1.0 + tanThetaSquared));\n}\n\nfloat sampling_schlick_fifth_power(float cosine) {\n float complement = clamp(1.0 - cosine, 0.0, 1.0);\n return pow(complement, 5.0);\n}\n\nfloat sampling_dielectric_fresnel(float incidentCosine, float etaIOverEtaT) {\n float cosineI = clamp(abs(incidentCosine), 0.0, 1.0);\n float sineTSquared = etaIOverEtaT * etaIOverEtaT\n * max(0.0, 1.0 - cosineI * cosineI);\n if (sineTSquared >= 1.0) {\n return 1.0;\n }\n\n float cosineT = sqrt(max(0.0, 1.0 - sineTSquared));\n float perpendicular = (cosineI - etaIOverEtaT * cosineT)\n / max(cosineI + etaIOverEtaT * cosineT, 1e-8);\n float parallel = (etaIOverEtaT * cosineI - cosineT)\n / max(etaIOverEtaT * cosineI + cosineT, 1e-8);\n return 0.5 * (\n perpendicular * perpendicular + parallel * parallel\n );\n}\n\nvec2 sampling_concentric_disk(vec2 samplePoint) {\n vec2 offset = 2.0 * samplePoint - vec2(1.0);\n if (offset.x == 0.0 && offset.y == 0.0) {\n return vec2(0.0);\n }\n\n float radius;\n float angle;\n if (abs(offset.x) > abs(offset.y)) {\n radius = offset.x;\n angle = 0.25 * PI * (offset.y / offset.x);\n }\n else {\n radius = offset.y;\n angle = 0.5 * PI - 0.25 * PI * (offset.x / offset.y);\n }\n return radius * vec2(cos(angle), sin(angle));\n}\n\nvec3 sampling_cosine_hemisphere(vec2 samplePoint) {\n vec2 diskPoint = sampling_concentric_disk(samplePoint);\n return vec3(\n diskPoint,\n sqrt(max(0.0, 1.0 - dot(diskPoint, diskPoint)))\n );\n}\n\nfloat sampling_power_heuristic(float firstPdf, float secondPdf) {\n float scale = max(firstPdf, secondPdf);\n if (scale <= 0.0) {\n return 0.0;\n }\n vec2 normalized = vec2(firstPdf, secondPdf) / scale;\n vec2 squared = normalized * normalized;\n return squared.x / (squared.x + squared.y);\n}\n\nvoid sampling_orthonormal_basis(in vec3 normal, out vec3 tangent, out vec3 bitangent) {\n float signZ = normal.z >= 0.0 ? 1.0 : -1.0;\n float factor = -1.0 / (signZ + normal.z);\n float xy = normal.x * normal.y * factor;\n tangent = vec3(\n 1.0 + signZ * normal.x * normal.x * factor,\n signZ * xy,\n -signZ * normal.x\n );\n bitangent = vec3(\n xy,\n signZ + normal.y * normal.y * factor,\n -normal.y\n );\n}\n\nvec3 sampling_spectral_rgb_filter(vec3 rgb, int channel) {\n if (channel == 0) {\n return rgb;\n }\n vec3 channelMask = vec3(0.0);\n channelMask[channel - 1] = 1.0;\n return rgb * channelMask;\n}\n\nfloat sampling_cauchy_ior(\n float wavelength,\n float referenceIor,\n float dispersionScale,\n float abbeNumber\n) {\n if (wavelength == 0.0 || dispersionScale <= 0.0) {\n return referenceIor;\n }\n\n const float FRAUNHOFER_C = 656.3;\n const float FRAUNHOFER_D = 587.6;\n const float FRAUNHOFER_F = 486.1;\n float inverseDifference = 1.0 / (\n 1.0 / (FRAUNHOFER_F * FRAUNHOFER_F)\n - 1.0 / (FRAUNHOFER_C * FRAUNHOFER_C)\n );\n float effectiveAbbe = max(abbeNumber / dispersionScale, 1e-6);\n float cauchyB = (referenceIor - 1.0) * inverseDifference / effectiveAbbe;\n float cauchyA = referenceIor\n - cauchyB / (FRAUNHOFER_D * FRAUNHOFER_D);\n return cauchyA + cauchyB / (wavelength * wavelength);\n}\n\nvec3 sampling_henyey_greenstein(\n vec3 forwardDirection,\n float anisotropy,\n vec2 samplePoint\n) {\n float cosine;\n if (abs(anisotropy) < 0.001) {\n cosine = 1.0 - 2.0 * samplePoint.y;\n }\n else {\n float ratio = (1.0 - anisotropy * anisotropy)\n / (1.0 + anisotropy - 2.0 * anisotropy * samplePoint.y);\n cosine = (\n ratio * ratio - 1.0 - anisotropy * anisotropy\n ) / (2.0 * anisotropy);\n }\n\n float sine = sqrt(max(0.0, 1.0 - cosine * cosine));\n float azimuth = TWOPI * samplePoint.x;\n vec3 tangent;\n vec3 bitangent;\n sampling_orthonormal_basis(forwardDirection, tangent, bitangent);\n return tangent * (sine * cos(azimuth))\n + bitangent * (sine * sin(azimuth))\n + forwardDirection * cosine;\n}\n\nfloat sampling_henyey_greenstein_phase(float cosine, float anisotropy) {\n float denominator = 1.0 + anisotropy * anisotropy\n + 2.0 * anisotropy * cosine;\n return INV4PI * (1.0 - anisotropy * anisotropy)\n / (denominator * sqrt(denominator));\n}\n`;\n"]}
@@ -24,41 +24,41 @@ const uint BOUNCE_STRIDE = 64u;
24
24
 
25
25
 
26
26
 
27
- uvec2 aZ;
28
- uint aQ;
29
- uint bT = 0u;
30
- uint cP = 0u;
31
- uint dG(uint kW) {
32
- uint x = kW;
27
+ uvec2 aJ;
28
+ uint aC;
29
+ uint samplingBounce = 0u;
30
+ uint hashedCounter = 0u;
31
+ uint cD(uint lm) {
32
+ uint x = lm;
33
33
  x ^= x >> 16u; x *= 0x7feb352du;
34
34
  x ^= x >> 15u; x *= 0x846ca68bu;
35
35
  return x ^ (x >> 16u);
36
36
  }
37
- uint ar(uint a, uint b) {
38
- return dG(a ^ dG(b + 0x9e3779b9u));
37
+ uint ak(uint a, uint b) {
38
+ return cD(a ^ cD(b + 0x9e3779b9u));
39
39
  }
40
- uint iV(uint kW, uint seed) {
41
- uint x = kW + seed;
40
+ uint jc(uint lm, uint seed) {
41
+ uint x = lm + seed;
42
42
  x ^= x * 0x6c50b47cu; x ^= x * 0xb82f1e52u;
43
43
  x ^= x * 0xc7afe638u; x ^= x * 0x8d22f6e6u;
44
44
  return x;
45
45
  }
46
- uint ua(uint x, uint seed) {
47
- return reverseBits(iV(reverseBits(x), seed));
46
+ uint vN(uint x, uint seed) {
47
+ return reverseBits(jc(reverseBits(x), seed));
48
48
  }
49
49
 
50
- uint su(uint kW) {
51
- uint r = reverseBits(kW);
50
+ uint tP(uint lm) {
51
+ uint r = reverseBits(lm);
52
52
  ${sobolD1Steps.map(([shift, mask]) => `r ^= (r << ${shift}u) & 0x${mask.toString(16)}u;`).join("\n ")}
53
53
  return r;
54
54
  }
55
- vec2 xE(uint index, uint seed) {
56
- uint i = ua(index, ar(seed, 0u));
57
- uint x = reverseBits(iV(i, ar(seed, 1u)));
58
- uint y = ua(su(i), ar(seed, 2u));
55
+ vec2 Ac(uint index, uint seed) {
56
+ uint i = vN(index, ak(seed, 0u));
57
+ uint x = reverseBits(jc(i, ak(seed, 1u)));
58
+ uint y = vN(tP(i), ak(seed, 2u));
59
59
  return vec2(float(x >> 8u), float(y >> 8u)) * (1.0 / 16777216.0);
60
60
  }
61
- uint uR(uvec2 p) {
61
+ uint wL(uvec2 p) {
62
62
  uvec2 v = p & uvec2(255u);
63
63
  v = (v | (v << uvec2(4u))) & uvec2(0x0f0fu);
64
64
  v = (v | (v << uvec2(2u))) & uvec2(0x3333u);
@@ -66,104 +66,104 @@ v = (v | (v << uvec2(1u))) & uvec2(0x5555u);
66
66
  return v.x | (v.y << 1u);
67
67
  }
68
68
  ${zSobolPackedPermutations.map((v, i) => `const uint Z_PERM_${i} = ${v}u;`).join("\n")}
69
- uint la(uint uU) {
70
- uint group = uU >> 2u;
69
+ uint lq(uint wO) {
70
+ uint group = wO >> 2u;
71
71
  uint word = Z_PERM_5;
72
72
  ${[0, 1, 2, 3, 4].map(i => `word = group == ${i}u ? Z_PERM_${i} : word;`).join("\n ")}
73
- return (word >> ((uU & 3u) * 8u)) & 255u;
73
+ return (word >> ((wO & 3u) * 8u)) & 255u;
74
74
  }
75
- uint qS(uint lu, uint dim, uint logSPP) {
75
+ uint rX(uint lS, uint dim, uint logSPP) {
76
76
  uint odd = logSPP & 1u;
77
- uint vN = 8u + ((logSPP + 1u) >> 1u);
77
+ uint xX = 8u + ((logSPP + 1u) >> 1u);
78
78
  uint result = 0u;
79
- for (int digit = int(vN) - 1; digit >= int(odd); digit--) {
79
+ for (int digit = int(xX) - 1; digit >= int(odd); digit--) {
80
80
  uint shift = 2u*uint(digit) - odd;
81
81
 
82
- uint tL = 0u;
83
- if (shift < 30u) { tL = lu >> (shift + 2u); }
84
- uint uU = (dG(tL ^ (0x55555555u * dim)) >> 24u) % 24u;
85
- uint d = (lu >> shift) & 3u;
86
- result |= ((la(uU) >> (2u*d)) & 3u) << shift;
82
+ uint vs = 0u;
83
+ if (shift < 30u) { vs = lS >> (shift + 2u); }
84
+ uint wO = (cD(vs ^ (0x55555555u * dim)) >> 24u) % 24u;
85
+ uint d = (lS >> shift) & 3u;
86
+ result |= ((lq(wO) >> (2u*d)) & 3u) << shift;
87
87
  }
88
88
  if (odd != 0u) {
89
- result |= (lu & 1u) ^ (dG((lu >> 1u) ^ (0x55555555u * dim)) & 1u);
89
+ result |= (lS & 1u) ^ (cD((lS >> 1u) ^ (0x55555555u * dim)) & 1u);
90
90
  }
91
91
  return result;
92
92
  }
93
93
 
94
94
 
95
95
 
96
- uint cE(uint slot) {
97
- return CAMERA_BEVEL_BASE + uint(BEVEL_SAMPLES) + bT * BOUNCE_STRIDE + slot;
96
+ uint aX(uint slot) {
97
+ return CAMERA_BEVEL_BASE + uint(BEVEL_SAMPLES) + samplingBounce * BOUNCE_STRIDE + slot;
98
98
  }
99
99
 
100
- uvec4 hA;
101
- uint hB;
102
- bool fQ = false;
103
- bool dv = false;
104
- uint dQ;
105
- uint gK;
106
- vec2 fa;
107
- void dN(uint dim) {
100
+ uvec4 hC;
101
+ uint hD;
102
+ bool fM = false;
103
+ bool cZ = false;
104
+ uint dF;
105
+ uint gM;
106
+ vec2 eT;
107
+ void ds(uint dim) {
108
108
 
109
- uint kI = aZ.x + aZ.y * uint(round(1.0 / pixelSize.x));
110
- uvec4 key = uvec4(dim, aQ, kI, uint(sequenceSeed));
111
- if (fQ && all(equal(hA, key)) && hB == uint(zSobolLogSPP)) { return; }
112
- hA = key; hB = uint(zSobolLogSPP);
113
- fQ = true; dv = false;
114
- uint seed = ar(ar(kI, dim), uint(sequenceSeed));
115
- uint index = aQ;
109
+ uint kT = aJ.x + aJ.y * uint(round(1.0 / pixelSize.x));
110
+ uvec4 key = uvec4(dim, aC, kT, uint(sequenceSeed));
111
+ if (fM && all(equal(hC, key)) && hD == uint(zSobolLogSPP)) { return; }
112
+ hC = key; hD = uint(zSobolLogSPP);
113
+ fM = true; cZ = false;
114
+ uint seed = ak(ak(kT, dim), uint(sequenceSeed));
115
+ uint index = aC;
116
116
  if (samplingPattern == 1) {
117
117
  uint logSPP = uint(zSobolLogSPP);
118
118
  if (index == 0u) { logSPP = 0u; }
119
119
  else { index -= 1u; }
120
120
 
121
- uint jw = index >> logSPP;
121
+ uint jH = index >> logSPP;
122
122
  uint mask = (1u << logSPP) - 1u;
123
- uint lu = (uR(aZ) << logSPP) | (index & mask);
124
- index = qS(lu, dim, logSPP);
125
- uvec2 tile = aZ >> uvec2(8u);
126
- seed = ar(ar(dim, uint(sequenceSeed)), ar(tile.x, tile.y));
123
+ uint lS = (wL(aJ) << logSPP) | (index & mask);
124
+ index = rX(lS, dim, logSPP);
125
+ uvec2 tile = aJ >> uvec2(8u);
126
+ seed = ak(ak(dim, uint(sequenceSeed)), ak(tile.x, tile.y));
127
127
 
128
- if (aQ != 0u) { jw += 1u; }
129
- seed = ar(seed, jw);
128
+ if (aC != 0u) { jH += 1u; }
129
+ seed = ak(seed, jH);
130
130
  }
131
- dQ = ua(index, ar(seed, 0u));
132
- gK = seed;
133
- uint x = reverseBits(iV(dQ, ar(seed, 1u)));
134
- fa.x = float(x >> 8u) * (1.0 / 16777216.0);
131
+ dF = vN(index, ak(seed, 0u));
132
+ gM = seed;
133
+ uint x = reverseBits(jc(dF, ak(seed, 1u)));
134
+ eT.x = float(x >> 8u) * (1.0 / 16777216.0);
135
135
  }
136
- vec2 lC(uint dim) {
137
- dN(dim);
138
- if (!dv) {
139
- uint y = ua(su(dQ), ar(gK, 2u));
140
- fa.y = float(y >> 8u) * (1.0 / 16777216.0);
141
- dv = true;
136
+ vec2 lZ(uint dim) {
137
+ ds(dim);
138
+ if (!cZ) {
139
+ uint y = vN(tP(dF), ak(gM, 2u));
140
+ eT.y = float(y >> 8u) * (1.0 / 16777216.0);
141
+ cZ = true;
142
142
  }
143
- return EPS + (1.0 - 2.0*EPS) * fa;
143
+ return EPS + (1.0 - 2.0*EPS) * eT;
144
144
  }
145
- float dp(uint dim) {
145
+ float sample1D(uint dim) {
146
146
  if (samplingPattern == 2) { return EPS + (1.0 - 2.0*EPS)*rand(); }
147
- dN(dim);
148
- return EPS + (1.0 - 2.0*EPS) * fa.x;
147
+ ds(dim);
148
+ return EPS + (1.0 - 2.0*EPS) * eT.x;
149
149
  }
150
- vec2 dZ(uint dim) {
150
+ vec2 sample2D(uint dim) {
151
151
  if (samplingPattern == 2) {
152
- float x = dp(dim); float y = dp(dim);
152
+ float x = sample1D(dim); float y = sample1D(dim);
153
153
  return vec2(x,y);
154
154
  }
155
- return lC(dim);
155
+ return lZ(dim);
156
156
  }
157
157
 
158
- float eC(uint slot) {
159
- uint dim = ar(ar(bT, slot), cP) | 0x80000000u;
160
- cP += 1u;
158
+ float cm(uint slot) {
159
+ uint dim = ak(ak(samplingBounce, slot), hashedCounter) | 0x80000000u;
160
+ hashedCounter += 1u;
161
161
  if (samplingPattern == 2) { return EPS + (1.0 - 2.0*EPS)*rand(); }
162
162
 
163
- uint kI = aZ.x + aZ.y * uint(round(1.0 / pixelSize.x));
164
- uint seed = ar(ar(kI, dim), uint(sequenceSeed));
165
- uint i = ua(aQ, ar(seed, 0u));
166
- uint x = reverseBits(iV(i, ar(seed, 1u)));
163
+ uint kT = aJ.x + aJ.y * uint(round(1.0 / pixelSize.x));
164
+ uint seed = ak(ak(kT, dim), uint(sequenceSeed));
165
+ uint i = vN(aC, ak(seed, 0u));
166
+ uint x = reverseBits(jc(i, ak(seed, 1u)));
167
167
  return EPS + (1.0 - 2.0*EPS) * (float(x >> 8u) * (1.0 / 16777216.0));
168
168
  }
169
169
  `;
@@ -0,0 +1,6 @@
1
+ export declare const spectralPrefixGlsl = "\nstruct SpectralCompleted {\n bool ready; vec4 result; RayTraceAuxiliary aux;\n uvec4 rng; uint counter; uint bounce;\n};\nSpectralCompleted spCompleted[2];\nbool spActive = true;\nint spChannel;\nint spCall = 0;\nint spForkCall = -1;\nstruct SpectralPrimary {\n SurfaceInteraction si; OpenPbrResolvedMaterial mat; RayTraceAuxiliary aux;\n uvec4 rng; uint counter; uint bounce;\n};\nSpectralPrimary spPrimary;\nbool spDisperses(OpenPbrResolvedMaterial mat) {\n return mat.transmissionDispersionScale > 0.0 && mat.specularIor != 1.0;\n}\nvoid spFork(inout Path path) {\n spActive = false; pathChannel = spChannel;\n path.li = sampling_spectral_rgb_filter(path.li, spChannel);\n}\nvec4 spReplay(int slot, inout RayTraceAuxiliary aux) {\n SpectralCompleted saved = spCompleted[slot];\n aux = saved.aux; s0 = saved.rng; hashedCounter = saved.counter; samplingBounce = saved.bounce;\n return vec4(sampling_spectral_rgb_filter(saved.result.rgb, spChannel), saved.result.a);\n}\nvec4 spFinish(int slot, vec4 result, RayTraceAuxiliary aux) {\n if (!spActive) return result;\n if (spChannel == 1) spCompleted[slot] = SpectralCompleted(true, result, aux, s0, hashedCounter, samplingBounce);\n return vec4(sampling_spectral_rgb_filter(result.rgb, spChannel), result.a);\n}\n";
2
+ export type PrefixBindings = Record<string, [type: string, expression: string]>;
3
+ export declare const prefixRandomBindings: PrefixBindings;
4
+ export declare function prefixCheckpoint(name: string, bindings: PrefixBindings): string;
5
+ export declare function prefixSave(name: string, bindings: PrefixBindings): string;
6
+ export declare function prefixRestore(name: string, bindings: PrefixBindings): string;
@@ -0,0 +1,47 @@
1
+ // The three wavelength continuations run inside one fragment invocation.
2
+ export const spectralPrefixGlsl = /* glsl */ `
3
+ struct eE {
4
+ bool ready; vec4 result; RayTraceAuxiliary aux;
5
+ uvec4 rng; uint counter; uint bounce;
6
+ };
7
+ eE eB[2];
8
+ bool spActive = true;
9
+ int spChannel;
10
+ int qz = 0;
11
+ int fC = -1;
12
+ struct qI {
13
+ SurfaceInteraction si; OpenPbrResolvedMaterial mat; RayTraceAuxiliary aux;
14
+ uvec4 rng; uint counter; uint bounce;
15
+ };
16
+ qI lY;
17
+ bool gf(OpenPbrResolvedMaterial mat) {
18
+ return mat.transmissionDispersionScale > 0.0 && mat.specularIor != 1.0;
19
+ }
20
+ void qA(inout Path path) {
21
+ spActive = false; pathChannel = spChannel;
22
+ path.li = sampling_spectral_rgb_filter(path.li, spChannel);
23
+ }
24
+ vec4 rN(int slot, inout RayTraceAuxiliary aux) {
25
+ eE oM = eB[slot];
26
+ aux = oM.aux; s0 = oM.rng; hashedCounter = oM.counter; samplingBounce = oM.bounce;
27
+ return vec4(sampling_spectral_rgb_filter(oM.result.rgb, spChannel), oM.result.a);
28
+ }
29
+ vec4 spFinish(int slot, vec4 result, RayTraceAuxiliary aux) {
30
+ if (!spActive) return result;
31
+ if (spChannel == 1) eB[slot] = eE(true, result, aux, s0, hashedCounter, samplingBounce);
32
+ return vec4(sampling_spectral_rgb_filter(result.rgb, spChannel), result.a);
33
+ }
34
+ `;
35
+ export const prefixRandomBindings = {
36
+ rng: ['uvec4', 's0'], counter: ['uint', 'hashedCounter'], bounce: ['uint', 'samplingBounce']
37
+ };
38
+ export function prefixCheckpoint(name, bindings) {
39
+ return `struct ${name}State {\n${Object.entries(bindings).map(([key, [type]]) => ` ${type} ${key};`).join('\n')}\n};\n${name}State ${name};\n`;
40
+ }
41
+ export function prefixSave(name, bindings) {
42
+ return Object.entries(bindings).map(([key, [, value]]) => `${name}.${key} = ${value};`).join('\n');
43
+ }
44
+ export function prefixRestore(name, bindings) {
45
+ return Object.entries(bindings).map(([key, [, value]]) => `${value} = ${name}.${key};`).join('\n');
46
+ }
47
+ //# sourceMappingURL=spectralPrefix.glsl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spectralPrefix.glsl.js","sourceRoot":"","sources":["../../../../src/renderer/glsl/chunks/spectralPrefix.glsl.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgC5C,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAmB;IAClD,GAAG,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,gBAAgB,CAAC;CAC7F,CAAC;AACF,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,QAAwB;IACrE,OAAO,UAAU,IAAI,YAAY,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,IAAI,IAAI,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,SAAS,IAAI,KAAK,CAAC;AAClJ,CAAC;AACD,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,QAAwB;IAC/D,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,GAAG,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrG,CAAC;AACD,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,QAAwB;IAClE,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,MAAM,IAAI,IAAI,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrG,CAAC","sourcesContent":["// The three wavelength continuations run inside one fragment invocation.\nexport const spectralPrefixGlsl = /* glsl */ `\nstruct SpectralCompleted {\n bool ready; vec4 result; RayTraceAuxiliary aux;\n uvec4 rng; uint counter; uint bounce;\n};\nSpectralCompleted spCompleted[2];\nbool spActive = true;\nint spChannel;\nint spCall = 0;\nint spForkCall = -1;\nstruct SpectralPrimary {\n SurfaceInteraction si; OpenPbrResolvedMaterial mat; RayTraceAuxiliary aux;\n uvec4 rng; uint counter; uint bounce;\n};\nSpectralPrimary spPrimary;\nbool spDisperses(OpenPbrResolvedMaterial mat) {\n return mat.transmissionDispersionScale > 0.0 && mat.specularIor != 1.0;\n}\nvoid spFork(inout Path path) {\n spActive = false; pathChannel = spChannel;\n path.li = sampling_spectral_rgb_filter(path.li, spChannel);\n}\nvec4 spReplay(int slot, inout RayTraceAuxiliary aux) {\n SpectralCompleted saved = spCompleted[slot];\n aux = saved.aux; s0 = saved.rng; hashedCounter = saved.counter; samplingBounce = saved.bounce;\n return vec4(sampling_spectral_rgb_filter(saved.result.rgb, spChannel), saved.result.a);\n}\nvec4 spFinish(int slot, vec4 result, RayTraceAuxiliary aux) {\n if (!spActive) return result;\n if (spChannel == 1) spCompleted[slot] = SpectralCompleted(true, result, aux, s0, hashedCounter, samplingBounce);\n return vec4(sampling_spectral_rgb_filter(result.rgb, spChannel), result.a);\n}\n`;\nexport type PrefixBindings = Record<string, [type: string, expression: string]>;\nexport const prefixRandomBindings: PrefixBindings = {\n rng: ['uvec4', 's0'], counter: ['uint', 'hashedCounter'], bounce: ['uint', 'samplingBounce']\n};\nexport function prefixCheckpoint(name: string, bindings: PrefixBindings) {\n return `struct ${name}State {\\n${Object.entries(bindings).map(([key, [type]]) => ` ${type} ${key};`).join('\\n')}\\n};\\n${name}State ${name};\\n`;\n}\nexport function prefixSave(name: string, bindings: PrefixBindings) {\n return Object.entries(bindings).map(([key, [, value]]) => `${name}.${key} = ${value};`).join('\\n');\n}\nexport function prefixRestore(name: string, bindings: PrefixBindings) {\n return Object.entries(bindings).map(([key, [, value]]) => `${value} = ${name}.${key};`).join('\\n');\n}\n"]}
@@ -9,16 +9,16 @@ vec4 textureLinear(sampler2D map, vec2 uv) {
9
9
  return texture(map, uv);
10
10
  #else
11
11
  vec2 size = vec2(textureSize(map, 0));
12
- vec2 qX = 1.0 / size;
12
+ vec2 se = 1.0 / size;
13
13
 
14
14
  uv = uv * size - 0.5;
15
15
  vec2 f = fract(uv);
16
16
  uv = floor(uv) + 0.5;
17
17
 
18
- vec4 s1 = texture(map, (uv + vec2(0, 0)) * qX);
19
- vec4 s2 = texture(map, (uv + vec2(1, 0)) * qX);
20
- vec4 s3 = texture(map, (uv + vec2(0, 1)) * qX);
21
- vec4 s4 = texture(map, (uv + vec2(1, 1)) * qX);
18
+ vec4 s1 = texture(map, (uv + vec2(0, 0)) * se);
19
+ vec4 s2 = texture(map, (uv + vec2(1, 0)) * se);
20
+ vec4 s3 = texture(map, (uv + vec2(0, 1)) * se);
21
+ vec4 s4 = texture(map, (uv + vec2(1, 1)) * se);
22
22
 
23
23
  return mix(mix(s1, s2, f.x), mix(s3, s4, f.x), f.y);
24
24
  #endif
@@ -8,12 +8,12 @@ float phi = acos(n.y) / PI;
8
8
  return vec2(theta, 1.0 - phi);
9
9
  }
10
10
 
11
- vec2 jh(vec3 pos, vec3 normal, vec2 uvScale) {
12
- vec3 dI = abs(normal);
11
+ vec2 jq(vec3 pos, vec3 normal, vec2 uvScale) {
12
+ vec3 dj = abs(normal);
13
13
  vec2 uv = vec2(0.0);
14
- if (dI.x > dI.y && dI.x > dI.z) {
14
+ if (dj.x > dj.y && dj.x > dj.z) {
15
15
  uv = pos.yz;
16
- } else if (dI.y > dI.x && dI.y > dI.z) {
16
+ } else if (dj.y > dj.x && dj.y > dj.z) {
17
17
  uv = pos.xz;
18
18
  } else {
19
19
  uv = pos.xy;
@@ -53,18 +53,18 @@ return fract(uv * uvScale);
53
53
 
54
54
 
55
55
 
56
- vec2 hT(vec3 pos, vec3 normal) {
56
+ vec2 hW(vec3 pos, vec3 normal) {
57
57
  float theta = atan(pos.z, pos.x) / (2.0 * PI) + 0.5;
58
58
  return vec2(theta, pos.y);
59
59
  }
60
60
 
61
- vec2 gU(int fE, vec3 pos, vec3 normal, vec2 uvScale) {
62
- if (fE == ${uvProjectionConstants.triplanar + ''}) {
63
- return jh(pos, normal, uvScale);
64
- } else if (fE == ${uvProjectionConstants.spherical + ''}) {
61
+ vec2 gW(int fu, vec3 pos, vec3 normal, vec2 uvScale) {
62
+ if (fu == ${uvProjectionConstants.triplanar + ''}) {
63
+ return jq(pos, normal, uvScale);
64
+ } else if (fu == ${uvProjectionConstants.spherical + ''}) {
65
65
  return sphericalProjection(pos) * uvScale;
66
- } else if (fE == ${uvProjectionConstants.cylindrical + ''}) {
67
- return hT(pos, normal) * uvScale;
66
+ } else if (fu == ${uvProjectionConstants.cylindrical + ''}) {
67
+ return hW(pos, normal) * uvScale;
68
68
  }
69
69
  return vec2(0.0);
70
70
  }