@woosh/meep-engine 3.65.0 → 3.68.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 (350) hide show
  1. package/package.json +1 -1
  2. package/src/engine/graphics3/GraphicsEngine.d.ts.map +1 -1
  3. package/src/engine/graphics3/GraphicsEngine.js +4 -9
  4. package/src/engine/graphics3/load_cube_environment.js +3 -3
  5. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  6. package/src/format/lut/cube/CubeLut.d.ts +38 -0
  7. package/src/format/lut/cube/CubeLut.d.ts.map +1 -0
  8. package/src/format/lut/cube/CubeLut.js +23 -0
  9. package/src/format/lut/cube/cube_read.d.ts +23 -0
  10. package/src/format/lut/cube/cube_read.d.ts.map +1 -0
  11. package/src/format/lut/cube/cube_read.js +199 -0
  12. package/src/format/lut/cube/cube_write.d.ts +15 -0
  13. package/src/format/lut/cube/cube_write.d.ts.map +1 -0
  14. package/src/format/lut/cube/cube_write.js +90 -0
  15. package/src/shade/playground/probe_clipmap/README.md +1 -0
  16. package/src/shade/playground/probe_clipmap/index.html +48 -0
  17. package/src/shade/playground/probe_clipmap/main.d.ts.map +1 -1
  18. package/src/shade/playground/probe_clipmap/main.js +36 -0
  19. package/src/shade/renderer/Renderer.d.ts +7 -0
  20. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  21. package/src/shade/renderer/Renderer.js +225 -27
  22. package/src/shade/renderer/ShadeIndirectLightingMode.d.ts +1 -0
  23. package/src/shade/renderer/ShadeIndirectLightingMode.js +9 -0
  24. package/src/shade/renderer/atmosphere/ATMOSPHERE_PARAMETERS_STRUCT.d.ts +22 -0
  25. package/src/shade/renderer/atmosphere/ATMOSPHERE_PARAMETERS_STRUCT.d.ts.map +1 -0
  26. package/src/shade/renderer/atmosphere/ATMOSPHERE_PARAMETERS_STRUCT.js +160 -0
  27. package/src/shade/renderer/atmosphere/ATMOSPHERE_UNIT_SCALE.d.ts +45 -0
  28. package/src/shade/renderer/atmosphere/ATMOSPHERE_UNIT_SCALE.d.ts.map +1 -0
  29. package/src/shade/renderer/atmosphere/ATMOSPHERE_UNIT_SCALE.js +57 -0
  30. package/src/shade/renderer/atmosphere/GPUSky.d.ts +23 -8
  31. package/src/shade/renderer/atmosphere/GPUSky.d.ts.map +1 -1
  32. package/src/shade/renderer/atmosphere/GPUSky.js +91 -34
  33. package/src/shade/renderer/atmosphere/SAMPLER_SKY_LUT.d.ts +17 -0
  34. package/src/shade/renderer/atmosphere/SAMPLER_SKY_LUT.d.ts.map +1 -1
  35. package/src/shade/renderer/atmosphere/SAMPLER_SKY_LUT.js +55 -25
  36. package/src/shade/renderer/atmosphere/SceneAtmosphere.d.ts +164 -0
  37. package/src/shade/renderer/atmosphere/SceneAtmosphere.d.ts.map +1 -0
  38. package/src/shade/renderer/atmosphere/SceneAtmosphere.js +308 -0
  39. package/src/shade/renderer/atmosphere/chunk_get_multiscatter_values.d.ts +3 -12
  40. package/src/shade/renderer/atmosphere/chunk_get_multiscatter_values.d.ts.map +1 -1
  41. package/src/shade/renderer/atmosphere/chunk_get_multiscatter_values.js +52 -89
  42. package/src/shade/renderer/atmosphere/chunk_raymarch_sky_scattering.d.ts +14 -0
  43. package/src/shade/renderer/atmosphere/chunk_raymarch_sky_scattering.d.ts.map +1 -0
  44. package/src/shade/renderer/atmosphere/chunk_raymarch_sky_scattering.js +103 -0
  45. package/src/shade/renderer/atmosphere/chunk_sample_multiscatter_lut.d.ts +10 -4
  46. package/src/shade/renderer/atmosphere/chunk_sample_multiscatter_lut.d.ts.map +1 -1
  47. package/src/shade/renderer/atmosphere/chunk_sample_multiscatter_lut.js +95 -57
  48. package/src/shade/renderer/atmosphere/chunk_sample_transmittance_lut.d.ts +10 -14
  49. package/src/shade/renderer/atmosphere/chunk_sample_transmittance_lut.d.ts.map +1 -1
  50. package/src/shade/renderer/atmosphere/chunk_sample_transmittance_lut.js +97 -69
  51. package/src/shade/renderer/atmosphere/chunk_sky_irradiance_lut_encode_uv.d.ts +17 -0
  52. package/src/shade/renderer/atmosphere/chunk_sky_irradiance_lut_encode_uv.d.ts.map +1 -1
  53. package/src/shade/renderer/atmosphere/chunk_sky_irradiance_lut_encode_uv.js +117 -48
  54. package/src/shade/renderer/atmosphere/chunk_sky_lut_compute_uv.d.ts +8 -0
  55. package/src/shade/renderer/atmosphere/chunk_sky_lut_compute_uv.d.ts.map +1 -1
  56. package/src/shade/renderer/atmosphere/chunk_sky_lut_compute_uv.js +65 -35
  57. package/src/shade/renderer/atmosphere/compute_mie_absorption.d.ts +2 -1
  58. package/src/shade/renderer/atmosphere/compute_mie_absorption.d.ts.map +1 -1
  59. package/src/shade/renderer/atmosphere/compute_mie_absorption.js +6 -6
  60. package/src/shade/renderer/atmosphere/resolve_atmosphere_sun.d.ts +41 -0
  61. package/src/shade/renderer/atmosphere/resolve_atmosphere_sun.d.ts.map +1 -0
  62. package/src/shade/renderer/atmosphere/resolve_atmosphere_sun.js +123 -0
  63. package/src/shade/renderer/atmosphere/shader_multiscatter_lut.d.ts.map +1 -1
  64. package/src/shade/renderer/atmosphere/shader_multiscatter_lut.js +21 -64
  65. package/src/shade/renderer/atmosphere/shader_sky_irradiance_lut.d.ts +6 -2
  66. package/src/shade/renderer/atmosphere/shader_sky_irradiance_lut.d.ts.map +1 -1
  67. package/src/shade/renderer/atmosphere/shader_sky_irradiance_lut.js +55 -179
  68. package/src/shade/renderer/atmosphere/shader_sky_view_lut.d.ts +7 -0
  69. package/src/shade/renderer/atmosphere/shader_sky_view_lut.d.ts.map +1 -0
  70. package/src/shade/renderer/atmosphere/shader_sky_view_lut.js +111 -0
  71. package/src/shade/renderer/atmosphere/shader_transmittance_lut.d.ts +0 -1
  72. package/src/shade/renderer/atmosphere/shader_transmittance_lut.d.ts.map +1 -1
  73. package/src/shade/renderer/atmosphere/shader_transmittance_lut.js +68 -79
  74. package/src/shade/renderer/deferred/shader_background.js +1 -1
  75. package/src/shade/renderer/deferred/shader_background_sky.d.ts +5 -0
  76. package/src/shade/renderer/deferred/shader_background_sky.d.ts.map +1 -0
  77. package/src/shade/renderer/deferred/shader_background_sky.js +130 -0
  78. package/src/shade/renderer/deferred/tonemap/ColorGrade.d.ts +73 -4
  79. package/src/shade/renderer/deferred/tonemap/ColorGrade.d.ts.map +1 -1
  80. package/src/shade/renderer/deferred/tonemap/ColorGrade.js +113 -7
  81. package/src/shade/renderer/deferred/tonemap/TONEMAP_PURKINJE_SHIFT.d.ts +12 -0
  82. package/src/shade/renderer/deferred/tonemap/TONEMAP_PURKINJE_SHIFT.d.ts.map +1 -0
  83. package/src/shade/renderer/deferred/tonemap/TONEMAP_PURKINJE_SHIFT.js +12 -0
  84. package/src/shade/renderer/deferred/tonemap/ToneMapper.d.ts +15 -1
  85. package/src/shade/renderer/deferred/tonemap/ToneMapper.d.ts.map +1 -1
  86. package/src/shade/renderer/deferred/tonemap/ToneMapper.js +31 -3
  87. package/src/shade/renderer/deferred/tonemap/chunk_tonemap_purkinje.d.ts +26 -0
  88. package/src/shade/renderer/deferred/tonemap/chunk_tonemap_purkinje.d.ts.map +1 -0
  89. package/src/shade/renderer/deferred/tonemap/chunk_tonemap_purkinje.js +55 -0
  90. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_lut.d.ts +2 -2
  91. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_lut.d.ts.map +1 -1
  92. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_lut.js +6 -3
  93. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_lut.d.ts +3 -2
  94. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_lut.d.ts.map +1 -1
  95. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_lut.js +7 -3
  96. package/src/shade/renderer/extension/ViewTextures.d.ts +3 -2
  97. package/src/shade/renderer/extension/ViewTextures.d.ts.map +1 -1
  98. package/src/shade/renderer/extension/ViewTextures.js +3 -2
  99. package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
  100. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
  101. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +6 -6
  102. package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
  103. package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
  104. package/src/shade/renderer/global_illumination/probe/octahedral/shader_lpv_build_gbuffer.js +1 -1
  105. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +20 -1
  106. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts.map +1 -1
  107. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.js +29 -0
  108. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_hit_light.d.ts +47 -0
  109. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_hit_light.d.ts.map +1 -0
  110. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_hit_light.js +246 -0
  111. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.d.ts +4 -15
  112. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.d.ts.map +1 -1
  113. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.js +8 -148
  114. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.d.ts +4 -9
  115. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.d.ts.map +1 -1
  116. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.js +9 -58
  117. package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.d.ts +142 -0
  118. package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.d.ts.map +1 -0
  119. package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.js +938 -0
  120. package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.d.ts +192 -0
  121. package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.d.ts.map +1 -0
  122. package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.js +231 -0
  123. package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeDebugView.d.ts +11 -0
  124. package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeDebugView.d.ts.map +1 -0
  125. package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeDebugView.js +25 -0
  126. package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.d.ts +110 -0
  127. package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.d.ts.map +1 -0
  128. package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.js +197 -0
  129. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe.d.ts +150 -0
  130. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe.d.ts.map +1 -0
  131. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe.js +408 -0
  132. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_brdf_density.d.ts +23 -0
  133. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_brdf_density.d.ts.map +1 -0
  134. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_brdf_density.js +63 -0
  135. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_brick_origin.d.ts +24 -0
  136. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_brick_origin.d.ts.map +1 -0
  137. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_brick_origin.js +61 -0
  138. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_interpolate.d.ts +39 -0
  139. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_interpolate.d.ts.map +1 -0
  140. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_interpolate.js +126 -0
  141. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_lighting_history.d.ts +21 -0
  142. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_lighting_history.d.ts.map +1 -0
  143. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_lighting_history.js +74 -0
  144. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_march_distance.d.ts +20 -0
  145. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_march_distance.d.ts.map +1 -0
  146. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_march_distance.js +26 -0
  147. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_ray_sort.d.ts +24 -0
  148. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_ray_sort.d.ts.map +1 -0
  149. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_ray_sort.js +57 -0
  150. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_screen_march.d.ts +22 -0
  151. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_screen_march.d.ts.map +1 -0
  152. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_screen_march.js +53 -0
  153. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_surface.d.ts +62 -0
  154. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_surface.d.ts.map +1 -0
  155. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_surface.js +156 -0
  156. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_workgroup_sum.d.ts +18 -0
  157. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_workgroup_sum.d.ts.map +1 -0
  158. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_workgroup_sum.js +50 -0
  159. package/src/shade/renderer/global_illumination/screen_probe/graph_screen_probe_debug_view.d.ts +21 -0
  160. package/src/shade/renderer/global_illumination/screen_probe/graph_screen_probe_debug_view.d.ts.map +1 -0
  161. package/src/shade/renderer/global_illumination/screen_probe/graph_screen_probe_debug_view.js +54 -0
  162. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_brick.d.ts +67 -0
  163. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_brick.d.ts.map +1 -0
  164. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_brick.js +509 -0
  165. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_debug.d.ts +20 -0
  166. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_debug.d.ts.map +1 -0
  167. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_debug.js +128 -0
  168. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.d.ts +62 -0
  169. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.d.ts.map +1 -0
  170. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.js +478 -0
  171. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_importance.d.ts +69 -0
  172. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_importance.d.ts.map +1 -0
  173. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_importance.js +457 -0
  174. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_indirect_lighting.d.ts +27 -0
  175. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_indirect_lighting.d.ts.map +1 -0
  176. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_indirect_lighting.js +219 -0
  177. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_pick.d.ts +22 -0
  178. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_pick.d.ts.map +1 -0
  179. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_pick.js +151 -0
  180. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_place.d.ts +66 -0
  181. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_place.d.ts.map +1 -0
  182. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_place.js +301 -0
  183. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.d.ts +59 -0
  184. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.d.ts.map +1 -0
  185. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.js +364 -0
  186. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_trace_screen.d.ts +40 -0
  187. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_trace_screen.d.ts.map +1 -0
  188. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_trace_screen.js +275 -0
  189. package/src/shade/renderer/grass/blade/GPUGrassBlades.d.ts.map +1 -1
  190. package/src/shade/renderer/grass/blade/GPUGrassBlades.js +17 -2
  191. package/src/shade/renderer/grass/blade/grass_blade_resolve.d.ts +18 -8
  192. package/src/shade/renderer/grass/blade/grass_blade_resolve.d.ts.map +1 -1
  193. package/src/shade/renderer/grass/blade/grass_blade_resolve.js +114 -32
  194. package/src/shade/renderer/light/GPULightCollection.d.ts +1 -1
  195. package/src/shade/renderer/light/GPULightCollection.d.ts.map +1 -1
  196. package/src/shade/renderer/light/GPULightCollection.js +213 -80
  197. package/src/shade/renderer/{atmosphere → light/environment}/chunk_sample_environment_color.d.ts +1 -2
  198. package/src/shade/renderer/light/environment/chunk_sample_environment_color.d.ts.map +1 -0
  199. package/src/shade/renderer/{atmosphere → light/environment}/chunk_sample_environment_color.js +3 -4
  200. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  201. package/src/shade/renderer/path_tracer/shader/chunk_render_trace_path.js +1 -1
  202. package/src/shade/renderer/postprocess/denoise/debug/graph_pass_debug_reprojection.js +1 -1
  203. package/src/shade/renderer/postprocess/eye/GPUCameraExposureManager.d.ts +35 -9
  204. package/src/shade/renderer/postprocess/eye/GPUCameraExposureManager.d.ts.map +1 -1
  205. package/src/shade/renderer/postprocess/eye/GPUCameraExposureManager.js +81 -11
  206. package/src/shade/renderer/postprocess/eye/shader_autoexposure_adapt.d.ts.map +1 -1
  207. package/src/shade/renderer/postprocess/eye/shader_autoexposure_adapt.js +4 -1
  208. package/src/shade/renderer/postprocess/motion_blur/MotionBlur.d.ts +1 -1
  209. package/src/shade/renderer/postprocess/motion_blur/MotionBlur.js +1 -1
  210. package/src/shade/renderer/postprocess/motion_blur/graph_postprocess_motion_blur.d.ts +1 -1
  211. package/src/shade/renderer/postprocess/motion_blur/graph_postprocess_motion_blur.js +1 -1
  212. package/src/shade/renderer/postprocess/motion_blur/shader_motion_blur_reconstruct.js +1 -1
  213. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  214. package/src/shade/renderer/postprocess/ssr/resolve/chunk_ssr_add_hit_irradiance.js +2 -0
  215. package/src/shade/renderer/postprocess/ssr/resolve/chunk_ssr_sample_radiance.js +2 -0
  216. package/src/shade/renderer/postprocess/taa/chunk_fsr2_compute_depth_clip.d.ts +6 -0
  217. package/src/shade/renderer/postprocess/taa/chunk_fsr2_compute_depth_clip.d.ts.map +1 -1
  218. package/src/shade/renderer/postprocess/taa/chunk_fsr2_compute_depth_clip.js +9 -1
  219. package/src/shade/renderer/postprocess/taa/shader_depth_occlusion_clip.d.ts.map +1 -1
  220. package/src/shade/renderer/postprocess/taa/shader_depth_occlusion_clip.js +4 -3
  221. package/src/shade/renderer/postprocess/velocity/VELOCITY_BUFFER.d.ts +17 -0
  222. package/src/shade/renderer/postprocess/velocity/VELOCITY_BUFFER.d.ts.map +1 -0
  223. package/src/shade/renderer/postprocess/velocity/VELOCITY_BUFFER.js +16 -0
  224. package/src/shade/renderer/postprocess/velocity/chunk_velocity_texel.d.ts +21 -0
  225. package/src/shade/renderer/postprocess/velocity/chunk_velocity_texel.d.ts.map +1 -0
  226. package/src/shade/renderer/postprocess/velocity/chunk_velocity_texel.js +30 -0
  227. package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.d.ts +7 -5
  228. package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.d.ts.map +1 -1
  229. package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.js +19 -17
  230. package/src/shade/renderer/rasterize/forward/chunk_forward_sample_indirect.js +2 -0
  231. package/src/shade/renderer/scene/GPUSceneContext.d.ts.map +1 -1
  232. package/src/shade/renderer/scene/GPUSceneContext.js +2 -1
  233. package/src/shade/renderer/scene/Scene.d.ts +9 -2
  234. package/src/shade/renderer/scene/Scene.d.ts.map +1 -1
  235. package/src/shade/renderer/scene/Scene.js +10 -2
  236. package/src/shade/renderer/shader/ImageShader.d.ts +24 -12
  237. package/src/shade/renderer/shader/ImageShader.d.ts.map +1 -1
  238. package/src/shade/renderer/shader/ImageShader.js +11 -8
  239. package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_HEIGHT_DECLARATION.d.ts +3 -1
  240. package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_HEIGHT_DECLARATION.d.ts.map +1 -1
  241. package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_HEIGHT_DECLARATION.js +11 -3
  242. package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_RADII_DECLARATION.d.ts +2 -11
  243. package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_RADII_DECLARATION.d.ts.map +1 -1
  244. package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_RADII_DECLARATION.js +23 -32
  245. package/src/shade/renderer/shader/chunk/atmosphere/PLANET_RADIUS_DECLARATION.d.ts +6 -0
  246. package/src/shade/renderer/shader/chunk/atmosphere/PLANET_RADIUS_DECLARATION.d.ts.map +1 -1
  247. package/src/shade/renderer/shader/chunk/atmosphere/PLANET_RADIUS_DECLARATION.js +14 -2
  248. package/src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_height.d.ts.map +1 -1
  249. package/src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_height.js +4 -2
  250. package/src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_intersection.d.ts.map +1 -1
  251. package/src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_intersection.js +11 -3
  252. package/src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_ray_bounds.d.ts.map +1 -1
  253. package/src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_ray_bounds.js +68 -69
  254. package/src/shade/renderer/shader/chunk/atmosphere/chunk_get_sun_transmittance.d.ts +4 -1
  255. package/src/shade/renderer/shader/chunk/atmosphere/chunk_get_sun_transmittance.d.ts.map +1 -1
  256. package/src/shade/renderer/shader/chunk/atmosphere/chunk_get_sun_transmittance.js +46 -39
  257. package/src/shade/renderer/shader/chunk/atmosphere/chunk_position_relative_to_planet_center.d.ts.map +1 -1
  258. package/src/shade/renderer/shader/chunk/atmosphere/chunk_position_relative_to_planet_center.js +5 -3
  259. package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.d.ts +6 -0
  260. package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.d.ts.map +1 -1
  261. package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.js +7 -0
  262. package/src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.d.ts +4 -4
  263. package/src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.d.ts.map +1 -1
  264. package/src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.js +86 -5
  265. package/src/shade/renderer/shader/chunk/color/tonemap/purkinje/chunk_apply_purkinje_shift.d.ts +73 -0
  266. package/src/shade/renderer/shader/chunk/color/tonemap/purkinje/chunk_apply_purkinje_shift.d.ts.map +1 -0
  267. package/src/shade/renderer/shader/chunk/color/tonemap/purkinje/chunk_apply_purkinje_shift.js +139 -0
  268. package/src/shade/renderer/shader/chunk/depth/chunk_get_device_depth.d.ts +14 -0
  269. package/src/shade/renderer/shader/chunk/depth/chunk_get_device_depth.d.ts.map +1 -0
  270. package/src/shade/renderer/shader/chunk/depth/chunk_get_device_depth.js +30 -0
  271. package/src/shade/renderer/shader/chunk/geometry/octahedron/chunk_uv_equal_area_sphere.d.ts +21 -0
  272. package/src/shade/renderer/shader/chunk/geometry/octahedron/chunk_uv_equal_area_sphere.d.ts.map +1 -0
  273. package/src/shade/renderer/shader/chunk/geometry/octahedron/chunk_uv_equal_area_sphere.js +60 -0
  274. package/src/shade/renderer/shader/chunk/light/{sky/chunk_sample_sky_color.d.ts → io/chunk_light_get_sun.d.ts} +3 -6
  275. package/src/shade/renderer/shader/chunk/light/io/chunk_light_get_sun.d.ts.map +1 -0
  276. package/src/shade/renderer/shader/chunk/light/{sky/chunk_sample_sky_color.js → io/chunk_light_get_sun.js} +6 -26
  277. package/src/shade/renderer/shadow/sdf/cascade/shader_scene_sdf_soft_shadows.js +1 -1
  278. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.d.ts +3 -1
  279. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.d.ts.map +1 -1
  280. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.js +4 -2
  281. package/src/shade/renderer/volumetrics/graph_build_volumetrics.d.ts.map +1 -1
  282. package/src/shade/renderer/volumetrics/graph_build_volumetrics.js +743 -739
  283. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_gi_sample.js +2 -0
  284. package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.d.ts.map +1 -1
  285. package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.js +19 -17
  286. package/src/shade/renderer/volumetrics/shader_volumetrics_build_scattering_lut.d.ts.map +1 -1
  287. package/src/shade/renderer/volumetrics/shader_volumetrics_build_scattering_lut.js +5 -3
  288. package/src/shade/renderer/water/chunk_water_gi.js +2 -0
  289. package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
  290. package/src/shade/renderer/wind/GPUSceneWind.d.ts +1 -1
  291. package/src/engine/graphics/sh3/path_tracer/make_sky_hosek.d.ts +0 -2
  292. package/src/engine/graphics/sh3/path_tracer/make_sky_hosek.d.ts.map +0 -1
  293. package/src/engine/graphics/sh3/path_tracer/make_sky_hosek.js +0 -45
  294. package/src/engine/graphics/sh3/path_tracer/make_sky_rtiw.d.ts +0 -2
  295. package/src/engine/graphics/sh3/path_tracer/make_sky_rtiw.d.ts.map +0 -1
  296. package/src/engine/graphics/sh3/path_tracer/make_sky_rtiw.js +0 -17
  297. package/src/engine/graphics/sh3/sky/hosek/README.md +0 -4
  298. package/src/engine/graphics/sh3/sky/hosek/data.d.ts +0 -17
  299. package/src/engine/graphics/sh3/sky/hosek/data.d.ts.map +0 -1
  300. package/src/engine/graphics/sh3/sky/hosek/data.js +0 -3744
  301. package/src/engine/graphics/sh3/sky/hosek/prototype_hosek.d.ts +0 -2
  302. package/src/engine/graphics/sh3/sky/hosek/prototype_hosek.d.ts.map +0 -1
  303. package/src/engine/graphics/sh3/sky/hosek/prototype_hosek.js +0 -71
  304. package/src/engine/graphics/sh3/sky/hosek/render_hosek_sky_to_equirectangular.d.ts +0 -26
  305. package/src/engine/graphics/sh3/sky/hosek/render_hosek_sky_to_equirectangular.d.ts.map +0 -1
  306. package/src/engine/graphics/sh3/sky/hosek/render_hosek_sky_to_equirectangular.js +0 -70
  307. package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.d.ts +0 -22
  308. package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.d.ts.map +0 -1
  309. package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.js +0 -388
  310. package/src/engine/graphics3/make_default_environment.d.ts +0 -15
  311. package/src/engine/graphics3/make_default_environment.d.ts.map +0 -1
  312. package/src/engine/graphics3/make_default_environment.js +0 -111
  313. package/src/shade/renderer/atmosphere/MIE_G.d.ts +0 -6
  314. package/src/shade/renderer/atmosphere/MIE_G.d.ts.map +0 -1
  315. package/src/shade/renderer/atmosphere/MIE_G.js +0 -5
  316. package/src/shade/renderer/atmosphere/chunk_sample_environment_color.d.ts.map +0 -1
  317. package/src/shade/renderer/atmosphere/hillaire/ATMOSPHERE_EARTH.d.ts +0 -4
  318. package/src/shade/renderer/atmosphere/hillaire/ATMOSPHERE_EARTH.d.ts.map +0 -1
  319. package/src/shade/renderer/atmosphere/hillaire/ATMOSPHERE_EARTH.js +0 -44
  320. package/src/shade/renderer/atmosphere/hillaire/ATMOSPHERE_PARAMETERS_STRUCT.d.ts +0 -2
  321. package/src/shade/renderer/atmosphere/hillaire/ATMOSPHERE_PARAMETERS_STRUCT.d.ts.map +0 -1
  322. package/src/shade/renderer/atmosphere/hillaire/ATMOSPHERE_PARAMETERS_STRUCT.js +0 -43
  323. package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_DENSITY_DECLARATION.d.ts +0 -3
  324. package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_DENSITY_DECLARATION.d.ts.map +0 -1
  325. package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_DENSITY_DECLARATION.js +0 -6
  326. package/src/shade/renderer/shader/chunk/atmosphere/chunk_absorb.d.ts +0 -3
  327. package/src/shade/renderer/shader/chunk/atmosphere/chunk_absorb.d.ts.map +0 -1
  328. package/src/shade/renderer/shader/chunk/atmosphere/chunk_absorb.js +0 -18
  329. package/src/shade/renderer/shader/chunk/atmosphere/chunk_integrate_optical_depth.d.ts +0 -14
  330. package/src/shade/renderer/shader/chunk/atmosphere/chunk_integrate_optical_depth.d.ts.map +0 -1
  331. package/src/shade/renderer/shader/chunk/atmosphere/chunk_integrate_optical_depth.js +0 -86
  332. package/src/shade/renderer/shader/chunk/atmosphere/chunk_integrate_scattering.d.ts +0 -8
  333. package/src/shade/renderer/shader/chunk/atmosphere/chunk_integrate_scattering.d.ts.map +0 -1
  334. package/src/shade/renderer/shader/chunk/atmosphere/chunk_integrate_scattering.js +0 -125
  335. package/src/shade/renderer/shader/chunk/atmosphere/chunk_planet_intersection.d.ts +0 -3
  336. package/src/shade/renderer/shader/chunk/atmosphere/chunk_planet_intersection.d.ts.map +0 -1
  337. package/src/shade/renderer/shader/chunk/atmosphere/chunk_planet_intersection.js +0 -17
  338. package/src/shade/renderer/shader/chunk/atmosphere/chunk_sphere_intersection_nearest.d.ts +0 -3
  339. package/src/shade/renderer/shader/chunk/atmosphere/chunk_sphere_intersection_nearest.d.ts.map +0 -1
  340. package/src/shade/renderer/shader/chunk/atmosphere/chunk_sphere_intersection_nearest.js +0 -38
  341. package/src/shade/renderer/shader/chunk/atmosphere/hillaire/DENSITY_PROFILE_LAYER_STRUCT.d.ts +0 -16
  342. package/src/shade/renderer/shader/chunk/atmosphere/hillaire/DENSITY_PROFILE_LAYER_STRUCT.d.ts.map +0 -1
  343. package/src/shade/renderer/shader/chunk/atmosphere/hillaire/DENSITY_PROFILE_LAYER_STRUCT.js +0 -28
  344. package/src/shade/renderer/shader/chunk/color/tonemap/purkinjie/chunk_apply_purkinjie_shift.d.ts +0 -11
  345. package/src/shade/renderer/shader/chunk/color/tonemap/purkinjie/chunk_apply_purkinjie_shift.d.ts.map +0 -1
  346. package/src/shade/renderer/shader/chunk/color/tonemap/purkinjie/chunk_apply_purkinjie_shift.js +0 -56
  347. package/src/shade/renderer/shader/chunk/light/sky/chunk_sample_sky_color.d.ts.map +0 -1
  348. package/src/shade/renderer/view/GPUViewSkyContext.d.ts +0 -26
  349. package/src/shade/renderer/view/GPUViewSkyContext.d.ts.map +0 -1
  350. package/src/shade/renderer/view/GPUViewSkyContext.js +0 -170
@@ -17,6 +17,11 @@ const HISTOGRAM_DESCRIPTOR = BufferResourceDescriptor.empty(
17
17
  GPUBufferUsage.STORAGE,
18
18
  );
19
19
 
20
+ /**
21
+ * The luminance an exposure of one shows at middle grey, cd/m²: the scene value the adaptation maps to 0.18.
22
+ */
23
+ const MIDDLE_GREY = 0.18;
24
+
20
25
  const TARGET_LUMINANCE_DESCRIPTOR = BufferResourceDescriptor.from(
21
26
  F32_CONTAINER_STRUCT.size,
22
27
  GPUBufferUsage.STORAGE | GPUBufferUsage.UNIFORM,
@@ -29,6 +34,10 @@ const TARGET_LUMINANCE_DESCRIPTOR = BufferResourceDescriptor.from(
29
34
  * The factor lives in one buffer for the manager's life, {@link multiplier}, which a frame's {@link update} or
30
35
  * {@link unadapted} writes over. A pass recorded ahead of that write in the frame reads the factor the last frame was
31
36
  * shown with: the exposure of the image on screen, Unreal Engine's `View.PreExposure`.
37
+ *
38
+ * Beside it, {@link adaptation}: the luminance the view is adapted to, cd/m², written by the same pass. Adapted, it is
39
+ * the luminance the eye has adapted to, without {@link exposure_compensation}; unadapted, it is the luminance the
40
+ * exposure shows at middle grey.
32
41
  */
33
42
  export class GPUCameraExposureManager {
34
43
  /**
@@ -47,6 +56,18 @@ export class GPUCameraExposureManager {
47
56
  */
48
57
  #multiplier;
49
58
 
59
+ /**
60
+ * {@link F32_CONTAINER_STRUCT}: the adaptation the last {@link update} or {@link unadapted} wrote, cd/m².
61
+ * @type {GPUTypedBuffer}
62
+ */
63
+ #adaptation;
64
+
65
+ /**
66
+ * The handles {@link update} and {@link unadapted} return, kept across frames.
67
+ * @type {{multiplier: number, adaptation: number}}
68
+ */
69
+ #written = { multiplier: -1, adaptation: -1 };
70
+
50
71
  /**
51
72
  * How fast do we adapt to brighter environments?
52
73
  * in f-stops per second.
@@ -78,15 +99,16 @@ export class GPUCameraExposureManager {
78
99
  exposure_compensation = 0.0;
79
100
 
80
101
  // what each pass's execution reads, kept across frames: a frame records them and runs them before the next does
81
- #unadapted_data = { output: -1 };
102
+ #unadapted_data = { output: -1, adaptation: -1 };
82
103
  #unadapted_value = { value: 1.0 };
104
+ #unadapted_adaptation = { value: MIDDLE_GREY };
83
105
  #build_data = { input_color: -1, output: -1 };
84
106
  #parse_data = { input_histogram: -1, output: -1 };
85
- #adapt_data = { goal: -1, previous: -1, adapted: -1, out_multiplier: -1 };
107
+ #adapt_data = { goal: -1, previous: -1, adapted: -1, out_multiplier: -1, out_adaptation: -1 };
86
108
  #adapt_settings = { speed_up: 0, speed_down: 0, time_delta: 0, exp_transition_distance: 0, compensation: 0 };
87
109
  #build_bindings = { tInput: null, histogram: null };
88
110
  #parse_bindings = { histogram: null, output: null };
89
- #adapt_bindings = { goal: null, previous: null, settings: this.#adapt_settings, adapted: null, out_multiplier: null };
111
+ #adapt_bindings = { goal: null, previous: null, settings: this.#adapt_settings, adapted: null, out_multiplier: null, out_adaptation: null };
90
112
 
91
113
  /**
92
114
  *
@@ -110,13 +132,24 @@ export class GPUCameraExposureManager {
110
132
  this.#multiplier = GPUTypedBuffer.create({
111
133
  label: 'exposure multiplier',
112
134
  device,
113
- usage: GPUBufferUsage.STORAGE | GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
135
+ usage: GPUBufferUsage.STORAGE | GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST | GPUBufferUsage.COPY_SRC,
114
136
  type: F32_CONTAINER_STRUCT,
115
137
  initial_value: {
116
138
  value: 1.0
117
139
  }
118
140
  });
119
141
 
142
+ // what a factor of one shows at middle grey, until the first frame writes its own
143
+ this.#adaptation = GPUTypedBuffer.create({
144
+ label: 'exposure adaptation',
145
+ device,
146
+ usage: GPUBufferUsage.STORAGE | GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
147
+ type: F32_CONTAINER_STRUCT,
148
+ initial_value: {
149
+ value: MIDDLE_GREY
150
+ }
151
+ });
152
+
120
153
  }
121
154
 
122
155
  destroy() {
@@ -125,6 +158,7 @@ export class GPUCameraExposureManager {
125
158
  }
126
159
 
127
160
  this.#multiplier.destroy();
161
+ this.#adaptation.destroy();
128
162
  }
129
163
 
130
164
  /**
@@ -132,12 +166,23 @@ export class GPUCameraExposureManager {
132
166
  * imports it into its graph once, and hands the handle both to the passes that read it ahead of the exposure,
133
167
  * which take the last frame's factor, and to {@link update} or {@link unadapted}, which write this frame's.
134
168
  *
135
- * @returns {GPUBuffer} usable as a uniform or read-only storage
169
+ * @returns {GPUBuffer} usable as a uniform or read-only storage, and as a copy source, to read it back
136
170
  */
137
171
  get multiplier() {
138
172
  return this.#multiplier.buffer;
139
173
  }
140
174
 
175
+ /**
176
+ * The luminance the view is adapted to, cd/m², {@link F32_CONTAINER_STRUCT}, as the last {@link update} or
177
+ * {@link unadapted} wrote it. Imported into a frame's graph once and handed to {@link update} or {@link unadapted},
178
+ * like {@link multiplier}.
179
+ *
180
+ * @returns {GPUBuffer} usable as a uniform or read-only storage
181
+ */
182
+ get adaptation() {
183
+ return this.#adaptation.buffer;
184
+ }
185
+
141
186
  /**
142
187
  * Offer the pipelines {@link update} meters and adapts with — see {@link PipelineEnquiry}.
143
188
  * {@link unadapted} dispatches none.
@@ -151,26 +196,37 @@ export class GPUCameraExposureManager {
151
196
  }
152
197
 
153
198
  /**
154
- * This frame's factor from {@link exposure_compensation} alone: 2^compensation.
199
+ * This frame's factor from {@link exposure_compensation} alone: 2^compensation. Its adaptation is the luminance
200
+ * that factor shows at middle grey, 0.18 / 2^compensation cd/m².
155
201
  *
156
202
  * @param {Object} options
157
203
  * @param {FrameGraph} options.graph
158
204
  * @param {number} options.multiplier the graph handle of {@link multiplier}, imported into `graph`
159
- * @return {number} the handle of {@link multiplier} with this frame's factor written
205
+ * @param {number} options.adaptation the graph handle of {@link adaptation}, imported into `graph`
206
+ * @return {{multiplier: number, adaptation: number}} the handles of {@link multiplier} and {@link adaptation}
207
+ * with this frame's written; the object is reused by the next call
160
208
  */
161
209
  unadapted({
162
210
  graph,
163
211
  multiplier,
212
+ adaptation,
164
213
  }) {
165
214
  assert.defined(graph, 'graph');
166
215
  assert.isNonNegativeInteger(multiplier, 'multiplier');
216
+ assert.isNonNegativeInteger(adaptation, 'adaptation');
167
217
 
168
218
  const data = this.#unadapted_data;
169
219
  const pass = graph.add("unadapted", data, this.#execute_unadapted);
170
220
 
171
221
  data.output = pass.write(multiplier);
222
+ data.adaptation = pass.write(adaptation);
223
+
224
+ const written = this.#written;
172
225
 
173
- return data.output;
226
+ written.multiplier = data.output;
227
+ written.adaptation = data.adaptation;
228
+
229
+ return written;
174
230
  }
175
231
 
176
232
  /**
@@ -186,26 +242,32 @@ export class GPUCameraExposureManager {
186
242
 
187
243
  // compensation is in f-stops: each stop doubles/halves brightness
188
244
  this.#unadapted_value.value = Math.pow(2, this.exposure_compensation);
245
+ this.#unadapted_adaptation.value = MIDDLE_GREY / this.#unadapted_value.value;
189
246
 
190
247
  // in the command stream, so a pass recorded ahead of this one still reads the last frame's factor
191
248
  encoder.writeValueBuffer(resources.get(data.output), 0, F32_CONTAINER_STRUCT, this.#unadapted_value);
249
+ encoder.writeValueBuffer(resources.get(data.adaptation), 0, F32_CONTAINER_STRUCT, this.#unadapted_adaptation);
192
250
  }
193
251
 
194
252
  /**
195
253
  * This frame's factor metered from `input_color`: the luminance adapted toward the frame's, from the last
196
- * frame's, by the adaptation speeds; its factor is middle grey over it, times 2^{@link exposure_compensation}.
254
+ * frame's, by the adaptation speeds; its factor is middle grey over it, times 2^{@link exposure_compensation}. Its
255
+ * adaptation is that adapted luminance, without the compensation.
197
256
  *
198
257
  * @param {Object} options
199
258
  * @param {FrameGraph} options.graph
200
259
  * @param {number} options.input_color
201
260
  * @param {number} options.multiplier the graph handle of {@link multiplier}, imported into `graph`
261
+ * @param {number} options.adaptation the graph handle of {@link adaptation}, imported into `graph`
202
262
  * @param {number} [options.time_delta_seconds]
203
- * @return {number} the handle of {@link multiplier} with this frame's factor written
263
+ * @return {{multiplier: number, adaptation: number}} the handles of {@link multiplier} and {@link adaptation}
264
+ * with this frame's written; the object is reused by the next call
204
265
  */
205
266
  update({
206
267
  input_color,
207
268
  graph,
208
269
  multiplier,
270
+ adaptation,
209
271
  time_delta_seconds = 0.01666,
210
272
  }) {
211
273
 
@@ -219,6 +281,7 @@ export class GPUCameraExposureManager {
219
281
 
220
282
  assert.defined(graph, 'graph');
221
283
  assert.isNonNegativeInteger(multiplier, 'multiplier');
284
+ assert.isNonNegativeInteger(adaptation, 'adaptation');
222
285
  assert.isNumber(time_delta_seconds, 'time_delta_seconds');
223
286
  assert.greaterThanOrEqual(time_delta_seconds, 0, 'time_delta_seconds');
224
287
 
@@ -249,8 +312,14 @@ export class GPUCameraExposureManager {
249
312
  adapt_data.previous = adapt_pass.read(graph_import_buffer(graph, exposure_buffer_previous.buffer, "previous adapted luminance"));
250
313
  adapt_data.adapted = adapt_pass.write(graph_import_buffer(graph, exposure_buffer_current.buffer, "adapted luminance"));
251
314
  adapt_data.out_multiplier = adapt_pass.write(multiplier);
315
+ adapt_data.out_adaptation = adapt_pass.write(adaptation);
316
+
317
+ const written = this.#written;
318
+
319
+ written.multiplier = adapt_data.out_multiplier;
320
+ written.adaptation = adapt_data.out_adaptation;
252
321
 
253
- return adapt_data.out_multiplier;
322
+ return written;
254
323
  }
255
324
 
256
325
  /**
@@ -319,6 +388,7 @@ export class GPUCameraExposureManager {
319
388
  bindings.previous = resources.get(data.previous);
320
389
  bindings.adapted = resources.get(data.adapted);
321
390
  bindings.out_multiplier = resources.get(data.out_multiplier);
391
+ bindings.out_adaptation = resources.get(data.out_adaptation);
322
392
 
323
393
  shader_autoexposure_adapt.dispatch({
324
394
  encoder: context.encoder,
@@ -1 +1 @@
1
- {"version":3,"file":"shader_autoexposure_adapt.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/postprocess/eye/shader_autoexposure_adapt.js"],"names":[],"mappings":"AASA,sDAsBE;AA+FF,sDAIG;6BAjI0B,mCAAmC;8BAElC,+BAA+B"}
1
+ {"version":3,"file":"shader_autoexposure_adapt.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/postprocess/eye/shader_autoexposure_adapt.js"],"names":[],"mappings":"AASA,sDAsBE;AAkGF,sDAIG;6BApI0B,mCAAmC;8BAElC,+BAA+B"}
@@ -41,6 +41,7 @@ resources.createGroup()
41
41
  .addUniform("previous", F32_CONTAINER_STRUCT)
42
42
  .addStorageBuffer("adapted", F32_CONTAINER_STRUCT, true)
43
43
  .addStorageBuffer("out_multiplier", F32_CONTAINER_STRUCT, true)
44
+ .addStorageBuffer("out_adaptation", F32_CONTAINER_STRUCT, true)
44
45
  ;
45
46
 
46
47
 
@@ -64,6 +65,7 @@ fn main(){
64
65
  */
65
66
  if (!(goal.value > 0.0)) {
66
67
  adapted.value = previous.value;
68
+ out_adaptation.value = previous.value;
67
69
 
68
70
  out_multiplier.value = (MIDDLE_GREY / current_linear) * exp2(settings.compensation);
69
71
 
@@ -113,7 +115,8 @@ fn main(){
113
115
  // convert back to linear space
114
116
  let new_linear = exp2(new_ev);
115
117
  adapted.value = new_linear;
116
-
118
+ out_adaptation.value = new_linear;
119
+
117
120
  // apply final transforms
118
121
 
119
122
  let shifted = MIDDLE_GREY / adapted.value;
@@ -38,7 +38,7 @@ export class MotionBlur {
38
38
  * @param {object} args
39
39
  * @param {FrameGraph} args.graph
40
40
  * @param {number} args.input_color FrameGraph handle, rgba16float HDR colour (post-TAA)
41
- * @param {number} args.velocity FrameGraph handle, rg16float pixel-space velocity
41
+ * @param {number} args.velocity FrameGraph handle, the velocity buffer (`VELOCITY_FORMAT`), read for its pixel-space deltas
42
42
  * @param {number} args.depth FrameGraph handle, depth texture
43
43
  * @param {number[]} args.resolution full output resolution `[w, h]`
44
44
  * @param {number[]} [args.velocity_resolution] resolution of `velocity` and `depth`, which are
@@ -42,7 +42,7 @@ export class MotionBlur {
42
42
  * @param {object} args
43
43
  * @param {FrameGraph} args.graph
44
44
  * @param {number} args.input_color FrameGraph handle, rgba16float HDR colour (post-TAA)
45
- * @param {number} args.velocity FrameGraph handle, rg16float pixel-space velocity
45
+ * @param {number} args.velocity FrameGraph handle, the velocity buffer (`VELOCITY_FORMAT`), read for its pixel-space deltas
46
46
  * @param {number} args.depth FrameGraph handle, depth texture
47
47
  * @param {number[]} args.resolution full output resolution `[w, h]`
48
48
  * @param {number[]} [args.velocity_resolution] resolution of `velocity` and `depth`, which are
@@ -31,7 +31,7 @@
31
31
  * @param {object} args
32
32
  * @param {FrameGraph} args.graph
33
33
  * @param {number} args.input_color FrameGraph handle, rgba16float HDR colour (post-TAA)
34
- * @param {number} args.velocity FrameGraph handle, rg16float pixel-space velocity
34
+ * @param {number} args.velocity FrameGraph handle, the velocity buffer (`VELOCITY_FORMAT`), read for its pixel-space deltas
35
35
  * @param {number} args.depth FrameGraph handle, depth texture
36
36
  * @param {number[]} args.resolution Full output resolution `[w, h]`
37
37
  * @param {number[]} [args.velocity_resolution] Resolution of `velocity` and `depth`, which are
@@ -38,7 +38,7 @@ import { shader_motion_blur_tile_max } from "./shader_motion_blur_tile_max.js";
38
38
  * @param {object} args
39
39
  * @param {FrameGraph} args.graph
40
40
  * @param {number} args.input_color FrameGraph handle, rgba16float HDR colour (post-TAA)
41
- * @param {number} args.velocity FrameGraph handle, rg16float pixel-space velocity
41
+ * @param {number} args.velocity FrameGraph handle, the velocity buffer (`VELOCITY_FORMAT`), read for its pixel-space deltas
42
42
  * @param {number} args.depth FrameGraph handle, depth texture
43
43
  * @param {number[]} args.resolution Full output resolution `[w, h]`
44
44
  * @param {number[]} [args.velocity_resolution] Resolution of `velocity` and `depth`, which are
@@ -19,7 +19,7 @@ resources.setImmediate("uStrength", F32_CONTAINER_STRUCT);
19
19
  resources.createGroup()
20
20
  // Post-TAA HDR color we're blurring.
21
21
  .addTexture("tColor", "float")
22
- // Full-resolution velocity (pixel-space deltas, rg16float).
22
+ // Full-resolution velocity (VELOCITY_FORMAT; its pixel-space deltas in rg).
23
23
  .addTexture("tVelocity", "float")
24
24
  // 1/K resolution dilated tile velocity from NeighborMax.
25
25
  .addTexture("tNeighborMax", "float")
@@ -51,7 +51,7 @@ export class NSS {
51
51
  * @returns {number}
52
52
  */
53
53
  static recommended_jitter_sequence_size(upscale_ratio: number): number;
54
- static "__#220@#preprocess_tensor_descriptor"(render_w: any, render_h: any): TextureResourceDescriptor;
54
+ static "__#223@#preprocess_tensor_descriptor"(render_w: any, render_h: any): TextureResourceDescriptor;
55
55
  /**
56
56
  * @param {GraphicsContext} graphics
57
57
  */
@@ -128,3 +128,5 @@ chunk_ssr_add_hit_irradiance.add(ShadeIndirectLightingMode.IBL, chunk_ssr_add_hi
128
128
  chunk_ssr_add_hit_irradiance.add(ShadeIndirectLightingMode.Brick4, chunk_ssr_add_hit_irradiance_none);
129
129
  chunk_ssr_add_hit_irradiance.add(ShadeIndirectLightingMode.LPV, chunk_ssr_add_hit_irradiance_lpv);
130
130
  chunk_ssr_add_hit_irradiance.add(ShadeIndirectLightingMode.ProbeClipmap, chunk_ssr_add_hit_irradiance_probe_clipmap);
131
+ // the screen probes light only the deferred opaque surfaces: every other reader takes the world-space probes
132
+ chunk_ssr_add_hit_irradiance.add(ShadeIndirectLightingMode.ScreenProbes, chunk_ssr_add_hit_irradiance_probe_clipmap);
@@ -94,3 +94,5 @@ chunk_ssr_sample_radiance.add(ShadeIndirectLightingMode.IBL, chunk_ssr_sample_ra
94
94
  chunk_ssr_sample_radiance.add(ShadeIndirectLightingMode.Brick4, chunk_ssr_sample_radiance_brick4);
95
95
  chunk_ssr_sample_radiance.add(ShadeIndirectLightingMode.LPV, chunk_ssr_sample_radiance_lpv);
96
96
  chunk_ssr_sample_radiance.add(ShadeIndirectLightingMode.ProbeClipmap, chunk_ssr_sample_radiance_probe_clipmap);
97
+ // the screen probes light only the deferred opaque surfaces: every other reader takes the world-space probes
98
+ chunk_ssr_sample_radiance.add(ShadeIndirectLightingMode.ScreenProbes, chunk_ssr_sample_radiance_probe_clipmap);
@@ -1,6 +1,12 @@
1
1
  /**
2
2
  * Returns confidence level in reprojected sample (1 = trust history, 0 = disocclusion).
3
3
  *
4
+ * `depth_motion` is the view depth the point moved through since last frame, the velocity buffer's z
5
+ * (`VELOCITY_FORMAT`). Last frame's depth is weighed against the point's depth then, its depth now
6
+ * less that, as UE's TSR weighs it (`PrevClosestDeviceZ`, TSRDilateVelocity.usf). FSR2 has no depth
7
+ * in its motion and weighs against the depth now, which reads a surface moving away from the camera
8
+ * as a disocclusion.
9
+ *
4
10
  * NOTE: deliberately uses a 2x2 *min*-gather over inverted-depth prev samples (= farthest
5
11
  * in view space), which is the OPPOSITE of FSR2's "closest reconstructed prev depth"
6
12
  * semantic. We do this on purpose:
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_fsr2_compute_depth_clip.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/postprocess/taa/chunk_fsr2_compute_depth_clip.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,4CAFU,SAAS,CAkGjB;0BA9HwB,oCAAoC"}
1
+ {"version":3,"file":"chunk_fsr2_compute_depth_clip.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/postprocess/taa/chunk_fsr2_compute_depth_clip.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,4CAFU,SAAS,CAoGjB;0BAtIwB,oCAAoC"}
@@ -9,6 +9,12 @@ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
9
9
  /**
10
10
  * Returns confidence level in reprojected sample (1 = trust history, 0 = disocclusion).
11
11
  *
12
+ * `depth_motion` is the view depth the point moved through since last frame, the velocity buffer's z
13
+ * (`VELOCITY_FORMAT`). Last frame's depth is weighed against the point's depth then, its depth now
14
+ * less that, as UE's TSR weighs it (`PrevClosestDeviceZ`, TSRDilateVelocity.usf). FSR2 has no depth
15
+ * in its motion and weighs against the depth now, which reads a surface moving away from the camera
16
+ * as a disocclusion.
17
+ *
12
18
  * NOTE: deliberately uses a 2x2 *min*-gather over inverted-depth prev samples (= farthest
13
19
  * in view space), which is the OPPOSITE of FSR2's "closest reconstructed prev depth"
14
20
  * semantic. We do this on purpose:
@@ -39,9 +45,11 @@ export const chunk_fsr2_compute_depth_clip = CodeChunk.from(
39
45
  fn fsr2_compute_depth_clip(
40
46
  previous_coord: vec2<f32>,
41
47
  current_depth_sample: f32,
48
+ depth_motion: f32,
42
49
  render_size: vec2<i32>
43
50
  ) -> f32 {
44
- let fCurrentDepthViewSpace = get_view_space_depth(current_depth_sample, camera_current);
51
+ // the point's view depth last frame: its depth now less the depth it moved through
52
+ let fCurrentDepthViewSpace = get_view_space_depth(current_depth_sample, camera_current) - depth_motion;
45
53
 
46
54
  // previous_coord is in this frame's pixels, and the previous depth keeps the size it was drawn
47
55
  // at across a resolution change, so carry the position into its grid. Equal sizes scale by 1.
@@ -1 +1 @@
1
- {"version":3,"file":"shader_depth_occlusion_clip.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/postprocess/taa/shader_depth_occlusion_clip.js"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;GAYG;AACH,2CAFU,SAAS,CAsBjB;AAqCF,sDAaG;0BApGuB,oCAAoC;4BAElC,6BAA6B"}
1
+ {"version":3,"file":"shader_depth_occlusion_clip.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/postprocess/taa/shader_depth_occlusion_clip.js"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;GAYG;AACH,2CAFU,SAAS,CAsBjB;AAsCF,sDAaG;0BArGuB,oCAAoC;4BAElC,6BAA6B"}
@@ -68,12 +68,13 @@ fn main(
68
68
 
69
69
  // Velocity at the nearest-depth pixel (FSR2's strategy). The choice is published in g below so
70
70
  // the TAA resolve reprojects with the same velocity; don't chain a second dilation on top.
71
- let velocity = textureLoad( VelocityBuffer, iNearestDepthCoord, 0 ).rg;
71
+ let velocity = textureLoad( VelocityBuffer, iNearestDepthCoord, 0 ).xyz;
72
72
 
73
73
  let prevFrameScreenST = coord.xy - velocity.xy;
74
74
 
75
- // get depth confidence factor, larger then 0, assume the history is valid
76
- let confidence = fsr2_compute_depth_clip( prevFrameScreenST, depth, render_size );
75
+ // get depth confidence factor, larger then 0, assume the history is valid; against the
76
+ // point's depth last frame, by the depth it moved through (velocity.z)
77
+ let confidence = fsr2_compute_depth_clip( prevFrameScreenST, depth, velocity.z, render_size );
77
78
 
78
79
  // r: history confidence. g: which texel won the nearest-depth search, so a consumer can fetch
79
80
  // the velocity this confidence was computed for from the raw velocity buffer.
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The velocity buffer's format: how each pixel's surface point moved since the last frame, four half floats
3
+ * (`chunk_velocity_texel` makes the texel):
4
+ *
5
+ * - **x, y**: internal pixels from the point's place on last frame's screen to its place on this one;
6
+ * - **z**: the point's view depth now less its view depth then, in world units: negative for a surface coming
7
+ * nearer, zero for one moving across the view at its depth, and zero for the sky;
8
+ * - **w**: zero.
9
+ *
10
+ * Both frames' projections are taken free of the TAA jitter, so a still surface under a still camera holds zero
11
+ * throughout. A delta rather than last frame's depth itself: a half float holds it to a share of the motion, and so
12
+ * holds the depth recovered from it, `depth − z`, to that share of the motion rather than of the depth.
13
+ *
14
+ * @type {GPUTextureFormat}
15
+ */
16
+ export const VELOCITY_FORMAT: GPUTextureFormat;
17
+ //# sourceMappingURL=VELOCITY_BUFFER.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VELOCITY_BUFFER.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/postprocess/velocity/VELOCITY_BUFFER.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,+CAA6C"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The velocity buffer's format: how each pixel's surface point moved since the last frame, four half floats
3
+ * (`chunk_velocity_texel` makes the texel):
4
+ *
5
+ * - **x, y**: internal pixels from the point's place on last frame's screen to its place on this one;
6
+ * - **z**: the point's view depth now less its view depth then, in world units: negative for a surface coming
7
+ * nearer, zero for one moving across the view at its depth, and zero for the sky;
8
+ * - **w**: zero.
9
+ *
10
+ * Both frames' projections are taken free of the TAA jitter, so a still surface under a still camera holds zero
11
+ * throughout. A delta rather than last frame's depth itself: a half float holds it to a share of the motion, and so
12
+ * holds the depth recovered from it, `depth − z`, to that share of the motion rather than of the depth.
13
+ *
14
+ * @type {GPUTextureFormat}
15
+ */
16
+ export const VELOCITY_FORMAT = 'rgba16float';
@@ -0,0 +1,21 @@
1
+ /**
2
+ * A pixel's texel of the velocity buffer (`VELOCITY_FORMAT`), from its surface point now and where that point stood a
3
+ * frame ago:
4
+ *
5
+ * ```wgsl
6
+ * fn velocity_texel(pixel: vec2<f32>, depth: f32, before: vec4<f32>, size: vec2<f32>) -> vec4<f32>
7
+ * ```
8
+ *
9
+ * - `pixel`: the pixel's centre, in the view's internal pixels; `size`: the view's size in them.
10
+ * - `depth`: the point's clip w this frame.
11
+ * - `before`: the point a frame ago, in last frame's clip space.
12
+ *
13
+ * Both clip spaces are the un-jittered projections' (`view_velocity_matrices`). The texel's z is the clip w now less
14
+ * then, which a perspective projection makes the view depth; under an orthographic one, whose w is always one, it is
15
+ * zero.
16
+ *
17
+ * @type {CodeChunk}
18
+ */
19
+ export const chunk_velocity_texel: CodeChunk;
20
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
21
+ //# sourceMappingURL=chunk_velocity_texel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_velocity_texel.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/postprocess/velocity/chunk_velocity_texel.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,mCAFU,SAAS,CAWhB;0BA7BuB,oCAAoC"}
@@ -0,0 +1,30 @@
1
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
2
+
3
+ /**
4
+ * A pixel's texel of the velocity buffer (`VELOCITY_FORMAT`), from its surface point now and where that point stood a
5
+ * frame ago:
6
+ *
7
+ * ```wgsl
8
+ * fn velocity_texel(pixel: vec2<f32>, depth: f32, before: vec4<f32>, size: vec2<f32>) -> vec4<f32>
9
+ * ```
10
+ *
11
+ * - `pixel`: the pixel's centre, in the view's internal pixels; `size`: the view's size in them.
12
+ * - `depth`: the point's clip w this frame.
13
+ * - `before`: the point a frame ago, in last frame's clip space.
14
+ *
15
+ * Both clip spaces are the un-jittered projections' (`view_velocity_matrices`). The texel's z is the clip w now less
16
+ * then, which a perspective projection makes the view depth; under an orthographic one, whose w is always one, it is
17
+ * zero.
18
+ *
19
+ * @type {CodeChunk}
20
+ */
21
+ export const chunk_velocity_texel = CodeChunk.from(
22
+ //language=WGSL
23
+ `
24
+ fn velocity_texel(pixel: vec2<f32>, depth: f32, before: vec4<f32>, size: vec2<f32>) -> vec4<f32> {
25
+ let ndc = before.xy / before.w;
26
+ let previous = vec2<f32>((ndc.x + 1.0) * 0.5 * size.x, (1.0 - ndc.y) * 0.5 * size.y);
27
+
28
+ return vec4<f32>(pixel - previous, depth - before.w, 0.0);
29
+ }
30
+ `);
@@ -27,10 +27,12 @@ export function enquire_per_object_velocity_pipelines(enquiry: PipelineEnquiry):
27
27
  * per-vertex skin deformation (the limb-ghosting case Stage 1
28
28
  * couldn't address) on top of the per-object motion.
29
29
  *
30
- * The skinned and rigid foreground branches both produce
31
- * pixel-space deltas in the same units, so downstream consumers
32
- * (TAA, motion blur) just see velocity — no skinning-awareness
33
- * needed at any layer above this pass.
30
+ * The skinned and rigid foreground branches both produce the
31
+ * velocity buffer's texel (`VELOCITY_FORMAT`: pixel deltas and the
32
+ * view depth moved through), so downstream consumers (TAA, motion
33
+ * blur, the screen probes) just see velocity — no
34
+ * skinning-awareness needed at any layer above this pass. The
35
+ * background's depth delta is zero.
34
36
  *
35
37
  * Un-jittered matrices are CPU-built from
36
38
  * `camera.projection_matrix × camera.view_matrix` — viewport
@@ -51,7 +53,7 @@ export function enquire_per_object_velocity_pipelines(enquiry: PipelineEnquiry):
51
53
  * placeholders and the shader forces the rigid path.
52
54
  * @param {number[]} args.resolution
53
55
  * @param {GPUViewContext} args.view
54
- * @returns {number} FrameGraph handle to the velocity texture (rg16float)
56
+ * @returns {number} FrameGraph handle to the velocity texture (`VELOCITY_FORMAT`)
55
57
  */
56
58
  export function graph_add_per_object_velocity({ graph, texture_depth, texture_visibility, buffer_visible_meshlets, buffer_scene_database, buffer_meshlet_metadata, buffer_meshlet_data, buffer_prev_position_offsets, buffer_prev_positions, skinning_active, resolution, view, }: {
57
59
  graph: FrameGraph;
@@ -1 +1 @@
1
- {"version":3,"file":"graph_add_per_object_velocity.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.js"],"names":[],"mappings":"AA8QA;;;;GAIG;AACH,+DAFW,eAAe,QAIzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH;IAhB4B,KAAK;IACT,aAAa,EAA1B,MAAM;IACO,kBAAkB,EAA/B,MAAM;IACO,uBAAuB,EAApC,MAAM;IACO,qBAAqB,EAAlC,MAAM;IACO,uBAAuB,EAApC,MAAM;IACO,mBAAmB,EAAhC,MAAM;IACO,4BAA4B,EAAzC,MAAM;IACO,qBAAqB,EAAlC,MAAM;IACQ,eAAe,EAA7B,OAAO;IAGQ,UAAU,EAAzB,MAAM,EAAE;IACa,IAAI;IACvB,MAAM,CA+DlB;8BA9VY,OAAO,6CAA6C,EAAE,eAAe"}
1
+ {"version":3,"file":"graph_add_per_object_velocity.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.js"],"names":[],"mappings":"AA8QA;;;;GAIG;AACH,+DAFW,eAAe,QAIzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH;IAhB4B,KAAK;IACT,aAAa,EAA1B,MAAM;IACO,kBAAkB,EAA/B,MAAM;IACO,uBAAuB,EAApC,MAAM;IACO,qBAAqB,EAAlC,MAAM;IACO,uBAAuB,EAApC,MAAM;IACO,mBAAmB,EAAhC,MAAM;IACO,4BAA4B,EAAzC,MAAM;IACO,qBAAqB,EAAlC,MAAM;IACQ,eAAe,EAA7B,OAAO;IAGQ,UAAU,EAAzB,MAAM,EAAE;IACa,IAAI;IACvB,MAAM,CA+DlB;8BA9VY,OAAO,6CAA6C,EAAE,eAAe"}
@@ -30,7 +30,9 @@ import { graph_image_pass } from "../../shader/graph/graph_image_pass.js";
30
30
  import { ImageShader } from "../../shader/ImageShader.js";
31
31
  import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
32
32
  import { ShaderDescriptor } from "../../shader/ShaderDescriptor.js";
33
+ import { chunk_velocity_texel } from "./chunk_velocity_texel.js";
33
34
  import { construct_pixel_reprojection_matrix } from "./construct_pixel_reprojection_matrix.js";
35
+ import { VELOCITY_FORMAT } from "./VELOCITY_BUFFER.js";
34
36
  import { view_velocity_matrices } from "./view_velocity_matrices.js";
35
37
  import {
36
38
  construct_reprojection_matrix_rotation_only,
@@ -92,7 +94,7 @@ fn read_prev_position(base: u32, vertex_index: u32) -> vec3<f32> {
92
94
  @fragment
93
95
  fn main(
94
96
  @builtin(position) coord: vec4<f32>,
95
- ) -> @location(0) vec2<f32> {
97
+ ) -> @location(0) vec4<f32> {
96
98
 
97
99
  let cur_px = coord.xy;
98
100
  let texel = vec2<u32>(cur_px);
@@ -103,12 +105,13 @@ fn main(
103
105
  // Visibility-buffer clears leave VISIBILITY_NONE on sky
104
106
  // pixels, where reverse-Z depth is always 0.0. Passing 0.0
105
107
  // directly avoids a tDepth textureLoad on every background pixel.
108
+ // The sky stands infinitely far, so it has no depth to move through.
106
109
  if visibility_word == VISIBILITY_NONE {
107
110
  let position_previous = v3_matrix4_project(
108
111
  vec3<f32>(cur_px, 0.0),
109
112
  mReprojectionRotation
110
113
  );
111
- return cur_px - position_previous.xy;
114
+ return vec4<f32>(cur_px - position_previous.xy, 0.0, 0.0);
112
115
  }
113
116
 
114
117
  // ── Reconstruct world-space position for this pixel ─────────
@@ -233,15 +236,11 @@ fn main(
233
236
  prev_world = prev_world_h.xyz / prev_world_h.w;
234
237
  }
235
238
 
236
- // ── Project to previous frame, compute pixel delta ──────────
237
- let prev_clip = mViewProjPrevious * vec4<f32>(prev_world, 1.0);
238
- let prev_ndc = prev_clip.xyz / prev_clip.w;
239
- let prev_px = vec2<f32>(
240
- (prev_ndc.x + 1.0) * 0.5 * res.x,
241
- (1.0 - prev_ndc.y) * 0.5 * res.y,
242
- );
243
-
244
- return cur_px - prev_px;
239
+ // ── Project to previous frame: the pixel and depth deltas ───
240
+ //
241
+ // This frame's clip w, the point's view depth, is the reciprocal of
242
+ // the w its unprojection came out with.
243
+ return velocity_texel(cur_px, 1.0 / cur_world_h.w, mViewProjPrevious * vec4<f32>(prev_world, 1.0), res);
245
244
  }
246
245
  `, [
247
246
  chunk_v3_matrix4_project,
@@ -251,6 +250,7 @@ fn main(
251
250
  chunk_read_meshlet_vertex_position,
252
251
  MESHLET_METADATA_STRUCT.declaration_chunk,
253
252
  chunk_visibility_decode,
253
+ chunk_velocity_texel,
254
254
  ]
255
255
  );
256
256
 
@@ -261,7 +261,7 @@ const shader = new ImageShader({
261
261
  body
262
262
  }),
263
263
  targets: [{
264
- format: "rg16float",
264
+ format: VELOCITY_FORMAT,
265
265
  }]
266
266
  });
267
267
 
@@ -300,10 +300,12 @@ export function enquire_per_object_velocity_pipelines(enquiry) {
300
300
  * per-vertex skin deformation (the limb-ghosting case Stage 1
301
301
  * couldn't address) on top of the per-object motion.
302
302
  *
303
- * The skinned and rigid foreground branches both produce
304
- * pixel-space deltas in the same units, so downstream consumers
305
- * (TAA, motion blur) just see velocity — no skinning-awareness
306
- * needed at any layer above this pass.
303
+ * The skinned and rigid foreground branches both produce the
304
+ * velocity buffer's texel (`VELOCITY_FORMAT`: pixel deltas and the
305
+ * view depth moved through), so downstream consumers (TAA, motion
306
+ * blur, the screen probes) just see velocity — no
307
+ * skinning-awareness needed at any layer above this pass. The
308
+ * background's depth delta is zero.
307
309
  *
308
310
  * Un-jittered matrices are CPU-built from
309
311
  * `camera.projection_matrix × camera.view_matrix` — viewport
@@ -324,7 +326,7 @@ export function enquire_per_object_velocity_pipelines(enquiry) {
324
326
  * placeholders and the shader forces the rigid path.
325
327
  * @param {number[]} args.resolution
326
328
  * @param {GPUViewContext} args.view
327
- * @returns {number} FrameGraph handle to the velocity texture (rg16float)
329
+ * @returns {number} FrameGraph handle to the velocity texture (`VELOCITY_FORMAT`)
328
330
  */
329
331
  export function graph_add_per_object_velocity({
330
332
  graph,
@@ -35,3 +35,5 @@ chunk_forward_sample_indirect.add(ShadeIndirectLightingMode.IBL, chunk_forward_s
35
35
  chunk_forward_sample_indirect.add(ShadeIndirectLightingMode.Brick4, chunk_forward_sample_indirect_brick4);
36
36
  chunk_forward_sample_indirect.add(ShadeIndirectLightingMode.LPV, chunk_forward_sample_indirect_environment);
37
37
  chunk_forward_sample_indirect.add(ShadeIndirectLightingMode.ProbeClipmap, chunk_forward_sample_indirect_probe_clipmap);
38
+ // the screen probes light only the deferred opaque surfaces: every other reader takes the world-space probes
39
+ chunk_forward_sample_indirect.add(ShadeIndirectLightingMode.ScreenProbes, chunk_forward_sample_indirect_probe_clipmap);