@woosh/meep-engine 3.61.3 → 3.62.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 (266) hide show
  1. package/package.json +1 -1
  2. package/src/engine/graphics3/PickingSystem.d.ts.map +1 -1
  3. package/src/engine/graphics3/PickingSystem.js +415 -413
  4. package/src/engine/graphics3/decal/GPUDecalRenderer.d.ts.map +1 -1
  5. package/src/engine/graphics3/decal/GPUDecalRenderer.js +2 -1
  6. package/src/engine/graphics3/decal/shader_decal_composite.d.ts.map +1 -1
  7. package/src/engine/graphics3/decal/shader_decal_composite.js +26 -16
  8. package/src/engine/graphics3/decal/shader_decal_tile_copy.d.ts.map +1 -1
  9. package/src/engine/graphics3/decal/shader_decal_tile_copy.js +6 -11
  10. package/src/engine/graphics3/highlight/GPUHighlightRenderer.d.ts.map +1 -1
  11. package/src/engine/graphics3/highlight/GPUHighlightRenderer.js +6 -2
  12. package/src/engine/graphics3/highlight/shader_highlight_outline.d.ts.map +1 -1
  13. package/src/engine/graphics3/highlight/shader_highlight_outline.js +167 -150
  14. package/src/engine/graphics3/shader_picking_gather.d.ts.map +1 -1
  15. package/src/engine/graphics3/shader_picking_gather.js +133 -120
  16. package/src/shade/device/mock/SoftwareGPUTexture.d.ts.map +1 -1
  17. package/src/shade/device/mock/SoftwareGPUTexture.js +11 -0
  18. package/src/shade/device/pipeline/rp_validate_and_rewrite_for_color_attachments.js +1 -1
  19. package/src/shade/playground/contact_shadows/ContactShadowLab.js +6 -6
  20. package/src/shade/playground/contact_shadows/shader_contact_lab_composite.d.ts.map +1 -1
  21. package/src/shade/playground/contact_shadows/shader_contact_lab_composite.js +6 -4
  22. package/src/shade/playground/contact_shadows/shader_contact_lab_reference.d.ts.map +1 -1
  23. package/src/shade/playground/contact_shadows/shader_contact_lab_reference.js +6 -4
  24. package/src/shade/playground/contact_shadows/shader_contact_shadow_march.d.ts.map +1 -1
  25. package/src/shade/playground/contact_shadows/shader_contact_shadow_march.js +6 -4
  26. package/src/shade/playground/ssr_reprojection/SpatialFilterProbe.js +1 -1
  27. package/src/shade/playground/ssr_variance/capture.js +1 -1
  28. package/src/shade/renderer/Renderer.d.ts +2 -2
  29. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  30. package/src/shade/renderer/Renderer.js +40 -53
  31. package/src/shade/renderer/deferred/chunk_read_gBuffer_material.d.ts.map +1 -1
  32. package/src/shade/renderer/deferred/chunk_read_gBuffer_material.js +3 -1
  33. package/src/shade/renderer/deferred/chunk_ss_trace_contact_shadow_soft.d.ts.map +1 -1
  34. package/src/shade/renderer/deferred/chunk_ss_trace_contact_shadow_soft.js +5 -4
  35. package/src/shade/renderer/deferred/shader_deferred_main.d.ts.map +1 -1
  36. package/src/shade/renderer/deferred/shader_deferred_main.js +6 -4
  37. package/src/shade/renderer/extension/GBufferTextures.d.ts +5 -1
  38. package/src/shade/renderer/extension/GBufferTextures.d.ts.map +1 -1
  39. package/src/shade/renderer/extension/GBufferTextures.js +5 -1
  40. package/src/shade/renderer/extension/ViewTextures.d.ts +11 -7
  41. package/src/shade/renderer/extension/ViewTextures.d.ts.map +1 -1
  42. package/src/shade/renderer/extension/ViewTextures.js +17 -13
  43. package/src/shade/renderer/gbuffer/G_BUFFER_ALBEDO_FORMAT.d.ts +2 -0
  44. package/src/shade/renderer/gbuffer/G_BUFFER_ALBEDO_FORMAT.d.ts.map +1 -1
  45. package/src/shade/renderer/gbuffer/G_BUFFER_ALBEDO_FORMAT.js +2 -0
  46. package/src/shade/renderer/gbuffer/G_BUFFER_COLOR_TARGETS.d.ts.map +1 -1
  47. package/src/shade/renderer/gbuffer/G_BUFFER_COLOR_TARGETS.js +8 -5
  48. package/src/shade/renderer/geometry/sdf/shader_sdf_visualize.d.ts +7 -5
  49. package/src/shade/renderer/geometry/sdf/shader_sdf_visualize.d.ts.map +1 -1
  50. package/src/shade/renderer/geometry/sdf/shader_sdf_visualize.js +29 -16
  51. package/src/shade/renderer/geometry/virtual/runtime/cut/chunk_vgeo_cut_instance.d.ts +9 -3
  52. package/src/shade/renderer/geometry/virtual/runtime/cut/chunk_vgeo_cut_instance.d.ts.map +1 -1
  53. package/src/shade/renderer/geometry/virtual/runtime/cut/chunk_vgeo_cut_instance.js +40 -32
  54. package/src/shade/renderer/geometry/virtual/runtime/cut/shader_vgeo_cut_collect.d.ts.map +1 -1
  55. package/src/shade/renderer/geometry/virtual/runtime/cut/shader_vgeo_cut_collect.js +14 -15
  56. package/src/shade/renderer/global_illumination/brick4/gpu/draw/shader_brick4_debug_draw.d.ts.map +1 -1
  57. package/src/shade/renderer/global_illumination/brick4/gpu/draw/shader_brick4_debug_draw.js +7 -3
  58. package/src/shade/renderer/global_illumination/brick4/gpu/draw/shader_brick4_diffuse.js +1 -1
  59. package/src/shade/renderer/global_illumination/brick4/gpu/draw/shader_brick4_indirect_lighting.d.ts.map +1 -1
  60. package/src/shade/renderer/global_illumination/brick4/gpu/draw/shader_brick4_indirect_lighting.js +5 -3
  61. package/src/shade/renderer/global_illumination/brick4/gpu/draw/shader_brick4_specular.d.ts.map +1 -1
  62. package/src/shade/renderer/global_illumination/brick4/gpu/draw/shader_brick4_specular.js +1 -3
  63. package/src/shade/renderer/global_illumination/ibl/shader_diffuse_IBL.js +1 -1
  64. package/src/shade/renderer/global_illumination/ibl/shader_specular_IBL.js +2 -2
  65. package/src/shade/renderer/global_illumination/lpv/shader_diffuse_LPV.js +1 -1
  66. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.d.ts.map +1 -1
  67. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.js +14 -1
  68. package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.d.ts.map +1 -1
  69. package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.js +10 -1
  70. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_diffuse.js +2 -2
  71. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_indirect_lighting.d.ts.map +1 -1
  72. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_indirect_lighting.js +5 -3
  73. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want.js +1 -1
  74. package/src/shade/renderer/global_illumination/shader_resolve_indirect_lighting.d.ts.map +1 -1
  75. package/src/shade/renderer/global_illumination/shader_resolve_indirect_lighting.js +5 -3
  76. package/src/shade/renderer/global_illumination/sharc/shader/debug/shader_colored_hash.js +1 -1
  77. package/src/shade/renderer/global_illumination/sharc/shader/debug/shader_sharc_debug_radiance.js +1 -1
  78. package/src/shade/renderer/global_illumination/sharc/shader/shader_sharc_update.js +1 -1
  79. package/src/shade/renderer/material/GPUMaterialManager.d.ts +22 -9
  80. package/src/shade/renderer/material/GPUMaterialManager.d.ts.map +1 -1
  81. package/src/shade/renderer/material/GPUMaterialManager.js +159 -65
  82. package/src/shade/renderer/material/MATERIAL_MASK.d.ts +19 -0
  83. package/src/shade/renderer/material/MATERIAL_MASK.d.ts.map +1 -0
  84. package/src/shade/renderer/material/MATERIAL_MASK.js +19 -0
  85. package/src/shade/renderer/material/dispatch/GPUMaterialComputeDispatch.d.ts +8 -8
  86. package/src/shade/renderer/material/dispatch/GPUMaterialComputeDispatch.d.ts.map +1 -1
  87. package/src/shade/renderer/material/dispatch/GPUMaterialComputeDispatch.js +11 -92
  88. package/src/shade/renderer/material/dispatch/chunk_material_quad_keys.d.ts.map +1 -1
  89. package/src/shade/renderer/material/dispatch/chunk_material_quad_keys.js +10 -2
  90. package/src/shade/renderer/material/dispatch/gbuffer_compute.js +2 -2
  91. package/src/shade/renderer/material/dispatch/graph_material_dispatch_compute.d.ts +7 -7
  92. package/src/shade/renderer/material/dispatch/graph_material_dispatch_compute.d.ts.map +1 -1
  93. package/src/shade/renderer/material/dispatch/graph_material_dispatch_compute.js +20 -16
  94. package/src/shade/renderer/material/dispatch/shader_material_pixel_count.d.ts.map +1 -1
  95. package/src/shade/renderer/material/dispatch/shader_material_pixel_count.js +3 -1
  96. package/src/shade/renderer/material/dispatch/shader_material_pixel_scatter.d.ts.map +1 -1
  97. package/src/shade/renderer/material/dispatch/shader_material_pixel_scatter.js +3 -1
  98. package/src/shade/renderer/material/standard/fragment_gbuffer.d.ts.map +1 -1
  99. package/src/shade/renderer/material/standard/fragment_gbuffer.js +26 -25
  100. package/src/shade/renderer/material/standard/material_gbuffer_vertex.d.ts +10 -8
  101. package/src/shade/renderer/material/standard/material_gbuffer_vertex.d.ts.map +1 -1
  102. package/src/shade/renderer/material/standard/material_gbuffer_vertex.js +16 -13
  103. package/src/shade/renderer/material/template/ShadeMaterialTemplate.d.ts +1 -1
  104. package/src/shade/renderer/material/template/ShadeMaterialTemplate.js +1 -1
  105. package/src/shade/renderer/postprocess/denoise/LigmaDenoiser.d.ts +5 -2
  106. package/src/shade/renderer/postprocess/denoise/LigmaDenoiser.d.ts.map +1 -1
  107. package/src/shade/renderer/postprocess/denoise/LigmaDenoiser.js +7 -4
  108. package/src/shade/renderer/postprocess/denoise/debug/graph_pass_debug_reprojection.d.ts +3 -3
  109. package/src/shade/renderer/postprocess/denoise/debug/graph_pass_debug_reprojection.d.ts.map +1 -1
  110. package/src/shade/renderer/postprocess/denoise/debug/graph_pass_debug_reprojection.js +12 -10
  111. package/src/shade/renderer/postprocess/denoise/fragment_shader_denoise_ao.js +2 -2
  112. package/src/shade/renderer/postprocess/denoise/shader_temporal_reprojection_luma.d.ts.map +1 -1
  113. package/src/shade/renderer/postprocess/denoise/shader_temporal_reprojection_luma.js +6 -4
  114. package/src/shade/renderer/postprocess/gtao/GTAO.d.ts +9 -7
  115. package/src/shade/renderer/postprocess/gtao/GTAO.d.ts.map +1 -1
  116. package/src/shade/renderer/postprocess/gtao/GTAO.js +11 -8
  117. package/src/shade/renderer/postprocess/gtao/ao_reproject_shader.d.ts +3 -3
  118. package/src/shade/renderer/postprocess/gtao/ao_reproject_shader.d.ts.map +1 -1
  119. package/src/shade/renderer/postprocess/gtao/ao_reproject_shader.js +17 -12
  120. package/src/shade/renderer/postprocess/gtao/chunk_integrate_lighting_sample.js +1 -1
  121. package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao.js +1 -1
  122. package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao_with_irradiance.js +4 -4
  123. package/src/shade/renderer/postprocess/gtao/shader_gtao_spatial_denoise.js +2 -2
  124. package/src/shade/renderer/postprocess/ssr/chunk_ssr_spatial_variance.js +41 -41
  125. package/src/shade/renderer/postprocess/ssr/prefilter/chunk_load_neighbourhood_sample.js +1 -1
  126. package/src/shade/renderer/postprocess/ssr/reproject/chunk_ssr_temporal_accumulate.js +3 -3
  127. package/src/shade/renderer/postprocess/ssr/resolve/chunk_ssr_add_hit_irradiance.d.ts.map +1 -1
  128. package/src/shade/renderer/postprocess/ssr/resolve/chunk_ssr_add_hit_irradiance.js +5 -2
  129. package/src/shade/renderer/postprocess/ssr/resolve/ssr_resolve_shader.js +4 -4
  130. package/src/shade/renderer/postprocess/ssr/ssr_combine_shader.d.ts.map +1 -1
  131. package/src/shade/renderer/postprocess/ssr/ssr_combine_shader.js +4 -2
  132. package/src/shade/renderer/postprocess/ssr/ssr_graph_prefilter_color.d.ts +2 -1
  133. package/src/shade/renderer/postprocess/ssr/ssr_graph_prefilter_color.d.ts.map +1 -1
  134. package/src/shade/renderer/postprocess/ssr/ssr_graph_prefilter_color.js +10 -2
  135. package/src/shade/renderer/postprocess/ssr/ssr_reproject_shader.js +1 -1
  136. package/src/shade/renderer/postprocess/ssr/ssr_spatial_denoise_shader.js +4 -4
  137. package/src/shade/renderer/postprocess/taa/shader_reprojection_map.d.ts.map +1 -1
  138. package/src/shade/renderer/postprocess/taa/shader_reprojection_map.js +6 -4
  139. package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.d.ts +6 -8
  140. package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.d.ts.map +1 -1
  141. package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.js +29 -33
  142. package/src/shade/renderer/rasterize/TemplatePassDescriptor.d.ts.map +1 -1
  143. package/src/shade/renderer/rasterize/TemplatePassDescriptor.js +1 -0
  144. package/src/shade/renderer/rasterize/bucket/graph_meshlets_rasterize_by_bucket.d.ts +6 -3
  145. package/src/shade/renderer/rasterize/bucket/graph_meshlets_rasterize_by_bucket.d.ts.map +1 -1
  146. package/src/shade/renderer/rasterize/bucket/graph_meshlets_rasterize_by_bucket.js +8 -3
  147. package/src/shade/renderer/rasterize/expand/GPUCollectionLimits.d.ts.map +1 -1
  148. package/src/shade/renderer/rasterize/expand/GPUCollectionLimits.js +3 -0
  149. package/src/shade/renderer/rasterize/expand/RasterizationCollectionType.d.ts +1 -0
  150. package/src/shade/renderer/rasterize/expand/RasterizationCollectionType.js +5 -0
  151. package/src/shade/renderer/rasterize/expand/graph_meshlets_rasterize.d.ts +8 -3
  152. package/src/shade/renderer/rasterize/expand/graph_meshlets_rasterize.d.ts.map +1 -1
  153. package/src/shade/renderer/rasterize/expand/graph_meshlets_rasterize.js +54 -5
  154. package/src/shade/renderer/rasterize/native/avboit/AVBOITSideChannel.d.ts +1 -0
  155. package/src/shade/renderer/rasterize/native/avboit/AVBOITSideChannel.d.ts.map +1 -1
  156. package/src/shade/renderer/rasterize/native/avboit/AVBOITSideChannel.js +1 -1
  157. package/src/shade/renderer/rasterize/native/avboit/graph_rasterize_meshes_transparent_avboit.d.ts +1 -1
  158. package/src/shade/renderer/rasterize/native/avboit/graph_rasterize_meshes_transparent_avboit.d.ts.map +1 -1
  159. package/src/shade/renderer/rasterize/native/avboit/graph_rasterize_meshes_transparent_avboit.js +2 -1
  160. package/src/shade/renderer/rasterize/native/graph_rasterize_meshes_alpha_tested.d.ts +7 -2
  161. package/src/shade/renderer/rasterize/native/graph_rasterize_meshes_alpha_tested.d.ts.map +1 -1
  162. package/src/shade/renderer/rasterize/native/graph_rasterize_meshes_alpha_tested.js +73 -9
  163. package/src/shade/renderer/rasterize/native/viz/shader_vertex.js +4 -4
  164. package/src/shade/renderer/rasterize/native/viz/viz_rasterization_alpha_tested_pass_descriptor.d.ts.map +1 -1
  165. package/src/shade/renderer/rasterize/native/viz/viz_rasterization_alpha_tested_pass_descriptor.js +23 -40
  166. package/src/shade/renderer/rasterize/native/viz/viz_rasterization_opaque_pass_descriptor.d.ts.map +1 -1
  167. package/src/shade/renderer/rasterize/native/viz/viz_rasterization_opaque_pass_descriptor.js +55 -76
  168. package/src/shade/renderer/rasterize/standard/graph_rasterize_partial_opaque.d.ts +4 -2
  169. package/src/shade/renderer/rasterize/standard/graph_rasterize_partial_opaque.d.ts.map +1 -1
  170. package/src/shade/renderer/rasterize/standard/graph_rasterize_partial_opaque.js +6 -2
  171. package/src/shade/renderer/rasterize/standard/graph_rasterize_remaining_opaque.d.ts +4 -2
  172. package/src/shade/renderer/rasterize/standard/graph_rasterize_remaining_opaque.d.ts.map +1 -1
  173. package/src/shade/renderer/rasterize/standard/graph_rasterize_remaining_opaque.js +6 -2
  174. package/src/shade/renderer/rasterize/standard/graph_rasterize_scene.d.ts +5 -2
  175. package/src/shade/renderer/rasterize/standard/graph_rasterize_scene.d.ts.map +1 -1
  176. package/src/shade/renderer/rasterize/standard/graph_rasterize_scene.js +43 -2
  177. package/src/shade/renderer/rasterize/visibility/VISIBILITY_BUFFER.d.ts +39 -0
  178. package/src/shade/renderer/rasterize/visibility/VISIBILITY_BUFFER.d.ts.map +1 -0
  179. package/src/shade/renderer/rasterize/visibility/VISIBILITY_BUFFER.js +45 -0
  180. package/src/shade/renderer/rasterize/visibility/chunk_visibility_decode.d.ts +26 -0
  181. package/src/shade/renderer/rasterize/visibility/chunk_visibility_decode.d.ts.map +1 -0
  182. package/src/shade/renderer/rasterize/visibility/chunk_visibility_decode.js +48 -0
  183. package/src/shade/renderer/rasterize/visibility/shader_visible_meshlets_append.d.ts +40 -0
  184. package/src/shade/renderer/rasterize/visibility/shader_visible_meshlets_append.d.ts.map +1 -0
  185. package/src/shade/renderer/rasterize/visibility/shader_visible_meshlets_append.js +172 -0
  186. package/src/shade/renderer/restir/di/chunk_restir_reconstruct_surface.d.ts.map +1 -1
  187. package/src/shade/renderer/restir/di/chunk_restir_reconstruct_surface.js +6 -4
  188. package/src/shade/renderer/restir/di/chunk_restir_spatial_reuse.js +1 -1
  189. package/src/shade/renderer/restir/di/shader_restir_di_denoise.js +2 -2
  190. package/src/shade/renderer/shader/chunk/color/sRGB/chunk_sRGBTransferEOTF.d.ts +9 -0
  191. package/src/shade/renderer/shader/chunk/color/sRGB/chunk_sRGBTransferEOTF.d.ts.map +1 -0
  192. package/src/shade/renderer/shader/chunk/color/sRGB/chunk_sRGBTransferEOTF.js +18 -0
  193. package/src/shade/renderer/shader/chunk/geometry/mat3/chunk_mat3_determinant.d.ts +20 -0
  194. package/src/shade/renderer/shader/chunk/geometry/mat3/chunk_mat3_determinant.d.ts.map +1 -0
  195. package/src/shade/renderer/shader/chunk/geometry/mat3/chunk_mat3_determinant.js +26 -0
  196. package/src/shade/renderer/shader/chunk/geometry/mat3/chunk_mat3_singular_values.d.ts +60 -18
  197. package/src/shade/renderer/shader/chunk/geometry/mat3/chunk_mat3_singular_values.d.ts.map +1 -1
  198. package/src/shade/renderer/shader/chunk/geometry/mat3/chunk_mat3_singular_values.js +163 -45
  199. package/src/shade/renderer/shader/chunk/geometry/mat4/chunk_mat4_linear_determinant.d.ts.map +1 -1
  200. package/src/shade/renderer/shader/chunk/geometry/mat4/chunk_mat4_linear_determinant.js +19 -18
  201. package/src/shade/renderer/shader/chunk/geometry/normal/chunk_decode_g_buffer_face_normal.d.ts +13 -0
  202. package/src/shade/renderer/shader/chunk/geometry/normal/chunk_decode_g_buffer_face_normal.d.ts.map +1 -0
  203. package/src/shade/renderer/shader/chunk/geometry/normal/chunk_decode_g_buffer_face_normal.js +22 -0
  204. package/src/shade/renderer/shader/chunk/geometry/normal/chunk_decode_g_buffer_normal.d.ts +8 -1
  205. package/src/shade/renderer/shader/chunk/geometry/normal/chunk_decode_g_buffer_normal.d.ts.map +1 -1
  206. package/src/shade/renderer/shader/chunk/geometry/normal/chunk_decode_g_buffer_normal.js +10 -8
  207. package/src/shade/renderer/shader/chunk/geometry/normal/chunk_encode_g_buffer_face_normal.d.ts +22 -0
  208. package/src/shade/renderer/shader/chunk/geometry/normal/chunk_encode_g_buffer_face_normal.d.ts.map +1 -0
  209. package/src/shade/renderer/shader/chunk/geometry/normal/chunk_encode_g_buffer_face_normal.js +32 -0
  210. package/src/shade/renderer/shader/chunk/geometry/normal/chunk_encode_g_buffer_normal.d.ts +11 -1
  211. package/src/shade/renderer/shader/chunk/geometry/normal/chunk_encode_g_buffer_normal.d.ts.map +1 -1
  212. package/src/shade/renderer/shader/chunk/geometry/normal/chunk_encode_g_buffer_normal.js +14 -6
  213. package/src/shade/renderer/shader/chunk/material/chunk_decode_g_buffer_albedo.d.ts +14 -0
  214. package/src/shade/renderer/shader/chunk/material/chunk_decode_g_buffer_albedo.d.ts.map +1 -0
  215. package/src/shade/renderer/shader/chunk/material/chunk_decode_g_buffer_albedo.js +24 -0
  216. package/src/shade/renderer/shader/chunk/material/chunk_encode_g_buffer_albedo.d.ts +17 -0
  217. package/src/shade/renderer/shader/chunk/material/chunk_encode_g_buffer_albedo.d.ts.map +1 -0
  218. package/src/shade/renderer/shader/chunk/material/chunk_encode_g_buffer_albedo.js +27 -0
  219. package/src/shade/renderer/shader/chunk/screen_space/SCREEN_SPACE_RESOURCES.d.ts +7 -1
  220. package/src/shade/renderer/shader/chunk/screen_space/SCREEN_SPACE_RESOURCES.d.ts.map +1 -1
  221. package/src/shade/renderer/shader/chunk/screen_space/SCREEN_SPACE_RESOURCES.js +8 -1
  222. package/src/shade/renderer/shader/chunk/screen_space/chunk_ffx_sssr_load_world_space_normal.js +1 -1
  223. package/src/shade/renderer/shader/chunk/screen_space/chunk_screen_space_newton_ray.js +10 -10
  224. package/src/shade/renderer/shader/pass/RenderPassDescriptor.d.ts +8 -0
  225. package/src/shade/renderer/shader/pass/RenderPassDescriptor.d.ts.map +1 -1
  226. package/src/shade/renderer/shader/pass/RenderPassDescriptor.js +9 -0
  227. package/src/shade/renderer/shader/util/shader_decode_octahedral_normal.js +1 -1
  228. package/src/shade/renderer/shadow/contact/graph_contact_shadow_linear.d.ts +3 -3
  229. package/src/shade/renderer/shadow/contact/graph_contact_shadow_linear.d.ts.map +1 -1
  230. package/src/shade/renderer/shadow/contact/graph_contact_shadow_linear.js +3 -3
  231. package/src/shade/renderer/shadow/contact/shader_contact_shadow_linear.d.ts.map +1 -1
  232. package/src/shade/renderer/shadow/contact/shader_contact_shadow_linear.js +6 -4
  233. package/src/shade/renderer/shadow/ray/RTXShadows.d.ts +6 -4
  234. package/src/shade/renderer/shadow/ray/RTXShadows.d.ts.map +1 -1
  235. package/src/shade/renderer/shadow/ray/RTXShadows.js +16 -5
  236. package/src/shade/renderer/shadow/ray/shader_ray_shadow_code.d.ts.map +1 -1
  237. package/src/shade/renderer/shadow/ray/shader_ray_shadow_code.js +7 -7
  238. package/src/shade/renderer/shadow/ray/shader_shadow_upscale.js +2 -2
  239. package/src/shade/renderer/shadow/ray/staged/gen/graph_gen_rays.d.ts +4 -2
  240. package/src/shade/renderer/shadow/ray/staged/gen/graph_gen_rays.d.ts.map +1 -1
  241. package/src/shade/renderer/shadow/ray/staged/gen/graph_gen_rays.js +79 -74
  242. package/src/shade/renderer/shadow/ray/staged/gen/shader_generate_rays.d.ts.map +1 -1
  243. package/src/shade/renderer/shadow/ray/staged/gen/shader_generate_rays.js +7 -7
  244. package/src/shade/renderer/shadow/sdf/cascade/shader_scene_sdf_soft_shadows.d.ts.map +1 -1
  245. package/src/shade/renderer/shadow/sdf/cascade/shader_scene_sdf_soft_shadows.js +7 -3
  246. package/src/shade/renderer/shadow/sdf/graph_draw_sdf_shadows.d.ts +7 -5
  247. package/src/shade/renderer/shadow/sdf/graph_draw_sdf_shadows.d.ts.map +1 -1
  248. package/src/shade/renderer/shadow/sdf/graph_draw_sdf_shadows.js +29 -16
  249. package/src/shade/renderer/texture/virtual/VirtualTextureManager.d.ts +5 -5
  250. package/src/shade/renderer/texture/virtual/VirtualTextureManager.d.ts.map +1 -1
  251. package/src/shade/renderer/texture/virtual/VirtualTextureManager.js +8 -8
  252. package/src/shade/renderer/texture/virtual/build_shader_vt_feedback.d.ts.map +1 -1
  253. package/src/shade/renderer/texture/virtual/build_shader_vt_feedback.js +13 -14
  254. package/src/shade/renderer/water/GPUWaterRenderer.d.ts +2 -1
  255. package/src/shade/renderer/water/GPUWaterRenderer.d.ts.map +1 -1
  256. package/src/shade/renderer/water/GPUWaterRenderer.js +6 -4
  257. package/src/shade/renderer/water/chunk_water_transport.d.ts.map +1 -1
  258. package/src/shade/renderer/water/chunk_water_transport.js +11 -9
  259. package/src/shade/renderer/water/shader_water.d.ts.map +1 -1
  260. package/src/shade/renderer/water/shader_water.js +13 -11
  261. package/src/shade/renderer/gbuffer/G_BUFFER_MIP_LEVELS.d.ts +0 -7
  262. package/src/shade/renderer/gbuffer/G_BUFFER_MIP_LEVELS.d.ts.map +0 -1
  263. package/src/shade/renderer/gbuffer/G_BUFFER_MIP_LEVELS.js +0 -6
  264. package/src/shade/renderer/postprocess/ssr/shader_downsample_encoded_normal.d.ts +0 -3
  265. package/src/shade/renderer/postprocess/ssr/shader_downsample_encoded_normal.d.ts.map +0 -1
  266. package/src/shade/renderer/postprocess/ssr/shader_downsample_encoded_normal.js +0 -104
@@ -0,0 +1,45 @@
1
+ import { MESHLET_DEFINITION_STRUCT } from "../../geometry/meshlet/encoding/MESHLET_DEFINITION_STRUCT.js";
2
+ import { MESHLET_COLLECTION_STRUCT } from "../MESHLET_COLLECTION_STRUCT.js";
3
+
4
+ /**
5
+ * The visibility buffer's format: one `u32` a pixel, `slot << VISIBILITY_TRIANGLE_BITS | triangle`. `slot` is
6
+ * the pixel's meshlet's place in the frame's visible-meshlet table, which says the meshlet and the mesh row
7
+ * it was drawn for (`chunk_visibility_decode`); `triangle` is the triangle within that meshlet.
8
+ *
9
+ * @type {GPUTextureFormat}
10
+ */
11
+ export const VISIBILITY_FORMAT = 'r32uint';
12
+
13
+ /**
14
+ * Bits of a visibility word that hold the triangle within its meshlet, below the slot.
15
+ *
16
+ * @type {number}
17
+ */
18
+ export const VISIBILITY_TRIANGLE_BITS = 8;
19
+
20
+ /**
21
+ * How many slots the visible-meshlet table can hold: every value the bits above the triangle reach, less
22
+ * the last, which {@link VISIBILITY_NONE} takes.
23
+ *
24
+ * @type {number}
25
+ */
26
+ export const VISIBLE_MESHLET_SLOT_LIMIT = 2 ** (32 - VISIBILITY_TRIANGLE_BITS) - 1;
27
+
28
+ /**
29
+ * What a pixel no surface covers holds, and what the visibility buffer is cleared to: the first word of the
30
+ * slot past every slot the table can hold. A 32-bit float holds it exactly, as a clear value has to be —
31
+ * `RenderPassColorAttachmentDescriptor` keeps one in a `Float32Array`, where every bit set would round up
32
+ * to 2^32.
33
+ *
34
+ * @type {number}
35
+ */
36
+ export const VISIBILITY_NONE = VISIBLE_MESHLET_SLOT_LIMIT * 2 ** VISIBILITY_TRIANGLE_BITS;
37
+
38
+ /**
39
+ * Where the table's elements start, counted in meshlet definitions from the start of its buffer. The table
40
+ * is a meshlet collection, a count before the elements; a pass that binds the whole buffer as a bare array
41
+ * of definitions — as the alpha-tested raster binds its lists — finds slot `s` at `s` plus this.
42
+ *
43
+ * @type {number}
44
+ */
45
+ export const VISIBLE_MESHLETS_ARRAY_OFFSET = MESHLET_COLLECTION_STRUCT.get('elements').offset / MESHLET_DEFINITION_STRUCT.size;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The frame's visible-meshlet table: every meshlet the view's raster drew into the visibility buffer, at
3
+ * the slot its pixels name. A meshlet collection, read-only to the passes that resolve pixels through it.
4
+ *
5
+ * @type {ShaderResourceDescriptor}
6
+ */
7
+ export const VISIBLE_MESHLETS_RESOURCE: ShaderResourceDescriptor;
8
+ /**
9
+ * What a visibility word says of its pixel ({@link VISIBILITY_FORMAT}): the scene row of the mesh, the
10
+ * meshlet (a global meshlet index) and the triangle within it, through the frame's visible-meshlet table,
11
+ * bound as `visible_meshlets`.
12
+ *
13
+ * ```wgsl
14
+ * const VISIBILITY_NONE: u32
15
+ * struct VisibilityTexel { mesh: u32, meshlet: u32, triangle: u32 }
16
+ * fn visibility_decode(encoded: u32) -> VisibilityTexel
17
+ * ```
18
+ *
19
+ * Only for a word that is not `VISIBILITY_NONE`, which no surface covers.
20
+ *
21
+ * @type {CodeChunk}
22
+ */
23
+ export const chunk_visibility_decode: CodeChunk;
24
+ import { ShaderResourceDescriptor } from "../../shader/resource/ShaderResourceDescriptor.js";
25
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
26
+ //# sourceMappingURL=chunk_visibility_decode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_visibility_decode.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/rasterize/visibility/chunk_visibility_decode.js"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,wCAFU,wBAAwB,CAE6F;AAE/H;;;;;;;;;;;;;;GAcG;AACH,sCAFU,SAAS,CAmBjB;yCA5CuC,mDAAmD;0BADlE,oCAAoC"}
@@ -0,0 +1,48 @@
1
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
2
+ import { ShaderResourceDescriptor } from "../../shader/resource/ShaderResourceDescriptor.js";
3
+ import { MESHLET_COLLECTION_STRUCT } from "../MESHLET_COLLECTION_STRUCT.js";
4
+ import { VISIBILITY_NONE, VISIBILITY_TRIANGLE_BITS } from "./VISIBILITY_BUFFER.js";
5
+
6
+ /**
7
+ * The frame's visible-meshlet table: every meshlet the view's raster drew into the visibility buffer, at
8
+ * the slot its pixels name. A meshlet collection, read-only to the passes that resolve pixels through it.
9
+ *
10
+ * @type {ShaderResourceDescriptor}
11
+ */
12
+ export const VISIBLE_MESHLETS_RESOURCE = ShaderResourceDescriptor.storageBuffer("visible_meshlets", MESHLET_COLLECTION_STRUCT);
13
+
14
+ /**
15
+ * What a visibility word says of its pixel ({@link VISIBILITY_FORMAT}): the scene row of the mesh, the
16
+ * meshlet (a global meshlet index) and the triangle within it, through the frame's visible-meshlet table,
17
+ * bound as `visible_meshlets`.
18
+ *
19
+ * ```wgsl
20
+ * const VISIBILITY_NONE: u32
21
+ * struct VisibilityTexel { mesh: u32, meshlet: u32, triangle: u32 }
22
+ * fn visibility_decode(encoded: u32) -> VisibilityTexel
23
+ * ```
24
+ *
25
+ * Only for a word that is not `VISIBILITY_NONE`, which no surface covers.
26
+ *
27
+ * @type {CodeChunk}
28
+ */
29
+ export const chunk_visibility_decode = CodeChunk.from(
30
+ //language=WGSL
31
+ `
32
+ const VISIBILITY_NONE: u32 = ${VISIBILITY_NONE}u;
33
+
34
+ struct VisibilityTexel {
35
+ mesh: u32,
36
+ meshlet: u32,
37
+ triangle: u32,
38
+ }
39
+
40
+ fn visibility_decode(encoded: u32) -> VisibilityTexel {
41
+ let meshlet = visible_meshlets.elements[encoded >> ${VISIBILITY_TRIANGLE_BITS}u];
42
+
43
+ return VisibilityTexel(meshlet.mesh, meshlet.index, encoded & ${2 ** VISIBILITY_TRIANGLE_BITS - 1}u);
44
+ }
45
+ `
46
+ );
47
+
48
+ chunk_visibility_decode.requireResource(VISIBLE_MESHLETS_RESOURCE);
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Reserve the slots of one list in the visible-meshlet table and write the commands that use them: `draw`
3
+ * draws the list's meshlets from the table, `instanceCount` of them from `firstInstance`, its first slot;
4
+ * `copy` dispatches {@link shader_visible_meshlets_copy} over them, one invocation a meshlet.
5
+ *
6
+ * The table's count is every slot asked for, as a meshlet collection's count is: a list past the table's
7
+ * end draws only what fits, and the count tells the collection limits how far to grow it.
8
+ *
9
+ * One invocation.
10
+ *
11
+ * @type {ComputeShader}
12
+ */
13
+ export const shader_visible_meshlets_reserve: ComputeShader;
14
+ /**
15
+ * Copy a list's reserved meshlets into the visible-meshlet table, at the slots `draw` holds
16
+ * ({@link shader_visible_meshlets_reserve}). Dispatched indirectly by its `copy` command.
17
+ *
18
+ * @type {ComputeShader}
19
+ */
20
+ export const shader_visible_meshlets_copy: ComputeShader;
21
+ /**
22
+ * {@link shader_visible_meshlets_copy} for a list kept as a bare array whose count is held elsewhere — the
23
+ * alpha-tested raster's, sorted by material, whose collection the reserve counts.
24
+ *
25
+ * @type {ComputeShader}
26
+ */
27
+ export const shader_visible_meshlets_copy_array: ComputeShader;
28
+ /**
29
+ * Move per-material draw commands over a sorted list onto the list's copy in the visible-meshlet table:
30
+ * each command's range of the list becomes the same range of the slots `draw` holds, cut to the slots the
31
+ * copy filled. The draws bind the table's whole buffer as a bare array of definitions, which puts slot `s`
32
+ * at `s + ${VISIBLE_MESHLETS_ARRAY_OFFSET}` ({@link VISIBLE_MESHLETS_ARRAY_OFFSET}).
33
+ *
34
+ * One invocation a command.
35
+ *
36
+ * @type {ComputeShader}
37
+ */
38
+ export const shader_visible_meshlets_offset_commands: ComputeShader;
39
+ import { ComputeShader } from "../../shader/ComputeShader.js";
40
+ //# sourceMappingURL=shader_visible_meshlets_append.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shader_visible_meshlets_append.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/rasterize/visibility/shader_visible_meshlets_append.js"],"names":[],"mappings":"AA4BA;;;;;;;;;;;GAWG;AACH,8CAFU,aAAa,CA8BpB;AAmCH;;;;;GAKG;AACH,2CAFU,aAAa,CAMpB;AASH;;;;;GAKG;AACH,iDAFU,aAAa,CAMpB;AAQH;;;;;;;;;GASG;AACH,sDAFU,aAAa,CAuBpB;8BAnK2B,+BAA+B"}
@@ -0,0 +1,172 @@
1
+ import { GEOMETRY_MESHLET_TRIANGLE_LIMIT } from "../../geometry/meshlet/GEOMETRY_MESHLET_TRIANGLE_LIMIT.js";
2
+ import { MESHLET_DEFINITION_STRUCT } from "../../geometry/meshlet/encoding/MESHLET_DEFINITION_STRUCT.js";
3
+ import { chunk_folded_dispatch } from "../../gpu_primitive/indirect/chunk_folded_dispatch.js";
4
+ import { STRUCT_DISPATCH_COMPUTE_COMMAND } from "../../gpu_primitive/indirect/STRUCT_DISPATCH_COMPUTE_COMMAND.js";
5
+ import { STRUCT_UNINDEXED_DRAW_COMMAND } from "../../gpu_primitive/indirect/STRUCT_UNINDEXED_DRAW_COMMAND.js";
6
+ import { chunk_folded_workgroup_index } from "../../shader/chunk/grid/chunk_folded_workgroup_index.js";
7
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
8
+ import { COMPUTE_SHADER_DEFAULT_GROUP_SIZE } from "../../shader/COMPUTE_SHADER_DEFAULT_GROUP_SIZE.js";
9
+ import { ComputeShader } from "../../shader/ComputeShader.js";
10
+ import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
11
+ import { WebGPUArray } from "../../shader/type/WebGPUArray.js";
12
+ import { MESHLET_COLLECTION_STRUCT } from "../MESHLET_COLLECTION_STRUCT.js";
13
+ import { VISIBLE_MESHLET_SLOT_LIMIT, VISIBLE_MESHLETS_ARRAY_OFFSET } from "./VISIBILITY_BUFFER.js";
14
+
15
+ /*
16
+ A draw into the visibility buffer takes its meshlets from the frame's visible-meshlet table, so that the
17
+ slot its pixels write names the meshlet for every later reader. Before each such draw its list is
18
+ appended to the table: one invocation reserves the slots, then the copy runs over the list.
19
+ */
20
+
21
+ const reserve_resources = new ShaderResourceSetDescriptor();
22
+
23
+ reserve_resources.createGroup()
24
+ .addStorageBuffer("input", MESHLET_COLLECTION_STRUCT)
25
+ .addStorageBuffer("visible_meshlets", MESHLET_COLLECTION_STRUCT, true)
26
+ .addStorageBuffer("draw", STRUCT_UNINDEXED_DRAW_COMMAND, true)
27
+ .addStorageBuffer("copy", STRUCT_DISPATCH_COMPUTE_COMMAND, true);
28
+
29
+ /**
30
+ * Reserve the slots of one list in the visible-meshlet table and write the commands that use them: `draw`
31
+ * draws the list's meshlets from the table, `instanceCount` of them from `firstInstance`, its first slot;
32
+ * `copy` dispatches {@link shader_visible_meshlets_copy} over them, one invocation a meshlet.
33
+ *
34
+ * The table's count is every slot asked for, as a meshlet collection's count is: a list past the table's
35
+ * end draws only what fits, and the count tells the collection limits how far to grow it.
36
+ *
37
+ * One invocation.
38
+ *
39
+ * @type {ComputeShader}
40
+ */
41
+ export const shader_visible_meshlets_reserve = ComputeShader.from({
42
+ label: "Visible meshlets / reserve",
43
+ resources: reserve_resources,
44
+ body: CodeChunk.from(
45
+ //language=WGSL
46
+ `
47
+ @compute @workgroup_size(1)
48
+ fn main() {
49
+ let count = min(input.count, arrayLength(&input.elements));
50
+
51
+ let base = visible_meshlets.count;
52
+ let capacity = min(arrayLength(&visible_meshlets.elements), ${VISIBLE_MESHLET_SLOT_LIMIT}u);
53
+ let stored = select(0u, min(count, capacity - base), base < capacity);
54
+
55
+ visible_meshlets.count = base + count;
56
+
57
+ draw.vertexCount = ${GEOMETRY_MESHLET_TRIANGLE_LIMIT * 3}u;
58
+ draw.instanceCount = stored;
59
+ draw.firstVertex = 0u;
60
+ draw.firstInstance = base;
61
+
62
+ let groups = folded_dispatch((stored + ${COMPUTE_SHADER_DEFAULT_GROUP_SIZE - 1}u) / ${COMPUTE_SHADER_DEFAULT_GROUP_SIZE}u);
63
+
64
+ copy.workgroupCountX = groups.x;
65
+ copy.workgroupCountY = groups.y;
66
+ copy.workgroupCountZ = groups.z;
67
+ }
68
+ `, [chunk_folded_dispatch])
69
+ });
70
+
71
+ /**
72
+ * The copy kernels' body: `source(i)` is the list's `i`-th meshlet.
73
+ *
74
+ * @param {string} source
75
+ * @returns {CodeChunk}
76
+ */
77
+ function copy_body(source) {
78
+ return CodeChunk.from(
79
+ //language=WGSL
80
+ `
81
+ @compute @workgroup_size(${COMPUTE_SHADER_DEFAULT_GROUP_SIZE})
82
+ fn main(
83
+ @builtin(workgroup_id) workgroup_id: vec3<u32>,
84
+ @builtin(local_invocation_index) local_index: u32,
85
+ ) {
86
+ let i = folded_workgroup_index(workgroup_id) * ${COMPUTE_SHADER_DEFAULT_GROUP_SIZE}u + local_index;
87
+
88
+ if (i >= draw.instanceCount) {
89
+ return;
90
+ }
91
+
92
+ visible_meshlets.elements[draw.firstInstance + i] = ${source};
93
+ }
94
+ `, [chunk_folded_workgroup_index]);
95
+ }
96
+
97
+ const copy_resources = new ShaderResourceSetDescriptor();
98
+
99
+ copy_resources.createGroup()
100
+ .addStorageBuffer("draw", STRUCT_UNINDEXED_DRAW_COMMAND)
101
+ .addStorageBuffer("input", MESHLET_COLLECTION_STRUCT)
102
+ .addStorageBuffer("visible_meshlets", MESHLET_COLLECTION_STRUCT, true);
103
+
104
+ /**
105
+ * Copy a list's reserved meshlets into the visible-meshlet table, at the slots `draw` holds
106
+ * ({@link shader_visible_meshlets_reserve}). Dispatched indirectly by its `copy` command.
107
+ *
108
+ * @type {ComputeShader}
109
+ */
110
+ export const shader_visible_meshlets_copy = ComputeShader.from({
111
+ label: "Visible meshlets / copy",
112
+ resources: copy_resources,
113
+ body: copy_body("input.elements[i]"),
114
+ });
115
+
116
+ const copy_array_resources = new ShaderResourceSetDescriptor();
117
+
118
+ copy_array_resources.createGroup()
119
+ .addStorageBuffer("draw", STRUCT_UNINDEXED_DRAW_COMMAND)
120
+ .addStorageBuffer("input", WebGPUArray.from(MESHLET_DEFINITION_STRUCT))
121
+ .addStorageBuffer("visible_meshlets", MESHLET_COLLECTION_STRUCT, true);
122
+
123
+ /**
124
+ * {@link shader_visible_meshlets_copy} for a list kept as a bare array whose count is held elsewhere — the
125
+ * alpha-tested raster's, sorted by material, whose collection the reserve counts.
126
+ *
127
+ * @type {ComputeShader}
128
+ */
129
+ export const shader_visible_meshlets_copy_array = ComputeShader.from({
130
+ label: "Visible meshlets / copy",
131
+ resources: copy_array_resources,
132
+ body: copy_body("input[i]"),
133
+ });
134
+
135
+ const offset_resources = new ShaderResourceSetDescriptor();
136
+
137
+ offset_resources.createGroup()
138
+ .addStorageBuffer("draw", STRUCT_UNINDEXED_DRAW_COMMAND)
139
+ .addStorageBuffer("commands", WebGPUArray.from(STRUCT_UNINDEXED_DRAW_COMMAND), true);
140
+
141
+ /**
142
+ * Move per-material draw commands over a sorted list onto the list's copy in the visible-meshlet table:
143
+ * each command's range of the list becomes the same range of the slots `draw` holds, cut to the slots the
144
+ * copy filled. The draws bind the table's whole buffer as a bare array of definitions, which puts slot `s`
145
+ * at `s + ${VISIBLE_MESHLETS_ARRAY_OFFSET}` ({@link VISIBLE_MESHLETS_ARRAY_OFFSET}).
146
+ *
147
+ * One invocation a command.
148
+ *
149
+ * @type {ComputeShader}
150
+ */
151
+ export const shader_visible_meshlets_offset_commands = ComputeShader.from({
152
+ label: "Visible meshlets / offset draw commands",
153
+ resources: offset_resources,
154
+ body: CodeChunk.from(
155
+ //language=WGSL
156
+ `
157
+ @compute @workgroup_size(${COMPUTE_SHADER_DEFAULT_GROUP_SIZE})
158
+ fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
159
+ let k = global_id.x;
160
+
161
+ if (k >= arrayLength(&commands)) {
162
+ return;
163
+ }
164
+
165
+ let start = commands[k].firstInstance;
166
+ let end = min(start + commands[k].instanceCount, draw.instanceCount);
167
+
168
+ commands[k].instanceCount = select(0u, end - start, start < end);
169
+ commands[k].firstInstance = draw.firstInstance + start + ${VISIBLE_MESHLETS_ARRAY_OFFSET}u;
170
+ }
171
+ `)
172
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_restir_reconstruct_surface.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/restir/di/chunk_restir_reconstruct_surface.js"],"names":[],"mappings":"AAWA;;;;;;;;;;GAUG;AACH,+CAFU,SAAS,CAqDjB;0BAhEwB,oCAAoC"}
1
+ {"version":3,"file":"chunk_restir_reconstruct_surface.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/restir/di/chunk_restir_reconstruct_surface.js"],"names":[],"mappings":"AAcA;;;;;;;;;;GAUG;AACH,+CAFU,SAAS,CAoDjB;0BA/DwB,oCAAoC"}
@@ -4,6 +4,9 @@ import { chunk_project_position_from_depth } from "../../shader/chunk/camera/chu
4
4
  import { chunk_get_view_space_depth } from "../../shader/chunk/depth/chunk_get_view_space_depth.js";
5
5
  import { chunk_mat4_extract_position } from "../../shader/chunk/geometry/mat4/chunk_mat4_extract_position.js";
6
6
  import { chunk_decode_g_buffer_normal } from "../../shader/chunk/geometry/normal/chunk_decode_g_buffer_normal.js";
7
+ import {
8
+ chunk_decode_g_buffer_face_normal
9
+ } from "../../shader/chunk/geometry/normal/chunk_decode_g_buffer_face_normal.js";
7
10
  import { GEOMETRIC_SHADING_INFO_STRUCT } from "../../shader/chunk/material/GEOMETRIC_SHADING_INFO_STRUCT.js";
8
11
  import { MATERIAL_SHADING_INFO_STRUCT } from "../../shader/chunk/material/MATERIAL_SHADING_INFO_STRUCT.js";
9
12
  import { chunk_texel_coordinate_to_uv } from "../../shader/chunk/texture/chunk_texel_coordinate_to_uv.js";
@@ -47,11 +50,9 @@ fn restir_reconstruct_surface(i_coord: vec2<u32>, texture_size: vec2<u32>) -> Re
47
50
  let camera_position_ws = mat4_extract_position(camera.transform);
48
51
  let view_direction = normalize(camera_position_ws - position_ws);
49
52
 
50
- let g_buffer_sample_normal = textureLoad(gBufferNormal, i_coord, 0);
51
-
52
53
  surface.geometry = ${GEOMETRIC_SHADING_INFO_STRUCT.wgsl_ref}(
53
- decode_g_buffer_normal(g_buffer_sample_normal.xy),
54
- decode_g_buffer_normal(g_buffer_sample_normal.zw),
54
+ decode_g_buffer_normal(textureLoad(gBufferNormal, i_coord, 0).x),
55
+ decode_g_buffer_face_normal(textureLoad(gBufferPBR, i_coord, 0)),
55
56
  position_ws,
56
57
  view_direction,
57
58
  );
@@ -69,6 +70,7 @@ fn restir_reconstruct_surface(i_coord: vec2<u32>, texture_size: vec2<u32>) -> Re
69
70
  chunk_project_position_from_depth,
70
71
  chunk_mat4_extract_position,
71
72
  chunk_decode_g_buffer_normal,
73
+ chunk_decode_g_buffer_face_normal,
72
74
  chunk_read_gBuffer_material,
73
75
  ]
74
76
  );
@@ -81,7 +81,7 @@ fn restir_spatial_reuse(
81
81
  if (abs(neighbour_view_depth - self_view_depth) > RESTIR_SPATIAL_DEPTH_TOLERANCE * self_view_depth) {
82
82
  continue;
83
83
  }
84
- let neighbour_normal = decode_g_buffer_normal(textureLoad(gBufferNormal, neighbour_u, 0).xy);
84
+ let neighbour_normal = decode_g_buffer_normal(textureLoad(gBufferNormal, neighbour_u, 0).x);
85
85
  if (dot(neighbour_normal, geometry.shading_normal) < RESTIR_SPATIAL_NORMAL_TOLERANCE) {
86
86
  continue;
87
87
  }
@@ -76,7 +76,7 @@ fn main(
76
76
  }
77
77
 
78
78
  let center_depth = get_view_space_depth(center_device_depth, camera);
79
- let center_normal = decode_g_buffer_normal(textureLoad(gBufferNormal, i_coord, 0).xy);
79
+ let center_normal = decode_g_buffer_normal(textureLoad(gBufferNormal, i_coord, 0).x);
80
80
  let center_luma = rgb_to_luminance(center_radiance);
81
81
 
82
82
  let step = i32(step_size);
@@ -107,7 +107,7 @@ fn main(
107
107
 
108
108
  let sample_radiance = textureLoad(tInput, p, 0).rgb;
109
109
  let sample_depth = get_view_space_depth(sample_device_depth, camera);
110
- let sample_normal = decode_g_buffer_normal(textureLoad(gBufferNormal, p, 0).xy);
110
+ let sample_normal = decode_g_buffer_normal(textureLoad(gBufferNormal, p, 0).x);
111
111
  let sample_luma = rgb_to_luminance(sample_radiance);
112
112
 
113
113
  let w_normal = normal_edge_stopping_weight(center_normal, sample_normal, PHI_NORMAL);
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Electro-optical transfer function (EOTF), the inverse of {@link chunk_sRGBTransferOETF}
3
+ *
4
+ * sRGB to sRGB-linear, the IEC 61966-2-1 curve an `-srgb` texture format decodes with.
5
+ * @see convert_channel_sRGB_to_linear the JS twin, which carries the same constants
6
+ */
7
+ export const chunk_sRGBTransferEOTF: CodeChunk;
8
+ import { CodeChunk } from "../../../compiler/CodeChunk.js";
9
+ //# sourceMappingURL=chunk_sRGBTransferEOTF.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_sRGBTransferEOTF.d.ts","sourceRoot":"","sources":["../../../../../../../../src/shade/renderer/shader/chunk/color/sRGB/chunk_sRGBTransferEOTF.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,+CASG;0BAjBuB,gCAAgC"}
@@ -0,0 +1,18 @@
1
+ import { CodeChunk } from "../../../compiler/CodeChunk.js";
2
+
3
+ /**
4
+ * Electro-optical transfer function (EOTF), the inverse of {@link chunk_sRGBTransferOETF}
5
+ *
6
+ * sRGB to sRGB-linear, the IEC 61966-2-1 curve an `-srgb` texture format decodes with.
7
+ * @see convert_channel_sRGB_to_linear the JS twin, which carries the same constants
8
+ */
9
+ export const chunk_sRGBTransferEOTF = CodeChunk.from(
10
+ //language=WGSL
11
+ `
12
+ fn sRGBTransferEOTF( value: vec3<f32> ) -> vec3<f32> {
13
+ let low = value * 0.0773993808;
14
+ let high = pow( value * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) );
15
+
16
+ return select( low, high, value >= vec3( 0.04045 ) );
17
+ }
18
+ `);
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Determinant of a 3×3 as the triple product of its columns, `dot(m[0], cross(m[1], m[2]))`. Same
3
+ * expression as {@link m4_linear_determinant}, the CPU twin of `mat4_linear_determinant`, which
4
+ * reads it through this.
5
+ *
6
+ * Written out rather than left to WGSL's `determinant`. The specification gives that builtin no
7
+ * accuracy at all ("Infinite ULP"), each backend expands it its own way, and no CPU model can stand
8
+ * in for it. This expression's accuracy is what `dot` and `cross` inherit from their operations. It
9
+ * is exactly zero for a column of zeros at any rotation, because every term of the expansion
10
+ * carries a factor from that column, even where the backend fuses the products.
11
+ *
12
+ * A caller dividing by a determinant tests that very number, not another expansion of it. Two
13
+ * expansions agree in exact arithmetic but not in f32, and near a singular matrix one can read zero
14
+ * where the other does not.
15
+ *
16
+ * @type {CodeChunk}
17
+ */
18
+ export const chunk_mat3_determinant: CodeChunk;
19
+ import { CodeChunk } from "../../../compiler/CodeChunk.js";
20
+ //# sourceMappingURL=chunk_mat3_determinant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_mat3_determinant.d.ts","sourceRoot":"","sources":["../../../../../../../../src/shade/renderer/shader/chunk/geometry/mat3/chunk_mat3_determinant.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,qCAFU,SAAS,CAQZ;0BAzBmB,gCAAgC"}
@@ -0,0 +1,26 @@
1
+ import { CodeChunk } from "../../../compiler/CodeChunk.js";
2
+
3
+ /**
4
+ * Determinant of a 3×3 as the triple product of its columns, `dot(m[0], cross(m[1], m[2]))`. Same
5
+ * expression as {@link m4_linear_determinant}, the CPU twin of `mat4_linear_determinant`, which
6
+ * reads it through this.
7
+ *
8
+ * Written out rather than left to WGSL's `determinant`. The specification gives that builtin no
9
+ * accuracy at all ("Infinite ULP"), each backend expands it its own way, and no CPU model can stand
10
+ * in for it. This expression's accuracy is what `dot` and `cross` inherit from their operations. It
11
+ * is exactly zero for a column of zeros at any rotation, because every term of the expansion
12
+ * carries a factor from that column, even where the backend fuses the products.
13
+ *
14
+ * A caller dividing by a determinant tests that very number, not another expansion of it. Two
15
+ * expansions agree in exact arithmetic but not in f32, and near a singular matrix one can read zero
16
+ * where the other does not.
17
+ *
18
+ * @type {CodeChunk}
19
+ */
20
+ export const chunk_mat3_determinant = CodeChunk.from(
21
+ //language=WGSL
22
+ `
23
+ fn mat3_determinant(m: mat3x3<f32>) -> f32 {
24
+ return dot(m[0], cross(m[1], m[2]));
25
+ }
26
+ `, []);
@@ -1,5 +1,10 @@
1
1
  /**
2
- * The largest and smallest singular values of a 3×3 matrix.
2
+ * The largest and smallest singular values of a 3×3 matrix. **Expensive but correct**: a couple of
3
+ * hundred ALU operations, a transcendental pair and a handful of square roots, where the longest
4
+ * and shortest column (`mat4_extract_scale`) cost three lengths. Those are the same numbers for any
5
+ * rotation times a scale, and the real-time paths (virtual geometry's cut, the probe clipmap's
6
+ * bricks) read the columns and accept that a shear goes unaccounted. Reach for this only where a
7
+ * shear has to be measured, and not per instance per view per frame.
3
8
  *
4
9
  * They are what "how much does this transform stretch a distance" actually means: a vector's length
5
10
  * is scaled by something between σ_min and σ_max, and both bounds are attained. Column lengths are
@@ -7,23 +12,60 @@
7
12
  * `[[1,0,0],[k,1,0],[0,0,1]]`, every column has length 1 or √(1+k²) while the true ratio grows
8
13
  * without bound in `k`. A shear has no scale in any column and stretches space anyway.
9
14
  *
10
- * Computed as the square roots of the eigenvalues of `MᵀM`, which is symmetric and positive
11
- * semi-definite, through the closed form for a symmetric 3×3 (Smith 1961). No iteration, no
12
- * branching past the diagonal case, and **exact for a uniform scale**: `MᵀM` is then `s²I`, the
13
- * off-diagonal sum is zero, and both values come back as `s`. That matters more than the general
14
- * case — a conservative bound that answered 5.2 for an unscaled instance would over-refine every
15
- * ordinary object in a scene to buy correctness for a sheared one.
16
- *
17
- * **Not a degeneracy test.** σ_min is zero exactly when the matrix is singular *in exact
18
- * arithmetic*, and this once said so without the qualifier. In f32 it holds only on the diagonal
19
- * branch: the trigonometric one computes the smallest eigenvalue as a difference of nearly equal
20
- * numbers, and the `sqrt` turns its absolute error of about `eps·σ_max²` into about
21
- * `sqrt(eps)·σ_max ≈ 3.4e-4·σ_max` in σ_min. A rotated matrix with one column of zeros therefore
22
- * comes back with a σ_min near 1e-4 rather than 0, and a caller testing `σ_min > 0` before
23
- * inverting is let through with the NaN it was guarding against
24
- * (`shader_vgeo_cut_collect`, REVIEW_LEDGER M3). A caller about to invert should test the
25
- * **determinant**, which is the number the inverse divides by and which is exactly zero whenever a
26
- * column is.
15
+ * **Method.** M is first scaled by the power of two that brings its largest entry into [1, 2), and
16
+ * the values are scaled back at the end. That is exact, and it keeps every square and product below
17
+ * far inside f32's range whatever the transform's scale.
18
+ *
19
+ * The eigenvalues of `MᵀM` are the squared singular values, and Smith's closed form (1961) gives
20
+ * them as `q + p·β` for the roots `β = 2cos(φ + 2πk/3)` of `β³ − 3β − det B`, with
21
+ * `B = (MᵀM − qI) / p`. Only one root is taken from that form: the one that stands apart from the
22
+ * other two, which is the largest when `det B ≥ 0` and the smallest otherwise (Scherzinger &
23
+ * Dohrmann 2008; Eberly, "A Robust Eigensolver for 3×3 Symmetric Matrices"). The other two are
24
+ * ill-conditioned where two roots meet: `det(B)/2` then sits at ±1, the edge of `acos`'s domain, so
25
+ * one rounding of it moves φ by `acos(1 − 2⁻²⁴)/3 ≈ 1.2e-4`, and those two roots by √3·p times
26
+ * that. For a beam-like scale p is a third of σ_max², which is enough to take σ_min to zero. The
27
+ * root that stands apart is stationary in φ at both edges, and lies at least √3 from the others,
28
+ * where the cubic's slope `3(β² − 1)` is at least 6. One Newton step there squares whatever error
29
+ * the device's `cos` and `acos` leave, which WGSL bounds only loosely.
30
+ *
31
+ * That root is used only for its eigenvector `v`. `B − βI` has rank two, and the longest cross
32
+ * product of two of its rows is normal to both. The complement of `v` is built from `v`'s own
33
+ * components (Eberly's `ComputeOrthogonalComplement`): `u` is `v` crossed with `e_y` or `e_x`,
34
+ * whichever `v` leans on less, and `w = v × u`. So `u` and `w` are off from `v` by no more than the
35
+ * rounding of `v`'s smaller components. That matters, because any component of `v` in the plane
36
+ * lets σ_max leak into the plane's values, which feel it squared and amplified by (σ_max / σ_mid)².
37
+ *
38
+ * Every value returned is measured on M itself, because a small singular value cannot come from
39
+ * `MᵀM`: its rounding is absolute, at the scale of σ_max² (Demmel & Veselić 1992). `v` and the plane
40
+ * split M into `|Mv|` and the 3×2 `[Mu Mw]`, whose larger singular value comes out of a 2×2 form
41
+ * with no cancellation in it. That gives σ_max and σ_mid, and σ_min = |det M| / (σ_max · σ_mid).
42
+ *
43
+ * **Contract.**
44
+ *
45
+ * - **Exact when `MᵀM` comes out diagonal**: any axis-aligned scale, the identity and a uniform
46
+ * scale among them. Both values are then square roots of the diagonal's extremes, scaled back by
47
+ * the same power of two, so a uniform scale returns σ_max equal to σ_min, and both are the column
48
+ * lengths to the accuracy of the device's `sqrt`. That matters more than the general case: a
49
+ * conservative bound that answered 5.2 for an unscaled instance would over-refine every ordinary
50
+ * object in a scene to buy correctness for a sheared one.
51
+ * - **Otherwise each value carries a relative error of order `u·K`**, with `u = 2⁻²⁴` and
52
+ * `K = |m₀|·|m₁|·|m₂| / |det M| ≥ 1`. `K` is 1 when the columns are orthogonal: a rotation times
53
+ * any scale, whatever the ratio of the scales. Rounding in `det M`, and in the three images of M,
54
+ * is first order in `u·K`. The eigenvector's own error enters at second order, amplified by
55
+ * (σ_max / σ_mid)². With orthogonal columns `v` lies on an axis to within u / (σ_max / σ_mid), so
56
+ * that term stays below u. Otherwise σ_max / σ_mid is itself bounded by a multiple of K, so the
57
+ * term stays below u·K while u·K is small.
58
+ * - **Either direction for σ_min, so it can over-estimate, but never past the shortest column's
59
+ * length** as f32 computes it. σ_max can only fall short, and never below the longest column's
60
+ * length. Every column is an image of a unit vector, so its length lies in [σ_min, σ_max] exactly,
61
+ * and the result is held to both bounds. It follows that σ_min ≤ σ_max.
62
+ * - **σ_min is zero exactly when `mat3_determinant(M)` is**, or when it underflows. A column or a
63
+ * row of zeros gives exactly zero at every rotation. A matrix that is singular only in exact
64
+ * arithmetic, such as a child turned under a flattened parent, has a determinant of rounding noise,
65
+ * and so a σ_min of the same noise rather than zero. A caller about to divide by a determinant
66
+ * tests that very number: another expansion can differ from this one in rounding, enough to
67
+ * disagree about zero near a singular matrix.
68
+ * - Valid for any finite M. Values below f32's normal range flush where the device flushes.
27
69
  *
28
70
  * @type {CodeChunk}
29
71
  *
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_mat3_singular_values.d.ts","sourceRoot":"","sources":["../../../../../../../../src/shade/renderer/shader/chunk/geometry/mat3/chunk_mat3_singular_values.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,yCALU,SAAS,CA6DZ;0BA1FmB,gCAAgC"}
1
+ {"version":3,"file":"chunk_mat3_singular_values.d.ts","sourceRoot":"","sources":["../../../../../../../../src/shade/renderer/shader/chunk/geometry/mat3/chunk_mat3_singular_values.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,yCALU,SAAS,CAuI0B;0BAhNnB,gCAAgC"}