@woosh/meep-engine 3.60.5 → 3.60.7

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 (376) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/build/bundle-worker-terrain.js +1 -1
  3. package/package.json +1 -1
  4. package/src/core/binary/BitSet.d.ts.map +1 -1
  5. package/src/core/binary/BitSet.js +2 -1
  6. package/src/{format/image/avif/av1/util → core/binary/operations}/ceil_log2.d.ts +2 -2
  7. package/src/core/binary/operations/ceil_log2.d.ts.map +1 -0
  8. package/src/{format/image/avif/av1/util → core/binary/operations}/ceil_log2.js +18 -18
  9. package/src/core/binary/zstd/ZstdReverseBitReader.d.ts.map +1 -1
  10. package/src/core/binary/zstd/ZstdReverseBitReader.js +225 -223
  11. package/src/core/binary/zstd/zstd_fse.d.ts.map +1 -1
  12. package/src/core/binary/zstd/zstd_fse.js +267 -265
  13. package/src/core/binary/zstd/zstd_huffman.d.ts.map +1 -1
  14. package/src/core/binary/zstd/zstd_huffman.js +246 -244
  15. package/src/core/bvh2/binary/2/BinaryUint32BVH.d.ts.map +1 -1
  16. package/src/core/bvh2/binary/2/BinaryUint32BVH.js +8 -2
  17. package/src/core/bvh2/bvh3/ebvh_optimize_treelet.d.ts.map +1 -1
  18. package/src/core/bvh2/bvh3/ebvh_optimize_treelet.js +8 -7
  19. package/src/core/collection/PairUint32Map.d.ts.map +1 -1
  20. package/src/core/collection/PairUint32Map.js +2 -2
  21. package/src/core/collection/Uint32Map.d.ts.map +1 -1
  22. package/src/core/collection/Uint32Map.js +2 -4
  23. package/src/core/collection/heap/FibonacciHeap.d.ts.map +1 -1
  24. package/src/core/collection/heap/FibonacciHeap.js +2 -1
  25. package/src/core/geom/2d/r-tree/StaticR2Tree.d.ts.map +1 -1
  26. package/src/core/geom/2d/r-tree/StaticR2Tree.js +8 -2
  27. package/src/core/geom/3d/shape/util/mesh_compute_triangle_edge_flags.d.ts.map +1 -1
  28. package/src/core/geom/3d/shape/util/mesh_compute_triangle_edge_flags.js +2 -3
  29. package/src/engine/graphics/texture/atlas/TextureAtlas.d.ts.map +1 -1
  30. package/src/engine/graphics/texture/atlas/TextureAtlas.js +13 -14
  31. package/src/engine/graphics/texture/atlas/sprite_atlas_border.d.ts.map +1 -1
  32. package/src/engine/graphics/texture/atlas/sprite_atlas_border.js +70 -69
  33. package/src/engine/graphics/texture/reflection/convolve_equirectangular_reflection.d.ts.map +1 -1
  34. package/src/engine/graphics/texture/reflection/convolve_equirectangular_reflection.js +2 -1
  35. package/src/engine/graphics3/GPUParticleEmitterSystem.d.ts.map +1 -1
  36. package/src/engine/graphics3/GPUParticleEmitterSystem.js +2 -1
  37. package/src/engine/graphics3/decal/GPUDecalRenderer.d.ts.map +1 -1
  38. package/src/engine/graphics3/decal/GPUDecalRenderer.js +2 -1
  39. package/src/engine/graphics3/decal/chunk_decal_record.d.ts +14 -0
  40. package/src/engine/graphics3/decal/chunk_decal_record.d.ts.map +1 -0
  41. package/src/engine/graphics3/decal/chunk_decal_record.js +44 -0
  42. package/src/engine/graphics3/decal/shader_cluster_assign_decals.d.ts.map +1 -1
  43. package/src/engine/graphics3/decal/shader_cluster_assign_decals.js +2 -15
  44. package/src/engine/graphics3/decal/shader_cull_decals_frustum.d.ts.map +1 -1
  45. package/src/engine/graphics3/decal/shader_cull_decals_frustum.js +3 -16
  46. package/src/engine/graphics3/decal/shader_decal_composite.d.ts.map +1 -1
  47. package/src/engine/graphics3/decal/shader_decal_composite.js +3 -23
  48. package/src/engine/graphics3/terrain/TERRAIN_MATERIAL_TEMPLATE.d.ts.map +1 -1
  49. package/src/engine/graphics3/terrain/TERRAIN_MATERIAL_TEMPLATE.js +2 -1
  50. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  51. package/src/engine/physics/queries/shape_cast.js +2 -2
  52. package/src/format/image/avif/av1/decode/decode_palette.js +442 -442
  53. package/src/format/image/avif/av1/entropy/SymbolWriter.d.ts.map +1 -1
  54. package/src/format/image/avif/av1/entropy/SymbolWriter.js +2 -1
  55. package/src/generation/foliage/material/foliage_tile.d.ts.map +1 -1
  56. package/src/generation/foliage/material/foliage_tile.js +2 -1
  57. package/src/shade/device/mock/SoftwareGPUDevice.d.ts.map +1 -1
  58. package/src/shade/device/mock/SoftwareGPUDevice.js +6 -13
  59. package/src/shade/playground/caldera/main.js +3 -2
  60. package/src/shade/playground/probe_clipmap/README.md +2 -1
  61. package/src/shade/playground/probe_clipmap/index.html +7 -2
  62. package/src/shade/playground/probe_clipmap/main.d.ts.map +1 -1
  63. package/src/shade/playground/probe_clipmap/main.js +17 -7
  64. package/src/shade/playground/sh_exponential/sh_exp_playground_shaders.d.ts.map +1 -1
  65. package/src/shade/playground/sh_exponential/sh_exp_playground_shaders.js +7 -13
  66. package/src/shade/playground/vgeo_scene/main.js +2 -1
  67. package/src/shade/playground/vsm/VSMDebugOverlay.d.ts.map +1 -1
  68. package/src/shade/playground/vsm/VSMDebugOverlay.js +3 -1
  69. package/src/shade/renderer/Renderer.d.ts +11 -0
  70. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  71. package/src/shade/renderer/Renderer.js +43 -1
  72. package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
  73. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
  74. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +6 -6
  75. package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
  76. package/src/shade/renderer/fluid/pressure/shader_fluid_mg_coarsest.d.ts.map +1 -1
  77. package/src/shade/renderer/fluid/pressure/shader_fluid_mg_coarsest.js +5 -4
  78. package/src/shade/renderer/fluid/pressure/shader_fluid_mg_residual_restrict.d.ts.map +1 -1
  79. package/src/shade/renderer/fluid/pressure/shader_fluid_mg_residual_restrict.js +168 -166
  80. package/src/shade/renderer/fluid/pressure/shader_fluid_mg_smooth.d.ts.map +1 -1
  81. package/src/shade/renderer/fluid/pressure/shader_fluid_mg_smooth.js +221 -219
  82. package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
  83. package/src/shade/renderer/fow/shader_fog_of_war.d.ts.map +1 -1
  84. package/src/shade/renderer/fow/shader_fog_of_war.js +8 -19
  85. package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.d.ts +26 -43
  86. package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.d.ts.map +1 -1
  87. package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.js +115 -123
  88. package/src/shade/renderer/geometry/sdf/MeshSDFLayout.d.ts.map +1 -1
  89. package/src/shade/renderer/geometry/sdf/MeshSDFLayout.js +2 -1
  90. package/src/shade/renderer/geometry/sdf/cards/GPUMeshCardSets.d.ts +20 -2
  91. package/src/shade/renderer/geometry/sdf/cards/GPUMeshCardSets.d.ts.map +1 -1
  92. package/src/shade/renderer/geometry/sdf/cards/GPUMeshCardSets.js +66 -2
  93. package/src/shade/renderer/geometry/virtual/proxy/vgeo_proxy_triangle_limit.d.ts +19 -0
  94. package/src/shade/renderer/geometry/virtual/proxy/vgeo_proxy_triangle_limit.d.ts.map +1 -0
  95. package/src/shade/renderer/geometry/virtual/proxy/vgeo_proxy_triangle_limit.js +25 -0
  96. package/src/shade/renderer/geometry/virtual/runtime/GPUVirtualGeometryRuntime.d.ts.map +1 -1
  97. package/src/shade/renderer/geometry/virtual/runtime/GPUVirtualGeometryRuntime.js +2 -1
  98. package/src/shade/renderer/geometry/virtual/runtime/VGeoResidency.d.ts.map +1 -1
  99. package/src/shade/renderer/geometry/virtual/runtime/VGeoResidency.js +2 -1
  100. package/src/shade/renderer/geometry/virtual/runtime/VirtualGeometry.d.ts +15 -0
  101. package/src/shade/renderer/geometry/virtual/runtime/VirtualGeometry.d.ts.map +1 -1
  102. package/src/shade/renderer/geometry/virtual/runtime/VirtualGeometry.js +38 -0
  103. package/src/shade/renderer/geometry/virtual/sdf/VGeoSDFProxies.d.ts +28 -59
  104. package/src/shade/renderer/geometry/virtual/sdf/VGeoSDFProxies.d.ts.map +1 -1
  105. package/src/shade/renderer/geometry/virtual/sdf/VGeoSDFProxies.js +84 -789
  106. package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v1/chunk_brick4_sh3_color_decode_from_storage.d.ts.map +1 -1
  107. package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v1/chunk_brick4_sh3_color_decode_from_storage.js +10 -31
  108. package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v1/chunk_brick4_sh3_color_encode_to_storage.d.ts.map +1 -1
  109. package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v1/chunk_brick4_sh3_color_encode_to_storage.js +9 -15
  110. package/src/shade/renderer/global_illumination/clipmap/shader_debug_clipmap.d.ts +2 -1
  111. package/src/shade/renderer/global_illumination/clipmap/shader_debug_clipmap.d.ts.map +1 -1
  112. package/src/shade/renderer/global_illumination/clipmap/shader_debug_clipmap.js +6 -5
  113. package/src/shade/renderer/global_illumination/probe/octahedral/convolve/graph_reduce_atlas_to_sh.d.ts.map +1 -1
  114. package/src/shade/renderer/global_illumination/probe/octahedral/convolve/graph_reduce_atlas_to_sh.js +2 -1
  115. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +15 -3
  116. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts.map +1 -1
  117. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.js +168 -18
  118. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSceneHolds.d.ts +2 -1
  119. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSceneHolds.d.ts.map +1 -1
  120. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSceneHolds.js +2 -1
  121. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.d.ts +98 -57
  122. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.d.ts.map +1 -1
  123. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.js +168 -77
  124. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.d.ts +4 -2
  125. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.d.ts.map +1 -1
  126. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.js +27 -12
  127. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap.d.ts.map +1 -1
  128. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap.js +12 -7
  129. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts.map +1 -1
  130. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.js +8 -2
  131. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_instance.d.ts +2 -2
  132. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_instance.js +2 -2
  133. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_walk.d.ts.map +1 -1
  134. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_walk.js +5 -2
  135. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_batch.js +1 -1
  136. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_gather.d.ts.map +1 -1
  137. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_gather.js +5 -3
  138. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_resolve.js +1 -1
  139. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_free.d.ts.map +1 -1
  140. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_free.js +1 -1
  141. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_movers_command.d.ts.map +1 -1
  142. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_movers_command.js +4 -2
  143. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_scroll.d.ts.map +1 -1
  144. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_scroll.js +1 -1
  145. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_store.d.ts.map +1 -1
  146. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_store.js +1 -1
  147. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_take.d.ts.map +1 -1
  148. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_take.js +3 -1
  149. package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_mesh_cards.js +2 -2
  150. package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.d.ts +114 -41
  151. package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.d.ts.map +1 -1
  152. package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.js +424 -207
  153. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.d.ts +34 -25
  154. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.d.ts.map +1 -1
  155. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.js +41 -31
  156. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP_RESAMPLING.d.ts +7 -5
  157. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP_RESAMPLING.d.ts.map +1 -1
  158. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP_RESAMPLING.js +7 -5
  159. package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapHitWants.d.ts +47 -0
  160. package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapHitWants.d.ts.map +1 -0
  161. package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapHitWants.js +84 -0
  162. package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapScreenWants.d.ts +48 -0
  163. package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapScreenWants.d.ts.map +1 -0
  164. package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapScreenWants.js +101 -0
  165. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.d.ts +58 -4
  166. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.d.ts.map +1 -1
  167. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.js +127 -30
  168. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_cage.d.ts +18 -7
  169. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_cage.d.ts.map +1 -1
  170. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_cage.js +39 -13
  171. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_pick.d.ts +29 -8
  172. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_pick.d.ts.map +1 -1
  173. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_pick.js +112 -56
  174. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_resample.d.ts +19 -0
  175. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_resample.d.ts.map +1 -0
  176. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_resample.js +35 -0
  177. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_sample_radiance.d.ts.map +1 -1
  178. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_sample_radiance.js +9 -3
  179. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_want.d.ts +3 -3
  180. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_want.js +5 -5
  181. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_accumulate.d.ts +8 -12
  182. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_accumulate.d.ts.map +1 -1
  183. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_accumulate.js +23 -56
  184. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_admit.d.ts +0 -3
  185. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_admit.d.ts.map +1 -1
  186. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_admit.js +11 -15
  187. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_bounce.d.ts +26 -0
  188. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_bounce.d.ts.map +1 -0
  189. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_bounce.js +173 -0
  190. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_candidate.d.ts +32 -0
  191. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_candidate.d.ts.map +1 -0
  192. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_candidate.js +166 -0
  193. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_due.d.ts +3 -4
  194. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_due.d.ts.map +1 -1
  195. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_due.js +3 -4
  196. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_guide.d.ts.map +1 -1
  197. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_guide.js +3 -1
  198. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.d.ts +6 -12
  199. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.d.ts.map +1 -1
  200. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.js +15 -65
  201. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_order.d.ts.map +1 -1
  202. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_order.js +7 -2
  203. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_project.d.ts +4 -4
  204. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_project.d.ts.map +1 -1
  205. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_project.js +24 -17
  206. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_publish.d.ts +7 -5
  207. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_publish.d.ts.map +1 -1
  208. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_publish.js +18 -10
  209. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_ray_layout.d.ts +2 -2
  210. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_ray_layout.d.ts.map +1 -1
  211. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_ray_layout.js +9 -5
  212. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_relocate.d.ts +3 -0
  213. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_relocate.d.ts.map +1 -1
  214. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_relocate.js +9 -6
  215. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_resample.d.ts +1 -1
  216. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_resample.d.ts.map +1 -1
  217. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_resample.js +16 -16
  218. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_resample_rays.d.ts +36 -0
  219. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_resample_rays.d.ts.map +1 -0
  220. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_resample_rays.js +233 -0
  221. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_schedule.d.ts.map +1 -1
  222. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_schedule.js +7 -5
  223. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_shade.d.ts.map +1 -1
  224. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_shade.js +5 -3
  225. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.d.ts.map +1 -1
  226. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.js +10 -4
  227. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace_command.d.ts +2 -1
  228. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace_command.d.ts.map +1 -1
  229. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace_command.js +12 -6
  230. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want.d.ts +1 -2
  231. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want.d.ts.map +1 -1
  232. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want.js +5 -6
  233. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_hits.d.ts +14 -18
  234. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_hits.d.ts.map +1 -1
  235. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_hits.js +25 -35
  236. package/src/shade/renderer/gpu_primitive/WEBGPU_GUARANTEED_MAX_UNIFORM_BUFFER_BINDING_SIZE.d.ts +13 -0
  237. package/src/shade/renderer/gpu_primitive/WEBGPU_GUARANTEED_MAX_UNIFORM_BUFFER_BINDING_SIZE.d.ts.map +1 -0
  238. package/src/shade/renderer/gpu_primitive/WEBGPU_GUARANTEED_MAX_UNIFORM_BUFFER_BINDING_SIZE.js +12 -0
  239. package/src/shade/renderer/gpu_primitive/hash_table/cpu_build_hash_table.d.ts +27 -2
  240. package/src/shade/renderer/gpu_primitive/hash_table/cpu_build_hash_table.d.ts.map +1 -1
  241. package/src/shade/renderer/gpu_primitive/hash_table/cpu_build_hash_table.js +62 -6
  242. package/src/shade/renderer/gpu_primitive/indirect/IndirectComputeCommandBuildPass.d.ts.map +1 -1
  243. package/src/shade/renderer/gpu_primitive/indirect/IndirectComputeCommandBuildPass.js +10 -19
  244. package/src/shade/renderer/gpu_primitive/indirect/chunk_folded_dispatch.d.ts.map +1 -1
  245. package/src/shade/renderer/gpu_primitive/indirect/chunk_folded_dispatch.js +6 -3
  246. package/src/shade/renderer/hiz/hzb_pick_alignment.d.ts.map +1 -1
  247. package/src/shade/renderer/hiz/hzb_pick_alignment.js +149 -148
  248. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_environment_cells.d.ts.map +1 -1
  249. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_environment_cells.js +4 -2
  250. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_log_floor.d.ts.map +1 -1
  251. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_log_floor.js +6 -5
  252. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_project.d.ts.map +1 -1
  253. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_project.js +3 -1
  254. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_reference_reflectance.d.ts.map +1 -1
  255. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_reference_reflectance.js +3 -1
  256. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_solve.d.ts.map +1 -1
  257. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_solve.js +3 -1
  258. package/src/shade/renderer/light/world_cluster/WORLD_LIGHT_CLUSTER.d.ts +0 -5
  259. package/src/shade/renderer/light/world_cluster/WORLD_LIGHT_CLUSTER.d.ts.map +1 -1
  260. package/src/shade/renderer/light/world_cluster/WORLD_LIGHT_CLUSTER.js +0 -7
  261. package/src/shade/renderer/light/world_cluster/graph_build_world_light_clusters.d.ts +15 -2
  262. package/src/shade/renderer/light/world_cluster/graph_build_world_light_clusters.d.ts.map +1 -1
  263. package/src/shade/renderer/light/world_cluster/graph_build_world_light_clusters.js +51 -16
  264. package/src/shade/renderer/light/world_cluster/shader_world_cluster_assign_lights.d.ts.map +1 -1
  265. package/src/shade/renderer/light/world_cluster/shader_world_cluster_assign_lights.js +3 -2
  266. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  267. package/src/shade/renderer/material/GPUMaterialManager.d.ts +4 -1
  268. package/src/shade/renderer/material/GPUMaterialManager.d.ts.map +1 -1
  269. package/src/shade/renderer/material/GPUMaterialManager.js +5 -8
  270. package/src/shade/renderer/postprocess/dof/raymarch/chunk_dof_lds_coc_cache.d.ts +17 -0
  271. package/src/shade/renderer/postprocess/dof/raymarch/chunk_dof_lds_coc_cache.d.ts.map +1 -0
  272. package/src/shade/renderer/postprocess/dof/raymarch/chunk_dof_lds_coc_cache.js +81 -0
  273. package/src/shade/renderer/postprocess/dof/raymarch/shader_dof_raymarch_compute.d.ts.map +1 -1
  274. package/src/shade/renderer/postprocess/dof/raymarch/shader_dof_raymarch_compute.js +5 -48
  275. package/src/shade/renderer/postprocess/dof/raymarch/shader_dof_slice_compute.d.ts.map +1 -1
  276. package/src/shade/renderer/postprocess/dof/raymarch/shader_dof_slice_compute.js +4 -44
  277. package/src/shade/renderer/postprocess/gtao/GTAO.d.ts +7 -3
  278. package/src/shade/renderer/postprocess/gtao/GTAO.d.ts.map +1 -1
  279. package/src/shade/renderer/postprocess/gtao/GTAO.js +26 -13
  280. package/src/shade/renderer/postprocess/gtao/ao_reproject_shader.d.ts +14 -0
  281. package/src/shade/renderer/postprocess/gtao/ao_reproject_shader.d.ts.map +1 -1
  282. package/src/shade/renderer/postprocess/gtao/ao_reproject_shader.js +196 -68
  283. package/src/shade/renderer/postprocess/gtao/chunk_integrate_lighting_sample.d.ts.map +1 -1
  284. package/src/shade/renderer/postprocess/gtao/chunk_integrate_lighting_sample.js +4 -1
  285. package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao.d.ts.map +1 -1
  286. package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao.js +42 -28
  287. package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao_with_irradiance.d.ts.map +1 -1
  288. package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao_with_irradiance.js +430 -414
  289. package/src/shade/renderer/postprocess/gtao/shader_gtao_spatial_denoise.d.ts +16 -0
  290. package/src/shade/renderer/postprocess/gtao/shader_gtao_spatial_denoise.d.ts.map +1 -0
  291. package/src/shade/renderer/postprocess/gtao/shader_gtao_spatial_denoise.js +156 -0
  292. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  293. package/src/shade/renderer/postprocess/nss/chunk_nss_luma_derivative.d.ts.map +1 -1
  294. package/src/shade/renderer/postprocess/nss/chunk_nss_luma_derivative.js +5 -7
  295. package/src/shade/renderer/postprocess/nss/chunk_nss_tonemap.d.ts +17 -0
  296. package/src/shade/renderer/postprocess/nss/chunk_nss_tonemap.d.ts.map +1 -0
  297. package/src/shade/renderer/postprocess/nss/chunk_nss_tonemap.js +56 -0
  298. package/src/shade/renderer/postprocess/nss/shader_nss_postprocess.d.ts.map +1 -1
  299. package/src/shade/renderer/postprocess/nss/shader_nss_postprocess.js +2 -22
  300. package/src/shade/renderer/postprocess/nss/shader_nss_preprocess.d.ts.map +1 -1
  301. package/src/shade/renderer/postprocess/nss/shader_nss_preprocess.js +2 -13
  302. package/src/shade/renderer/rasterize/bucket/prepare_meshlet_draw_commands_by_material.d.ts.map +1 -1
  303. package/src/shade/renderer/rasterize/bucket/prepare_meshlet_draw_commands_by_material.js +10 -13
  304. package/src/shade/renderer/rasterize/expand/bucket/RASTERIZATION_BUCKET_LIMIT.d.ts.map +1 -1
  305. package/src/shade/renderer/rasterize/expand/bucket/RASTERIZATION_BUCKET_LIMIT.js +39 -38
  306. package/src/shade/renderer/rasterize/expand/mesh/shader_prefix_sum_to_command.d.ts.map +1 -1
  307. package/src/shade/renderer/rasterize/expand/mesh/shader_prefix_sum_to_command.js +7 -12
  308. package/src/shade/renderer/scene/GPUSceneContext.d.ts +2 -2
  309. package/src/shade/renderer/scene/GPUSceneContext.js +5 -5
  310. package/src/shade/renderer/shader/chunk/clipmap/CLIPMAP_LEVEL_STRUCT.d.ts +8 -6
  311. package/src/shade/renderer/shader/chunk/clipmap/CLIPMAP_LEVEL_STRUCT.d.ts.map +1 -1
  312. package/src/shade/renderer/shader/chunk/clipmap/CLIPMAP_LEVEL_STRUCT.js +10 -7
  313. package/src/shade/renderer/shader/chunk/clipmap/chunk_clipmap_key.d.ts +16 -0
  314. package/src/shade/renderer/shader/chunk/clipmap/chunk_clipmap_key.d.ts.map +1 -0
  315. package/src/shade/renderer/shader/chunk/clipmap/chunk_clipmap_key.js +35 -0
  316. package/src/shade/renderer/shader/chunk/clipmap/chunk_clipmap_select_finest.d.ts +5 -2
  317. package/src/shade/renderer/shader/chunk/clipmap/chunk_clipmap_select_finest.d.ts.map +1 -1
  318. package/src/shade/renderer/shader/chunk/clipmap/chunk_clipmap_select_finest.js +27 -18
  319. package/src/shade/renderer/shader/chunk/spherical_harmonics/chunk_sh2_color_get_irradiance_at.d.ts.map +1 -1
  320. package/src/shade/renderer/shader/chunk/spherical_harmonics/chunk_sh2_color_get_irradiance_at.js +5 -15
  321. package/src/shade/renderer/shader/chunk/spherical_harmonics/chunk_sh3_convolve_with_cosine_kernel.d.ts.map +1 -1
  322. package/src/shade/renderer/shader/chunk/spherical_harmonics/chunk_sh3_convolve_with_cosine_kernel.js +5 -19
  323. package/src/shade/renderer/shader/chunk/spherical_harmonics/dering/chunk_sh3_windowing.d.ts.map +1 -1
  324. package/src/shade/renderer/shader/chunk/spherical_harmonics/dering/chunk_sh3_windowing.js +3 -22
  325. package/src/shade/renderer/shadow/map/ShadowmapDrawSelector.d.ts.map +1 -1
  326. package/src/shade/renderer/shadow/map/ShadowmapDrawSelector.js +2 -1
  327. package/src/shade/renderer/volumetrics/chunk_volumetrics_sun_shadow_group_list.d.ts.map +1 -1
  328. package/src/shade/renderer/volumetrics/chunk_volumetrics_sun_shadow_group_list.js +154 -152
  329. package/src/shade/renderer/volumetrics/irradiance_clipmap/GPUIrradianceClipmap.d.ts.map +1 -1
  330. package/src/shade/renderer/volumetrics/irradiance_clipmap/GPUIrradianceClipmap.js +2 -1
  331. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP.d.ts +3 -1
  332. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP.d.ts.map +1 -1
  333. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP.js +4 -3
  334. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP_STRUCT.d.ts +7 -1
  335. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP_STRUCT.d.ts.map +1 -1
  336. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP_STRUCT.js +54 -47
  337. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_sample.d.ts.map +1 -1
  338. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_sample.js +371 -370
  339. package/src/shade/renderer/water/GPUWaterRenderer.d.ts.map +1 -1
  340. package/src/shade/renderer/water/GPUWaterRenderer.js +2 -1
  341. package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
  342. package/src/shade/renderer/water/surface/lod/shader_water_lod.d.ts.map +1 -1
  343. package/src/shade/renderer/water/surface/lod/shader_water_lod.js +12 -14
  344. package/src/shade/renderer/water/surface/particles/GPUWaterParticles.d.ts.map +1 -1
  345. package/src/shade/renderer/water/surface/particles/GPUWaterParticles.js +2 -9
  346. package/src/shade/renderer/water/surface/particles/chunk_water_particle.d.ts.map +1 -1
  347. package/src/shade/renderer/water/surface/particles/chunk_water_particle.js +2 -1
  348. package/src/shade/renderer/wind/WIND_FIELD.d.ts +3 -1
  349. package/src/shade/renderer/wind/WIND_FIELD.d.ts.map +1 -1
  350. package/src/shade/renderer/wind/WIND_FIELD.js +4 -3
  351. package/src/shade/renderer/wind/WIND_FIELD_STRUCT.d.ts +8 -2
  352. package/src/shade/renderer/wind/WIND_FIELD_STRUCT.d.ts.map +1 -1
  353. package/src/shade/renderer/wind/WIND_FIELD_STRUCT.js +11 -4
  354. package/src/shade/renderer/wind/chunk_wind_field_sample_cascades.d.ts +2 -2
  355. package/src/shade/renderer/wind/chunk_wind_field_sample_cascades.d.ts.map +1 -1
  356. package/src/shade/renderer/wind/chunk_wind_field_sample_cascades.js +13 -4
  357. package/src/shade/util/texture_mip_extent.d.ts.map +1 -1
  358. package/src/shade/util/texture_mip_extent.js +88 -87
  359. package/src/shade/wgsl/emulator/WGSLLanguageCore.d.ts.map +1 -1
  360. package/src/shade/wgsl/emulator/WGSLLanguageCore.js +9 -7
  361. package/src/format/image/avif/av1/util/ceil_log2.d.ts.map +0 -1
  362. package/src/shade/renderer/geometry/virtual/sdf/VGEO_SDF.d.ts +0 -47
  363. package/src/shade/renderer/geometry/virtual/sdf/VGEO_SDF.d.ts.map +0 -1
  364. package/src/shade/renderer/geometry/virtual/sdf/VGEO_SDF.js +0 -80
  365. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_collect.d.ts +0 -16
  366. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_collect.d.ts.map +0 -1
  367. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_collect.js +0 -67
  368. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_decode.d.ts +0 -17
  369. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_decode.d.ts.map +0 -1
  370. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_decode.js +0 -145
  371. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_traverse.d.ts +0 -12
  372. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_traverse.d.ts.map +0 -1
  373. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_traverse.js +0 -105
  374. package/src/shade/renderer/shader/chunk/color/chunk_hash_squirrel3.d.ts +0 -1
  375. package/src/shade/renderer/shader/chunk/color/chunk_hash_squirrel3.d.ts.map +0 -1
  376. package/src/shade/renderer/shader/chunk/color/chunk_hash_squirrel3.js +0 -0
@@ -0,0 +1,16 @@
1
+ /**
2
+ * GTAO's own spatial filter: one 3x3 edge-stopped pass over visibility and the bend.
3
+ *
4
+ * Its input and output are `rgba16float`: visibility in `x`, and in `yzw` the world-space bend, the bent normal
5
+ * minus the shading normal. The bend is what is filtered, never the bent normal, so an unoccluded texel, whose
6
+ * bend is zero, keeps the normal map's detail exactly however much its neighbours are averaged in.
7
+ *
8
+ * Visibility is filtered as `fragment_shader_denoise_ao` filters it — the A-trous step, its edge-stopping
9
+ * weights and phi values — with the variance taken from visibility alone, since the input carries no second
10
+ * moment. That shader stays as it is: it is shared with denoisers that do keep moments.
11
+ *
12
+ * @type {ImageShader}
13
+ */
14
+ export const shader_gtao_spatial_denoise: ImageShader;
15
+ import { ImageShader } from "../../shader/ImageShader.js";
16
+ //# sourceMappingURL=shader_gtao_spatial_denoise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shader_gtao_spatial_denoise.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/postprocess/gtao/shader_gtao_spatial_denoise.js"],"names":[],"mappings":"AA+HA;;;;;;;;;;;;GAYG;AACH,0CAFU,WAAW,CAiBlB;4BAvJyB,6BAA6B"}
@@ -0,0 +1,156 @@
1
+ import { DEPTH_STENCIL_FOREGROUND_ONLY } from "../../depth/DEPTH_STENCIL_FOREGROUND_ONLY.js";
2
+ import { chunk_compute_edge_stopping_weight } from "../../shader/chunk/filter/chunk_compute_edge_stopping_weight.js";
3
+ import { chunk_decode_g_buffer_normal } from "../../shader/chunk/geometry/normal/chunk_decode_g_buffer_normal.js";
4
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
5
+ import { ImageShader } from "../../shader/ImageShader.js";
6
+ import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
7
+ import { ShaderDescriptor } from "../../shader/ShaderDescriptor.js";
8
+
9
+ const resources = new ShaderResourceSetDescriptor();
10
+
11
+ resources.createGroup()
12
+ .addTexture("tInput")
13
+ .addTexture("tDepth")
14
+ .addTexture("tNormal", "uint");
15
+
16
+ const body = CodeChunk.from(
17
+ //language=WGSL
18
+ `
19
+ const phi_visibility = 4.0;
20
+ const phi_normal = 128.0;
21
+ const sigma_depth = 1.0;
22
+
23
+ const offsets = array< vec2<i32>, 8 >(
24
+ vec2( -1, -1 ),
25
+ vec2( 0, -1 ),
26
+ vec2( 1, -1 ),
27
+ vec2( -1, 0 ),
28
+ vec2( 1, 0 ),
29
+ vec2( -1, 1 ),
30
+ vec2( 0, 1 ),
31
+ vec2( 1, 1 ),
32
+ );
33
+
34
+ // Visibility's spatial variance over a 3x3 Gaussian. The input carries visibility alone, so its second moment
35
+ // is the square of each texel's.
36
+ fn gtao_visibility_variance(ipos: vec2<i32>) -> f32 {
37
+ let kernel = array<f32, 3>(0.25, 0.125, 0.0625);
38
+
39
+ var moments = vec2<f32>(0.0);
40
+
41
+ for (var yy = -1; yy <= 1; yy++) {
42
+ for (var xx = -1; xx <= 1; xx++) {
43
+ let v = textureLoad(tInput, ipos + vec2<i32>(xx, yy), 0).x;
44
+
45
+ moments += vec2(v, v * v) * kernel[ abs(xx) + abs(yy) ];
46
+ }
47
+ }
48
+
49
+ return max(moments.y - moments.x * moments.x, 0.0);
50
+ }
51
+
52
+ @fragment
53
+ fn main(
54
+ @builtin(position) coord: vec4<f32>,
55
+ ) -> @location(0) vec4<f32> {
56
+ let ipos = vec2<i32>(coord.xy);
57
+ let screen_size = vec2<i32>(textureDimensions(tInput));
58
+
59
+ const eps_variance = 1e-10;
60
+ const kernel_weights = array<f32,3>( 1.0, 2.0 / 3.0, 1.0 / 6.0 );
61
+
62
+ let center = textureLoad(tInput, ipos, 0);
63
+
64
+ let std_dev = sqrt(max(0.0, eps_variance + gtao_visibility_variance(ipos)));
65
+
66
+ let phi_luma = phi_visibility * std_dev;
67
+
68
+ let current_normal = decode_g_buffer_normal(textureLoad(tNormal, ipos, 0).xy);
69
+ let center_depth = textureLoad(tDepth, ipos, 0).r;
70
+
71
+ // the centre at weight 1, so the edge-stopping functions cannot leave nothing
72
+ var sum_w_visibility = 1.0;
73
+ var sum_visibility = center.x;
74
+
75
+ // The bend is averaged weighted by visibility as well. A bent normal stands for the visible directions;
76
+ // the bent normal of several texels together is the sum of each one's scaled by how much it sees,
77
+ // normalized, and with neighbours whose normals agree that is the shading normal plus this average.
78
+ var sum_w_bend = center.x;
79
+ var sum_bend = center.yzw * center.x;
80
+
81
+ for (var i = 0; i < 8; i++) {
82
+ let offset = offsets[i];
83
+
84
+ let p = ipos + offset;
85
+
86
+ if (any(p < vec2(0)) || any(p >= screen_size)) {
87
+ continue;
88
+ }
89
+
90
+ let kernel = kernel_weights[ abs(offset.x) ] * kernel_weights[ abs(offset.y) ];
91
+
92
+ let texel = textureLoad(tInput, p, 0);
93
+
94
+ let sample_normal = decode_g_buffer_normal(textureLoad(tNormal, p, 0).xy);
95
+ let sample_depth = textureLoad(tDepth, p, 0).r;
96
+
97
+ let w = compute_edge_stopping_weight(
98
+ center_depth,
99
+ sample_depth,
100
+ sigma_depth,
101
+
102
+ current_normal,
103
+ sample_normal,
104
+ phi_normal,
105
+
106
+ center.x,
107
+ texel.x,
108
+ phi_luma
109
+ ) * kernel;
110
+
111
+ sum_w_visibility += w;
112
+ sum_visibility += w * texel.x;
113
+
114
+ let w_bend = w * texel.x;
115
+
116
+ sum_w_bend += w_bend;
117
+ sum_bend += w_bend * texel.yzw;
118
+ }
119
+
120
+ return vec4(sum_visibility / sum_w_visibility, sum_bend / sum_w_bend);
121
+ }
122
+ `,
123
+ [
124
+ chunk_decode_g_buffer_normal,
125
+ chunk_compute_edge_stopping_weight,
126
+ ]);
127
+
128
+ /**
129
+ * GTAO's own spatial filter: one 3x3 edge-stopped pass over visibility and the bend.
130
+ *
131
+ * Its input and output are `rgba16float`: visibility in `x`, and in `yzw` the world-space bend, the bent normal
132
+ * minus the shading normal. The bend is what is filtered, never the bent normal, so an unoccluded texel, whose
133
+ * bend is zero, keeps the normal map's detail exactly however much its neighbours are averaged in.
134
+ *
135
+ * Visibility is filtered as `fragment_shader_denoise_ao` filters it — the A-trous step, its edge-stopping
136
+ * weights and phi values — with the variance taken from visibility alone, since the input carries no second
137
+ * moment. That shader stays as it is: it is shared with denoisers that do keep moments.
138
+ *
139
+ * @type {ImageShader}
140
+ */
141
+ export const shader_gtao_spatial_denoise = ImageShader.from({
142
+ descriptor: ShaderDescriptor.from({
143
+ label: "GTAO Spatial Denoise",
144
+ resources,
145
+ body
146
+ }),
147
+ depthStencil: DEPTH_STENCIL_FOREGROUND_ONLY,
148
+ targets: [
149
+ {
150
+ format: "rgba16float",
151
+ // Background is skipped, so it keeps the clear: not occluded, not bent. Downstream neighbourhoods
152
+ // read across silhouettes and must see background as unoccluded.
153
+ clearValue: [1, 0, 0, 0],
154
+ }
155
+ ]
156
+ });
@@ -51,7 +51,7 @@ export class NSS {
51
51
  * @returns {number}
52
52
  */
53
53
  static recommended_jitter_sequence_size(upscale_ratio: number): number;
54
- static "__#210@#preprocess_tensor_descriptor"(render_w: any, render_h: any): TextureResourceDescriptor;
54
+ static "__#212@#preprocess_tensor_descriptor"(render_w: any, render_h: any): TextureResourceDescriptor;
55
55
  /**
56
56
  * @param {GraphicsContext} graphics
57
57
  */
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_nss_luma_derivative.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/postprocess/nss/chunk_nss_luma_derivative.js"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,kDAoBE;0BAhCwB,oCAAoC"}
1
+ {"version":3,"file":"chunk_nss_luma_derivative.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/postprocess/nss/chunk_nss_luma_derivative.js"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,kDAkBE;0BA/BwB,oCAAoC"}
@@ -1,6 +1,6 @@
1
- import { chunk_rgb_to_luminance } from "../../shader/chunk/color/chunk_rgb_to_luminance.js";
2
- import { F16_MAX_DEFINITION } from "../../shader/chunk/math/F16_MAX_DEFINITION.js";
1
+ import { chunk_rgb_to_luminance } from "../../shader/chunk/color/chunk_rgb_to_luminance.js";
3
2
  import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
3
+ import { chunk_nss_tonemap } from "./chunk_nss_tonemap.js";
4
4
 
5
5
  /**
6
6
  * Computes a per-pixel "luminance derivative" — the delta between the
@@ -16,10 +16,8 @@ export const chunk_nss_luma_derivative = CodeChunk.from(
16
16
  //language=WGSL
17
17
  `
18
18
  fn nss_luma_derivative(current_rgb: vec3<f32>, history_rgb: vec3<f32>) -> f32 {
19
- let current_finite = select(vec3<f32>(0.0), clamp(current_rgb, vec3<f32>(0.0), vec3<f32>(F16_MAX)), current_rgb == current_rgb);
20
- let lc = rgb_to_luminance(current_finite);
21
- let history_finite = select(vec3<f32>(0.0), clamp(history_rgb, vec3<f32>(0.0), vec3<f32>(F16_MAX)), history_rgb == history_rgb);
22
- let lh = rgb_to_luminance(history_finite);
19
+ let lc = rgb_to_luminance(nss_sanitize_hdr(current_rgb));
20
+ let lh = rgb_to_luminance(nss_sanitize_hdr(history_rgb));
23
21
 
24
22
  // tonemap the luma to compress HDR before differencing — same trick TAA
25
23
  // uses to keep specular highlights from saturating the variance metric.
@@ -29,7 +27,7 @@ fn nss_luma_derivative(current_rgb: vec3<f32>, history_rgb: vec3<f32>) -> f32 {
29
27
  return saturate(abs(lc_t - lh_t) * 4.0);
30
28
  }
31
29
  `, [
32
- F16_MAX_DEFINITION,
30
+ chunk_nss_tonemap,
33
31
  chunk_rgb_to_luminance,
34
32
  ]
35
33
  );
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Shared HDR sanitization and max-channel Karis tonemapping (`c / (1 + max(r, g, b))`) and its
3
+ * inverse for Neural Super Sampling (NSS).
4
+ *
5
+ * ```wgsl
6
+ * const NSS_EXPOSURE: f32 = 7.38905609893;
7
+ * fn nss_sanitize_hdr(rgb: vec3<f32>) -> vec3<f32>
8
+ * fn nss_tonemap(rgb: vec3<f32>) -> vec3<f32>
9
+ * fn nss_tonemap_exposure(rgb: vec3<f32>) -> vec3<f32>
10
+ * fn nss_tonemap_inv(rgb: vec3<f32>) -> vec3<f32>
11
+ * ```
12
+ *
13
+ * @type {CodeChunk}
14
+ */
15
+ export const chunk_nss_tonemap: CodeChunk;
16
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
17
+ //# sourceMappingURL=chunk_nss_tonemap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_nss_tonemap.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/postprocess/nss/chunk_nss_tonemap.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AACH,gCAFU,SAAS,CAwCjB;0BAtDwB,oCAAoC"}
@@ -0,0 +1,56 @@
1
+ import { F16_MAX_DEFINITION } from "../../shader/chunk/math/F16_MAX_DEFINITION.js";
2
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
3
+
4
+ /**
5
+ * Shared HDR sanitization and max-channel Karis tonemapping (`c / (1 + max(r, g, b))`) and its
6
+ * inverse for Neural Super Sampling (NSS).
7
+ *
8
+ * ```wgsl
9
+ * const NSS_EXPOSURE: f32 = 7.38905609893;
10
+ * fn nss_sanitize_hdr(rgb: vec3<f32>) -> vec3<f32>
11
+ * fn nss_tonemap(rgb: vec3<f32>) -> vec3<f32>
12
+ * fn nss_tonemap_exposure(rgb: vec3<f32>) -> vec3<f32>
13
+ * fn nss_tonemap_inv(rgb: vec3<f32>) -> vec3<f32>
14
+ * ```
15
+ *
16
+ * @type {CodeChunk}
17
+ */
18
+ export const chunk_nss_tonemap = CodeChunk.from(
19
+ //language=WGSL
20
+ `
21
+ const NSS_EXPOSURE: f32 = 7.38905609893; // e^2
22
+
23
+ fn nss_sanitize_hdr(rgb: vec3<f32>) -> vec3<f32> {
24
+ return select(vec3<f32>(0.0), clamp(rgb, vec3<f32>(0.0), vec3<f32>(F16_MAX)), rgb == rgb);
25
+ }
26
+
27
+ // Karis tonemap (max-of-channels).
28
+ // The guard is a FINITE clamp, not just a non-negative one: this target is rgba16float, so shading
29
+ // above its range stores as +Inf and rgb / (1.0 + m) is Inf/Inf = NaN, which goes straight into the
30
+ // next frame's history and stays there. NaN fails every comparison including with itself, which is
31
+ // what the componentwise test in nss_sanitize_hdr is.
32
+ fn nss_tonemap(rgb: vec3<f32>) -> vec3<f32> {
33
+ let finite = nss_sanitize_hdr(rgb);
34
+ let m = max(max(finite.r, finite.g), finite.b);
35
+ return finite / (1.0 + m);
36
+ }
37
+
38
+ // Karis tonemap (max-of-channels), applied to EXPOSURE-scaled colour.
39
+ // ARM's training distribution: Tonemap(EXPOSURE * raw) -> network input.
40
+ fn nss_tonemap_exposure(rgb: vec3<f32>) -> vec3<f32> {
41
+ let scaled = nss_sanitize_hdr(rgb) * NSS_EXPOSURE;
42
+ let m = max(max(scaled.r, scaled.g), scaled.b);
43
+ return scaled / (1.0 + m);
44
+ }
45
+
46
+ // Karis inverse — clamp to dodge the inf at m == 1.0.
47
+ fn nss_tonemap_inv(rgb: vec3<f32>) -> vec3<f32> {
48
+ let c = clamp(rgb, vec3<f32>(0.0), vec3<f32>(0.99999));
49
+ let m = max(max(c.r, c.g), c.b);
50
+ return c / (1.0 - m);
51
+ }
52
+ `,
53
+ [
54
+ F16_MAX_DEFINITION,
55
+ ]
56
+ );
@@ -1 +1 @@
1
- {"version":3,"file":"shader_nss_postprocess.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/postprocess/nss/shader_nss_postprocess.js"],"names":[],"mappings":"AAiSA,mDAIG;8BAnS2B,+BAA+B"}
1
+ {"version":3,"file":"shader_nss_postprocess.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/postprocess/nss/shader_nss_postprocess.js"],"names":[],"mappings":"AA6QA,mDAIG;8BAhR2B,+BAA+B"}
@@ -1,8 +1,8 @@
1
1
  import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
2
- import { F16_MAX_DEFINITION } from "../../shader/chunk/math/F16_MAX_DEFINITION.js";
3
2
  import { ComputeShader } from "../../shader/ComputeShader.js";
4
3
  import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
5
4
  import { SAMPLER_LINEAR_UPSCALE } from "../../texture/SAMPLER_LINEAR_UPSCALE.js";
5
+ import { chunk_nss_tonemap } from "./chunk_nss_tonemap.js";
6
6
  import { NSS_WORKGROUP_SIZE } from "./NSS_CONSTANTS.js";
7
7
  import { NSS_SETTINGS_STRUCT } from "./NSS_SETTINGS_STRUCT.js";
8
8
 
@@ -50,26 +50,6 @@ resources.createGroup()
50
50
  const body = CodeChunk.from(
51
51
  //language=WGSL
52
52
  `
53
- const NSS_EXPOSURE: f32 = 7.38905609893; // e^2
54
-
55
- // Karis tonemap (max-of-channels).
56
- // The guard is a FINITE clamp, not just a non-negative one: this target is rgba16float, so shading
57
- // above its range stores as +Inf and rgb / (1.0 + m) is Inf/Inf = NaN, which goes straight into the
58
- // next frame's history and stays there. NaN fails every comparison including with itself, which is
59
- // what the componentwise test below is.
60
- fn nss_tonemap(rgb: vec3<f32>) -> vec3<f32> {
61
- let finite = select(vec3<f32>(0.0), min(rgb, vec3<f32>(F16_MAX)), rgb == rgb);
62
- let m = max(max(finite.r, finite.g), finite.b);
63
- return finite / (1.0 + m);
64
- }
65
-
66
- // Karis inverse — clamp to dodge the inf at m == 1.0.
67
- fn nss_tonemap_inv(rgb: vec3<f32>) -> vec3<f32> {
68
- let c = clamp(rgb, vec3<f32>(0.0), vec3<f32>(0.99999));
69
- let m = max(max(c.r, c.g), c.b);
70
- return c / (1.0 - m);
71
- }
72
-
73
53
  fn nss_warped_history(prev_uv: vec2<f32>) -> vec3<f32> {
74
54
  let on_screen = all(prev_uv >= vec2<f32>(0.0)) && all(prev_uv <= vec2<f32>(1.0));
75
55
  if (!on_screen) {
@@ -282,7 +262,7 @@ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
282
262
  textureStore(tOutput, out_st, vec4<f32>(final_rgb, theta));
283
263
  }
284
264
  `, [
285
- F16_MAX_DEFINITION,
265
+ chunk_nss_tonemap,
286
266
  NSS_SETTINGS_STRUCT.declaration_chunk,
287
267
  ]
288
268
  );
@@ -1 +1 @@
1
- {"version":3,"file":"shader_nss_preprocess.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/postprocess/nss/shader_nss_preprocess.js"],"names":[],"mappings":"AAiPA,kDAIG;8BAnP2B,+BAA+B"}
1
+ {"version":3,"file":"shader_nss_preprocess.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/postprocess/nss/shader_nss_preprocess.js"],"names":[],"mappings":"AAsOA,kDAIG;8BAzO2B,+BAA+B"}
@@ -1,10 +1,10 @@
1
1
  import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
2
- import { F16_MAX_DEFINITION } from "../../shader/chunk/math/F16_MAX_DEFINITION.js";
3
2
  import { ComputeShader } from "../../shader/ComputeShader.js";
4
3
  import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
5
4
  import { SAMPLER_LINEAR_UPSCALE } from "../../texture/SAMPLER_LINEAR_UPSCALE.js";
6
5
  import { chunk_nss_find_nearest_depth } from "./chunk_nss_find_nearest_depth.js";
7
6
  import { chunk_nss_luma_derivative } from "./chunk_nss_luma_derivative.js";
7
+ import { chunk_nss_tonemap } from "./chunk_nss_tonemap.js";
8
8
  import { NSS_WORKGROUP_SIZE } from "./NSS_CONSTANTS.js";
9
9
  import { NSS_SETTINGS_STRUCT } from "./NSS_SETTINGS_STRUCT.js";
10
10
 
@@ -68,17 +68,6 @@ resources.createGroup()
68
68
  const body = CodeChunk.from(
69
69
  //language=WGSL
70
70
  `
71
- const NSS_EXPOSURE: f32 = 7.38905609893; // e^2
72
-
73
- // Karis tonemap (max-of-channels), applied to EXPOSURE-scaled colour.
74
- // ARM's training distribution: Tonemap(EXPOSURE * raw) -> network input.
75
- fn nss_tonemap_exposure(rgb: vec3<f32>) -> vec3<f32> {
76
- let finite = select(vec3<f32>(0.0), clamp(rgb, vec3<f32>(0.0), vec3<f32>(F16_MAX)), rgb == rgb);
77
- let scaled = finite * NSS_EXPOSURE;
78
- let m = max(max(scaled.r, scaled.g), scaled.b);
79
- return scaled / (1.0 + m);
80
- }
81
-
82
71
  // ARM's network was trained against inputs that go through their Quantize
83
72
  // formula: int8 = round(fp * 255 - 128). The conv then sees (uint8 - 128)
84
73
  // = signed int8 in [-128, 127] - i.e. fp 0 -> -128, fp 0.5 -> 0, fp 1 -> 127.
@@ -232,9 +221,9 @@ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
232
221
  textureStore(tNearestOffset, st, vec4<f32>(nearest_packed, 0.0, 0.0));
233
222
  }
234
223
  `, [
235
- F16_MAX_DEFINITION,
236
224
  chunk_nss_find_nearest_depth,
237
225
  chunk_nss_luma_derivative,
226
+ chunk_nss_tonemap,
238
227
  NSS_SETTINGS_STRUCT.declaration_chunk,
239
228
  ]
240
229
  );
@@ -1 +1 @@
1
- {"version":3,"file":"prepare_meshlet_draw_commands_by_material.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/rasterize/bucket/prepare_meshlet_draw_commands_by_material.js"],"names":[],"mappings":"AA+BA;;;;;;;;;;;;;;;GAeG;AACH,uKAJa;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,MAAM,CAAC;IAAC,wBAAwB,EAAE,MAAM,CAAA;CAAC,CA2VnH"}
1
+ {"version":3,"file":"prepare_meshlet_draw_commands_by_material.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/rasterize/bucket/prepare_meshlet_draw_commands_by_material.js"],"names":[],"mappings":"AAiCA;;;;;;;;;;;;;;;GAeG;AACH,uKAJa;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,MAAM,CAAC;IAAC,wBAAwB,EAAE,MAAM,CAAA;CAAC,CAsVnH"}
@@ -1,10 +1,12 @@
1
1
  import { assert } from "../../../../core/assert.js";
2
- import { ceilPowerOfTwo } from "../../../../core/binary/operations/ceilPowerOfTwo.js";
3
2
  import { round_up } from "../../../../core/math/round_up.js";
4
3
  import { BufferResourceDescriptor } from "../../../device/graph/BufferResourceDescriptor.js";
5
4
  import { u32 } from "../../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
6
5
  import { STRUCT_UNINDEXED_DRAW_COMMAND } from "../../gpu_primitive/indirect/STRUCT_UNINDEXED_DRAW_COMMAND.js";
7
- import { cpu_build_hash_table } from "../../gpu_primitive/hash_table/cpu_build_hash_table.js";
6
+ import {
7
+ cpu_hash_table_create,
8
+ cpu_hash_table_word_count
9
+ } from "../../gpu_primitive/hash_table/cpu_build_hash_table.js";
8
10
  import {
9
11
  graph_prefix_scan_csdldf,
10
12
  prefix_scan_csdldf_output_descriptor
@@ -215,21 +217,16 @@ export function graph_prepare_meshlet_draw_commands_by_material({
215
217
  // 2. build material lookup table
216
218
  const material_ids = materials.map(m => m.id);
217
219
  const material_count = material_ids.length;
218
- const HASH_TABLE_SLACK = 1.3;
219
- const material_table_size = ceilPowerOfTwo(Math.max(1, material_count * HASH_TABLE_SLACK));
220
- const material_lookup_data = new ArrayBuffer((material_table_size * 2 + 2) * 4)
221
- const material_lookup = new Uint32Array(material_lookup_data);
222
- cpu_build_hash_table(
223
- material_lookup, 0,
224
- material_table_size,
225
- material_ids,
226
- material_count,
227
- );
220
+ let material_lookup = new Uint32Array(cpu_hash_table_word_count(material_count));
221
+
222
+ while (!cpu_hash_table_create(material_lookup, material_ids, material_count)) {
223
+ material_lookup = new Uint32Array(material_lookup.length * 2);
224
+ }
228
225
 
229
226
  // TODO build the table on the GPU
230
227
  const gr_material_lookup = graph_import_raw_buffer({
231
228
  graph,
232
- value: material_lookup_data,
229
+ value: material_lookup.buffer,
233
230
  usage: GPUBufferUsage.STORAGE,
234
231
  });
235
232
 
@@ -1 +1 @@
1
- {"version":3,"file":"RASTERIZATION_BUCKET_LIMIT.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/rasterize/expand/bucket/RASTERIZATION_BUCKET_LIMIT.js"],"names":[],"mappings":"AAkBA,+DAA0F;AAC1F,8DAAsF;AAEtF;;;;;;;;GAQG;AACH,0DAFU,MAAM,CAE6C;AAE7D;;;;GAIG;AACH,yCAFU,MAAM,CAEsK"}
1
+ {"version":3,"file":"RASTERIZATION_BUCKET_LIMIT.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/rasterize/expand/bucket/RASTERIZATION_BUCKET_LIMIT.js"],"names":[],"mappings":"AAmBA,+DAA0F;AAC1F,8DAAsF;AAEtF;;;;;;;;GAQG;AACH,0DAFU,MAAM,CAE6C;AAE7D;;;;GAIG;AACH,yCAFU,MAAM,CAEsK"}
@@ -1,38 +1,39 @@
1
- import { assert } from "../../../../../core/assert.js";
2
- import { ShadeDrawMode } from "../../../material/ShadeDrawMode.js";
3
- import { TransparencyMode } from "../../../material/TransparencyMode.js";
4
-
5
- /**
6
- *
7
- * @param {Object} e enum
8
- * @return {number} number of bits required to represent it
9
- */
10
- function enum_bit_count(e) {
11
- const max = Math.max.apply(null, Object.values(e));
12
-
13
- assert.isNonNegativeInteger(max, 'max');
14
- assert.lessThanOrEqual(max, 5, "the bucket count is going to be absurd");
15
-
16
- return 32 - Math.clz32(max);
17
- }
18
-
19
- export const RASTERIZATION_BUCKET_BIT_COUNT_ALPHA_MODE = enum_bit_count(TransparencyMode);
20
- export const RASTERIZATION_BUCKET_BIT_COUNT_DRAW_MODE = enum_bit_count(ShadeDrawMode);
21
-
22
- /**
23
- * One bit, not the two {@link ShadeDrawSide} would need. Only double-sided geometry needs a
24
- * pipeline of its own — `cullMode: 'none'` has no winding equivalent. `Front` and `Back` share
25
- * one: a back-sided material is a front-sided one drawn with its winding reversed, and the
26
- * vertex shader does the reversing.
27
- *
28
- * @see rasterization_material_bucket
29
- * @type {number}
30
- */
31
- export const RASTERIZATION_BUCKET_BIT_COUNT_DOUBLE_SIDED = 1;
32
-
33
- /**
34
- * Maximum number of rasterization buckets. This is a number of permutations of different alpha and draw modes.
35
- * See Northlight talk on "Alan Wake 2" meshlet shading.
36
- * @type {number}
37
- */
38
- export const RASTERIZATION_BUCKET_LIMIT = (1 << (RASTERIZATION_BUCKET_BIT_COUNT_ALPHA_MODE + RASTERIZATION_BUCKET_BIT_COUNT_DRAW_MODE + RASTERIZATION_BUCKET_BIT_COUNT_DOUBLE_SIDED));
1
+ import { assert } from "../../../../../core/assert.js";
2
+ import { ShadeDrawMode } from "../../../material/ShadeDrawMode.js";
3
+ import { TransparencyMode } from "../../../material/TransparencyMode.js";
4
+ import { ceil_log2 } from "../../../../../core/binary/operations/ceil_log2.js";
5
+
6
+ /**
7
+ *
8
+ * @param {Object} e enum
9
+ * @return {number} number of bits required to represent it
10
+ */
11
+ function enum_bit_count(e) {
12
+ const max = Math.max.apply(null, Object.values(e));
13
+
14
+ assert.isNonNegativeInteger(max, 'max');
15
+ assert.lessThanOrEqual(max, 5, "the bucket count is going to be absurd");
16
+
17
+ return ceil_log2(max + 1);
18
+ }
19
+
20
+ export const RASTERIZATION_BUCKET_BIT_COUNT_ALPHA_MODE = enum_bit_count(TransparencyMode);
21
+ export const RASTERIZATION_BUCKET_BIT_COUNT_DRAW_MODE = enum_bit_count(ShadeDrawMode);
22
+
23
+ /**
24
+ * One bit, not the two {@link ShadeDrawSide} would need. Only double-sided geometry needs a
25
+ * pipeline of its own — `cullMode: 'none'` has no winding equivalent. `Front` and `Back` share
26
+ * one: a back-sided material is a front-sided one drawn with its winding reversed, and the
27
+ * vertex shader does the reversing.
28
+ *
29
+ * @see rasterization_material_bucket
30
+ * @type {number}
31
+ */
32
+ export const RASTERIZATION_BUCKET_BIT_COUNT_DOUBLE_SIDED = 1;
33
+
34
+ /**
35
+ * Maximum number of rasterization buckets. This is a number of permutations of different alpha and draw modes.
36
+ * See Northlight talk on "Alan Wake 2" meshlet shading.
37
+ * @type {number}
38
+ */
39
+ export const RASTERIZATION_BUCKET_LIMIT = (1 << (RASTERIZATION_BUCKET_BIT_COUNT_ALPHA_MODE + RASTERIZATION_BUCKET_BIT_COUNT_DRAW_MODE + RASTERIZATION_BUCKET_BIT_COUNT_DOUBLE_SIDED));
@@ -1 +1 @@
1
- {"version":3,"file":"shader_prefix_sum_to_command.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/rasterize/expand/mesh/shader_prefix_sum_to_command.js"],"names":[],"mappings":"AA8DA,yDAIG;8BA1D2B,kCAAkC"}
1
+ {"version":3,"file":"shader_prefix_sum_to_command.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/rasterize/expand/mesh/shader_prefix_sum_to_command.js"],"names":[],"mappings":"AAyDA,yDAIG;8BAvD2B,kCAAkC"}
@@ -1,6 +1,4 @@
1
- import {
2
- WEBGPU_GUARANTEED_MAX_COMPUTE_WORKGROUPS_PER_DIMENSION
3
- } from "../../../gpu_primitive/indirect/WEBGPU_GUARANTEED_MAX_COMPUTE_WORKGROUPS_PER_DIMENSION.js";
1
+ import { chunk_folded_dispatch } from "../../../gpu_primitive/indirect/chunk_folded_dispatch.js";
4
2
  import { STRUCT_DISPATCH_COMPUTE_COMMAND } from "../../../gpu_primitive/indirect/STRUCT_DISPATCH_COMPUTE_COMMAND.js";
5
3
  import { COLLECTION_U32_STRUCT_READ } from "../../../gpu_primitive/COLLECTION_U32_STRUCT_READ.js";
6
4
  import { chunk_divide_round_up_u32 } from "../../../shader/chunk/math/chunk_divide_round_up_u32.js";
@@ -43,20 +41,17 @@ fn main(){
43
41
  It is also the stride folded_workgroup_index flattens by, so the two builders have to agree on
44
42
  it: a row of x shorter than that would leave a gap in the index.
45
43
  */
46
- const LIMIT = ${WEBGPU_GUARANTEED_MAX_COMPUTE_WORKGROUPS_PER_DIMENSION}u;
47
-
48
44
  let desired_groups = divide_round_up_u32(total_count, TARGET_GROUP_SIZE);
45
+ let folded = folded_dispatch(desired_groups);
49
46
 
50
- let rows = divide_round_up_u32(desired_groups, LIMIT);
51
- let slices = divide_round_up_u32(rows, LIMIT);
52
-
53
- command.workgroupCountX = min( desired_groups, LIMIT );
54
- command.workgroupCountY = min( max( rows, 1u ), LIMIT );
55
- command.workgroupCountZ = max( slices, 1u );
47
+ command.workgroupCountX = folded.x;
48
+ command.workgroupCountY = folded.y;
49
+ command.workgroupCountZ = folded.z;
56
50
 
57
51
  }
58
52
  `, [
59
- chunk_divide_round_up_u32
53
+ chunk_divide_round_up_u32,
54
+ chunk_folded_dispatch,
60
55
  ]
61
56
  )
62
57
 
@@ -105,8 +105,8 @@ export class GPUSceneContext {
105
105
  * (REVIEW_LEDGER U1): `register` a container with {@link virtual_geometry_residency}, and every
106
106
  * page after the root arrives because a cut asked for it. The renderer opens and closes each
107
107
  * frame and schedules each reading, and {@link destroy} releases all of it; a host touches none
108
- * of it. With them, the source of its geometries' caches ({@link VGeoSDFProxies}): a cache asked
109
- * of a virtual geometry is baked from a proxy cut from it.
108
+ * of it. With them, the source of its geometries' caches and cards ({@link VGeoSDFProxies}): a virtual
109
+ * geometry whose cache is asked for stands in through its proxy.
110
110
  *
111
111
  * @param {Object} [options] passed to {@link GPUVirtualGeometryPool} and
112
112
  * {@link GPUVirtualGeometryRuntime}, except for `residency`
@@ -399,8 +399,8 @@ export class GPUSceneContext {
399
399
  * (REVIEW_LEDGER U1): `register` a container with {@link virtual_geometry_residency}, and every
400
400
  * page after the root arrives because a cut asked for it. The renderer opens and closes each
401
401
  * frame and schedules each reading, and {@link destroy} releases all of it; a host touches none
402
- * of it. With them, the source of its geometries' caches ({@link VGeoSDFProxies}): a cache asked
403
- * of a virtual geometry is baked from a proxy cut from it.
402
+ * of it. With them, the source of its geometries' caches and cards ({@link VGeoSDFProxies}): a virtual
403
+ * geometry whose cache is asked for stands in through its proxy.
404
404
  *
405
405
  * @param {Object} [options] passed to {@link GPUVirtualGeometryPool} and
406
406
  * {@link GPUVirtualGeometryRuntime}, except for `residency`
@@ -448,8 +448,8 @@ export class GPUSceneContext {
448
448
 
449
449
  feedback = new VGeoFeedbackLoop({ runtime, residency: tiers });
450
450
 
451
- // last: it makes its buffers and subscribes to the caches as it is made
452
- proxies = new VGeoSDFProxies({ device: this.#device, runtime, geometries: this.geometries });
451
+ // last: it subscribes to the caches as it is made
452
+ proxies = new VGeoSDFProxies({ geometries: this.geometries });
453
453
  } catch (error) {
454
454
  // the pool is the only one holding anything yet: the fetcher spawns its workers on its
455
455
  // first fetch, and the runtime makes its buffer on its first frame
@@ -874,7 +874,7 @@ export class GPUSceneContext {
874
874
  return;
875
875
  }
876
876
 
877
- // its proxies out of the geometry manager, and its cut's buffers, ahead of the runtime's
877
+ // it hears no more of the caches; its proxies stay with the geometry manager, destroyed with it
878
878
  this.#virtual_geometry_proxies.destroy();
879
879
 
880
880
  this.#virtual_geometry_feedback.destroy();
@@ -1,8 +1,3 @@
1
- /**
2
- * Levels a clipmap table holds at most, and how far `clipmap_select_finest` walks.
3
- * @type {number}
4
- */
5
- export const CLIPMAP_LEVEL_LIMIT: number;
6
1
  /**
7
2
  * One level of a clipmap as a shader reads it: the level's window, and how big its cell is. Levels
8
3
  * sit finest first in a {@link CLIPMAP_LEVEL_ARRAY}.
@@ -13,7 +8,14 @@ export const CLIPMAP_LEVEL_LIMIT: number;
13
8
  */
14
9
  export const CLIPMAP_LEVEL_STRUCT: WebGPUStruct;
15
10
  /**
16
- * A clipmap's table of levels, as a field of the uniform that carries it.
11
+ * Levels a clipmap table holds: as many as fill the uniform binding every device allows, 2,048. The
12
+ * table is a uniform, whose length its type fixes, so this is the most levels any clipmap can have;
13
+ * a walk over it stops at the clipmap's own count, and a writer uploads only the levels it has.
14
+ * @type {number}
15
+ */
16
+ export const CLIPMAP_LEVEL_LIMIT: number;
17
+ /**
18
+ * A clipmap's table of levels, a uniform of its own, {@link CLIPMAP_LEVEL_LIMIT} long.
17
19
  * @type {WebGPUArray}
18
20
  */
19
21
  export const CLIPMAP_LEVEL_ARRAY: WebGPUArray;