@woosh/meep-engine 3.67.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 (311) 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/shade/playground/probe_clipmap/index.html +43 -0
  7. package/src/shade/playground/probe_clipmap/main.d.ts.map +1 -1
  8. package/src/shade/playground/probe_clipmap/main.js +29 -0
  9. package/src/shade/renderer/Renderer.d.ts +7 -0
  10. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  11. package/src/shade/renderer/Renderer.js +213 -15
  12. package/src/shade/renderer/ShadeIndirectLightingMode.d.ts +1 -0
  13. package/src/shade/renderer/ShadeIndirectLightingMode.js +9 -0
  14. package/src/shade/renderer/atmosphere/ATMOSPHERE_PARAMETERS_STRUCT.d.ts +22 -0
  15. package/src/shade/renderer/atmosphere/ATMOSPHERE_PARAMETERS_STRUCT.d.ts.map +1 -0
  16. package/src/shade/renderer/atmosphere/ATMOSPHERE_PARAMETERS_STRUCT.js +160 -0
  17. package/src/shade/renderer/atmosphere/ATMOSPHERE_UNIT_SCALE.d.ts +45 -0
  18. package/src/shade/renderer/atmosphere/ATMOSPHERE_UNIT_SCALE.d.ts.map +1 -0
  19. package/src/shade/renderer/atmosphere/ATMOSPHERE_UNIT_SCALE.js +57 -0
  20. package/src/shade/renderer/atmosphere/GPUSky.d.ts +23 -8
  21. package/src/shade/renderer/atmosphere/GPUSky.d.ts.map +1 -1
  22. package/src/shade/renderer/atmosphere/GPUSky.js +91 -34
  23. package/src/shade/renderer/atmosphere/SAMPLER_SKY_LUT.d.ts +17 -0
  24. package/src/shade/renderer/atmosphere/SAMPLER_SKY_LUT.d.ts.map +1 -1
  25. package/src/shade/renderer/atmosphere/SAMPLER_SKY_LUT.js +55 -25
  26. package/src/shade/renderer/atmosphere/SceneAtmosphere.d.ts +164 -0
  27. package/src/shade/renderer/atmosphere/SceneAtmosphere.d.ts.map +1 -0
  28. package/src/shade/renderer/atmosphere/SceneAtmosphere.js +308 -0
  29. package/src/shade/renderer/atmosphere/chunk_get_multiscatter_values.d.ts +3 -12
  30. package/src/shade/renderer/atmosphere/chunk_get_multiscatter_values.d.ts.map +1 -1
  31. package/src/shade/renderer/atmosphere/chunk_get_multiscatter_values.js +52 -89
  32. package/src/shade/renderer/atmosphere/chunk_raymarch_sky_scattering.d.ts +14 -0
  33. package/src/shade/renderer/atmosphere/chunk_raymarch_sky_scattering.d.ts.map +1 -0
  34. package/src/shade/renderer/atmosphere/chunk_raymarch_sky_scattering.js +103 -0
  35. package/src/shade/renderer/atmosphere/chunk_sample_multiscatter_lut.d.ts +10 -4
  36. package/src/shade/renderer/atmosphere/chunk_sample_multiscatter_lut.d.ts.map +1 -1
  37. package/src/shade/renderer/atmosphere/chunk_sample_multiscatter_lut.js +95 -57
  38. package/src/shade/renderer/atmosphere/chunk_sample_transmittance_lut.d.ts +10 -14
  39. package/src/shade/renderer/atmosphere/chunk_sample_transmittance_lut.d.ts.map +1 -1
  40. package/src/shade/renderer/atmosphere/chunk_sample_transmittance_lut.js +97 -69
  41. package/src/shade/renderer/atmosphere/chunk_sky_irradiance_lut_encode_uv.d.ts +17 -0
  42. package/src/shade/renderer/atmosphere/chunk_sky_irradiance_lut_encode_uv.d.ts.map +1 -1
  43. package/src/shade/renderer/atmosphere/chunk_sky_irradiance_lut_encode_uv.js +117 -48
  44. package/src/shade/renderer/atmosphere/chunk_sky_lut_compute_uv.d.ts +8 -0
  45. package/src/shade/renderer/atmosphere/chunk_sky_lut_compute_uv.d.ts.map +1 -1
  46. package/src/shade/renderer/atmosphere/chunk_sky_lut_compute_uv.js +65 -35
  47. package/src/shade/renderer/atmosphere/compute_mie_absorption.d.ts +2 -1
  48. package/src/shade/renderer/atmosphere/compute_mie_absorption.d.ts.map +1 -1
  49. package/src/shade/renderer/atmosphere/compute_mie_absorption.js +6 -6
  50. package/src/shade/renderer/atmosphere/resolve_atmosphere_sun.d.ts +41 -0
  51. package/src/shade/renderer/atmosphere/resolve_atmosphere_sun.d.ts.map +1 -0
  52. package/src/shade/renderer/atmosphere/resolve_atmosphere_sun.js +123 -0
  53. package/src/shade/renderer/atmosphere/shader_multiscatter_lut.d.ts.map +1 -1
  54. package/src/shade/renderer/atmosphere/shader_multiscatter_lut.js +21 -64
  55. package/src/shade/renderer/atmosphere/shader_sky_irradiance_lut.d.ts +6 -2
  56. package/src/shade/renderer/atmosphere/shader_sky_irradiance_lut.d.ts.map +1 -1
  57. package/src/shade/renderer/atmosphere/shader_sky_irradiance_lut.js +55 -179
  58. package/src/shade/renderer/atmosphere/shader_sky_view_lut.d.ts +7 -0
  59. package/src/shade/renderer/atmosphere/shader_sky_view_lut.d.ts.map +1 -0
  60. package/src/shade/renderer/atmosphere/shader_sky_view_lut.js +111 -0
  61. package/src/shade/renderer/atmosphere/shader_transmittance_lut.d.ts +0 -1
  62. package/src/shade/renderer/atmosphere/shader_transmittance_lut.d.ts.map +1 -1
  63. package/src/shade/renderer/atmosphere/shader_transmittance_lut.js +68 -79
  64. package/src/shade/renderer/deferred/shader_background.js +1 -1
  65. package/src/shade/renderer/deferred/shader_background_sky.d.ts +5 -0
  66. package/src/shade/renderer/deferred/shader_background_sky.d.ts.map +1 -0
  67. package/src/shade/renderer/deferred/shader_background_sky.js +130 -0
  68. package/src/shade/renderer/deferred/tonemap/chunk_tonemap_purkinje.d.ts +2 -1
  69. package/src/shade/renderer/deferred/tonemap/chunk_tonemap_purkinje.d.ts.map +1 -1
  70. package/src/shade/renderer/deferred/tonemap/chunk_tonemap_purkinje.js +6 -2
  71. package/src/shade/renderer/extension/ViewTextures.d.ts +3 -2
  72. package/src/shade/renderer/extension/ViewTextures.d.ts.map +1 -1
  73. package/src/shade/renderer/extension/ViewTextures.js +3 -2
  74. package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
  75. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
  76. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +6 -6
  77. package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
  78. package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
  79. package/src/shade/renderer/global_illumination/probe/octahedral/shader_lpv_build_gbuffer.js +1 -1
  80. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +20 -1
  81. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts.map +1 -1
  82. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.js +29 -0
  83. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_hit_light.d.ts +47 -0
  84. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_hit_light.d.ts.map +1 -0
  85. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_hit_light.js +246 -0
  86. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.d.ts +4 -15
  87. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.d.ts.map +1 -1
  88. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.js +8 -148
  89. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.d.ts +4 -9
  90. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.d.ts.map +1 -1
  91. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.js +9 -58
  92. package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.d.ts +142 -0
  93. package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.d.ts.map +1 -0
  94. package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.js +938 -0
  95. package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.d.ts +192 -0
  96. package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.d.ts.map +1 -0
  97. package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.js +231 -0
  98. package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeDebugView.d.ts +11 -0
  99. package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeDebugView.d.ts.map +1 -0
  100. package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeDebugView.js +25 -0
  101. package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.d.ts +110 -0
  102. package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.d.ts.map +1 -0
  103. package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.js +197 -0
  104. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe.d.ts +150 -0
  105. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe.d.ts.map +1 -0
  106. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe.js +408 -0
  107. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_brdf_density.d.ts +23 -0
  108. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_brdf_density.d.ts.map +1 -0
  109. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_brdf_density.js +63 -0
  110. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_brick_origin.d.ts +24 -0
  111. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_brick_origin.d.ts.map +1 -0
  112. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_brick_origin.js +61 -0
  113. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_interpolate.d.ts +39 -0
  114. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_interpolate.d.ts.map +1 -0
  115. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_interpolate.js +126 -0
  116. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_lighting_history.d.ts +21 -0
  117. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_lighting_history.d.ts.map +1 -0
  118. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_lighting_history.js +74 -0
  119. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_march_distance.d.ts +20 -0
  120. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_march_distance.d.ts.map +1 -0
  121. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_march_distance.js +26 -0
  122. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_ray_sort.d.ts +24 -0
  123. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_ray_sort.d.ts.map +1 -0
  124. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_ray_sort.js +57 -0
  125. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_screen_march.d.ts +22 -0
  126. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_screen_march.d.ts.map +1 -0
  127. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_screen_march.js +53 -0
  128. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_surface.d.ts +62 -0
  129. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_surface.d.ts.map +1 -0
  130. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_surface.js +156 -0
  131. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_workgroup_sum.d.ts +18 -0
  132. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_workgroup_sum.d.ts.map +1 -0
  133. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_workgroup_sum.js +50 -0
  134. package/src/shade/renderer/global_illumination/screen_probe/graph_screen_probe_debug_view.d.ts +21 -0
  135. package/src/shade/renderer/global_illumination/screen_probe/graph_screen_probe_debug_view.d.ts.map +1 -0
  136. package/src/shade/renderer/global_illumination/screen_probe/graph_screen_probe_debug_view.js +54 -0
  137. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_brick.d.ts +67 -0
  138. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_brick.d.ts.map +1 -0
  139. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_brick.js +509 -0
  140. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_debug.d.ts +20 -0
  141. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_debug.d.ts.map +1 -0
  142. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_debug.js +128 -0
  143. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.d.ts +62 -0
  144. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.d.ts.map +1 -0
  145. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.js +478 -0
  146. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_importance.d.ts +69 -0
  147. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_importance.d.ts.map +1 -0
  148. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_importance.js +457 -0
  149. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_indirect_lighting.d.ts +27 -0
  150. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_indirect_lighting.d.ts.map +1 -0
  151. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_indirect_lighting.js +219 -0
  152. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_pick.d.ts +22 -0
  153. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_pick.d.ts.map +1 -0
  154. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_pick.js +151 -0
  155. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_place.d.ts +66 -0
  156. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_place.d.ts.map +1 -0
  157. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_place.js +301 -0
  158. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.d.ts +59 -0
  159. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.d.ts.map +1 -0
  160. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.js +364 -0
  161. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_trace_screen.d.ts +40 -0
  162. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_trace_screen.d.ts.map +1 -0
  163. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_trace_screen.js +275 -0
  164. package/src/shade/renderer/grass/blade/GPUGrassBlades.d.ts.map +1 -1
  165. package/src/shade/renderer/grass/blade/GPUGrassBlades.js +17 -2
  166. package/src/shade/renderer/grass/blade/grass_blade_resolve.d.ts +18 -8
  167. package/src/shade/renderer/grass/blade/grass_blade_resolve.d.ts.map +1 -1
  168. package/src/shade/renderer/grass/blade/grass_blade_resolve.js +114 -32
  169. package/src/shade/renderer/light/GPULightCollection.d.ts +1 -1
  170. package/src/shade/renderer/light/GPULightCollection.d.ts.map +1 -1
  171. package/src/shade/renderer/light/GPULightCollection.js +213 -80
  172. package/src/shade/renderer/{atmosphere → light/environment}/chunk_sample_environment_color.d.ts +1 -2
  173. package/src/shade/renderer/light/environment/chunk_sample_environment_color.d.ts.map +1 -0
  174. package/src/shade/renderer/{atmosphere → light/environment}/chunk_sample_environment_color.js +3 -4
  175. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  176. package/src/shade/renderer/path_tracer/shader/chunk_render_trace_path.js +1 -1
  177. package/src/shade/renderer/postprocess/denoise/debug/graph_pass_debug_reprojection.js +1 -1
  178. package/src/shade/renderer/postprocess/motion_blur/MotionBlur.d.ts +1 -1
  179. package/src/shade/renderer/postprocess/motion_blur/MotionBlur.js +1 -1
  180. package/src/shade/renderer/postprocess/motion_blur/graph_postprocess_motion_blur.d.ts +1 -1
  181. package/src/shade/renderer/postprocess/motion_blur/graph_postprocess_motion_blur.js +1 -1
  182. package/src/shade/renderer/postprocess/motion_blur/shader_motion_blur_reconstruct.js +1 -1
  183. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  184. package/src/shade/renderer/postprocess/ssr/resolve/chunk_ssr_add_hit_irradiance.js +2 -0
  185. package/src/shade/renderer/postprocess/ssr/resolve/chunk_ssr_sample_radiance.js +2 -0
  186. package/src/shade/renderer/postprocess/taa/chunk_fsr2_compute_depth_clip.d.ts +6 -0
  187. package/src/shade/renderer/postprocess/taa/chunk_fsr2_compute_depth_clip.d.ts.map +1 -1
  188. package/src/shade/renderer/postprocess/taa/chunk_fsr2_compute_depth_clip.js +9 -1
  189. package/src/shade/renderer/postprocess/taa/shader_depth_occlusion_clip.d.ts.map +1 -1
  190. package/src/shade/renderer/postprocess/taa/shader_depth_occlusion_clip.js +4 -3
  191. package/src/shade/renderer/postprocess/velocity/VELOCITY_BUFFER.d.ts +17 -0
  192. package/src/shade/renderer/postprocess/velocity/VELOCITY_BUFFER.d.ts.map +1 -0
  193. package/src/shade/renderer/postprocess/velocity/VELOCITY_BUFFER.js +16 -0
  194. package/src/shade/renderer/postprocess/velocity/chunk_velocity_texel.d.ts +21 -0
  195. package/src/shade/renderer/postprocess/velocity/chunk_velocity_texel.d.ts.map +1 -0
  196. package/src/shade/renderer/postprocess/velocity/chunk_velocity_texel.js +30 -0
  197. package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.d.ts +7 -5
  198. package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.d.ts.map +1 -1
  199. package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.js +19 -17
  200. package/src/shade/renderer/rasterize/forward/chunk_forward_sample_indirect.js +2 -0
  201. package/src/shade/renderer/scene/GPUSceneContext.d.ts.map +1 -1
  202. package/src/shade/renderer/scene/GPUSceneContext.js +2 -1
  203. package/src/shade/renderer/scene/Scene.d.ts +9 -2
  204. package/src/shade/renderer/scene/Scene.d.ts.map +1 -1
  205. package/src/shade/renderer/scene/Scene.js +10 -2
  206. package/src/shade/renderer/shader/ImageShader.d.ts +24 -12
  207. package/src/shade/renderer/shader/ImageShader.d.ts.map +1 -1
  208. package/src/shade/renderer/shader/ImageShader.js +11 -8
  209. package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_HEIGHT_DECLARATION.d.ts +3 -1
  210. package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_HEIGHT_DECLARATION.d.ts.map +1 -1
  211. package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_HEIGHT_DECLARATION.js +11 -3
  212. package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_RADII_DECLARATION.d.ts +2 -11
  213. package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_RADII_DECLARATION.d.ts.map +1 -1
  214. package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_RADII_DECLARATION.js +23 -32
  215. package/src/shade/renderer/shader/chunk/atmosphere/PLANET_RADIUS_DECLARATION.d.ts +6 -0
  216. package/src/shade/renderer/shader/chunk/atmosphere/PLANET_RADIUS_DECLARATION.d.ts.map +1 -1
  217. package/src/shade/renderer/shader/chunk/atmosphere/PLANET_RADIUS_DECLARATION.js +14 -2
  218. package/src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_height.d.ts.map +1 -1
  219. package/src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_height.js +4 -2
  220. package/src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_intersection.d.ts.map +1 -1
  221. package/src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_intersection.js +11 -3
  222. package/src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_ray_bounds.d.ts.map +1 -1
  223. package/src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_ray_bounds.js +68 -69
  224. package/src/shade/renderer/shader/chunk/atmosphere/chunk_get_sun_transmittance.d.ts +4 -1
  225. package/src/shade/renderer/shader/chunk/atmosphere/chunk_get_sun_transmittance.d.ts.map +1 -1
  226. package/src/shade/renderer/shader/chunk/atmosphere/chunk_get_sun_transmittance.js +46 -39
  227. package/src/shade/renderer/shader/chunk/atmosphere/chunk_position_relative_to_planet_center.d.ts.map +1 -1
  228. package/src/shade/renderer/shader/chunk/atmosphere/chunk_position_relative_to_planet_center.js +5 -3
  229. package/src/shade/renderer/shader/chunk/color/tonemap/purkinje/chunk_apply_purkinje_shift.d.ts +18 -10
  230. package/src/shade/renderer/shader/chunk/color/tonemap/purkinje/chunk_apply_purkinje_shift.d.ts.map +1 -1
  231. package/src/shade/renderer/shader/chunk/color/tonemap/purkinje/chunk_apply_purkinje_shift.js +30 -27
  232. package/src/shade/renderer/shader/chunk/depth/chunk_get_device_depth.d.ts +14 -0
  233. package/src/shade/renderer/shader/chunk/depth/chunk_get_device_depth.d.ts.map +1 -0
  234. package/src/shade/renderer/shader/chunk/depth/chunk_get_device_depth.js +30 -0
  235. package/src/shade/renderer/shader/chunk/geometry/octahedron/chunk_uv_equal_area_sphere.d.ts +21 -0
  236. package/src/shade/renderer/shader/chunk/geometry/octahedron/chunk_uv_equal_area_sphere.d.ts.map +1 -0
  237. package/src/shade/renderer/shader/chunk/geometry/octahedron/chunk_uv_equal_area_sphere.js +60 -0
  238. package/src/shade/renderer/shader/chunk/light/{sky/chunk_sample_sky_color.d.ts → io/chunk_light_get_sun.d.ts} +3 -6
  239. package/src/shade/renderer/shader/chunk/light/io/chunk_light_get_sun.d.ts.map +1 -0
  240. package/src/shade/renderer/shader/chunk/light/{sky/chunk_sample_sky_color.js → io/chunk_light_get_sun.js} +6 -26
  241. package/src/shade/renderer/shadow/sdf/cascade/shader_scene_sdf_soft_shadows.js +1 -1
  242. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.d.ts +3 -1
  243. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.d.ts.map +1 -1
  244. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.js +4 -2
  245. package/src/shade/renderer/volumetrics/graph_build_volumetrics.d.ts.map +1 -1
  246. package/src/shade/renderer/volumetrics/graph_build_volumetrics.js +743 -739
  247. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_gi_sample.js +2 -0
  248. package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.d.ts.map +1 -1
  249. package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.js +19 -17
  250. package/src/shade/renderer/volumetrics/shader_volumetrics_build_scattering_lut.d.ts.map +1 -1
  251. package/src/shade/renderer/volumetrics/shader_volumetrics_build_scattering_lut.js +5 -3
  252. package/src/shade/renderer/water/chunk_water_gi.js +2 -0
  253. package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
  254. package/src/shade/renderer/wind/GPUSceneWind.d.ts +1 -1
  255. package/src/engine/graphics/sh3/path_tracer/make_sky_hosek.d.ts +0 -2
  256. package/src/engine/graphics/sh3/path_tracer/make_sky_hosek.d.ts.map +0 -1
  257. package/src/engine/graphics/sh3/path_tracer/make_sky_hosek.js +0 -45
  258. package/src/engine/graphics/sh3/path_tracer/make_sky_rtiw.d.ts +0 -2
  259. package/src/engine/graphics/sh3/path_tracer/make_sky_rtiw.d.ts.map +0 -1
  260. package/src/engine/graphics/sh3/path_tracer/make_sky_rtiw.js +0 -17
  261. package/src/engine/graphics/sh3/sky/hosek/README.md +0 -4
  262. package/src/engine/graphics/sh3/sky/hosek/data.d.ts +0 -17
  263. package/src/engine/graphics/sh3/sky/hosek/data.d.ts.map +0 -1
  264. package/src/engine/graphics/sh3/sky/hosek/data.js +0 -3744
  265. package/src/engine/graphics/sh3/sky/hosek/prototype_hosek.d.ts +0 -2
  266. package/src/engine/graphics/sh3/sky/hosek/prototype_hosek.d.ts.map +0 -1
  267. package/src/engine/graphics/sh3/sky/hosek/prototype_hosek.js +0 -71
  268. package/src/engine/graphics/sh3/sky/hosek/render_hosek_sky_to_equirectangular.d.ts +0 -26
  269. package/src/engine/graphics/sh3/sky/hosek/render_hosek_sky_to_equirectangular.d.ts.map +0 -1
  270. package/src/engine/graphics/sh3/sky/hosek/render_hosek_sky_to_equirectangular.js +0 -70
  271. package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.d.ts +0 -22
  272. package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.d.ts.map +0 -1
  273. package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.js +0 -388
  274. package/src/engine/graphics3/make_default_environment.d.ts +0 -15
  275. package/src/engine/graphics3/make_default_environment.d.ts.map +0 -1
  276. package/src/engine/graphics3/make_default_environment.js +0 -111
  277. package/src/shade/renderer/atmosphere/MIE_G.d.ts +0 -6
  278. package/src/shade/renderer/atmosphere/MIE_G.d.ts.map +0 -1
  279. package/src/shade/renderer/atmosphere/MIE_G.js +0 -5
  280. package/src/shade/renderer/atmosphere/chunk_sample_environment_color.d.ts.map +0 -1
  281. package/src/shade/renderer/atmosphere/hillaire/ATMOSPHERE_EARTH.d.ts +0 -4
  282. package/src/shade/renderer/atmosphere/hillaire/ATMOSPHERE_EARTH.d.ts.map +0 -1
  283. package/src/shade/renderer/atmosphere/hillaire/ATMOSPHERE_EARTH.js +0 -44
  284. package/src/shade/renderer/atmosphere/hillaire/ATMOSPHERE_PARAMETERS_STRUCT.d.ts +0 -2
  285. package/src/shade/renderer/atmosphere/hillaire/ATMOSPHERE_PARAMETERS_STRUCT.d.ts.map +0 -1
  286. package/src/shade/renderer/atmosphere/hillaire/ATMOSPHERE_PARAMETERS_STRUCT.js +0 -43
  287. package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_DENSITY_DECLARATION.d.ts +0 -3
  288. package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_DENSITY_DECLARATION.d.ts.map +0 -1
  289. package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_DENSITY_DECLARATION.js +0 -6
  290. package/src/shade/renderer/shader/chunk/atmosphere/chunk_absorb.d.ts +0 -3
  291. package/src/shade/renderer/shader/chunk/atmosphere/chunk_absorb.d.ts.map +0 -1
  292. package/src/shade/renderer/shader/chunk/atmosphere/chunk_absorb.js +0 -18
  293. package/src/shade/renderer/shader/chunk/atmosphere/chunk_integrate_optical_depth.d.ts +0 -14
  294. package/src/shade/renderer/shader/chunk/atmosphere/chunk_integrate_optical_depth.d.ts.map +0 -1
  295. package/src/shade/renderer/shader/chunk/atmosphere/chunk_integrate_optical_depth.js +0 -86
  296. package/src/shade/renderer/shader/chunk/atmosphere/chunk_integrate_scattering.d.ts +0 -8
  297. package/src/shade/renderer/shader/chunk/atmosphere/chunk_integrate_scattering.d.ts.map +0 -1
  298. package/src/shade/renderer/shader/chunk/atmosphere/chunk_integrate_scattering.js +0 -125
  299. package/src/shade/renderer/shader/chunk/atmosphere/chunk_planet_intersection.d.ts +0 -3
  300. package/src/shade/renderer/shader/chunk/atmosphere/chunk_planet_intersection.d.ts.map +0 -1
  301. package/src/shade/renderer/shader/chunk/atmosphere/chunk_planet_intersection.js +0 -17
  302. package/src/shade/renderer/shader/chunk/atmosphere/chunk_sphere_intersection_nearest.d.ts +0 -3
  303. package/src/shade/renderer/shader/chunk/atmosphere/chunk_sphere_intersection_nearest.d.ts.map +0 -1
  304. package/src/shade/renderer/shader/chunk/atmosphere/chunk_sphere_intersection_nearest.js +0 -38
  305. package/src/shade/renderer/shader/chunk/atmosphere/hillaire/DENSITY_PROFILE_LAYER_STRUCT.d.ts +0 -16
  306. package/src/shade/renderer/shader/chunk/atmosphere/hillaire/DENSITY_PROFILE_LAYER_STRUCT.d.ts.map +0 -1
  307. package/src/shade/renderer/shader/chunk/atmosphere/hillaire/DENSITY_PROFILE_LAYER_STRUCT.js +0 -28
  308. package/src/shade/renderer/shader/chunk/light/sky/chunk_sample_sky_color.d.ts.map +0 -1
  309. package/src/shade/renderer/view/GPUViewSkyContext.d.ts +0 -26
  310. package/src/shade/renderer/view/GPUViewSkyContext.d.ts.map +0 -1
  311. package/src/shade/renderer/view/GPUViewSkyContext.js +0 -170
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_atmosphere_ray_bounds.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_ray_bounds.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;GAiBG;AACH,0CAFU,SAAS,CAiDjB;0BApEwB,6BAA6B"}
1
+ {"version":3,"file":"chunk_atmosphere_ray_bounds.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_ray_bounds.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;GAiBG;AACH,0CAFU,SAAS,CAgDjB;0BAnEwB,6BAA6B"}
@@ -1,69 +1,68 @@
1
- import { CodeChunk } from "../../compiler/CodeChunk.js";
2
- import { ATMOSPHERE_RADII_DECLARATION } from "./ATMOSPHERE_RADII_DECLARATION.js";
3
-
4
- /**
5
- * How far a ray inside the atmosphere may be marched, and whether it ends on the surface.
6
- *
7
- * The ground and the atmosphere shell are concentric on the planet and the ray is shared, so
8
- * one quadratic setup serves both intersections — only the radius term differs. Calling a
9
- * general sphere-intersection routine twice instead recomputes the ray-origin offset and all
10
- * three dot products for the second sphere, and re-derives a leading coefficient that is 1
11
- * for a unit direction.
12
- *
13
- * `origin_rel` is relative to the planet centre and assumed to be inside the atmosphere and
14
- * at or above the surface, which is what makes the shell's far root the exit point.
15
- * `ray_direction` must be normalised.
16
- *
17
- * `ground_distance` is negative when the ray never meets the surface, which includes looking
18
- * up from above it: both roots are behind the origin there.
19
- *
20
- * @type {CodeChunk}
21
- */
22
- export const chunk_atmosphere_ray_bounds = CodeChunk.from(
23
- //language=WGSL
24
- `
25
- struct AtmosphereRayBounds {
26
- // as far as a march may go: the surface when the ray meets it, the shell otherwise
27
- t_max: f32,
28
- // distance to the surface, negative when there is no hit ahead
29
- ground_distance: f32,
30
- hits_ground: bool,
31
- }
32
-
33
- fn atmosphere_ray_bounds(
34
- origin_rel: vec3<f32>,
35
- ray_direction: vec3<f32>
36
- ) -> AtmosphereRayBounds {
37
-
38
- // ray_direction is a unit vector, so the leading coefficient is 1 and the factors of two
39
- // divide out of both roots
40
- let b = dot(origin_rel, ray_direction);
41
- let r2 = dot(origin_rel, origin_rel);
42
- let b2 = b * b;
43
-
44
- // inside the shell, so its constant term is negative, the discriminant is positive, and
45
- // the far root is where the ray leaves
46
- let atmosphere_distance = -b + sqrt(max(b2 - (r2 - ATMOSPHERE_TOP_RADIUS_SQUARED), 0.0));
47
-
48
- // the ground is the near root, and only when that root is ahead of us
49
- let ground_discriminant = b2 - (r2 - ATMOSPHERE_GROUND_RADIUS_SQUARED);
50
- let ground_distance = select(
51
- -1.0,
52
- -b - sqrt(max(ground_discriminant, 0.0)),
53
- ground_discriminant >= 0.0
54
- );
55
-
56
- let hits_ground = ground_distance > 0.0;
57
-
58
- var result: AtmosphereRayBounds;
59
-
60
- result.t_max = select(atmosphere_distance, ground_distance, hits_ground);
61
- result.ground_distance = ground_distance;
62
- result.hits_ground = hits_ground;
63
-
64
- return result;
65
- }
66
- `, [
67
- ATMOSPHERE_RADII_DECLARATION,
68
- ]
69
- );
1
+ import { CodeChunk } from "../../compiler/CodeChunk.js";
2
+ import { ATMOSPHERE_RADII_DECLARATION } from "./ATMOSPHERE_RADII_DECLARATION.js";
3
+
4
+ /**
5
+ * How far a ray inside the atmosphere may be marched, and whether it ends on the surface.
6
+ *
7
+ * The ground and the atmosphere shell are concentric on the planet and the ray is shared, so
8
+ * one quadratic setup serves both intersections — only the radius term differs. Calling a
9
+ * general sphere-intersection routine twice instead recomputes the ray-origin offset and all
10
+ * three dot products for the second sphere, and re-derives a leading coefficient that is 1
11
+ * for a unit direction.
12
+ *
13
+ * `origin_rel` is relative to the planet centre and assumed to be inside the atmosphere and
14
+ * at or above the surface, which is what makes the shell's far root the exit point.
15
+ * `ray_direction` must be normalised.
16
+ *
17
+ * `ground_distance` is negative when the ray never meets the surface, which includes looking
18
+ * up from above it: both roots are behind the origin there.
19
+ *
20
+ * @type {CodeChunk}
21
+ */
22
+ export const chunk_atmosphere_ray_bounds = CodeChunk.from(
23
+ //language=WGSL
24
+ `
25
+ struct AtmosphereRayBounds {
26
+ // as far as a march may go: the surface when the ray meets it, the shell otherwise
27
+ t_max: f32,
28
+ // distance to the surface, negative when there is no hit ahead
29
+ ground_distance: f32,
30
+ hits_ground: bool,
31
+ }
32
+
33
+ fn atmosphere_ray_bounds(
34
+ origin_rel: vec3<f32>,
35
+ ray_direction: vec3<f32>
36
+ ) -> AtmosphereRayBounds {
37
+
38
+ // ray_direction is a unit vector, so the leading coefficient is 1 and the factors of two
39
+ // divide out of both roots
40
+ let b = dot(origin_rel, ray_direction);
41
+ let r = length(origin_rel);
42
+ let b2 = b * b;
43
+
44
+ // Difference-of-squares factoring (r - R)(r + R) avoids catastrophic f32 cancellation when
45
+ // altitude (r - R) is metres above a 6,378 km planet radius.
46
+ let atmosphere_distance = -b + sqrt(max(b2 - (r - ATMOSPHERE_TOP_RADIUS) * (r + ATMOSPHERE_TOP_RADIUS), 0.0));
47
+
48
+ // the ground is the near root, and only when that root is ahead of us
49
+ let ground_discriminant = b2 - (r - ATMOSPHERE_GROUND_RADIUS) * (r + ATMOSPHERE_GROUND_RADIUS);
50
+ let hits_ground = (b < 0.0) && (ground_discriminant >= 0.0);
51
+ let ground_distance = select(
52
+ -1.0,
53
+ max(-b - sqrt(max(ground_discriminant, 0.0)), 0.0),
54
+ hits_ground
55
+ );
56
+
57
+ var result: AtmosphereRayBounds;
58
+
59
+ result.t_max = select(atmosphere_distance, ground_distance, hits_ground);
60
+ result.ground_distance = ground_distance;
61
+ result.hits_ground = hits_ground;
62
+
63
+ return result;
64
+ }
65
+ `, [
66
+ ATMOSPHERE_RADII_DECLARATION,
67
+ ]
68
+ );
@@ -1,5 +1,8 @@
1
1
  /**
2
- * @see https://www.shadertoy.com/view/slSXRW
2
+ * Integrates direct solar transmittance from `pos` along `sunDir` to the top of the atmosphere,
3
+ * returning zero when the ray intersects the planet sphere.
4
+ *
5
+ * @see "A Scalable and Production Ready Sky and Atmosphere Rendering Technique", Hillaire (2020)
3
6
  * @type {CodeChunk}
4
7
  */
5
8
  export const chunk_get_sun_transmittance: CodeChunk;
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_get_sun_transmittance.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/shader/chunk/atmosphere/chunk_get_sun_transmittance.js"],"names":[],"mappings":"AASA;;;GAGG;AACH,0CAFU,SAAS,CA+CjB;0BA1DwB,6BAA6B"}
1
+ {"version":3,"file":"chunk_get_sun_transmittance.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/shader/chunk/atmosphere/chunk_get_sun_transmittance.js"],"names":[],"mappings":"AAMA;;;;;;GAMG;AACH,0CAFU,SAAS,CAsDjB;0BA7DwB,6BAA6B"}
@@ -1,59 +1,66 @@
1
+ import {
2
+ ATMOSPHERE_PARAMETERS_STRUCT,
3
+ chunk_atmosphere_parameters
4
+ } from "../../../atmosphere/ATMOSPHERE_PARAMETERS_STRUCT.js";
1
5
  import { CodeChunk } from "../../compiler/CodeChunk.js";
2
- import { chunk_atmosphere_density } from "./chunk_atmosphere_density.js";
3
- import { chunk_atmosphere_height } from "./chunk_atmosphere_height.js";
4
- import { chunk_atmosphere_intersection } from "./chunk_atmosphere_intersection.js";
5
- import { chunk_compute_extinction } from "./chunk_compute_extinction.js";
6
- import { chunk_sphere_intersection } from "./chunk_sphere_intersection.js";
7
- import { PLANET_CENTER_DECLARATION } from "./PLANET_CENTER_DECLARATION.js";
8
- import { PLANET_RADIUS_DECLARATION } from "./PLANET_RADIUS_DECLARATION.js";
9
6
 
10
7
  /**
11
- * @see https://www.shadertoy.com/view/slSXRW
8
+ * Integrates direct solar transmittance from `pos` along `sunDir` to the top of the atmosphere,
9
+ * returning zero when the ray intersects the planet sphere.
10
+ *
11
+ * @see "A Scalable and Production Ready Sky and Atmosphere Rendering Technique", Hillaire (2020)
12
12
  * @type {CodeChunk}
13
13
  */
14
14
  export const chunk_get_sun_transmittance = CodeChunk.from(
15
15
  //language=WGSL
16
16
  `
17
- fn get_sun_transmittance(pos: vec3<f32>, sunDir: vec3<f32>, sunTransmittanceSteps: f32) -> vec3<f32>{
18
-
19
- if (sphere_intersection(pos, sunDir, PLANET_CENTER, PLANET_RADIUS).x > 0.0) {
20
- // we're outside of the atmosphere
21
- return vec3(0.0);
17
+ fn get_sun_transmittance_rel_for(
18
+ atm: ${ATMOSPHERE_PARAMETERS_STRUCT.wgsl_ref},
19
+ rel: vec3<f32>,
20
+ sunDir: vec3<f32>,
21
+ sunTransmittanceSteps: f32
22
+ ) -> vec3<f32> {
23
+ let bounds = atmosphere_ray_bounds_for(atm, rel, sunDir);
24
+
25
+ if (bounds.hits_ground) {
26
+ return vec3<f32>(0.0);
22
27
  }
23
-
24
- let ray_length = atmosphere_intersection(pos, sunDir ).y;
28
+
29
+ let ray_length = bounds.t_max;
25
30
  var t = 0.0;
26
-
27
- var transmittance = vec3(1.0);
28
-
29
- // integrate optical depth
31
+ var transmittance = vec3<f32>(1.0);
32
+
30
33
  for (var i = 0.0; i < sunTransmittanceSteps; i += 1.0) {
31
34
  let f = (i + 0.3) / sunTransmittanceSteps;
32
-
33
35
  let newT = f * ray_length;
34
36
  let dt = newT - t;
35
37
  t = newT;
36
-
37
- let newPos = pos + t * sunDir;
38
-
39
- let local_height = atmosphere_height(newPos);
40
- let local_density = atmosphere_density(local_height);
41
-
42
- let extinction = compute_extinction(local_density);
43
-
44
- transmittance *= exp(-dt * extinction);
45
-
38
+
39
+ let step_rel = rel + t * sunDir;
40
+ let local_height = length(step_rel) - atm.planet_radius;
41
+ let local_density = atmosphere_density_for(atm, local_height);
42
+ let extinction = atmosphere_extinction_for(atm, local_density);
43
+
44
+ transmittance *= exp(-dt * extinction);
46
45
  }
47
-
46
+
48
47
  return transmittance;
49
48
  }
49
+
50
+ fn get_sun_transmittance_for(
51
+ atm: ${ATMOSPHERE_PARAMETERS_STRUCT.wgsl_ref},
52
+ pos_ws: vec3<f32>,
53
+ sunDir: vec3<f32>,
54
+ sunTransmittanceSteps: f32
55
+ ) -> vec3<f32> {
56
+ let rel = atmosphere_position_relative_for(atm, pos_ws);
57
+ return get_sun_transmittance_rel_for(atm, rel, sunDir, sunTransmittanceSteps);
58
+ }
59
+
60
+ fn get_sun_transmittance(pos_ws: vec3<f32>, sunDir: vec3<f32>, sunTransmittanceSteps: f32) -> vec3<f32> {
61
+ return get_sun_transmittance_for(atmosphere_earth_parameters(), pos_ws, sunDir, sunTransmittanceSteps);
62
+ }
50
63
  `, [
51
- chunk_sphere_intersection,
52
- chunk_atmosphere_height,
53
- chunk_atmosphere_density,
54
- PLANET_RADIUS_DECLARATION,
55
- PLANET_CENTER_DECLARATION,
56
- chunk_atmosphere_intersection,
57
- chunk_compute_extinction,
64
+ chunk_atmosphere_parameters,
58
65
  ]
59
- );
66
+ );
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_position_relative_to_planet_center.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/shader/chunk/atmosphere/chunk_position_relative_to_planet_center.js"],"names":[],"mappings":"AAGA,iEASE;0BAZwB,6BAA6B"}
1
+ {"version":3,"file":"chunk_position_relative_to_planet_center.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/shader/chunk/atmosphere/chunk_position_relative_to_planet_center.js"],"names":[],"mappings":"AAIA,iEAUE;0BAbwB,6BAA6B"}
@@ -1,13 +1,15 @@
1
+ import { ATMOSPHERE_UNIT_SCALE_DECLARATION } from "../../../atmosphere/ATMOSPHERE_UNIT_SCALE.js";
1
2
  import { CodeChunk } from "../../compiler/CodeChunk.js";
2
3
  import { PLANET_CENTER_DECLARATION } from "./PLANET_CENTER_DECLARATION.js";
3
4
 
4
5
  export const chunk_position_relative_to_planet_center = CodeChunk.from(
5
- //language=WGSL
6
+ //language=WGSL
6
7
  `
7
- fn position_relative_to_planet_center(pos:vec3<f32>) -> vec3<f32> {
8
- return pos - PLANET_CENTER;
8
+ fn position_relative_to_planet_center(pos: vec3<f32>) -> vec3<f32> {
9
+ return pos * METERS_TO_ATMOSPHERE_UNITS - PLANET_CENTER;
9
10
  }
10
11
  `, [
12
+ ATMOSPHERE_UNIT_SCALE_DECLARATION,
11
13
  PLANET_CENTER_DECLARATION
12
14
  ]
13
15
  );
@@ -1,12 +1,15 @@
1
1
  /**
2
- * How much of the eye's response is the rods', at an adaptation: 1 at and below {@link PURKINJE_MESOPIC_MIN_NITS}, 0 at
3
- * and above {@link PURKINJE_MESOPIC_MAX_NITS}, linear in log luminance in between. The share `apply_purkinje_shift`
4
- * blends by, for code that needs it on the CPU.
2
+ * How much of the eye's response is the rods', at an adaptation, across a response range: 1 at and below `rods_below`,
3
+ * 0 at and above `cones_above`, linear in log luminance in between. CIE 191's range is
4
+ * {@link PURKINJE_MESOPIC_MIN_NITS} to {@link PURKINJE_MESOPIC_MAX_NITS}. The share `apply_purkinje_shift` blends by,
5
+ * for code that needs it on the CPU.
5
6
  *
6
7
  * @param {number} adaptation_luminance cd/m²
8
+ * @param {number} rods_below cd/m², over 0
9
+ * @param {number} cones_above cd/m², over `rods_below`
7
10
  * @returns {number} 0 to 1
8
11
  */
9
- export function purkinje_rod_share(adaptation_luminance: number): number;
12
+ export function purkinje_rod_share(adaptation_luminance: number, rods_below: number, cones_above: number): number;
10
13
  /**
11
14
  * Rec.709 photopic luminance weights: what the cones see of a linear Rec.709 colour.
12
15
  * @type {ReadonlyArray<number>}
@@ -26,6 +29,7 @@ export const PURKINJE_REC709_SCOTOPIC: ReadonlyArray<number>;
26
29
  export const PURKINJE_NIGHT_TINT: ReadonlyArray<number>;
27
30
  /**
28
31
  * CIE 191's mesopic range, cd/m²: rods alone below the lower bound (scotopic), cones alone above the upper (photopic).
32
+ * The response range of the tone mapper's run-time shift.
29
33
  */
30
34
  export const PURKINJE_MESOPIC_MIN_NITS: 0.005;
31
35
  export const PURKINJE_MESOPIC_MAX_NITS: 5;
@@ -34,14 +38,18 @@ export const PURKINJE_MESOPIC_MAX_NITS: 5;
34
38
  * Human vision system shifts color perception away from red in night-time conditions.
35
39
  *
36
40
  * ```wgsl
37
- * fn apply_purkinje_shift(color_rec709: vec3<f32>, adaptation_luminance: f32) -> vec3<f32>
38
- * fn purkinje_rod_share(adaptation_luminance: f32) -> f32
41
+ * fn purkinje_rod_share(adaptation_luminance: f32, rods_below: f32, cones_above: f32) -> f32
42
+ * fn apply_purkinje_shift(color_rec709: vec3<f32>, rod_share: f32) -> vec3<f32>
39
43
  * ```
40
44
  *
41
- * `color_rec709` is scene-linear Rec.709; `adaptation_luminance` is the luminance the eye is adapted to, cd/m². Above
42
- * 5 cd/m² the colour is returned as it is; below 0.005 cd/m² it is the rod response alone, its scotopic luminance
43
- * carried by a blue tint; in between the two blend linearly in log luminance, by `purkinje_rod_share`. The shift is
44
- * linear in the colour, so it gives the same result ahead of the exposure as after it.
45
+ * `purkinje_rod_share` is how much of the eye's response is the rods' at `adaptation_luminance`, the luminance the eye
46
+ * is adapted to, across a response range, all in cd/m²: 1 at and below `rods_below`, 0 at and above `cones_above`
47
+ * (which must be over `rods_below`, itself over 0), linear in log luminance in between. CIE 191's mesopic range,
48
+ * `PURKINJE_MESOPIC_MIN_NITS` to `PURKINJE_MESOPIC_MAX_NITS` (0.005 to 5 cd/m²), is the eye's.
49
+ *
50
+ * `apply_purkinje_shift` blends `color_rec709`, scene-linear Rec.709, towards the rod response by `rod_share`: at 0 the
51
+ * colour is returned as it is; at 1 it is the rod response alone, its scotopic luminance carried by a blue tint. The
52
+ * shift is linear in the colour, so it gives the same result ahead of the exposure as after it.
45
53
  *
46
54
  * The constants are the module's exports ({@link PURKINJE_REC709_SCOTOPIC} and the rest), and
47
55
  * {@link purkinje_rod_share} is the share on the CPU.
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_apply_purkinje_shift.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/shade/renderer/shader/chunk/color/tonemap/purkinje/chunk_apply_purkinje_shift.js"],"names":[],"mappings":"AAiCA;;;;;;;GAOG;AACH,yDAHW,MAAM,GACJ,MAAM,CAQlB;AA7CD;;;GAGG;AACH,uCAFU,cAAc,MAAM,CAAC,CAEiD;AAEhF;;;;GAIG;AACH,uCAFU,cAAc,MAAM,CAAC,CAEiD;AAEhF;;;;GAIG;AACH,kCAFU,cAAc,MAAM,CAAC,CAEmC;AAElE;;GAEG;AACH,8CAA+C;AAC/C,0CAA2C;AAwC3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,yCAFU,SAAS,CAwCjB;0BAvIwB,mCAAmC"}
1
+ {"version":3,"file":"chunk_apply_purkinje_shift.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/shade/renderer/shader/chunk/color/tonemap/purkinje/chunk_apply_purkinje_shift.js"],"names":[],"mappings":"AA6BA;;;;;;;;;;GAUG;AACH,yDALW,MAAM,cACN,MAAM,eACN,MAAM,GACJ,MAAM,CAQlB;AA5CD;;;GAGG;AACH,uCAFU,cAAc,MAAM,CAAC,CAEiD;AAEhF;;;;GAIG;AACH,uCAFU,cAAc,MAAM,CAAC,CAEiD;AAEhF;;;;GAIG;AACH,kCAFU,cAAc,MAAM,CAAC,CAEmC;AAElE;;;GAGG;AACH,8CAA+C;AAC/C,0CAA2C;AAsC3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,yCAFU,SAAS,CAwCjB;0BA1IwB,mCAAmC"}
@@ -22,27 +22,26 @@ export const PURKINJE_NIGHT_TINT = Object.freeze([0.3, 0.5, 0.9]);
22
22
 
23
23
  /**
24
24
  * CIE 191's mesopic range, cd/m²: rods alone below the lower bound (scotopic), cones alone above the upper (photopic).
25
+ * The response range of the tone mapper's run-time shift.
25
26
  */
26
27
  export const PURKINJE_MESOPIC_MIN_NITS = 0.005;
27
28
  export const PURKINJE_MESOPIC_MAX_NITS = 5;
28
29
 
29
30
  /**
30
- * The least adaptation the share is read at, cd/m²: under it, the rods alone see, as they do at the bound itself.
31
- */
32
- const ADAPTATION_FLOOR_NITS = 1e-5;
33
-
34
- /**
35
- * How much of the eye's response is the rods', at an adaptation: 1 at and below {@link PURKINJE_MESOPIC_MIN_NITS}, 0 at
36
- * and above {@link PURKINJE_MESOPIC_MAX_NITS}, linear in log luminance in between. The share `apply_purkinje_shift`
37
- * blends by, for code that needs it on the CPU.
31
+ * How much of the eye's response is the rods', at an adaptation, across a response range: 1 at and below `rods_below`,
32
+ * 0 at and above `cones_above`, linear in log luminance in between. CIE 191's range is
33
+ * {@link PURKINJE_MESOPIC_MIN_NITS} to {@link PURKINJE_MESOPIC_MAX_NITS}. The share `apply_purkinje_shift` blends by,
34
+ * for code that needs it on the CPU.
38
35
  *
39
36
  * @param {number} adaptation_luminance cd/m²
37
+ * @param {number} rods_below cd/m², over 0
38
+ * @param {number} cones_above cd/m², over `rods_below`
40
39
  * @returns {number} 0 to 1
41
40
  */
42
- export function purkinje_rod_share(adaptation_luminance) {
43
- const low = Math.log(PURKINJE_MESOPIC_MIN_NITS);
44
- const high = Math.log(PURKINJE_MESOPIC_MAX_NITS);
45
- const t = (Math.log(Math.max(adaptation_luminance, ADAPTATION_FLOOR_NITS)) - low) / (high - low);
41
+ export function purkinje_rod_share(adaptation_luminance, rods_below, cones_above) {
42
+ const low = Math.log(rods_below);
43
+ const high = Math.log(cones_above);
44
+ const t = (Math.log(Math.min(Math.max(adaptation_luminance, rods_below), cones_above)) - low) / (high - low);
46
45
 
47
46
  return 1 - Math.min(1, Math.max(0, t));
48
47
  }
@@ -69,14 +68,18 @@ function wgsl_vec3(v) {
69
68
  * Human vision system shifts color perception away from red in night-time conditions.
70
69
  *
71
70
  * ```wgsl
72
- * fn apply_purkinje_shift(color_rec709: vec3<f32>, adaptation_luminance: f32) -> vec3<f32>
73
- * fn purkinje_rod_share(adaptation_luminance: f32) -> f32
71
+ * fn purkinje_rod_share(adaptation_luminance: f32, rods_below: f32, cones_above: f32) -> f32
72
+ * fn apply_purkinje_shift(color_rec709: vec3<f32>, rod_share: f32) -> vec3<f32>
74
73
  * ```
75
74
  *
76
- * `color_rec709` is scene-linear Rec.709; `adaptation_luminance` is the luminance the eye is adapted to, cd/m². Above
77
- * 5 cd/m² the colour is returned as it is; below 0.005 cd/m² it is the rod response alone, its scotopic luminance
78
- * carried by a blue tint; in between the two blend linearly in log luminance, by `purkinje_rod_share`. The shift is
79
- * linear in the colour, so it gives the same result ahead of the exposure as after it.
75
+ * `purkinje_rod_share` is how much of the eye's response is the rods' at `adaptation_luminance`, the luminance the eye
76
+ * is adapted to, across a response range, all in cd/m²: 1 at and below `rods_below`, 0 at and above `cones_above`
77
+ * (which must be over `rods_below`, itself over 0), linear in log luminance in between. CIE 191's mesopic range,
78
+ * `PURKINJE_MESOPIC_MIN_NITS` to `PURKINJE_MESOPIC_MAX_NITS` (0.005 to 5 cd/m²), is the eye's.
79
+ *
80
+ * `apply_purkinje_shift` blends `color_rec709`, scene-linear Rec.709, towards the rod response by `rod_share`: at 0 the
81
+ * colour is returned as it is; at 1 it is the rod response alone, its scotopic luminance carried by a blue tint. The
82
+ * shift is linear in the colour, so it gives the same result ahead of the exposure as after it.
80
83
  *
81
84
  * The constants are the module's exports ({@link PURKINJE_REC709_SCOTOPIC} and the rest), and
82
85
  * {@link purkinje_rod_share} is the share on the CPU.
@@ -104,21 +107,21 @@ const PURKINJE_NIGHT_TINT = ${wgsl_vec3(PURKINJE_NIGHT_TINT)};
104
107
  const PURKINJE_MESOPIC_MIN_NITS = ${wgsl_float(PURKINJE_MESOPIC_MIN_NITS)}; // Rods dominate below this
105
108
  const PURKINJE_MESOPIC_MAX_NITS = ${wgsl_float(PURKINJE_MESOPIC_MAX_NITS)}; // Cones dominate above this
106
109
 
107
- // how much of the response is the rods', linear in log luminance across the mesopic range: a perceptually linear
110
+ // how much of the response is the rods', linear in log luminance across the response range: a perceptually linear
108
111
  // transition
109
- fn purkinje_rod_share(adaptation_luminance: f32) -> f32 {
110
- let logLum = log(max(adaptation_luminance, ${wgsl_float(ADAPTATION_FLOOR_NITS)}));
112
+ fn purkinje_rod_share(adaptation_luminance: f32, rods_below: f32, cones_above: f32) -> f32 {
113
+ let logLum = log(clamp(adaptation_luminance, rods_below, cones_above));
111
114
 
112
- const logLow = log(PURKINJE_MESOPIC_MIN_NITS);
113
- const logHigh = log(PURKINJE_MESOPIC_MAX_NITS);
114
- const logDelta = logHigh - logLow;
115
+ let logLow = log(rods_below);
116
+ let logHigh = log(cones_above);
117
+ let logDelta = logHigh - logLow;
115
118
 
116
119
  return 1.0 - saturate( (logLum - logLow) / logDelta );
117
120
  }
118
121
 
119
122
  fn apply_purkinje_shift(
120
123
  color_rec709: vec3<f32>,
121
- adaptation_luminance: f32
124
+ rod_share: f32
122
125
  ) -> vec3<f32>{
123
126
  // 1. Calculate Rod Luminance (Night)
124
127
  // Note: Red objects will have a near-zero Y_night, making them turn black.
@@ -129,8 +132,8 @@ fn apply_purkinje_shift(
129
132
  // We treat the rod signal as a scalar intensity applied to our blue tint
130
133
  let color_night = Y_night * PURKINJE_NIGHT_TINT;
131
134
 
132
- // 3. Lerp from Day view to Night view, by the rods' share at the adaptation
133
- return mix(color_rec709, color_night, purkinje_rod_share(adaptation_luminance));
135
+ // 3. Lerp from Day view to Night view, by the rods' share
136
+ return mix(color_rec709, color_night, rod_share);
134
137
  }
135
138
  `
136
139
  );
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The device depth a camera's projection gives a view depth, the inverse of {@link chunk_get_view_space_depth}:
3
+ *
4
+ * ```wgsl
5
+ * fn get_device_depth(view_depth: f32, camera: CameraUniforms) -> f32
6
+ * ```
7
+ *
8
+ * Reverse Z, as `device_depth_to_view_space` is ({@link compute_device_depth_to_view_space_depth_params}).
9
+ *
10
+ * @type {CodeChunk}
11
+ */
12
+ export const chunk_get_device_depth: CodeChunk;
13
+ import { CodeChunk } from "../../compiler/CodeChunk.js";
14
+ //# sourceMappingURL=chunk_get_device_depth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_get_device_depth.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/shader/chunk/depth/chunk_get_device_depth.js"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,qCAFU,SAAS,CAiBjB;0BA5BwB,6BAA6B"}
@@ -0,0 +1,30 @@
1
+ import { CAMERA_UNIFORM_STRUCT } from "../../../camera/CAMERA_UNIFORM_STRUCT.js";
2
+ import { CodeChunk } from "../../compiler/CodeChunk.js";
3
+
4
+ /**
5
+ * The device depth a camera's projection gives a view depth, the inverse of {@link chunk_get_view_space_depth}:
6
+ *
7
+ * ```wgsl
8
+ * fn get_device_depth(view_depth: f32, camera: CameraUniforms) -> f32
9
+ * ```
10
+ *
11
+ * Reverse Z, as `device_depth_to_view_space` is ({@link compute_device_depth_to_view_space_depth_params}).
12
+ *
13
+ * @type {CodeChunk}
14
+ */
15
+ export const chunk_get_device_depth = CodeChunk.from(
16
+ //language=WGSL
17
+ `
18
+ fn get_device_depth(
19
+ view_depth: f32,
20
+ camera: ${CAMERA_UNIFORM_STRUCT.wgsl_ref}
21
+ ) -> f32 {
22
+
23
+ let device_to_view_depth = camera.device_depth_to_view_space;
24
+
25
+ return device_to_view_depth.y / view_depth - device_to_view_depth.x;
26
+ }
27
+ `, [
28
+ CAMERA_UNIFORM_STRUCT.declaration_chunk,
29
+ ]
30
+ );
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Clarberg's equal-area mapping between the unit square and the unit sphere, octahedrally folded: every
3
+ * region of the square covers 4π times its area of the sphere, so a regular n×n grid of texels splits the
4
+ * sphere into texels of 4π/n² steradians each, and a point drawn uniformly inside a texel is a direction drawn
5
+ * uniformly over that texel's solid angle.
6
+ *
7
+ * ```wgsl
8
+ * fn uv_equal_area_sphere_decode(uv: vec2<f32>) -> vec3<f32> // the square [0, 1]² to a unit vector
9
+ * fn uv_equal_area_sphere_encode(direction: vec3<f32>) -> vec2<f32> // any non-zero vector to the square
10
+ * ```
11
+ *
12
+ * The square's diamond |2u−1| + |2v−1| ≤ 1 is the +z hemisphere and its centre +z; the four corners meet at −z.
13
+ * The fold is the standard octahedral one, so the square's edges join as an octahedral map's do.
14
+ *
15
+ * @see Petrik Clarberg, "Fast Equal-Area Mapping of the (Hemi)Sphere using SIMD", Journal of Graphics Tools
16
+ * 13(3), 2008
17
+ * @type {CodeChunk}
18
+ */
19
+ export const chunk_uv_equal_area_sphere: CodeChunk;
20
+ import { CodeChunk } from "../../../compiler/CodeChunk.js";
21
+ //# sourceMappingURL=chunk_uv_equal_area_sphere.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_uv_equal_area_sphere.d.ts","sourceRoot":"","sources":["../../../../../../../../src/shade/renderer/shader/chunk/geometry/octahedron/chunk_uv_equal_area_sphere.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;GAiBG;AACH,yCAFU,SAAS,CAwCZ;0BA3DmB,gCAAgC"}
@@ -0,0 +1,60 @@
1
+ import { CodeChunk } from "../../../compiler/CodeChunk.js";
2
+ import { PI_DECLARATION } from "../../math/PI_DECLARATION.js";
3
+
4
+ /**
5
+ * Clarberg's equal-area mapping between the unit square and the unit sphere, octahedrally folded: every
6
+ * region of the square covers 4π times its area of the sphere, so a regular n×n grid of texels splits the
7
+ * sphere into texels of 4π/n² steradians each, and a point drawn uniformly inside a texel is a direction drawn
8
+ * uniformly over that texel's solid angle.
9
+ *
10
+ * ```wgsl
11
+ * fn uv_equal_area_sphere_decode(uv: vec2<f32>) -> vec3<f32> // the square [0, 1]² to a unit vector
12
+ * fn uv_equal_area_sphere_encode(direction: vec3<f32>) -> vec2<f32> // any non-zero vector to the square
13
+ * ```
14
+ *
15
+ * The square's diamond |2u−1| + |2v−1| ≤ 1 is the +z hemisphere and its centre +z; the four corners meet at −z.
16
+ * The fold is the standard octahedral one, so the square's edges join as an octahedral map's do.
17
+ *
18
+ * @see Petrik Clarberg, "Fast Equal-Area Mapping of the (Hemi)Sphere using SIMD", Journal of Graphics Tools
19
+ * 13(3), 2008
20
+ * @type {CodeChunk}
21
+ */
22
+ export const chunk_uv_equal_area_sphere = CodeChunk.from(
23
+ //language=WGSL
24
+ `
25
+ fn uv_equal_area_sphere_decode(uv: vec2<f32>) -> vec3<f32> {
26
+ let s = fma(uv, vec2<f32>(2.0), vec2<f32>(-1.0));
27
+ let d = 1.0 - (abs(s.x) + abs(s.y));
28
+ let r = 1.0 - abs(d);
29
+
30
+ // the square's centre and corners are the poles, where r is zero and the azimuth is any
31
+ let phi = select((PI * 0.25) * ((abs(s.y) - abs(s.x)) / r + 1.0), 0.0, r == 0.0);
32
+ let f = r * sqrt(2.0 - r * r);
33
+
34
+ return vec3<f32>(
35
+ f * sign(s.x) * abs(cos(phi)),
36
+ f * sign(s.y) * abs(sin(phi)),
37
+ sign(d) * (1.0 - r * r),
38
+ );
39
+ }
40
+
41
+ fn uv_equal_area_sphere_encode(direction: vec3<f32>) -> vec2<f32> {
42
+ let n = normalize(direction);
43
+ let a = abs(n);
44
+ let r = sqrt(max(1.0 - a.z, 0.0));
45
+
46
+ // the azimuth in the quadrant, 0 along x to 1 along y; on the z axis r is zero and it is never read
47
+ let tangent = min(a.x, a.y) / max(max(a.x, a.y), 1e-30);
48
+ let half_turn = atan(tangent) * (2.0 / PI);
49
+ let phi = select(half_turn, 1.0 - half_turn, a.x < a.y);
50
+
51
+ var folded = vec2<f32>(r - phi * r, phi * r);
52
+
53
+ folded = select(folded, 1.0 - folded.yx, n.z < 0.0);
54
+ folded = select(folded, -folded, n.xy < vec2<f32>(0.0));
55
+
56
+ return fma(folded, vec2<f32>(0.5), vec2<f32>(0.5));
57
+ }
58
+ `, [
59
+ PI_DECLARATION,
60
+ ]);
@@ -8,12 +8,9 @@
8
8
  * iterating; per-pixel direct shading should iterate via
9
9
  * {@link chunk_directional_lights_iteration_mask} so every directional
10
10
  * light contributes.
11
- */
12
- export const chunk_light_get_sun: CodeChunk;
13
- /**
14
- * @see https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK/blob/1bbe66e7ea0d358e84af4471a90aa9c35b583de0/framework/rendermodules/skydome/shaders/skydomeproc.hlsl#L177
11
+ *
15
12
  * @type {CodeChunk}
16
13
  */
17
- export const chunk_sample_sky_color: CodeChunk;
14
+ export const chunk_light_get_sun: CodeChunk;
18
15
  import { CodeChunk } from "../../../compiler/CodeChunk.js";
19
- //# sourceMappingURL=chunk_sample_sky_color.d.ts.map
16
+ //# sourceMappingURL=chunk_light_get_sun.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_light_get_sun.d.ts","sourceRoot":"","sources":["../../../../../../../../src/shade/renderer/shader/chunk/light/io/chunk_light_get_sun.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;GAYG;AACH,kCAFU,SAAS,CAmBjB;0BApCwB,gCAAgC"}