@woosh/meep-engine 3.59.0 → 3.60.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (326) hide show
  1. package/package.json +1 -1
  2. package/src/shade/playground/probe_clipmap/index.html +12 -0
  3. package/src/shade/playground/probe_clipmap/main.d.ts.map +1 -1
  4. package/src/shade/playground/probe_clipmap/main.js +5 -0
  5. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  6. package/src/shade/renderer/Renderer.js +4 -6
  7. package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.d.ts +63 -1
  8. package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.d.ts.map +1 -1
  9. package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.js +228 -16
  10. package/src/shade/renderer/geometry/sdf/cards/GPUMeshCardSets.d.ts +27 -4
  11. package/src/shade/renderer/geometry/sdf/cards/GPUMeshCardSets.d.ts.map +1 -1
  12. package/src/shade/renderer/geometry/sdf/cards/GPUMeshCardSets.js +526 -23
  13. package/src/shade/renderer/geometry/sdf/cards/MeshCardCaptureMode.d.ts +11 -0
  14. package/src/shade/renderer/geometry/sdf/cards/MeshCardCaptureMode.d.ts.map +1 -0
  15. package/src/shade/renderer/geometry/sdf/cards/MeshCardCaptureMode.js +21 -0
  16. package/src/shade/renderer/geometry/sdf/cards/mesh_cards_raster_pass_descriptor.d.ts +65 -0
  17. package/src/shade/renderer/geometry/sdf/cards/mesh_cards_raster_pass_descriptor.d.ts.map +1 -0
  18. package/src/shade/renderer/geometry/sdf/cards/mesh_cards_raster_pass_descriptor.js +376 -0
  19. package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_capture.d.ts +7 -3
  20. package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_capture.d.ts.map +1 -1
  21. package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_capture.js +70 -6
  22. package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_raster_args.d.ts +20 -0
  23. package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_raster_args.d.ts.map +1 -0
  24. package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_raster_args.js +80 -0
  25. package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_raster_scatter.d.ts +18 -0
  26. package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_raster_scatter.d.ts.map +1 -0
  27. package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_raster_scatter.js +113 -0
  28. package/src/shade/renderer/geometry/virtual/sdf/VGEO_SDF.d.ts +47 -0
  29. package/src/shade/renderer/geometry/virtual/sdf/VGEO_SDF.d.ts.map +1 -0
  30. package/src/shade/renderer/geometry/virtual/sdf/VGEO_SDF.js +80 -0
  31. package/src/shade/renderer/geometry/virtual/sdf/VGeoSDFProxies.d.ts +91 -0
  32. package/src/shade/renderer/geometry/virtual/sdf/VGeoSDFProxies.d.ts.map +1 -0
  33. package/src/shade/renderer/geometry/virtual/sdf/VGeoSDFProxies.js +902 -0
  34. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_collect.d.ts +16 -0
  35. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_collect.d.ts.map +1 -0
  36. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_collect.js +67 -0
  37. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_decode.d.ts +17 -0
  38. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_decode.d.ts.map +1 -0
  39. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_decode.js +145 -0
  40. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_traverse.d.ts +12 -0
  41. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_traverse.d.ts.map +1 -0
  42. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_traverse.js +105 -0
  43. package/src/shade/renderer/global_illumination/probe/octahedral/shader_lpv_build_gbuffer.d.ts.map +1 -1
  44. package/src/shade/renderer/global_illumination/probe/octahedral/shader_lpv_build_gbuffer.js +2 -1
  45. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +3 -9
  46. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts.map +1 -1
  47. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.js +13 -31
  48. package/src/shade/renderer/global_illumination/probe_clipmap/PROBE_CLIPMAP_PROPOSAL_2026_10_27.md +764 -48
  49. package/src/shade/renderer/global_illumination/probe_clipmap/PROBE_RAYS_VARIABLE_AND_SORTED_SCOPE_2026_10_30.md +410 -0
  50. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSceneHolds.d.ts +3 -2
  51. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSceneHolds.d.ts.map +1 -1
  52. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSceneHolds.js +4 -3
  53. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.d.ts +41 -17
  54. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.d.ts.map +1 -1
  55. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.js +57 -33
  56. package/src/shade/renderer/global_illumination/probe_clipmap/brick/BRICK_CLIPMAP.d.ts +11 -3
  57. package/src/shade/renderer/global_illumination/probe_clipmap/brick/BRICK_CLIPMAP.d.ts.map +1 -1
  58. package/src/shade/renderer/global_illumination/probe_clipmap/brick/BRICK_CLIPMAP.js +13 -4
  59. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.d.ts +9 -18
  60. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.d.ts.map +1 -1
  61. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.js +8 -10
  62. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap.d.ts +12 -0
  63. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap.d.ts.map +1 -1
  64. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap.js +28 -0
  65. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts +1 -29
  66. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts.map +1 -1
  67. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.js +1 -74
  68. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MESH_BRICK.d.ts +161 -0
  69. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MESH_BRICK.d.ts.map +1 -0
  70. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MESH_BRICK.js +219 -0
  71. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MESH_BRICK_INSTANCE_STRUCT.d.ts +1 -8
  72. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MESH_BRICK_INSTANCE_STRUCT.d.ts.map +1 -1
  73. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MESH_BRICK_INSTANCE_STRUCT.js +1 -9
  74. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MeshSDFBrickProvider.d.ts +40 -12
  75. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MeshSDFBrickProvider.d.ts.map +1 -1
  76. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MeshSDFBrickProvider.js +373 -31
  77. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_instance.d.ts +2 -1
  78. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_instance.d.ts.map +1 -1
  79. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_instance.js +2 -1
  80. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_texel.d.ts +15 -8
  81. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_texel.d.ts.map +1 -1
  82. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_texel.js +28 -14
  83. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_walk.d.ts +23 -0
  84. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_walk.d.ts.map +1 -0
  85. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_walk.js +66 -0
  86. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_batch.d.ts +29 -0
  87. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_batch.d.ts.map +1 -0
  88. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_batch.js +210 -0
  89. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_command.d.ts +29 -0
  90. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_command.d.ts.map +1 -0
  91. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_command.js +86 -0
  92. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_gather.d.ts +41 -0
  93. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_gather.d.ts.map +1 -0
  94. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_gather.js +439 -0
  95. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_resolve.d.ts +23 -0
  96. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_resolve.d.ts.map +1 -0
  97. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_resolve.js +135 -0
  98. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_free.d.ts +3 -1
  99. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_free.d.ts.map +1 -1
  100. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_free.js +12 -3
  101. package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.d.ts +21 -18
  102. package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.d.ts.map +1 -1
  103. package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.js +254 -73
  104. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.d.ts +149 -8
  105. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.d.ts.map +1 -1
  106. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.js +181 -13
  107. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.d.ts +179 -7
  108. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.d.ts.map +1 -1
  109. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.js +412 -31
  110. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_pick.js +4 -4
  111. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_sample_radiance.d.ts.map +1 -1
  112. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_sample_radiance.js +4 -3
  113. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_accumulate.d.ts +36 -10
  114. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_accumulate.d.ts.map +1 -1
  115. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_accumulate.js +218 -29
  116. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_admit.d.ts +5 -1
  117. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_admit.d.ts.map +1 -1
  118. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_admit.js +24 -14
  119. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_due.d.ts +15 -6
  120. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_due.d.ts.map +1 -1
  121. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_due.js +21 -22
  122. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_guide.d.ts +36 -0
  123. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_guide.d.ts.map +1 -0
  124. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_guide.js +257 -0
  125. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.d.ts +18 -7
  126. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.d.ts.map +1 -1
  127. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.js +157 -51
  128. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_order.d.ts +23 -0
  129. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_order.d.ts.map +1 -0
  130. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_order.js +110 -0
  131. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_project.d.ts +24 -2
  132. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_project.d.ts.map +1 -1
  133. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_project.js +90 -10
  134. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_ray_layout.d.ts +45 -0
  135. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_ray_layout.d.ts.map +1 -0
  136. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_ray_layout.js +205 -0
  137. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_relocate.js +1 -1
  138. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_retire.d.ts +16 -3
  139. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_retire.d.ts.map +1 -1
  140. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_retire.js +55 -10
  141. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_schedule.d.ts +19 -4
  142. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_schedule.d.ts.map +1 -1
  143. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_schedule.js +60 -6
  144. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_shade.d.ts +4 -8
  145. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_shade.d.ts.map +1 -1
  146. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_shade.js +21 -36
  147. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.d.ts +21 -14
  148. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.d.ts.map +1 -1
  149. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.js +100 -30
  150. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace_command.d.ts +6 -2
  151. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace_command.d.ts.map +1 -1
  152. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace_command.js +26 -10
  153. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_hits.d.ts +3 -2
  154. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_hits.d.ts.map +1 -1
  155. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_hits.js +12 -12
  156. package/src/shade/renderer/gpu_primitive/sort/SORT_DIGIT_SETTINGS_STRUCT.d.ts +10 -0
  157. package/src/shade/renderer/gpu_primitive/sort/SORT_DIGIT_SETTINGS_STRUCT.d.ts.map +1 -0
  158. package/src/shade/renderer/gpu_primitive/sort/SORT_DIGIT_SETTINGS_STRUCT.js +21 -0
  159. package/src/shade/renderer/gpu_primitive/sort/SORT_PASS_SETTINGS_STRUCT.d.ts +5 -2
  160. package/src/shade/renderer/gpu_primitive/sort/SORT_PASS_SETTINGS_STRUCT.d.ts.map +1 -1
  161. package/src/shade/renderer/gpu_primitive/sort/SORT_PASS_SETTINGS_STRUCT.js +31 -23
  162. package/src/shade/renderer/gpu_primitive/sort/SORT_SIZE_STRUCT.d.ts +10 -0
  163. package/src/shade/renderer/gpu_primitive/sort/SORT_SIZE_STRUCT.d.ts.map +1 -0
  164. package/src/shade/renderer/gpu_primitive/sort/SORT_SIZE_STRUCT.js +22 -0
  165. package/src/shade/renderer/gpu_primitive/sort/chunk_sort_constants.d.ts +9 -0
  166. package/src/shade/renderer/gpu_primitive/sort/chunk_sort_constants.d.ts.map +1 -0
  167. package/src/shade/renderer/gpu_primitive/sort/chunk_sort_constants.js +18 -0
  168. package/src/shade/renderer/gpu_primitive/sort/chunk_sort_digit.d.ts +8 -3
  169. package/src/shade/renderer/gpu_primitive/sort/chunk_sort_digit.d.ts.map +1 -1
  170. package/src/shade/renderer/gpu_primitive/sort/chunk_sort_digit.js +41 -32
  171. package/src/shade/renderer/gpu_primitive/sort/chunk_sort_histogram_tile.d.ts +31 -0
  172. package/src/shade/renderer/gpu_primitive/sort/chunk_sort_histogram_tile.d.ts.map +1 -0
  173. package/src/shade/renderer/gpu_primitive/sort/chunk_sort_histogram_tile.js +71 -0
  174. package/src/shade/renderer/gpu_primitive/sort/chunk_sort_scatter_tile.d.ts +47 -0
  175. package/src/shade/renderer/gpu_primitive/sort/chunk_sort_scatter_tile.d.ts.map +1 -0
  176. package/src/shade/renderer/gpu_primitive/sort/chunk_sort_scatter_tile.js +210 -0
  177. package/src/shade/renderer/gpu_primitive/sort/defs.d.ts +5 -4
  178. package/src/shade/renderer/gpu_primitive/sort/defs.d.ts.map +1 -1
  179. package/src/shade/renderer/gpu_primitive/sort/defs.js +5 -4
  180. package/src/shade/renderer/gpu_primitive/sort/graph_radix_sort.d.ts +56 -15
  181. package/src/shade/renderer/gpu_primitive/sort/graph_radix_sort.d.ts.map +1 -1
  182. package/src/shade/renderer/gpu_primitive/sort/graph_radix_sort.js +410 -61
  183. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_histogram.d.ts +4 -1
  184. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_histogram.d.ts.map +1 -1
  185. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_histogram.js +16 -42
  186. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_histogram_indirect.d.ts +15 -0
  187. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_histogram_indirect.d.ts.map +1 -0
  188. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_histogram_indirect.js +60 -0
  189. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_prepare.d.ts +25 -0
  190. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_prepare.d.ts.map +1 -0
  191. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_prepare.js +89 -0
  192. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_scatter.d.ts +3 -8
  193. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_scatter.d.ts.map +1 -1
  194. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_scatter.js +28 -160
  195. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_scatter_indirect.d.ts +12 -0
  196. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_scatter_indirect.d.ts.map +1 -0
  197. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_scatter_indirect.js +74 -0
  198. package/src/shade/renderer/gpu_primitive/sort/verify_radix_sort.d.ts +3 -1
  199. package/src/shade/renderer/gpu_primitive/sort/verify_radix_sort.d.ts.map +1 -1
  200. package/src/shade/renderer/gpu_primitive/sort/verify_radix_sort.js +387 -188
  201. package/src/shade/renderer/lightmap/bake/shader_lightmap_viz_to_irradiance_flat.js +1 -1
  202. package/src/shade/renderer/lightmap/bake/shader_lightmap_viz_to_sh.js +1 -1
  203. package/src/shade/renderer/material/resident/GPUResidentMaterialContext.d.ts.map +1 -1
  204. package/src/shade/renderer/material/resident/GPUResidentMaterialContext.js +90 -72
  205. package/src/shade/renderer/material/resident/RESIDENT_MATERIAL_TEXTURE_LAYOUT.d.ts +5 -0
  206. package/src/shade/renderer/material/resident/RESIDENT_MATERIAL_TEXTURE_LAYOUT.d.ts.map +1 -1
  207. package/src/shade/renderer/material/resident/RESIDENT_MATERIAL_TEXTURE_LAYOUT.js +9 -0
  208. package/src/shade/renderer/path_tracer/shader/INDIRECT_TEXTURE_FILTER.d.ts +13 -0
  209. package/src/shade/renderer/path_tracer/shader/INDIRECT_TEXTURE_FILTER.d.ts.map +1 -0
  210. package/src/shade/renderer/path_tracer/shader/INDIRECT_TEXTURE_FILTER.js +14 -0
  211. package/src/shade/renderer/path_tracer/shader/IndirectTextureFilter.d.ts +10 -0
  212. package/src/shade/renderer/path_tracer/shader/IndirectTextureFilter.d.ts.map +1 -0
  213. package/src/shade/renderer/path_tracer/shader/IndirectTextureFilter.js +15 -0
  214. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_tangent_normal.d.ts +4 -3
  215. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_tangent_normal.d.ts.map +1 -1
  216. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_tangent_normal.js +6 -5
  217. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_texture.d.ts +17 -2
  218. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_texture.d.ts.map +1 -1
  219. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_texture.js +25 -57
  220. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_texture_exact.d.ts +13 -0
  221. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_texture_exact.d.ts.map +1 -0
  222. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_texture_exact.js +70 -0
  223. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_texture_stochastic.d.ts +10 -0
  224. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_texture_stochastic.d.ts.map +1 -0
  225. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_texture_stochastic.js +59 -0
  226. package/src/shade/renderer/path_tracer/shader/chunk_indirect_texture_load.d.ts +12 -0
  227. package/src/shade/renderer/path_tracer/shader/chunk_indirect_texture_load.d.ts.map +1 -0
  228. package/src/shade/renderer/path_tracer/shader/chunk_indirect_texture_load.js +49 -0
  229. package/src/shade/renderer/path_tracer/shader/chunk_ray_hit_to_opacity.d.ts.map +1 -1
  230. package/src/shade/renderer/path_tracer/shader/chunk_ray_hit_to_opacity.js +1 -0
  231. package/src/shade/renderer/path_tracer/shader/chunk_render_trace_path.d.ts.map +1 -1
  232. package/src/shade/renderer/path_tracer/shader/chunk_render_trace_path.js +1 -0
  233. package/src/shade/renderer/path_tracer/shader/chunk_sample_material.d.ts.map +1 -1
  234. package/src/shade/renderer/path_tracer/shader/chunk_sample_material.js +2 -1
  235. package/src/shade/renderer/path_tracer/shader/chunk_sample_material_data.d.ts +7 -0
  236. package/src/shade/renderer/path_tracer/shader/chunk_sample_material_data.d.ts.map +1 -1
  237. package/src/shade/renderer/path_tracer/shader/chunk_sample_material_data.js +15 -6
  238. package/src/shade/renderer/scene/GPUSceneContext.d.ts +7 -1
  239. package/src/shade/renderer/scene/GPUSceneContext.d.ts.map +1 -1
  240. package/src/shade/renderer/scene/GPUSceneContext.js +26 -1
  241. package/src/shade/renderer/shader/chunk/bvh/chunk_bvh_query_aabb_cooperative.d.ts +7 -7
  242. package/src/shade/renderer/shader/chunk/bvh/chunk_bvh_query_aabb_cooperative.d.ts.map +1 -1
  243. package/src/shade/renderer/shader/chunk/bvh/chunk_bvh_query_aabb_cooperative.js +262 -294
  244. package/src/shade/renderer/shader/chunk/filter/MULTISCALE_MEAN_STRUCT.d.ts +9 -0
  245. package/src/shade/renderer/shader/chunk/filter/MULTISCALE_MEAN_STRUCT.d.ts.map +1 -0
  246. package/src/shade/renderer/shader/chunk/filter/MULTISCALE_MEAN_STRUCT.js +21 -0
  247. package/src/shade/renderer/shader/chunk/filter/chunk_multiscale_mean.d.ts +43 -0
  248. package/src/shade/renderer/shader/chunk/filter/chunk_multiscale_mean.d.ts.map +1 -0
  249. package/src/shade/renderer/shader/chunk/filter/chunk_multiscale_mean.js +87 -0
  250. package/src/shade/renderer/shader/chunk/noise/r/chunk_r2_canonical.d.ts +7 -1
  251. package/src/shade/renderer/shader/chunk/noise/r/chunk_r2_canonical.d.ts.map +1 -1
  252. package/src/shade/renderer/shader/chunk/noise/r/chunk_r2_canonical.js +1 -1
  253. package/src/shade/renderer/shader/chunk/subgroup/chunk_subgroup_reserve_workgroup.d.ts +21 -0
  254. package/src/shade/renderer/shader/chunk/subgroup/chunk_subgroup_reserve_workgroup.d.ts.map +1 -0
  255. package/src/shade/renderer/shader/chunk/subgroup/chunk_subgroup_reserve_workgroup.js +42 -0
  256. package/src/shade/renderer/wind/GPUSceneWind.d.ts +1 -1
  257. package/src/shade/wgsl/emulator/CPUBitmapData.d.ts +19 -0
  258. package/src/shade/wgsl/emulator/CPUBitmapData.d.ts.map +1 -1
  259. package/src/shade/wgsl/emulator/CPUBitmapData.js +27 -0
  260. package/src/shade/wgsl/emulator/WGSLLanguageCore.d.ts.map +1 -1
  261. package/src/shade/wgsl/emulator/WGSLLanguageCore.js +39 -18
  262. package/src/view/elements/progress/segmented/GhostTrail.d.ts +56 -0
  263. package/src/view/elements/progress/segmented/GhostTrail.d.ts.map +1 -0
  264. package/src/view/elements/progress/segmented/GhostTrail.js +98 -0
  265. package/src/view/elements/progress/segmented/RESOURCE_BAR_SEGMENTS.d.ts +3 -1
  266. package/src/view/elements/progress/segmented/RESOURCE_BAR_SEGMENTS.d.ts.map +1 -1
  267. package/src/view/elements/progress/segmented/RESOURCE_BAR_SEGMENTS.js +3 -1
  268. package/src/view/elements/progress/segmented/SEGMENT_TIERS_DEFAULT.d.ts +11 -0
  269. package/src/view/elements/progress/segmented/SEGMENT_TIERS_DEFAULT.d.ts.map +1 -0
  270. package/src/view/elements/progress/segmented/SEGMENT_TIERS_DEFAULT.js +15 -0
  271. package/src/view/elements/progress/segmented/SegmentDefinition.d.ts +3 -0
  272. package/src/view/elements/progress/segmented/SegmentDefinition.d.ts.map +1 -1
  273. package/src/view/elements/progress/segmented/SegmentDefinition.js +3 -0
  274. package/src/view/elements/progress/segmented/SegmentTier.d.ts +38 -0
  275. package/src/view/elements/progress/segmented/SegmentTier.d.ts.map +1 -0
  276. package/src/view/elements/progress/segmented/SegmentTier.js +50 -0
  277. package/src/view/elements/progress/segmented/SegmentedResourceBarView.d.ts +155 -10
  278. package/src/view/elements/progress/segmented/SegmentedResourceBarView.d.ts.map +1 -1
  279. package/src/view/elements/progress/segmented/SegmentedResourceBarView.js +427 -101
  280. package/src/view/elements/progress/segmented/playground/index.html +78 -0
  281. package/src/view/elements/progress/segmented/playground/main.d.ts +2 -0
  282. package/src/view/elements/progress/segmented/playground/main.d.ts.map +1 -0
  283. package/src/view/elements/progress/segmented/playground/main.js +173 -0
  284. package/src/view/elements/progress/segmented/segment_cell_layout.d.ts +48 -0
  285. package/src/view/elements/progress/segmented/segment_cell_layout.d.ts.map +1 -0
  286. package/src/view/elements/progress/segmented/segment_cell_layout.js +75 -0
  287. package/src/view/elements/progress/segmented/segment_notch_place.d.ts +18 -0
  288. package/src/view/elements/progress/segmented/segment_notch_place.d.ts.map +1 -0
  289. package/src/view/elements/progress/segmented/segment_notch_place.js +28 -0
  290. package/src/view/elements/progress/segmented/segment_tick_positions.d.ts +32 -0
  291. package/src/view/elements/progress/segmented/segment_tick_positions.d.ts.map +1 -0
  292. package/src/view/elements/progress/segmented/segment_tick_positions.js +103 -0
  293. package/src/view/elements/progress/segmented/segmented-resource-bar.css +142 -0
  294. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_provider.d.ts +0 -35
  295. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_provider.d.ts.map +0 -1
  296. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_provider.js +0 -238
  297. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/VGEO_BRICK.d.ts +0 -99
  298. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/VGEO_BRICK.d.ts.map +0 -1
  299. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/VGEO_BRICK.js +0 -139
  300. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/VGeoBrickProvider.d.ts +0 -65
  301. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/VGeoBrickProvider.d.ts.map +0 -1
  302. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/VGeoBrickProvider.js +0 -393
  303. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/chunk_vgeo_brick_box.d.ts +0 -17
  304. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/chunk_vgeo_brick_box.d.ts.map +0 -1
  305. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/chunk_vgeo_brick_box.js +0 -36
  306. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/chunk_vgeo_brick_pair.d.ts +0 -29
  307. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/chunk_vgeo_brick_pair.d.ts.map +0 -1
  308. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/chunk_vgeo_brick_pair.js +0 -108
  309. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/chunk_vgeo_brick_texel.d.ts +0 -31
  310. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/chunk_vgeo_brick_texel.d.ts.map +0 -1
  311. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/chunk_vgeo_brick_texel.js +0 -113
  312. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/chunk_vgeo_brick_triangle.d.ts +0 -36
  313. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/chunk_vgeo_brick_triangle.d.ts.map +0 -1
  314. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/chunk_vgeo_brick_triangle.js +0 -85
  315. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/shader_vgeo_brick_distance.d.ts +0 -23
  316. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/shader_vgeo_brick_distance.d.ts.map +0 -1
  317. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/shader_vgeo_brick_distance.js +0 -273
  318. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/shader_vgeo_brick_gather.d.ts +0 -13
  319. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/shader_vgeo_brick_gather.d.ts.map +0 -1
  320. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/shader_vgeo_brick_gather.js +0 -151
  321. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/shader_vgeo_brick_traverse.d.ts +0 -13
  322. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/shader_vgeo_brick_traverse.d.ts.map +0 -1
  323. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/shader_vgeo_brick_traverse.js +0 -133
  324. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/shader_vgeo_brick_wait.d.ts +0 -22
  325. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/shader_vgeo_brick_wait.d.ts.map +0 -1
  326. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/shader_vgeo_brick_wait.js +0 -135
@@ -21,6 +21,7 @@ import { INDIRECT_MATERIAL_ARRAY_TYPE } from "./INDIRECT_MATERIAL_ARRAY_TYPE.js"
21
21
  import { INDIRECT_MATERIAL_STRUCT } from "./INDIRECT_MATERIAL_STRUCT.js";
22
22
  import {
23
23
  RESIDENT_MATERIAL_TEXTURE_LAYER_SIZE,
24
+ RESIDENT_MATERIAL_TEXTURE_LEVEL_COUNT,
24
25
  RESIDENT_MATERIAL_TEXTURE_RESOLUTION,
25
26
  RESIDENT_MATERIAL_TEXTURE_SLOT_RESOLUTION
26
27
  } from "./RESIDENT_MATERIAL_TEXTURE_LAYOUT.js";
@@ -381,7 +382,8 @@ export class GPUResidentMaterialContext {
381
382
  descriptor.format = "rgba8unorm";
382
383
  descriptor.dimension = "2d";
383
384
  descriptor.size = [RESIDENT_MATERIAL_TEXTURE_LAYER_SIZE, RESIDENT_MATERIAL_TEXTURE_LAYER_SIZE, 1];
384
- descriptor.mipLevelCount = 1;
385
+ // a slot's chain down to one texel; see RESIDENT_MATERIAL_TEXTURE_LAYOUT
386
+ descriptor.mipLevelCount = RESIDENT_MATERIAL_TEXTURE_LEVEL_COUNT;
385
387
  descriptor.usage = GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_DST;
386
388
 
387
389
  }
@@ -548,8 +550,6 @@ export class GPUResidentMaterialContext {
548
550
  Math.ceil(texture_count / slice_slot_count)
549
551
  );
550
552
 
551
- const target_texture = this.buffer_textures;
552
-
553
553
  const texture_manager = this.#texture_manager;
554
554
 
555
555
  {
@@ -582,80 +582,13 @@ export class GPUResidentMaterialContext {
582
582
 
583
583
  const source_ctx = texture_manager.obtain(source);
584
584
 
585
- const is_square = source_ctx.width === source_ctx.height;
586
-
587
- /*
588
- The fast path is a copyTextureToTexture, which requires the two formats to be
589
- copy-compatible. `!is_srgb` used to stand in for that and was true only by accident: every
590
- material texture was rgba8unorm, so the only way to differ was the srgb suffix. A BC7
591
- source would have reached the copy and failed validation.
592
-
593
- Asking the question directly costs nothing and covers every format at once — a source
594
- that does not match takes the render path below, which samples it into the atlas and is
595
- what that path exists for.
596
- */
597
- const format_matches = source_ctx.gpu_texture.format === target_texture.gpu_texture.format;
598
-
599
- const is_pot_w = isPowerOfTwo(source_ctx.width) && isPowerOfTwo(source_ctx.height);
600
-
601
- const source_mip_w = Math.log2(source_ctx.width / RESIDENT_MATERIAL_TEXTURE_RESOLUTION)
602
- const source_mip_h = Math.log2(source_ctx.height / RESIDENT_MATERIAL_TEXTURE_RESOLUTION)
603
-
604
-
605
585
  const texture_slot_z = Math.floor(info.id / slice_slot_count);
606
586
  const id_in_slice = info.id % slice_slot_count;
607
587
  const texture_slot_y = Math.floor(id_in_slice / RESIDENT_MATERIAL_TEXTURE_SLOT_RESOLUTION);
608
588
  const texture_slot_x = id_in_slice % RESIDENT_MATERIAL_TEXTURE_SLOT_RESOLUTION;
609
589
 
610
- if (is_square && is_pot_w && source_mip_w >= 0 && source_ctx.gpu_texture.mipLevelCount >= source_mip_w && format_matches) {
611
-
612
- encoder.copyTextureToTexture(
613
- {
614
- texture: source_ctx.gpu_texture,
615
- mipLevel: source_mip_w,
616
- },
617
- {
618
- texture: target_texture.gpu_texture,
619
- mipLevel: 0,
620
- origin: [
621
- texture_slot_x * RESIDENT_MATERIAL_TEXTURE_RESOLUTION,
622
- texture_slot_y * RESIDENT_MATERIAL_TEXTURE_RESOLUTION,
623
- texture_slot_z
624
- ]
625
- },
626
- [RESIDENT_MATERIAL_TEXTURE_RESOLUTION, RESIDENT_MATERIAL_TEXTURE_RESOLUTION]
627
- );
628
-
629
- } else {
630
- const nearest_mip = Math.max(0, Math.floor(Math.min(source_mip_w, source_mip_h)));
631
-
632
- // needs resizing and potentially color-space conversion
633
- render_copy_texture(
634
- {
635
- graphics: this.#graphics,
636
- encoder: encoder,
637
- target_format: target_texture.gpu_texture.format,
638
- output_view: target_texture.obtainView(TextureViewDescriptor.from({
639
- baseArrayLayer: texture_slot_z,
640
- dimension: "2d"
641
- })),
642
- source_view: source_ctx.obtainView(TextureViewDescriptor.from({
643
- baseMipLevel: nearest_mip
644
- })),
645
- source_clip: [
646
- 0, 0,
647
- source_ctx.width >> nearest_mip, source_ctx.height >> nearest_mip
648
- ],
649
- output_clip: [
650
- texture_slot_x * RESIDENT_MATERIAL_TEXTURE_RESOLUTION,
651
- texture_slot_y * RESIDENT_MATERIAL_TEXTURE_RESOLUTION,
652
-
653
- RESIDENT_MATERIAL_TEXTURE_RESOLUTION,
654
- RESIDENT_MATERIAL_TEXTURE_RESOLUTION,
655
- ]
656
- },
657
- );
658
-
590
+ for (let level = 0; level < RESIDENT_MATERIAL_TEXTURE_LEVEL_COUNT; level++) {
591
+ this.#write_slot_level(encoder, source_ctx, texture_slot_x, texture_slot_y, texture_slot_z, level);
659
592
  }
660
593
  }
661
594
 
@@ -665,6 +598,91 @@ export class GPUResidentMaterialContext {
665
598
 
666
599
  }
667
600
 
601
+ /**
602
+ * Mip `level` of a texture's slot, from the texture's own chain: copied from the source level the
603
+ * slot's level is the size of, or drawn from the source level nearest above its size where no level
604
+ * can be copied as it is. The source's chain does the filtering either way.
605
+ *
606
+ * @param {ShadeGPUCommandContext} encoder
607
+ * @param {GPUTextureContext} source_ctx
608
+ * @param {number} slot_x
609
+ * @param {number} slot_y
610
+ * @param {number} slot_z
611
+ * @param {number} level
612
+ */
613
+ #write_slot_level(encoder, source_ctx, slot_x, slot_y, slot_z, level) {
614
+ const target_texture = this.#buffer_textures;
615
+ const source_texture = source_ctx.gpu_texture;
616
+
617
+ const size = RESIDENT_MATERIAL_TEXTURE_RESOLUTION >> level;
618
+
619
+ const is_square = source_ctx.width === source_ctx.height;
620
+
621
+ /*
622
+ The fast path is a copyTextureToTexture, which requires the two formats to be
623
+ copy-compatible. `!is_srgb` used to stand in for that and was true only by accident: every
624
+ material texture was rgba8unorm, so the only way to differ was the srgb suffix. A BC7
625
+ source would have reached the copy and failed validation.
626
+
627
+ Asking the question directly costs nothing and covers every format at once — a source
628
+ that does not match takes the render path below, which samples it into the atlas and is
629
+ what that path exists for.
630
+ */
631
+ const format_matches = source_texture.format === target_texture.gpu_texture.format;
632
+
633
+ const is_pot_w = isPowerOfTwo(source_ctx.width) && isPowerOfTwo(source_ctx.height);
634
+
635
+ const source_mip_w = Math.log2(source_ctx.width / size);
636
+ const source_mip_h = Math.log2(source_ctx.height / size);
637
+
638
+ if (is_square && is_pot_w && source_mip_w >= 0 && source_mip_w < source_texture.mipLevelCount && format_matches) {
639
+
640
+ encoder.copyTextureToTexture(
641
+ {
642
+ texture: source_texture,
643
+ mipLevel: source_mip_w,
644
+ },
645
+ {
646
+ texture: target_texture.gpu_texture,
647
+ mipLevel: level,
648
+ origin: [slot_x * size, slot_y * size, slot_z]
649
+ },
650
+ [size, size]
651
+ );
652
+
653
+ } else {
654
+ // a chain that stops short draws from its last level
655
+ const nearest_mip = Math.min(
656
+ Math.max(0, Math.floor(Math.min(source_mip_w, source_mip_h))),
657
+ source_texture.mipLevelCount - 1
658
+ );
659
+
660
+ // needs resizing and potentially color-space conversion
661
+ render_copy_texture(
662
+ {
663
+ graphics: this.#graphics,
664
+ encoder: encoder,
665
+ target_format: target_texture.gpu_texture.format,
666
+ output_view: target_texture.obtainView(TextureViewDescriptor.from({
667
+ baseArrayLayer: slot_z,
668
+ dimension: "2d",
669
+ baseMipLevel: level,
670
+ mipLevelCount: 1,
671
+ })),
672
+ source_view: source_ctx.obtainView(TextureViewDescriptor.from({
673
+ baseMipLevel: nearest_mip
674
+ })),
675
+ source_clip: [
676
+ 0, 0,
677
+ source_ctx.width >> nearest_mip, source_ctx.height >> nearest_mip
678
+ ],
679
+ output_clip: [slot_x * size, slot_y * size, size, size]
680
+ },
681
+ );
682
+
683
+ }
684
+ }
685
+
668
686
  /**
669
687
  * Every texture slot's mean, after the slots are written (PROBE_CLIPMAP_PROPOSAL_2026_10_27.md §6.6):
670
688
  * the rows' sums, then the slots' means, which {@link buffer_texture_means} holds.
@@ -3,6 +3,11 @@
3
3
  * @type {number}
4
4
  */
5
5
  export const RESIDENT_MATERIAL_TEXTURE_RESOLUTION: number;
6
+ /**
7
+ * Mip levels a slot has, the last one texel.
8
+ * @type {number}
9
+ */
10
+ export const RESIDENT_MATERIAL_TEXTURE_LEVEL_COUNT: number;
6
11
  /**
7
12
  * Texels a side of a layer.
8
13
  * @type {number}
@@ -1 +1 @@
1
- {"version":3,"file":"RESIDENT_MATERIAL_TEXTURE_LAYOUT.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/material/resident/RESIDENT_MATERIAL_TEXTURE_LAYOUT.js"],"names":[],"mappings":"AAOA;;;GAGG;AACH,mDAFU,MAAM,CAEuC;AAEvD;;;GAGG;AACH,mDAFU,MAAM,CAEyC;AAEzD;;;GAGG;AACH,wDAFU,MAAM,CAEiI;AAEjJ;;;GAGG;AACH,wDAFU,MAAM,CAE+H"}
1
+ {"version":3,"file":"RESIDENT_MATERIAL_TEXTURE_LAYOUT.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/material/resident/RESIDENT_MATERIAL_TEXTURE_LAYOUT.js"],"names":[],"mappings":"AAUA;;;GAGG;AACH,mDAFU,MAAM,CAEuC;AAEvD;;;GAGG;AACH,oDAFU,MAAM,CAEyF;AAEzG;;;GAGG;AACH,mDAFU,MAAM,CAEyC;AAEzD;;;GAGG;AACH,wDAFU,MAAM,CAEiI;AAEjJ;;;GAGG;AACH,wDAFU,MAAM,CAE+H"}
@@ -3,6 +3,9 @@
3
3
  each texture a square slot, the slots in rows across a layer, the layers stacked. Slot `s` is in layer
4
4
  `⌊s / SLOTS_PER_LAYER⌋`, at column `s mod SLOT_RESOLUTION` and row `⌊s / SLOT_RESOLUTION⌋ mod
5
5
  SLOT_RESOLUTION` of it.
6
+
7
+ The array has LEVEL_COUNT mip levels, a slot's chain down to one texel: level k of a slot is
8
+ (RESOLUTION >> k)² texels at the slot's level-0 origin >> k, in level k of the same layer.
6
9
  */
7
10
 
8
11
  /**
@@ -11,6 +14,12 @@
11
14
  */
12
15
  export const RESIDENT_MATERIAL_TEXTURE_RESOLUTION = 64;
13
16
 
17
+ /**
18
+ * Mip levels a slot has, the last one texel.
19
+ * @type {number}
20
+ */
21
+ export const RESIDENT_MATERIAL_TEXTURE_LEVEL_COUNT = Math.log2(RESIDENT_MATERIAL_TEXTURE_RESOLUTION) + 1;
22
+
14
23
  /**
15
24
  * Texels a side of a layer.
16
25
  * @type {number}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * How a shader reads the resident material textures — decided by {@link chunk_indirect_sample_texture},
3
+ * so the material reads written once (`sample_material_data`, `sample_material_alpha`) take one filter
4
+ * or the other by the pipeline they are linked into.
5
+ *
6
+ * Whether the pass averages its reads is the pass's, so it is fixed per shader: `Stochastic`, the
7
+ * default, for every pass that never sets it; `Exact` for the card capture, which stores each read.
8
+ *
9
+ * @type {ShaderSwitch}
10
+ */
11
+ export const INDIRECT_TEXTURE_FILTER: ShaderSwitch;
12
+ import { ShaderSwitch } from "../../shader/compiler/ShaderSwitch.js";
13
+ //# sourceMappingURL=INDIRECT_TEXTURE_FILTER.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"INDIRECT_TEXTURE_FILTER.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/path_tracer/shader/INDIRECT_TEXTURE_FILTER.js"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,sCAFU,YAAY,CAEqF;6BAb9E,uCAAuC"}
@@ -0,0 +1,14 @@
1
+ import { ShaderSwitch } from "../../shader/compiler/ShaderSwitch.js";
2
+ import { IndirectTextureFilter } from "./IndirectTextureFilter.js";
3
+
4
+ /**
5
+ * How a shader reads the resident material textures — decided by {@link chunk_indirect_sample_texture},
6
+ * so the material reads written once (`sample_material_data`, `sample_material_alpha`) take one filter
7
+ * or the other by the pipeline they are linked into.
8
+ *
9
+ * Whether the pass averages its reads is the pass's, so it is fixed per shader: `Stochastic`, the
10
+ * default, for every pass that never sets it; `Exact` for the card capture, which stores each read.
11
+ *
12
+ * @type {ShaderSwitch}
13
+ */
14
+ export const INDIRECT_TEXTURE_FILTER = ShaderSwitch.enum('indirect texture filter', IndirectTextureFilter);
@@ -0,0 +1,10 @@
1
+ /**
2
+ * How a read of the resident material textures (`indirect_sample_texture`) takes the texture filtered
3
+ * at a level: trilinearly, bilinear at the two levels around it and those lerped.
4
+ */
5
+ export type IndirectTextureFilter = number;
6
+ export namespace IndirectTextureFilter {
7
+ let Stochastic: number;
8
+ let Exact: number;
9
+ }
10
+ //# sourceMappingURL=IndirectTextureFilter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IndirectTextureFilter.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/path_tracer/shader/IndirectTextureFilter.js"],"names":[],"mappings":";;;;oCAIU,MAAM"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * How a read of the resident material textures (`indirect_sample_texture`) takes the texture filtered
3
+ * at a level: trilinearly, bilinear at the two levels around it and those lerped.
4
+ *
5
+ * @enum {number}
6
+ */
7
+ export const IndirectTextureFilter = {
8
+ /**
9
+ * One tap of the filter, a texel of the two levels' eight drawn with its weight: what the filter
10
+ * gives on average, for a pass that averages many reads into each result — the path tracer.
11
+ */
12
+ Stochastic: 0,
13
+ /** The filter itself, every tap weighed: for a pass that keeps each read as it is — the card capture. */
14
+ Exact: 1,
15
+ };
@@ -1,7 +1,8 @@
1
1
  /**
2
- * A resident material's tangent-space normal at `uv`, from its normal texture in the atlas — or +Z,
3
- * the geometric normal exactly, when it has none (`id` is GPU_DATABASE_NULL; see
4
- * INDIRECT_MATERIAL_STRUCT's `texture_normal` for why there is no default texture to read instead).
2
+ * A resident material's tangent-space normal at `uv`, from its normal texture in the atlas at `level`
3
+ * (see {@link chunk_indirect_sample_texture}) — or +Z, the geometric normal exactly, when it has none
4
+ * (`id` is GPU_DATABASE_NULL; see INDIRECT_MATERIAL_STRUCT's `texture_normal` for why there is no
5
+ * default texture to read instead).
5
6
  *
6
7
  * Reads the `textures` atlas binding, which {@link chunk_indirect_sample_texture} leaves to the
7
8
  * shader that includes it.
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_indirect_sample_tangent_normal.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/path_tracer/shader/chunk_indirect_sample_tangent_normal.js"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,mDAFU,SAAS,CAeZ;0BA1BmB,oCAAoC"}
1
+ {"version":3,"file":"chunk_indirect_sample_tangent_normal.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/path_tracer/shader/chunk_indirect_sample_tangent_normal.js"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AACH,mDAFU,SAAS,CAeZ;0BA3BmB,oCAAoC"}
@@ -4,9 +4,10 @@ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
4
4
  import { chunk_indirect_sample_texture } from "./chunk_indirect_sample_texture.js";
5
5
 
6
6
  /**
7
- * A resident material's tangent-space normal at `uv`, from its normal texture in the atlas — or +Z,
8
- * the geometric normal exactly, when it has none (`id` is GPU_DATABASE_NULL; see
9
- * INDIRECT_MATERIAL_STRUCT's `texture_normal` for why there is no default texture to read instead).
7
+ * A resident material's tangent-space normal at `uv`, from its normal texture in the atlas at `level`
8
+ * (see {@link chunk_indirect_sample_texture}) — or +Z, the geometric normal exactly, when it has none
9
+ * (`id` is GPU_DATABASE_NULL; see INDIRECT_MATERIAL_STRUCT's `texture_normal` for why there is no
10
+ * default texture to read instead).
10
11
  *
11
12
  * Reads the `textures` atlas binding, which {@link chunk_indirect_sample_texture} leaves to the
12
13
  * shader that includes it.
@@ -16,12 +17,12 @@ import { chunk_indirect_sample_texture } from "./chunk_indirect_sample_texture.j
16
17
  export const chunk_indirect_sample_tangent_normal = CodeChunk.from(
17
18
  //language=WGSL
18
19
  `
19
- fn indirect_sample_tangent_normal(id: u32, sampler_packed: u32, uv: vec2<f32>) -> vec3<f32> {
20
+ fn indirect_sample_tangent_normal(id: u32, sampler_packed: u32, uv: vec2<f32>, level: f32) -> vec3<f32> {
20
21
  if (id == ${GPU_DATABASE_NULL}u) {
21
22
  return vec3<f32>(0.0, 0.0, 1.0);
22
23
  }
23
24
 
24
- return decode_tangent_normal(indirect_sample_texture(id, sampler_packed, uv));
25
+ return decode_tangent_normal(indirect_sample_texture(id, sampler_packed, uv, level));
25
26
  }
26
27
  `, [
27
28
  chunk_decode_tangent_normal,
@@ -1,3 +1,18 @@
1
- export const chunk_indirect_sample_texture: CodeChunk;
2
- import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
1
+ /**
2
+ * A resident material texture filtered at a level:
3
+ * `indirect_sample_texture(id: u32, sampler_packed: u32, uv: vec2<f32>, level: f32) -> vec4<f32>`, texture
4
+ * `id` of the atlas with its packed sampler's wrap and filter, trilinearly at `level`: log2 of the texels
5
+ * of a slot's level 0 the read's footprint spans, clamped to the slot's chain. A read at level 0 is
6
+ * level 0's bilinear filter.
7
+ *
8
+ * By the pass's {@link INDIRECT_TEXTURE_FILTER}: one tap of the filter
9
+ * ({@link chunk_indirect_sample_texture_stochastic}, the default), or the filter itself
10
+ * ({@link chunk_indirect_sample_texture_exact}).
11
+ *
12
+ * Reads the `textures` atlas binding, which the shader that includes it declares.
13
+ *
14
+ * @type {CodeChunkChoice}
15
+ */
16
+ export const chunk_indirect_sample_texture: CodeChunkChoice;
17
+ import { CodeChunkChoice } from "../../shader/compiler/CodeChunkChoice.js";
3
18
  //# sourceMappingURL=chunk_indirect_sample_texture.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_indirect_sample_texture.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/path_tracer/shader/chunk_indirect_sample_texture.js"],"names":[],"mappings":"AAWA,sDA6CE;0BApDwB,oCAAoC"}
1
+ {"version":3,"file":"chunk_indirect_sample_texture.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/path_tracer/shader/chunk_indirect_sample_texture.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;GAcG;AACH,4CAFU,eAAe,CAEkE;gCArB3D,0CAA0C"}
@@ -1,57 +1,25 @@
1
- import { chunk_coordinate_wrap } from "../../shader/chunk/texture/chunk_coordinate_wrap.js";
2
- import { chunk_texture_sampler_enums } from "../../shader/chunk/texture/chunk_texture_sampler_enums.js";
3
- import { chunk_sampler_descriptor_unpack } from "../../shader/chunk/texture/chunk_sampler_descriptor_unpack.js";
4
- import { chunk_random_round_vec2 } from "../../shader/chunk/random/chunk_random_round_vec2.js";
5
- import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
6
- import {
7
- RESIDENT_MATERIAL_TEXTURE_RESOLUTION,
8
- RESIDENT_MATERIAL_TEXTURE_SLOT_RESOLUTION,
9
- RESIDENT_MATERIAL_TEXTURE_SLOTS_PER_LAYER
10
- } from "../../material/resident/RESIDENT_MATERIAL_TEXTURE_LAYOUT.js";
11
-
12
- export const chunk_indirect_sample_texture = CodeChunk.from(
13
- //language=WGSL
14
- `
15
- fn indirect_sample_texture(id: u32, sampler_packed: u32, uv: vec2<f32>) -> vec4<f32>{
16
-
17
- let sampler = sampler_descriptor_unpack(sampler_packed);
18
-
19
- // figure out slot
20
- let slot_z = id / ${RESIDENT_MATERIAL_TEXTURE_SLOTS_PER_LAYER};
21
-
22
- let in_slice_id = id - slot_z * ${RESIDENT_MATERIAL_TEXTURE_SLOTS_PER_LAYER};
23
-
24
- let slot_y = in_slice_id / ${RESIDENT_MATERIAL_TEXTURE_SLOT_RESOLUTION};
25
- let slot_x = in_slice_id % ${RESIDENT_MATERIAL_TEXTURE_SLOT_RESOLUTION};
26
-
27
- let texture_texel_coord = uv * vec2<f32>( ${RESIDENT_MATERIAL_TEXTURE_RESOLUTION} ) - 0.5;
28
-
29
- // Texture Filtering: Nearest snaps to the closest texel; everything else
30
- // (Linear and the higher-order filters) resolves to a stochastic bilinear
31
- // tap, which converges to the filtered result across many samples. Mip
32
- // level is ignored in the indirect path - we always read level 0.
33
- var sample_coord: vec2<f32>;
34
- if (sampler.mag_filter == TEXTURE_FILTER_NEAREST) {
35
- sample_coord = round(texture_texel_coord);
36
- } else {
37
- sample_coord = random_round_vec2(texture_texel_coord);
38
- }
39
-
40
- // Texture Wrapping (per-axis, S->U / T->V)
41
- let wrapped_coord = vec2(
42
- coordinate_wrap(sample_coord.x, ${RESIDENT_MATERIAL_TEXTURE_RESOLUTION}, sampler.address_mode_u),
43
- coordinate_wrap(sample_coord.y, ${RESIDENT_MATERIAL_TEXTURE_RESOLUTION}, sampler.address_mode_v),
44
- );
45
-
46
- // Convert to atlas space
47
- let pixel_coord = vec2<u32>(slot_x, slot_y) * ${RESIDENT_MATERIAL_TEXTURE_RESOLUTION} + vec2<u32>(wrapped_coord);
48
-
49
- return textureLoad(textures, pixel_coord, slot_z, 0 );
50
- }
51
- `, [
52
- chunk_random_round_vec2,
53
- chunk_coordinate_wrap,
54
- chunk_texture_sampler_enums,
55
- chunk_sampler_descriptor_unpack,
56
- ]
57
- );
1
+ import { CodeChunkChoice } from "../../shader/compiler/CodeChunkChoice.js";
2
+ import { chunk_indirect_sample_texture_exact } from "./chunk_indirect_sample_texture_exact.js";
3
+ import { chunk_indirect_sample_texture_stochastic } from "./chunk_indirect_sample_texture_stochastic.js";
4
+ import { INDIRECT_TEXTURE_FILTER } from "./INDIRECT_TEXTURE_FILTER.js";
5
+ import { IndirectTextureFilter } from "./IndirectTextureFilter.js";
6
+
7
+ /**
8
+ * A resident material texture filtered at a level:
9
+ * `indirect_sample_texture(id: u32, sampler_packed: u32, uv: vec2<f32>, level: f32) -> vec4<f32>`, texture
10
+ * `id` of the atlas with its packed sampler's wrap and filter, trilinearly at `level`: log2 of the texels
11
+ * of a slot's level 0 the read's footprint spans, clamped to the slot's chain. A read at level 0 is
12
+ * level 0's bilinear filter.
13
+ *
14
+ * By the pass's {@link INDIRECT_TEXTURE_FILTER}: one tap of the filter
15
+ * ({@link chunk_indirect_sample_texture_stochastic}, the default), or the filter itself
16
+ * ({@link chunk_indirect_sample_texture_exact}).
17
+ *
18
+ * Reads the `textures` atlas binding, which the shader that includes it declares.
19
+ *
20
+ * @type {CodeChunkChoice}
21
+ */
22
+ export const chunk_indirect_sample_texture = CodeChunkChoice.from(INDIRECT_TEXTURE_FILTER);
23
+
24
+ chunk_indirect_sample_texture.add(IndirectTextureFilter.Stochastic, chunk_indirect_sample_texture_stochastic);
25
+ chunk_indirect_sample_texture.add(IndirectTextureFilter.Exact, chunk_indirect_sample_texture_exact);
@@ -0,0 +1,13 @@
1
+ /**
2
+ * `indirect_sample_texture(id, sampler_packed, uv, level)` as the filter itself
3
+ * ({@link INDIRECT_TEXTURE_FILTER} `Exact`): bilinear at the levels on either side of `level`, lerped by
4
+ * where it falls between them. No draw, so the same read gives the same value every time.
5
+ *
6
+ * Between a level's texels the filter is the sampler's mag filter, at every level, as the stochastic
7
+ * read takes it: Nearest snaps to the closest texel.
8
+ *
9
+ * @type {CodeChunk}
10
+ */
11
+ export const chunk_indirect_sample_texture_exact: CodeChunk;
12
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
13
+ //# sourceMappingURL=chunk_indirect_sample_texture_exact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_indirect_sample_texture_exact.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/path_tracer/shader/chunk_indirect_sample_texture_exact.js"],"names":[],"mappings":"AAUA;;;;;;;;;GASG;AACH,kDAFU,SAAS,CAmDjB;0BA9DwB,oCAAoC"}
@@ -0,0 +1,70 @@
1
+ import {
2
+ RESIDENT_MATERIAL_TEXTURE_LEVEL_COUNT,
3
+ RESIDENT_MATERIAL_TEXTURE_RESOLUTION
4
+ } from "../../material/resident/RESIDENT_MATERIAL_TEXTURE_LAYOUT.js";
5
+ import { chunk_sampler_descriptor_unpack } from "../../shader/chunk/texture/chunk_sampler_descriptor_unpack.js";
6
+ import { chunk_texture_sampler_enums } from "../../shader/chunk/texture/chunk_texture_sampler_enums.js";
7
+ import { SAMPLER_DESCRIPTOR_STRUCT } from "../../shader/chunk/texture/SAMPLER_DESCRIPTOR_STRUCT.js";
8
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
9
+ import { chunk_indirect_texture_load } from "./chunk_indirect_texture_load.js";
10
+
11
+ /**
12
+ * `indirect_sample_texture(id, sampler_packed, uv, level)` as the filter itself
13
+ * ({@link INDIRECT_TEXTURE_FILTER} `Exact`): bilinear at the levels on either side of `level`, lerped by
14
+ * where it falls between them. No draw, so the same read gives the same value every time.
15
+ *
16
+ * Between a level's texels the filter is the sampler's mag filter, at every level, as the stochastic
17
+ * read takes it: Nearest snaps to the closest texel.
18
+ *
19
+ * @type {CodeChunk}
20
+ */
21
+ export const chunk_indirect_sample_texture_exact = CodeChunk.from(
22
+ //language=WGSL
23
+ `
24
+ fn indirect_sample_texture_level(id: u32, sampler: ${SAMPLER_DESCRIPTOR_STRUCT.wgsl_ref}, uv: vec2<f32>, mip: u32) -> vec4<f32>{
25
+
26
+ let texture_texel_coord = uv * f32(${RESIDENT_MATERIAL_TEXTURE_RESOLUTION}u >> mip) - 0.5;
27
+
28
+ if (sampler.mag_filter == TEXTURE_FILTER_NEAREST) {
29
+ return indirect_texture_load(id, sampler, round(texture_texel_coord), mip);
30
+ }
31
+
32
+ let corner = floor(texture_texel_coord);
33
+ let weight = texture_texel_coord - corner;
34
+
35
+ let row_0 = mix(
36
+ indirect_texture_load(id, sampler, corner, mip),
37
+ indirect_texture_load(id, sampler, corner + vec2<f32>(1.0, 0.0), mip),
38
+ weight.x
39
+ );
40
+ let row_1 = mix(
41
+ indirect_texture_load(id, sampler, corner + vec2<f32>(0.0, 1.0), mip),
42
+ indirect_texture_load(id, sampler, corner + vec2<f32>(1.0, 1.0), mip),
43
+ weight.x
44
+ );
45
+
46
+ return mix(row_0, row_1, weight.y);
47
+ }
48
+
49
+ fn indirect_sample_texture(id: u32, sampler_packed: u32, uv: vec2<f32>, level: f32) -> vec4<f32>{
50
+
51
+ let sampler = sampler_descriptor_unpack(sampler_packed);
52
+
53
+ let within = clamp(level, 0.0, ${RESIDENT_MATERIAL_TEXTURE_LEVEL_COUNT - 1}.0);
54
+
55
+ let lower = u32(within);
56
+ let upper = min(lower + 1u, ${RESIDENT_MATERIAL_TEXTURE_LEVEL_COUNT - 1}u);
57
+
58
+ return mix(
59
+ indirect_sample_texture_level(id, sampler, uv, lower),
60
+ indirect_sample_texture_level(id, sampler, uv, upper),
61
+ within - f32(lower)
62
+ );
63
+ }
64
+ `, [
65
+ SAMPLER_DESCRIPTOR_STRUCT.declaration_chunk,
66
+ chunk_texture_sampler_enums,
67
+ chunk_sampler_descriptor_unpack,
68
+ chunk_indirect_texture_load,
69
+ ]
70
+ );
@@ -0,0 +1,10 @@
1
+ /**
2
+ * `indirect_sample_texture(id, sampler_packed, uv, level)` as one tap of the filter
3
+ * ({@link INDIRECT_TEXTURE_FILTER} `Stochastic`, the default): what the filter gives on average, which
4
+ * a pass converges to across many reads.
5
+ *
6
+ * @type {CodeChunk}
7
+ */
8
+ export const chunk_indirect_sample_texture_stochastic: CodeChunk;
9
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
10
+ //# sourceMappingURL=chunk_indirect_sample_texture_stochastic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_indirect_sample_texture_stochastic.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/path_tracer/shader/chunk_indirect_sample_texture_stochastic.js"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH,uDAFU,SAAS,CA0CjB;0BAlDwB,oCAAoC"}
@@ -0,0 +1,59 @@
1
+ import {
2
+ RESIDENT_MATERIAL_TEXTURE_LEVEL_COUNT,
3
+ RESIDENT_MATERIAL_TEXTURE_RESOLUTION
4
+ } from "../../material/resident/RESIDENT_MATERIAL_TEXTURE_LAYOUT.js";
5
+ import { chunk_random } from "../../shader/chunk/random/chunk_random.js";
6
+ import { chunk_random_round_vec2 } from "../../shader/chunk/random/chunk_random_round_vec2.js";
7
+ import { chunk_sampler_descriptor_unpack } from "../../shader/chunk/texture/chunk_sampler_descriptor_unpack.js";
8
+ import { chunk_texture_sampler_enums } from "../../shader/chunk/texture/chunk_texture_sampler_enums.js";
9
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
10
+ import { chunk_indirect_texture_load } from "./chunk_indirect_texture_load.js";
11
+
12
+ /**
13
+ * `indirect_sample_texture(id, sampler_packed, uv, level)` as one tap of the filter
14
+ * ({@link INDIRECT_TEXTURE_FILTER} `Stochastic`, the default): what the filter gives on average, which
15
+ * a pass converges to across many reads.
16
+ *
17
+ * @type {CodeChunk}
18
+ */
19
+ export const chunk_indirect_sample_texture_stochastic = CodeChunk.from(
20
+ //language=WGSL
21
+ `
22
+ fn indirect_sample_texture(id: u32, sampler_packed: u32, uv: vec2<f32>, level: f32) -> vec4<f32>{
23
+
24
+ let sampler = sampler_descriptor_unpack(sampler_packed);
25
+
26
+ // a level between two is the upper one with the probability of its fraction: a draw, and none at a
27
+ // whole level, so a read at level 0 takes the random numbers it always did
28
+ let within = clamp(level, 0.0, ${RESIDENT_MATERIAL_TEXTURE_LEVEL_COUNT - 1}.0);
29
+
30
+ var mip = u32(within);
31
+
32
+ let fraction = within - f32(mip);
33
+
34
+ if (fraction > 0.0 && random() < fraction) {
35
+ mip += 1u;
36
+ }
37
+
38
+ let texture_texel_coord = uv * f32(${RESIDENT_MATERIAL_TEXTURE_RESOLUTION}u >> mip) - 0.5;
39
+
40
+ // Texture Filtering: Nearest snaps to the closest texel; everything else
41
+ // (Linear and the higher-order filters) resolves to a stochastic bilinear
42
+ // tap, which converges to the filtered result across many samples.
43
+ var sample_coord: vec2<f32>;
44
+ if (sampler.mag_filter == TEXTURE_FILTER_NEAREST) {
45
+ sample_coord = round(texture_texel_coord);
46
+ } else {
47
+ sample_coord = random_round_vec2(texture_texel_coord);
48
+ }
49
+
50
+ return indirect_texture_load(id, sampler, sample_coord, mip);
51
+ }
52
+ `, [
53
+ chunk_random,
54
+ chunk_random_round_vec2,
55
+ chunk_texture_sampler_enums,
56
+ chunk_sampler_descriptor_unpack,
57
+ chunk_indirect_texture_load,
58
+ ]
59
+ );
@@ -0,0 +1,12 @@
1
+ /**
2
+ * One texel of a resident material texture: `indirect_texture_load(id, sampler, texel, level)`, the texel
3
+ * at the integer-valued coordinate `texel` of texture `id`'s slot at mip `level`, the coordinate wrapped
4
+ * within the slot at that level by the sampler's address modes (RESIDENT_MATERIAL_TEXTURE_LAYOUT).
5
+ *
6
+ * Reads the `textures` atlas binding, which the shader that includes it declares.
7
+ *
8
+ * @type {CodeChunk}
9
+ */
10
+ export const chunk_indirect_texture_load: CodeChunk;
11
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
12
+ //# sourceMappingURL=chunk_indirect_texture_load.d.ts.map