@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
@@ -0,0 +1,111 @@
1
+ import { CAMERA_UNIFORM_STRUCT } from "../camera/CAMERA_UNIFORM_STRUCT.js";
2
+ import { chunk_mat4_extract_position } from "../shader/chunk/geometry/mat4/chunk_mat4_extract_position.js";
3
+ import { CodeChunk } from "../shader/compiler/CodeChunk.js";
4
+ import { ImageShader } from "../shader/ImageShader.js";
5
+ import { ShaderResourceSetDescriptor } from "../shader/resource/ShaderResourceSetDescriptor.js";
6
+ import { ShaderDescriptor } from "../shader/ShaderDescriptor.js";
7
+ import { u32, vec3f } from "../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
8
+ import { WebGPUStruct } from "../shader/type/WebGPUStruct.js";
9
+ import { ATMOSPHERE_PARAMETERS_STRUCT } from "./ATMOSPHERE_PARAMETERS_STRUCT.js";
10
+ import { chunk_raymarch_sky_scattering } from "./chunk_raymarch_sky_scattering.js";
11
+ import { chunk_sky_irradiance_lut_encode_uv } from "./chunk_sky_irradiance_lut_encode_uv.js";
12
+ import {
13
+ SKY_LUT_MULTISCATTER_RESOURCE,
14
+ SKY_LUT_SAMPLER_RESOURCE,
15
+ SKY_LUT_TRANSMITTANCE_RESOURCE
16
+ } from "./SAMPLER_SKY_LUT.js";
17
+
18
+ export const SKY_VIEW_LUT_WIDTH = 192;
19
+ export const SKY_VIEW_LUT_HEIGHT = 108;
20
+
21
+ export const SKY_VIEW_LUT_SETTINGS_STRUCT = WebGPUStruct.from({
22
+ sun_direction: vec3f,
23
+ resolution_x: u32,
24
+ sun_irradiance: vec3f,
25
+ resolution_y: u32,
26
+ }, "SkyViewLutSettings");
27
+
28
+ const resources = new ShaderResourceSetDescriptor();
29
+
30
+ resources.setImmediate("settings", SKY_VIEW_LUT_SETTINGS_STRUCT);
31
+
32
+ resources.createGroup()
33
+ .addUniform("camera", CAMERA_UNIFORM_STRUCT)
34
+ .addUniform("atmosphere", ATMOSPHERE_PARAMETERS_STRUCT)
35
+ .add(SKY_LUT_TRANSMITTANCE_RESOURCE)
36
+ .add(SKY_LUT_MULTISCATTER_RESOURCE)
37
+ .add(SKY_LUT_SAMPLER_RESOURCE);
38
+
39
+ /**
40
+ * Per-view $192 \times 108$ horizon-warped Sky-View LUT generator (Hillaire 2020, §5.3).
41
+ *
42
+ * Evaluates scattering in the camera's local planet-up frame where `up = +Y` and the sun lies in
43
+ * the `+X/+Y` half-plane, matching {@link chunk_sky_irradiance_lut_encode_uv}.
44
+ *
45
+ * @type {CodeChunk}
46
+ */
47
+ const body = CodeChunk.from(
48
+ //language=WGSL
49
+ `
50
+ @fragment
51
+ fn main(
52
+ @builtin(position) coord: vec4<f32>,
53
+ ) -> @location(0) vec4<f32> {
54
+ let sun_len_sq = dot(settings.sun_direction, settings.sun_direction);
55
+ if (sun_len_sq <= 1e-12 || all(settings.sun_irradiance <= vec3<f32>(0.0))) {
56
+ return vec4<f32>(0.0, 0.0, 0.0, 1.0);
57
+ }
58
+
59
+ let sun_dir_world = settings.sun_direction * inverseSqrt(sun_len_sq);
60
+
61
+ let view_pos = mat4_extract_position(camera.transform);
62
+ let view_rel_world = atmosphere_clamped_observer_relative(atmosphere, view_pos);
63
+ let observer_radius = length(view_rel_world);
64
+ let up_world = view_rel_world / observer_radius;
65
+
66
+ let resolution = vec2<f32>(f32(settings.resolution_x), f32(settings.resolution_y));
67
+ let decoded = sky_view_lut_decode_texel(
68
+ atmosphere.planet_radius,
69
+ observer_radius,
70
+ floor(coord.xy),
71
+ resolution
72
+ );
73
+
74
+ let sun_cos_zenith = clamp(dot(sun_dir_world, up_world), -1.0, 1.0);
75
+ let sun_sin_zenith = sqrt(max(1.0 - sun_cos_zenith * sun_cos_zenith, 0.0));
76
+ let sun_local = vec3<f32>(sun_sin_zenith, sun_cos_zenith, 0.0);
77
+
78
+ let view_rel_local = vec3<f32>(0.0, observer_radius, 0.0);
79
+ let bounds = atmosphere_ray_bounds_for(atmosphere, view_rel_local, decoded.ray_local);
80
+
81
+ let lum = raymarch_sky_scattering(
82
+ atmosphere,
83
+ view_rel_local,
84
+ decoded.ray_local,
85
+ sun_local,
86
+ bounds.t_max,
87
+ decoded.hits_ground && bounds.hits_ground
88
+ );
89
+
90
+ return vec4<f32>(lum * settings.sun_irradiance, 1.0);
91
+ }
92
+ `, [
93
+ chunk_mat4_extract_position,
94
+ chunk_sky_irradiance_lut_encode_uv,
95
+ chunk_raymarch_sky_scattering,
96
+ ]
97
+ );
98
+
99
+ export const shader_sky_view_lut = new ImageShader({
100
+ descriptor: ShaderDescriptor.from({
101
+ label: "Sky / sky-view LUT",
102
+ resources,
103
+ body,
104
+ }),
105
+ targets: [
106
+ {
107
+ label: "sky_view_lut",
108
+ format: "rgba16float",
109
+ }
110
+ ]
111
+ });
@@ -1,5 +1,4 @@
1
1
  /**
2
- * @see https://www.shadertoy.com/view/slSXRW
3
2
  * @type {ImageShader}
4
3
  */
5
4
  export const shader_transmittance_lut: ImageShader;
@@ -1 +1 @@
1
- {"version":3,"file":"shader_transmittance_lut.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/atmosphere/shader_transmittance_lut.js"],"names":[],"mappings":"AAgEA;;;GAGG;AACH,uCAFU,WAAW,CAWlB;4BAtEyB,0BAA0B"}
1
+ {"version":3,"file":"shader_transmittance_lut.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/atmosphere/shader_transmittance_lut.js"],"names":[],"mappings":"AAuDA;;GAEG;AACH,uCAFU,WAAW,CAWlB;4BAhEyB,0BAA0B"}
@@ -1,79 +1,68 @@
1
- import { u32, vec2u } from "../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
2
- import { WebGPUStruct } from "../shader/type/WebGPUStruct.js";
3
- import { ATMOSPHERE_HEIGHT_DECLARATION } from "../shader/chunk/atmosphere/ATMOSPHERE_HEIGHT_DECLARATION.js";
4
- import { chunk_get_sun_transmittance } from "../shader/chunk/atmosphere/chunk_get_sun_transmittance.js";
5
- import { chunk_safe_acos } from "../shader/chunk/math/chunk_safe_acos.js";
6
- import { chunk_sky_lut_texel_to_unit } from "./chunk_sky_lut_texel_to_unit.js";
7
- import { CodeChunk } from "../shader/compiler/CodeChunk.js";
8
- import { ImageShader } from "../shader/ImageShader.js";
9
- import { ShaderResourceSetDescriptor } from "../shader/resource/ShaderResourceSetDescriptor.js";
10
- import { ShaderDescriptor } from "../shader/ShaderDescriptor.js";
11
-
12
- const TRANSMITTANCE_LUT_SETTINGS_STRUCT = WebGPUStruct.from({
13
- // how many ray-marching steps to take per pixel of LUT, more steps = higher accuracy but lower performance
14
- steps: u32,
15
- // size of the target being written, which a fragment shader cannot ask for. Needed to
16
- // know which point of the parameter range each texel stands for -- see
17
- // chunk_sky_lut_texel_to_unit. Pass the dimensions of the texture actually being drawn
18
- // into: a mismatch silently skews the whole LUT.
19
- resolution: vec2u,
20
- });
21
-
22
- const resources = new ShaderResourceSetDescriptor();
23
-
24
- // per-pass, 16 bytes, read-only: immediate data rather than a uniform buffer
25
- resources.setImmediate("settings", TRANSMITTANCE_LUT_SETTINGS_STRUCT);
26
-
27
- /**
28
- * @see https://www.shadertoy.com/view/slSXRW
29
- * @type {CodeChunk}
30
- */
31
- const body = CodeChunk.from(
32
- //language=WGSL
33
- `
34
-
35
- @fragment
36
- fn main(
37
- @builtin(position) coord: vec4<f32>,
38
- ) -> @location(0) vec4<f32> {
39
-
40
- // coord.xy is the fragment centre, so flooring it gives this texel's index. The point of
41
- // each range the texel stands for then comes from sky_lut_texel_to_unit, whose inverse
42
- // sky_lut_uv every lookup goes through -- a generator that skipped it would write a LUT
43
- // addressed half a texel off at both ends.
44
- let unit = sky_lut_texel_to_unit(floor(coord.xy), vec2<f32>(settings.resolution));
45
-
46
- let sunCosTheta = 2.0*unit.x - 1.0;
47
- let sunTheta = safe_acos(sunCosTheta);
48
-
49
- let height = ATMOSPHERE_HEIGHT*unit.y;
50
-
51
- let pos = vec3(0.0, height, 0.0);
52
- let sunDir = normalize(vec3(0.0, sunCosTheta, -sin(sunTheta)));
53
-
54
- return vec4(get_sun_transmittance(pos, sunDir, f32(settings.steps)), 1.0);
55
-
56
- }
57
- `, [
58
- chunk_get_sun_transmittance,
59
- chunk_safe_acos,
60
- chunk_sky_lut_texel_to_unit,
61
- ATMOSPHERE_HEIGHT_DECLARATION,
62
- ]
63
- );
64
-
65
- /**
66
- * @see https://www.shadertoy.com/view/slSXRW
67
- * @type {ImageShader}
68
- */
69
- export const shader_transmittance_lut = new ImageShader({
70
- descriptor: ShaderDescriptor.from({
71
- label: "Sky / transmittance LUT",
72
- resources,
73
- body
74
- }),
75
- targets: [{
76
- format: "rgba16float",
77
- }]
78
- });
79
-
1
+ import { chunk_get_sun_transmittance } from "../shader/chunk/atmosphere/chunk_get_sun_transmittance.js";
2
+ import { chunk_safe_acos } from "../shader/chunk/math/chunk_safe_acos.js";
3
+ import { CodeChunk } from "../shader/compiler/CodeChunk.js";
4
+ import { ImageShader } from "../shader/ImageShader.js";
5
+ import { ShaderResourceSetDescriptor } from "../shader/resource/ShaderResourceSetDescriptor.js";
6
+ import { ShaderDescriptor } from "../shader/ShaderDescriptor.js";
7
+ import { u32, vec2u } from "../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
8
+ import { WebGPUStruct } from "../shader/type/WebGPUStruct.js";
9
+ import { ATMOSPHERE_PARAMETERS_STRUCT } from "./ATMOSPHERE_PARAMETERS_STRUCT.js";
10
+ import { chunk_sky_lut_texel_to_unit } from "./chunk_sky_lut_texel_to_unit.js";
11
+
12
+ const TRANSMITTANCE_LUT_SETTINGS_STRUCT = WebGPUStruct.from({
13
+ steps: u32,
14
+ resolution: vec2u,
15
+ }, "TransmittanceLutSettings");
16
+
17
+ const resources = new ShaderResourceSetDescriptor();
18
+
19
+ resources.setImmediate("settings", TRANSMITTANCE_LUT_SETTINGS_STRUCT);
20
+ resources.createGroup()
21
+ .addUniform("atmosphere", ATMOSPHERE_PARAMETERS_STRUCT);
22
+
23
+ /**
24
+ * Transmittance LUT generator (`256×64` `rgba16float`), parameterised by `(sunCosTheta, altitude)`
25
+ * and driven by the scene's {@link ATMOSPHERE_PARAMETERS_STRUCT} uniform.
26
+ *
27
+ * @see "A Scalable and Production Ready Sky and Atmosphere Rendering Technique", Hillaire (2020)
28
+ * @type {CodeChunk}
29
+ */
30
+ const body = CodeChunk.from(
31
+ //language=WGSL
32
+ `
33
+ @fragment
34
+ fn main(
35
+ @builtin(position) coord: vec4<f32>,
36
+ ) -> @location(0) vec4<f32> {
37
+ let unit = sky_lut_texel_to_unit(floor(coord.xy), vec2<f32>(settings.resolution));
38
+
39
+ let sunCosTheta = 2.0 * unit.x - 1.0;
40
+ let sunTheta = safe_acos(sunCosTheta);
41
+
42
+ let height = atmosphere.atmosphere_height * unit.y;
43
+
44
+ let origin_rel = vec3<f32>(0.0, atmosphere.planet_radius + height, 0.0);
45
+ let sunDir = normalize(vec3<f32>(0.0, sunCosTheta, -sin(sunTheta)));
46
+
47
+ return vec4<f32>(get_sun_transmittance_rel_for(atmosphere, origin_rel, sunDir, f32(settings.steps)), 1.0);
48
+ }
49
+ `, [
50
+ chunk_get_sun_transmittance,
51
+ chunk_safe_acos,
52
+ chunk_sky_lut_texel_to_unit,
53
+ ]
54
+ );
55
+
56
+ /**
57
+ * @type {ImageShader}
58
+ */
59
+ export const shader_transmittance_lut = new ImageShader({
60
+ descriptor: ShaderDescriptor.from({
61
+ label: "Sky / transmittance LUT",
62
+ resources,
63
+ body
64
+ }),
65
+ targets: [{
66
+ format: "rgba16float",
67
+ }]
68
+ });
@@ -1,6 +1,6 @@
1
1
  import { SamplerDescriptor } from "../../descriptor/texture/SamplerDescriptor.js";
2
2
  import { CAMERA_UNIFORM_STRUCT } from "../camera/CAMERA_UNIFORM_STRUCT.js";
3
- import { chunk_sample_environment_color } from "../atmosphere/chunk_sample_environment_color.js";
3
+ import { chunk_sample_environment_color } from "../light/environment/chunk_sample_environment_color.js";
4
4
  import { chunk_uv_to_ndc } from "../shader/chunk/texture/chunk_uv_to_ndc.js";
5
5
  import { CodeChunk } from "../shader/compiler/CodeChunk.js";
6
6
  import { ImageShader } from "../shader/ImageShader.js";
@@ -0,0 +1,5 @@
1
+ export const SKY_BACKGROUND_SETTINGS_STRUCT: WebGPUStruct;
2
+ export const shader_background_sky: ImageShader;
3
+ import { WebGPUStruct } from "../shader/type/WebGPUStruct.js";
4
+ import { ImageShader } from "../shader/ImageShader.js";
5
+ //# sourceMappingURL=shader_background_sky.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shader_background_sky.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/deferred/shader_background_sky.js"],"names":[],"mappings":"AAeA,0DAK4B;AA6F5B,gDAgBG;6BApH0B,gCAAgC;4BAJjC,0BAA0B"}
@@ -0,0 +1,130 @@
1
+ import { ATMOSPHERE_PARAMETERS_STRUCT } from "../atmosphere/ATMOSPHERE_PARAMETERS_STRUCT.js";
2
+ import { chunk_sample_transmittance_lut_params_for } from "../atmosphere/chunk_sample_transmittance_lut.js";
3
+ import { chunk_sky_irradiance_lut_encode_uv } from "../atmosphere/chunk_sky_irradiance_lut_encode_uv.js";
4
+ import { SKY_LUT_SAMPLER_RESOURCE, SKY_LUT_TRANSMITTANCE_RESOURCE } from "../atmosphere/SAMPLER_SKY_LUT.js";
5
+ import { CAMERA_UNIFORM_STRUCT } from "../camera/CAMERA_UNIFORM_STRUCT.js";
6
+ import { chunk_mat4_extract_position } from "../shader/chunk/geometry/mat4/chunk_mat4_extract_position.js";
7
+ import { PI_DECLARATION } from "../shader/chunk/math/PI_DECLARATION.js";
8
+ import { chunk_uv_to_ndc } from "../shader/chunk/texture/chunk_uv_to_ndc.js";
9
+ import { CodeChunk } from "../shader/compiler/CodeChunk.js";
10
+ import { ImageShader } from "../shader/ImageShader.js";
11
+ import { ShaderResourceSetDescriptor } from "../shader/resource/ShaderResourceSetDescriptor.js";
12
+ import { ShaderDescriptor } from "../shader/ShaderDescriptor.js";
13
+ import { f32, u32, vec3f } from "../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
14
+ import { WebGPUStruct } from "../shader/type/WebGPUStruct.js";
15
+
16
+ export const SKY_BACKGROUND_SETTINGS_STRUCT = WebGPUStruct.from({
17
+ sun_direction: vec3f,
18
+ sun_disk_radius: f32,
19
+ sun_irradiance: vec3f,
20
+ sun_has_disc: u32,
21
+ }, "SkyBackgroundSettings");
22
+
23
+ const resources = new ShaderResourceSetDescriptor();
24
+
25
+ resources.setImmediate("settings", SKY_BACKGROUND_SETTINGS_STRUCT);
26
+
27
+ resources.createGroup()
28
+ .addUniform("camera", CAMERA_UNIFORM_STRUCT)
29
+ .addUniform("atmosphere", ATMOSPHERE_PARAMETERS_STRUCT)
30
+ .addTexture("tSkyViewLut", "float")
31
+ .add(SKY_LUT_TRANSMITTANCE_RESOURCE)
32
+ .add(SKY_LUT_SAMPLER_RESOURCE);
33
+
34
+ /**
35
+ * Full-screen atmospheric sky background shader sampling Hillaire's $192 \times 108$ Sky-View LUT
36
+ * and compositing a transmittance-attenuated, limb-darkened solar disc when the ray misses the
37
+ * planet sphere.
38
+ *
39
+ * @type {CodeChunk}
40
+ */
41
+ const body = CodeChunk.from(
42
+ //language=WGSL
43
+ `
44
+ // Clamp pre-bloom f16 sky-disc radiance well inside rgba16float range (max 65504) to prevent Inf/NaN.
45
+ const MAX_SOLAR_DISC_RADIANCE = 16384.0;
46
+
47
+ @fragment
48
+ fn main(
49
+ @builtin(position) coord: vec4<f32>,
50
+ @location(0) uv: vec2<f32>,
51
+ ) -> @location(0) vec4<f32> {
52
+ let clip_pos = vec4<f32>(uv_to_ndc(uv), 0.0, 1.0);
53
+ let world_dir_h = camera.view_projection_matrix_inverse * clip_pos;
54
+ let view_direction = normalize(world_dir_h.xyz);
55
+ let view_position = mat4_extract_position(camera.transform);
56
+
57
+ let sun_len_sq = dot(settings.sun_direction, settings.sun_direction);
58
+ if (sun_len_sq <= 1e-12 || all(settings.sun_irradiance <= vec3<f32>(0.0))) {
59
+ return vec4<f32>(0.0, 0.0, 0.0, 1.0);
60
+ }
61
+ let sun_dir = settings.sun_direction * inverseSqrt(sun_len_sq);
62
+
63
+ let lut_res = vec2<f32>(textureDimensions(tSkyViewLut));
64
+ let sky_uv = sky_view_lut_uv_for(atmosphere, view_position, view_direction, sun_dir, lut_res);
65
+ var result = textureSampleLevel(tSkyViewLut, sSkyLut, sky_uv, 0.0).rgb;
66
+
67
+ if (settings.sun_has_disc != 0u && settings.sun_disk_radius > 0.0) {
68
+ let view_rel = atmosphere_clamped_observer_relative(atmosphere, view_position);
69
+ let bounds = atmosphere_ray_bounds_for(atmosphere, view_rel, view_direction);
70
+
71
+ if (!bounds.hits_ground) {
72
+ let angular_radius = max(settings.sun_disk_radius, 0.0045);
73
+ let cos_outer = cos(angular_radius * 1.06);
74
+ let cos_inner = cos(angular_radius * 0.88);
75
+ let cos_angle = dot(view_direction, sun_dir);
76
+ let disc_mask = smoothstep(cos_outer, cos_inner, cos_angle);
77
+
78
+ if (disc_mask > 0.0) {
79
+ let cos_radius = cos(angular_radius);
80
+ let mu = sqrt(saturate((cos_angle - cos_outer) / max(1.0 - cos_outer, 1e-6)));
81
+ // Eddington solar limb darkening (mean over disc = 0.8)
82
+ let limb = (0.4 + 0.6 * mu) * (1.0 / 0.8);
83
+ let solid_angle = max(2.0 * PI * (1.0 - cos_radius), 1e-6);
84
+
85
+ let observer_radius = length(view_rel);
86
+ let up = view_rel / observer_radius;
87
+ let altitude = observer_radius - atmosphere.planet_radius;
88
+ let sun_transmittance = sample_transmittance_lut_params_for(
89
+ atmosphere,
90
+ altitude,
91
+ dot(view_direction, up)
92
+ );
93
+
94
+ let raw_disc_radiance = (settings.sun_irradiance / solid_angle) * limb * sun_transmittance;
95
+ let max_channel = max(max(raw_disc_radiance.r, raw_disc_radiance.g), max(raw_disc_radiance.b, 1e-6));
96
+ let disc_radiance = raw_disc_radiance * min(1.0, MAX_SOLAR_DISC_RADIANCE / max_channel);
97
+
98
+ result += disc_radiance * disc_mask;
99
+ }
100
+ }
101
+ }
102
+
103
+ return vec4<f32>(result, 1.0);
104
+ }
105
+ `, [
106
+ PI_DECLARATION,
107
+ chunk_uv_to_ndc,
108
+ chunk_mat4_extract_position,
109
+ chunk_sky_irradiance_lut_encode_uv,
110
+ chunk_sample_transmittance_lut_params_for,
111
+ ]
112
+ );
113
+
114
+ export const shader_background_sky = ImageShader.from({
115
+ descriptor: ShaderDescriptor.from({
116
+ label: "Scene Background / Atmosphere Sky",
117
+ resources,
118
+ body
119
+ }),
120
+ depthStencil: {
121
+ format: "depth32float",
122
+ depthCompare: "equal"
123
+ },
124
+ targets: [
125
+ {
126
+ label: "shaded",
127
+ format: "rgba16float"
128
+ }
129
+ ]
130
+ });
@@ -9,6 +9,10 @@
9
9
  * - `zone_bounds`: `shadows_max`, `highlights_min`, `highlights_max`.
10
10
  * - `curve_counts`: the keys of the hue, saturation and lightness curves. They follow the uniform in `grade_keys`, in
11
11
  * that order.
12
+ * - `luma_curve_counts`: the keys of the red, green, blue and all-channel saturation-against-luma curves. They follow
13
+ * the hue curves' keys in `grade_keys`, in that order.
14
+ * - `luma_gain_counts`: the keys of the red, green and blue gain-against-luma curves and the exposure-against-luma
15
+ * curve. They follow the saturation-against-luma curves' keys in `grade_keys`, in that order.
12
16
  */
13
17
  export const COLOR_GRADE_STRUCT: WebGPUStruct;
14
18
  /**
@@ -64,8 +68,20 @@ export class ColorGradeZone {
64
68
  * 2. **Primaries**, Unreal's `ColorCorrectAll` in AP1: saturation, contrast, gamma, gain and offset for {@link global},
65
69
  * {@link shadows}, {@link midtones} and {@link highlights}, the zones blended by AP1 luma between
66
70
  * {@link shadows_max}, {@link highlights_min} and {@link highlights_max}. Values from an Unreal project's post-process
67
- * settings give the same result. The colour is clamped at zero in Rec.709 after it, as the operator takes it.
68
- * 3. **Hue curves**, in OkLCh. Each curve's time is the colour's OkLCh hue in degrees, 0 to 360, and is evaluated as
71
+ * settings give the same result.
72
+ * 3. **Gain against luma**, in AP1 after the primaries: each channel multiplied by its gain at the colour's AP1 luma's
73
+ * stops from middle grey — {@link luma_gain_red}, {@link luma_gain_green}, {@link luma_gain_blue} — and every channel
74
+ * by 2 to the power of {@link luma_exposure} there. Grading by tonal range at any luma, with any blend between ranges:
75
+ * a range that fades in and out over spans of stops, as a smoothstep does, is a cubic between its edges, so ranges
76
+ * sum exactly into curves keyed at their edges. A curve with no keys is a gain of 1, or an exposure of 0. Clamped at
77
+ * zero.
78
+ * 4. **Saturation against luma**, after the gain against luma: each channel drawn away from the colour's AP1 luma by its
79
+ * factor at that luma's stops from middle grey, `log2(luma / 0.18)`: {@link luma_saturation} times the channel's
80
+ * own curve — {@link luma_saturation_red}, {@link luma_saturation_green}, {@link luma_saturation_blue}. Unreal's
81
+ * saturation and per-channel saturation, varying across the tonal range. Each curve is evaluated as
82
+ * {@link AnimationCurve#evaluate} would and holds its end keys' values beyond them; a curve with no keys is a factor
83
+ * of 1, and a colour with no luma is left as it is. Clamped at zero, as the primaries' saturation is. The colour is clamped at zero in Rec.709 after it, as the operator takes it.
84
+ * 5. **Hue curves**, in OkLCh. Each curve's time is the colour's OkLCh hue in degrees, 0 to 360, and is evaluated as
69
85
  * {@link AnimationCurve#evaluate} would; a curve with no keys does nothing. The curve holds its end keys' values
70
86
  * outside them, so for a seamless circle key 0 and 360 with the same value and tangent.
71
87
  * - {@link hue_shift}: degrees added to the hue.
@@ -143,8 +159,61 @@ export class ColorGrade {
143
159
  */
144
160
  readonly hue_lightness: AnimationCurve;
145
161
  /**
146
- * The grade as the bake reads it: {@link COLOR_GRADE_STRUCT}, then the three curves' keys, each
147
- * {@link COLOR_GRADE_KEY_FLOATS} floats, with room for one key when there are none. The array is reused while the
162
+ * Saturation of every channel against the colour's AP1 luma in stops from middle grey: 1 leaves it, 0 draws it to
163
+ * the luma. Each channel's own curve multiplies it.
164
+ * @readonly
165
+ * @type {AnimationCurve}
166
+ */
167
+ readonly luma_saturation: AnimationCurve;
168
+ /**
169
+ * Saturation of the red channel against the colour's AP1 luma in stops from middle grey, times
170
+ * {@link luma_saturation}.
171
+ * @readonly
172
+ * @type {AnimationCurve}
173
+ */
174
+ readonly luma_saturation_red: AnimationCurve;
175
+ /**
176
+ * Saturation of the green channel against the colour's AP1 luma in stops from middle grey, times
177
+ * {@link luma_saturation}.
178
+ * @readonly
179
+ * @type {AnimationCurve}
180
+ */
181
+ readonly luma_saturation_green: AnimationCurve;
182
+ /**
183
+ * Saturation of the blue channel against the colour's AP1 luma in stops from middle grey, times
184
+ * {@link luma_saturation}.
185
+ * @readonly
186
+ * @type {AnimationCurve}
187
+ */
188
+ readonly luma_saturation_blue: AnimationCurve;
189
+ /**
190
+ * Gain of the red channel against the colour's AP1 luma in stops from middle grey: 1 leaves it.
191
+ * @readonly
192
+ * @type {AnimationCurve}
193
+ */
194
+ readonly luma_gain_red: AnimationCurve;
195
+ /**
196
+ * Gain of the green channel against the colour's AP1 luma in stops from middle grey: 1 leaves it.
197
+ * @readonly
198
+ * @type {AnimationCurve}
199
+ */
200
+ readonly luma_gain_green: AnimationCurve;
201
+ /**
202
+ * Gain of the blue channel against the colour's AP1 luma in stops from middle grey: 1 leaves it.
203
+ * @readonly
204
+ * @type {AnimationCurve}
205
+ */
206
+ readonly luma_gain_blue: AnimationCurve;
207
+ /**
208
+ * Exposure of every channel against the colour's AP1 luma in stops from middle grey, in stops: 0 leaves it.
209
+ * @readonly
210
+ * @type {AnimationCurve}
211
+ */
212
+ readonly luma_exposure: AnimationCurve;
213
+ /**
214
+ * The grade as the bake reads it: {@link COLOR_GRADE_STRUCT}, then the three hue curves' keys, the four
215
+ * saturation-against-luma curves' keys (red, green, blue, all) and the four gain-against-luma curves' keys (red,
216
+ * green, blue, exposure), each {@link COLOR_GRADE_KEY_FLOATS} floats, with room for one key when there are none. The array is reused while the
148
217
  * key count stays the same.
149
218
  *
150
219
  * @returns {Float32Array}
@@ -1 +1 @@
1
- {"version":3,"file":"ColorGrade.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/deferred/tonemap/ColorGrade.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;GAWG;AACH,8CAyBG;AAEH;;;GAGG;AACH,wCAFU,MAAM,CAE4B;AAE5C;;;GAGG;AACH,qCAFU,MAAM,CAEwB;AAExC;;;GAGG;AACH;IACI;;;;OAIG;IACH,qBAFU,OAAO,CAEoB;IAErC;;;;OAIG;IACH,mBAFU,OAAO,CAEkB;IAEnC;;;;OAIG;IACH,gBAFU,OAAO,CAEe;IAEhC;;;OAGG;IACH,eAFU,OAAO,CAEc;IAE/B;;;;OAIG;IACH,iBAFU,OAAO,CAEgB;CACpC;AAwED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;IACI;;;OAGG;IACH,mBAFU,MAAM,CAEsC;IAEtD;;;OAGG;IACH,YAFU,MAAM,CAEwB;IAExC;;;;OAIG;IACH,iBAFU,cAAc,CAEM;IAE9B;;;OAGG;IACH,kBAFU,cAAc,CAEO;IAE/B;;;OAGG;IACH,mBAFU,cAAc,CAEQ;IAEhC;;;OAGG;IACH,qBAFU,cAAc,CAEU;IAElC;;;OAGG;IACH,aAFU,MAAM,CAEG;IAEnB;;;OAGG;IACH,gBAFU,MAAM,CAEK;IAErB;;;OAGG;IACH,gBAFU,MAAM,CAEG;IAEnB;;;;OAIG;IACH,oBAFU,cAAc,CAES;IAEjC;;;;OAIG;IACH,yBAFU,cAAc,CAEc;IAEtC;;;;OAIG;IACH,wBAFU,cAAc,CAEa;IAarC;;;;;;OAMG;IACH,QAFa,YAAY,CAqDxB;;CACJ;6BA5U4B,mCAAmC;wBAHxC,kCAAkC;+BAC3B,sDAAsD"}
1
+ {"version":3,"file":"ColorGrade.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/deferred/tonemap/ColorGrade.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;GAeG;AACH,8CA2BG;AAEH;;;GAGG;AACH,wCAFU,MAAM,CAE4B;AAE5C;;;GAGG;AACH,qCAFU,MAAM,CAEwB;AAExC;;;GAGG;AACH;IACI;;;;OAIG;IACH,qBAFU,OAAO,CAEoB;IAErC;;;;OAIG;IACH,mBAFU,OAAO,CAEkB;IAEnC;;;;OAIG;IACH,gBAFU,OAAO,CAEe;IAEhC;;;OAGG;IACH,eAFU,OAAO,CAEc;IAE/B;;;;OAIG;IACH,iBAFU,OAAO,CAEgB;CACpC;AAwED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH;IACI;;;OAGG;IACH,mBAFU,MAAM,CAEsC;IAEtD;;;OAGG;IACH,YAFU,MAAM,CAEwB;IAExC;;;;OAIG;IACH,iBAFU,cAAc,CAEM;IAE9B;;;OAGG;IACH,kBAFU,cAAc,CAEO;IAE/B;;;OAGG;IACH,mBAFU,cAAc,CAEQ;IAEhC;;;OAGG;IACH,qBAFU,cAAc,CAEU;IAElC;;;OAGG;IACH,aAFU,MAAM,CAEG;IAEnB;;;OAGG;IACH,gBAFU,MAAM,CAEK;IAErB;;;OAGG;IACH,gBAFU,MAAM,CAEG;IAEnB;;;;OAIG;IACH,oBAFU,cAAc,CAES;IAEjC;;;;OAIG;IACH,yBAFU,cAAc,CAEc;IAEtC;;;;OAIG;IACH,wBAFU,cAAc,CAEa;IAErC;;;;;OAKG;IACH,0BAFU,cAAc,CAEe;IAEvC;;;;;OAKG;IACH,8BAFU,cAAc,CAEmB;IAE3C;;;;;OAKG;IACH,gCAFU,cAAc,CAEqB;IAE7C;;;;;OAKG;IACH,+BAFU,cAAc,CAEoB;IAE5C;;;;OAIG;IACH,wBAFU,cAAc,CAEa;IAErC;;;;OAIG;IACH,0BAFU,cAAc,CAEe;IAEvC;;;;OAIG;IACH,yBAFU,cAAc,CAEc;IAEtC;;;;OAIG;IACH,wBAFU,cAAc,CAEa;IAarC;;;;;;;OAOG;IACH,QAFa,YAAY,CAgFxB;;CACJ;6BAtb4B,mCAAmC;wBAHxC,kCAAkC;+BAC3B,sDAAsD"}