@woosh/meep-engine 3.11.1 → 3.11.3

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 (225) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/package.json +1 -1
  3. package/src/engine/ecs/storage/populateEngineSerializationRegistry.d.ts.map +1 -1
  4. package/src/engine/ecs/storage/populateEngineSerializationRegistry.js +294 -290
  5. package/src/engine/graphics3/ParticipatingMedia.d.ts +111 -0
  6. package/src/engine/graphics3/ParticipatingMedia.d.ts.map +1 -0
  7. package/src/engine/graphics3/ParticipatingMedia.js +203 -0
  8. package/src/engine/graphics3/ParticipatingMediaSerializationAdapter.d.ts +34 -0
  9. package/src/engine/graphics3/ParticipatingMediaSerializationAdapter.d.ts.map +1 -0
  10. package/src/engine/graphics3/ParticipatingMediaSerializationAdapter.js +73 -0
  11. package/src/engine/graphics3/ParticipatingMediaSystem3.d.ts +87 -0
  12. package/src/engine/graphics3/ParticipatingMediaSystem3.d.ts.map +1 -0
  13. package/src/engine/graphics3/ParticipatingMediaSystem3.js +184 -0
  14. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  15. package/src/shade/descriptor/pipeline/PipelineLayoutDescriptor.d.ts +16 -2
  16. package/src/shade/descriptor/pipeline/PipelineLayoutDescriptor.d.ts.map +1 -1
  17. package/src/shade/descriptor/pipeline/PipelineLayoutDescriptor.js +28 -4
  18. package/src/shade/descriptor/pipeline/compute/ComputePipelineDescriptor.d.ts +1 -1
  19. package/src/shade/descriptor/pipeline/compute/ComputePipelineDescriptor.d.ts.map +1 -1
  20. package/src/shade/descriptor/pipeline/compute/ComputePipelineDescriptor.js +5 -2
  21. package/src/shade/device/IMMEDIATE_DATA_PLAN_2026_08_28.md +564 -451
  22. package/src/shade/device/ShadeGPUCommandContext.d.ts +18 -2
  23. package/src/shade/device/ShadeGPUCommandContext.d.ts.map +1 -1
  24. package/src/shade/device/ShadeGPUCommandContext.js +994 -940
  25. package/src/shade/device/immediate_data_supported.d.ts +33 -0
  26. package/src/shade/device/immediate_data_supported.d.ts.map +1 -0
  27. package/src/shade/device/immediate_data_supported.js +53 -0
  28. package/src/shade/device/mock/SoftwareGPUCommandEncoder.d.ts +18 -0
  29. package/src/shade/device/mock/SoftwareGPUCommandEncoder.d.ts.map +1 -1
  30. package/src/shade/device/mock/SoftwareGPUCommandEncoder.js +24 -0
  31. package/src/shade/device/mock/SoftwareGPUComputePassEncoder.d.ts +7 -0
  32. package/src/shade/device/mock/SoftwareGPUComputePassEncoder.d.ts.map +1 -1
  33. package/src/shade/device/mock/SoftwareGPUComputePassEncoder.js +49 -1
  34. package/src/shade/device/mock/SoftwareGPUDevice.d.ts.map +1 -1
  35. package/src/shade/device/mock/SoftwareGPUDevice.js +20 -2
  36. package/src/shade/device/mock/SoftwareGPUImmediateData.d.ts +65 -0
  37. package/src/shade/device/mock/SoftwareGPUImmediateData.d.ts.map +1 -0
  38. package/src/shade/device/mock/SoftwareGPUImmediateData.js +160 -0
  39. package/src/shade/device/mock/SoftwareGPURenderPassEncoder.d.ts +7 -0
  40. package/src/shade/device/mock/SoftwareGPURenderPassEncoder.d.ts.map +1 -1
  41. package/src/shade/device/mock/SoftwareGPURenderPassEncoder.js +50 -0
  42. package/src/shade/device/mock/pipeline_immediate_size.d.ts +11 -0
  43. package/src/shade/device/mock/pipeline_immediate_size.d.ts.map +1 -0
  44. package/src/shade/device/mock/pipeline_immediate_size.js +18 -0
  45. package/src/shade/device/pipeline/PipelineLayoutManager.d.ts.map +1 -1
  46. package/src/shade/device/pipeline/PipelineLayoutManager.js +1 -0
  47. package/src/shade/playground/volumetrics_froxel/README.md +104 -1
  48. package/src/shade/playground/volumetrics_froxel/index.html +20 -1
  49. package/src/shade/playground/volumetrics_froxel/main.d.ts.map +1 -1
  50. package/src/shade/playground/volumetrics_froxel/main.js +298 -0
  51. package/src/shade/playground/volumetrics_froxel/measure.d.ts +119 -0
  52. package/src/shade/playground/volumetrics_froxel/measure.d.ts.map +1 -0
  53. package/src/shade/playground/volumetrics_froxel/measure.js +559 -0
  54. package/src/shade/renderer/GraphicsContext.d.ts +9 -2
  55. package/src/shade/renderer/GraphicsContext.d.ts.map +1 -1
  56. package/src/shade/renderer/GraphicsContext.js +13 -1
  57. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  58. package/src/shade/renderer/Renderer.js +22 -18
  59. package/src/shade/renderer/atmosphere/GPUSky.d.ts.map +1 -1
  60. package/src/shade/renderer/atmosphere/GPUSky.js +145 -142
  61. package/src/shade/renderer/atmosphere/MULTISCATTER_LUT_CONFIG.d.ts +34 -0
  62. package/src/shade/renderer/atmosphere/MULTISCATTER_LUT_CONFIG.d.ts.map +1 -0
  63. package/src/shade/renderer/atmosphere/MULTISCATTER_LUT_CONFIG.js +36 -0
  64. package/src/shade/renderer/atmosphere/SAMPLER_SKY_LUT.d.ts +20 -0
  65. package/src/shade/renderer/atmosphere/SAMPLER_SKY_LUT.d.ts.map +1 -0
  66. package/src/shade/renderer/atmosphere/SAMPLER_SKY_LUT.js +25 -0
  67. package/src/shade/renderer/atmosphere/chunk_get_multiscatter_values.d.ts +14 -1
  68. package/src/shade/renderer/atmosphere/chunk_get_multiscatter_values.d.ts.map +1 -1
  69. package/src/shade/renderer/atmosphere/chunk_get_multiscatter_values.js +163 -177
  70. package/src/shade/renderer/atmosphere/chunk_multiscatter_sample_direction.d.ts +20 -0
  71. package/src/shade/renderer/atmosphere/chunk_multiscatter_sample_direction.d.ts.map +1 -0
  72. package/src/shade/renderer/atmosphere/chunk_multiscatter_sample_direction.js +46 -0
  73. package/src/shade/renderer/atmosphere/chunk_sample_multiscatter_lut.d.ts +11 -1
  74. package/src/shade/renderer/atmosphere/chunk_sample_multiscatter_lut.d.ts.map +1 -1
  75. package/src/shade/renderer/atmosphere/chunk_sample_multiscatter_lut.js +57 -27
  76. package/src/shade/renderer/atmosphere/chunk_sample_transmittance_lut.d.ts +19 -1
  77. package/src/shade/renderer/atmosphere/chunk_sample_transmittance_lut.d.ts.map +1 -1
  78. package/src/shade/renderer/atmosphere/chunk_sample_transmittance_lut.js +69 -33
  79. package/src/shade/renderer/atmosphere/chunk_sky_lut_compute_uv.d.ts +13 -0
  80. package/src/shade/renderer/atmosphere/chunk_sky_lut_compute_uv.d.ts.map +1 -1
  81. package/src/shade/renderer/atmosphere/chunk_sky_lut_compute_uv.js +35 -35
  82. package/src/shade/renderer/atmosphere/chunk_sky_lut_params.d.ts +13 -0
  83. package/src/shade/renderer/atmosphere/chunk_sky_lut_params.d.ts.map +1 -0
  84. package/src/shade/renderer/atmosphere/chunk_sky_lut_params.js +38 -0
  85. package/src/shade/renderer/atmosphere/chunk_sky_lut_texel_to_unit.d.ts +17 -0
  86. package/src/shade/renderer/atmosphere/chunk_sky_lut_texel_to_unit.d.ts.map +1 -0
  87. package/src/shade/renderer/atmosphere/chunk_sky_lut_texel_to_unit.js +29 -0
  88. package/src/shade/renderer/atmosphere/chunk_sky_lut_uv.d.ts +21 -0
  89. package/src/shade/renderer/atmosphere/chunk_sky_lut_uv.d.ts.map +1 -0
  90. package/src/shade/renderer/atmosphere/chunk_sky_lut_uv.js +42 -0
  91. package/src/shade/renderer/atmosphere/shader_multiscatter_lut.d.ts +2 -2
  92. package/src/shade/renderer/atmosphere/shader_multiscatter_lut.d.ts.map +1 -1
  93. package/src/shade/renderer/atmosphere/shader_multiscatter_lut.js +165 -84
  94. package/src/shade/renderer/atmosphere/shader_sky_irradiance_lut.d.ts.map +1 -1
  95. package/src/shade/renderer/atmosphere/shader_sky_irradiance_lut.js +215 -204
  96. package/src/shade/renderer/atmosphere/shader_transmittance_lut.d.ts.map +1 -1
  97. package/src/shade/renderer/atmosphere/shader_transmittance_lut.js +79 -67
  98. package/src/shade/renderer/light/cluster/graph_assign_clsuters.d.ts.map +1 -1
  99. package/src/shade/renderer/light/cluster/graph_assign_clsuters.js +6 -2
  100. package/src/shade/renderer/postprocess/gtao/GTAO.d.ts.map +1 -1
  101. package/src/shade/renderer/postprocess/gtao/GTAO.js +4 -0
  102. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  103. package/src/shade/renderer/rasterize/bucket/prepare_meshlet_draw_commands_by_material.d.ts.map +1 -1
  104. package/src/shade/renderer/rasterize/bucket/prepare_meshlet_draw_commands_by_material.js +341 -345
  105. package/src/shade/renderer/rasterize/bucket/shader_read_out_bucket.d.ts +0 -2
  106. package/src/shade/renderer/rasterize/bucket/shader_read_out_bucket.d.ts.map +1 -1
  107. package/src/shade/renderer/rasterize/bucket/shader_read_out_bucket.js +58 -57
  108. package/src/shade/renderer/rasterize/expand/mesh/graph_expand_meshes_to_meshlets.d.ts.map +1 -1
  109. package/src/shade/renderer/rasterize/expand/mesh/graph_expand_meshes_to_meshlets.js +7 -3
  110. package/src/shade/renderer/rasterize/fast/graph_extract_meshes_from_bucket.d.ts.map +1 -1
  111. package/src/shade/renderer/rasterize/fast/graph_extract_meshes_from_bucket.js +77 -81
  112. package/src/shade/renderer/rasterize/standard/graph_rasterize_scene.d.ts.map +1 -1
  113. package/src/shade/renderer/rasterize/standard/graph_rasterize_scene.js +5 -1
  114. package/src/shade/renderer/shader/ComputeShader.d.ts.map +1 -1
  115. package/src/shade/renderer/shader/ComputeShader.js +6 -2
  116. package/src/shade/renderer/shader/ImageShader.d.ts.map +1 -1
  117. package/src/shade/renderer/shader/ImageShader.js +4 -1
  118. package/src/shade/renderer/shader/ShaderDescriptor.d.ts.map +1 -1
  119. package/src/shade/renderer/shader/ShaderDescriptor.js +26 -0
  120. package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_RADII_DECLARATION.d.ts +18 -0
  121. package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_RADII_DECLARATION.d.ts.map +1 -0
  122. package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_RADII_DECLARATION.js +32 -0
  123. package/src/shade/renderer/shader/chunk/atmosphere/PLANET_CENTER_DECLARATION.d.ts +7 -0
  124. package/src/shade/renderer/shader/chunk/atmosphere/PLANET_CENTER_DECLARATION.d.ts.map +1 -1
  125. package/src/shade/renderer/shader/chunk/atmosphere/PLANET_CENTER_DECLARATION.js +17 -6
  126. package/src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_ray_bounds.d.ts +21 -0
  127. package/src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_ray_bounds.d.ts.map +1 -0
  128. package/src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_ray_bounds.js +69 -0
  129. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_contains_aabb3.d.ts +9 -0
  130. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_contains_aabb3.d.ts.map +1 -0
  131. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_contains_aabb3.js +22 -0
  132. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_from_transformed_corners.d.ts +16 -0
  133. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_from_transformed_corners.d.ts.map +1 -0
  134. package/src/shade/renderer/shader/chunk/geometry/aabb3/chunk_aabb3_from_transformed_corners.js +41 -0
  135. package/src/shade/renderer/shader/chunk/geometry/frustum/chunk_frustum_transform_m4.d.ts +11 -0
  136. package/src/shade/renderer/shader/chunk/geometry/frustum/chunk_frustum_transform_m4.d.ts.map +1 -1
  137. package/src/shade/renderer/shader/chunk/geometry/frustum/chunk_frustum_transform_m4.js +15 -19
  138. package/src/shade/renderer/shader/chunk/geometry/frustum/chunk_frustum_transform_plane_matrix.d.ts +23 -0
  139. package/src/shade/renderer/shader/chunk/geometry/frustum/chunk_frustum_transform_plane_matrix.d.ts.map +1 -0
  140. package/src/shade/renderer/shader/chunk/geometry/frustum/chunk_frustum_transform_plane_matrix.js +44 -0
  141. package/src/shade/renderer/shader/chunk/geometry/octahedron/chunk_uv_octahedral_unit_decode.d.ts.map +1 -1
  142. package/src/shade/renderer/shader/chunk/geometry/octahedron/chunk_uv_octahedral_unit_decode.js +1 -4
  143. package/src/shade/renderer/shader/compiler/CodeChunk.d.ts +7 -1
  144. package/src/shade/renderer/shader/compiler/CodeChunk.d.ts.map +1 -1
  145. package/src/shade/renderer/shader/compiler/CodeChunk.js +37 -2
  146. package/src/shade/renderer/shader/graph/compute/compute_binding_read_names.d.ts.map +1 -1
  147. package/src/shade/renderer/shader/graph/compute/compute_binding_read_names.js +6 -0
  148. package/src/shade/renderer/shader/graph/compute/graph_compute_indirect_pass.js +1 -1
  149. package/src/shade/renderer/shader/graph/compute/graph_compute_pass.js +1 -1
  150. package/src/shade/renderer/shader/graph/graph_image_pass.js +1 -1
  151. package/src/shade/renderer/shader/graph/graph_prepare_bindings.d.ts.map +1 -1
  152. package/src/shade/renderer/shader/graph/graph_prepare_bindings.js +7 -0
  153. package/src/shade/renderer/shader/graph/graph_prepare_pass_input_data.d.ts +3 -1
  154. package/src/shade/renderer/shader/graph/graph_prepare_pass_input_data.d.ts.map +1 -1
  155. package/src/shade/renderer/shader/graph/graph_prepare_pass_input_data.js +12 -1
  156. package/src/shade/renderer/shader/pass/RenderPassDescriptor.d.ts.map +1 -1
  157. package/src/shade/renderer/shader/pass/RenderPassDescriptor.js +1 -0
  158. package/src/shade/renderer/shader/resource/IMMEDIATE_DATA.d.ts +21 -0
  159. package/src/shade/renderer/shader/resource/IMMEDIATE_DATA.d.ts.map +1 -0
  160. package/src/shade/renderer/shader/resource/IMMEDIATE_DATA.js +21 -0
  161. package/src/shade/renderer/shader/resource/ShaderResourceSetDescriptor.d.ts +59 -1
  162. package/src/shade/renderer/shader/resource/ShaderResourceSetDescriptor.d.ts.map +1 -1
  163. package/src/shade/renderer/shader/resource/ShaderResourceSetDescriptor.js +195 -2
  164. package/src/shade/renderer/shader/type/type_has_arrays.d.ts +14 -0
  165. package/src/shade/renderer/shader/type/type_has_arrays.d.ts.map +1 -0
  166. package/src/shade/renderer/shader/type/type_has_arrays.js +33 -0
  167. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_point2.d.ts +14 -13
  168. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_point2.d.ts.map +1 -1
  169. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_point2.js +133 -129
  170. package/src/shade/renderer/view/GPUViewSkyContext.d.ts.map +1 -1
  171. package/src/shade/renderer/view/GPUViewSkyContext.js +169 -173
  172. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.d.ts.map +1 -1
  173. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.js +480 -315
  174. package/src/shade/renderer/volumetrics/NOTES.md +887 -8
  175. package/src/shade/renderer/volumetrics/ParticipatingMediaVolume.d.ts +5 -0
  176. package/src/shade/renderer/volumetrics/ParticipatingMediaVolume.d.ts.map +1 -1
  177. package/src/shade/renderer/volumetrics/ParticipatingMediaVolume.js +21 -2
  178. package/src/shade/renderer/volumetrics/SceneVolumetrics.d.ts +26 -0
  179. package/src/shade/renderer/volumetrics/SceneVolumetrics.d.ts.map +1 -1
  180. package/src/shade/renderer/volumetrics/SceneVolumetrics.js +64 -21
  181. package/src/shade/renderer/volumetrics/VOLUMETRICS_METADATA_STRUCT.d.ts.map +1 -1
  182. package/src/shade/renderer/volumetrics/VOLUMETRICS_METADATA_STRUCT.js +84 -28
  183. package/src/shade/renderer/volumetrics/VOLUMETRICS_SUN_SHADOW_RESOLUTION.d.ts +98 -0
  184. package/src/shade/renderer/volumetrics/VOLUMETRICS_SUN_SHADOW_RESOLUTION.d.ts.map +1 -0
  185. package/src/shade/renderer/volumetrics/VOLUMETRICS_SUN_SHADOW_RESOLUTION.js +111 -0
  186. package/src/shade/renderer/volumetrics/build_volumetrics_sun_shadow_transform.d.ts +84 -0
  187. package/src/shade/renderer/volumetrics/build_volumetrics_sun_shadow_transform.d.ts.map +1 -0
  188. package/src/shade/renderer/volumetrics/build_volumetrics_sun_shadow_transform.js +252 -0
  189. package/src/shade/renderer/volumetrics/chunk_integrate_optical_depth.js +75 -75
  190. package/src/shade/renderer/volumetrics/chunk_volumetrics_local_light_shadow.d.ts +43 -0
  191. package/src/shade/renderer/volumetrics/chunk_volumetrics_local_light_shadow.d.ts.map +1 -0
  192. package/src/shade/renderer/volumetrics/chunk_volumetrics_local_light_shadow.js +145 -0
  193. package/src/shade/renderer/volumetrics/chunk_volumetrics_sample_froxel_extinction.d.ts +20 -0
  194. package/src/shade/renderer/volumetrics/chunk_volumetrics_sample_froxel_extinction.d.ts.map +1 -0
  195. package/src/shade/renderer/volumetrics/chunk_volumetrics_sample_froxel_extinction.js +48 -0
  196. package/src/shade/renderer/volumetrics/chunk_volumetrics_sun_optical_depth.d.ts +38 -0
  197. package/src/shade/renderer/volumetrics/chunk_volumetrics_sun_optical_depth.d.ts.map +1 -0
  198. package/src/shade/renderer/volumetrics/chunk_volumetrics_sun_optical_depth.js +130 -0
  199. package/src/shade/renderer/volumetrics/graph_build_volumetrics.d.ts +18 -3
  200. package/src/shade/renderer/volumetrics/graph_build_volumetrics.d.ts.map +1 -1
  201. package/src/shade/renderer/volumetrics/graph_build_volumetrics.js +193 -70
  202. package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.d.ts +16 -0
  203. package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.d.ts.map +1 -1
  204. package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.js +83 -15
  205. package/src/shade/renderer/volumetrics/shader_volumetrics_build_participating_media.d.ts.map +1 -1
  206. package/src/shade/renderer/volumetrics/shader_volumetrics_build_participating_media.js +29 -18
  207. package/src/shade/renderer/volumetrics/shader_volumetrics_build_scattering_lut.js +260 -260
  208. package/src/shade/renderer/volumetrics/shader_volumetrics_build_sun_shadow_volume.d.ts +58 -0
  209. package/src/shade/renderer/volumetrics/shader_volumetrics_build_sun_shadow_volume.d.ts.map +1 -0
  210. package/src/shade/renderer/volumetrics/shader_volumetrics_build_sun_shadow_volume.js +290 -0
  211. package/src/shade/wgsl/emulator/CPUBitmapData.d.ts +25 -0
  212. package/src/shade/wgsl/emulator/CPUBitmapData.d.ts.map +1 -1
  213. package/src/shade/wgsl/emulator/CPUBitmapData.js +33 -0
  214. package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.js +2228 -2215
  215. package/src/shade/wgsl/emulator/WGSLLanguageCore.d.ts.map +1 -1
  216. package/src/shade/wgsl/emulator/WGSLLanguageCore.js +210 -2
  217. package/src/shade/wgsl/emulator/cpu_texture_gather.d.ts +69 -0
  218. package/src/shade/wgsl/emulator/cpu_texture_gather.d.ts.map +1 -0
  219. package/src/shade/wgsl/emulator/cpu_texture_gather.js +148 -0
  220. package/src/shade/wgsl/emulator/cpu_texture_sample.d.ts +16 -0
  221. package/src/shade/wgsl/emulator/cpu_texture_sample.d.ts.map +1 -1
  222. package/src/shade/wgsl/emulator/cpu_texture_sample.js +176 -172
  223. package/src/shade/renderer/volumetrics/VOLUMETRICS_WORKGROUP_RESOLUTION.d.ts +0 -2
  224. package/src/shade/renderer/volumetrics/VOLUMETRICS_WORKGROUP_RESOLUTION.d.ts.map +0 -1
  225. package/src/shade/renderer/volumetrics/VOLUMETRICS_WORKGROUP_RESOLUTION.js +0 -1
@@ -1,177 +1,163 @@
1
- import { ATMOSPHERE_HEIGHT_DECLARATION } from "../shader/chunk/atmosphere/ATMOSPHERE_HEIGHT_DECLARATION.js";
2
- import {
3
- C_MIE_ABSORPTION_DECLARATION,
4
- C_MIE_SCATTERING_DECLARATION
5
- } from "../shader/chunk/atmosphere/C_MIE_SCATTERING_DECLARATION.js";
6
- import { C_OZONE_DECLARATION } from "../shader/chunk/atmosphere/C_OZONE_DECLARATION.js";
7
- import { C_RAYLEIGH_DECLARATION } from "../shader/chunk/atmosphere/C_RAYLEIGH_DECLARATION.js";
8
- import { chunk_atmosphere_density } from "../shader/chunk/atmosphere/chunk_atmosphere_density.js";
9
- import { chunk_atmosphere_height } from "../shader/chunk/atmosphere/chunk_atmosphere_height.js";
10
- import { chunk_atmosphere_intersection } from "../shader/chunk/atmosphere/chunk_atmosphere_intersection.js";
11
- import {
12
- chunk_position_relative_to_planet_center
13
- } from "../shader/chunk/atmosphere/chunk_position_relative_to_planet_center.js";
14
- import { chunk_sphere_intersection } from "../shader/chunk/atmosphere/chunk_sphere_intersection.js";
15
- import { chunk_sphere_intersection_nearest } from "../shader/chunk/atmosphere/chunk_sphere_intersection_nearest.js";
16
- import {
17
- chunk_phase_mie_cornette_shanks
18
- } from "../shader/chunk/atmosphere/phase/chunk_phase_mie_cornette_shanks.js";
19
- import { chunk_phase_rayleigh } from "../shader/chunk/atmosphere/phase/chunk_phase_rayleigh.js";
20
- import { PLANET_CENTER_DECLARATION } from "../shader/chunk/atmosphere/PLANET_CENTER_DECLARATION.js";
21
- import { PLANET_RADIUS_DECLARATION } from "../shader/chunk/atmosphere/PLANET_RADIUS_DECLARATION.js";
22
- import { chunk_spherical_to_cartesian } from "../shader/chunk/geometry/sphere/chunk_spherical_to_cartesian.js";
23
- import { chunk_safe_acos } from "../shader/chunk/math/chunk_safe_acos.js";
24
- import { PI_DECLARATION } from "../shader/chunk/math/PI_DECLARATION.js";
25
- import { CodeChunk } from "../shader/compiler/CodeChunk.js";
26
- import { chunk_sample_transmittance_lut } from "./chunk_sample_transmittance_lut.js";
27
- import { MIE_G } from "./MIE_G.js";
28
-
29
-
30
- /**
31
- * Calculates Equation (5) and (7) from the paper.
32
- * @see "A Scalable and Production Ready Sky and Atmosphere Rendering Technique", Hillaire (2020)
33
- */
34
- export const chunk_get_multiscatter_values = CodeChunk.from(
35
- //language=WGSL
36
- `
37
- fn get_multiscatter_values(
38
- pos: vec3<f32>,
39
- sunDir: vec3<f32>,
40
- steps: f32,
41
- sqrt_samples: u32,
42
- out_lumTotal: ptr<function,vec3<f32>>,
43
- out_fms: ptr<function,vec3<f32>>,
44
- ) {
45
- const groundAlbedo = vec3(0.3);
46
-
47
- var lumTotal = vec3(0.0);
48
- var fms = vec3(0.0);
49
-
50
- let inv_samples = 1.0 / f32( sqrt_samples * sqrt_samples );
51
-
52
- for (var i = 0u; i < sqrt_samples; i++) {
53
- for (var j = 0u; j < sqrt_samples; j++) {
54
-
55
- // This integral is symmetric about theta = 0 (or theta = PI), so we
56
- // only need to integrate from zero to PI, not zero to 2*PI.
57
-
58
- let theta = PI * ( f32(i) + 0.5 ) / f32(sqrt_samples);
59
- let phi = safe_acos(1.0 - 2.0*(f32(j) + 0.5) / f32(sqrt_samples));
60
-
61
- let rayDir = spherical_to_cartesian(theta, phi);
62
-
63
- // distance to the edge of the atmosphere
64
- let atmoDist = sphere_intersection_nearest(pos, rayDir, PLANET_CENTER, PLANET_RADIUS + ATMOSPHERE_HEIGHT);
65
- let groundDist = sphere_intersection_nearest(pos, rayDir, PLANET_CENTER, PLANET_RADIUS);
66
-
67
- var tMax = atmoDist;
68
-
69
- if (groundDist > 0.0) {
70
- // in case we're looking down
71
- tMax = groundDist;
72
- }
73
-
74
- let cosTheta = dot(rayDir, sunDir);
75
-
76
- let miePhaseValue = phase_mie(cosTheta, ${MIE_G});
77
- let rayleighPhaseValue = phase_rayleigh(-cosTheta);
78
-
79
- var lum = vec3(0.0);
80
- var lumFactor = vec3(0.0);
81
- var transmittance = vec3(1.0);
82
-
83
- var t = 0.0;
84
- for (var stepI = 0.0; stepI < steps; stepI += 1.0) {
85
- let newT = ( (stepI + 0.3) / steps ) * tMax;
86
- let dt = newT - t;
87
- t = newT;
88
-
89
- let newPos = pos + t * rayDir;
90
-
91
-
92
- let local_height = atmosphere_height(newPos);
93
- let local_density = atmosphere_density(local_height);
94
-
95
- let ozone_density = local_density.z;
96
- let ozone_absorption = ozone_density * C_OZONE;
97
-
98
- let mie_density = local_density.y;
99
- let mie_absorption = mie_density * C_MIE_ABSORPTION;
100
- let mie_scattering = mie_density * C_MIE_SCATTERING;
101
-
102
- // note - taken from the Hillaire's atmosphere code: https://github.com/sebh/UnrealEngineSkyAtmosphere/blob/183ead5bdacc701b3b626347a680a2f3cd3d4fbd/Resources/RenderSkyCommon.hlsl#L248
103
- let rayleigh_absorption = 0.0;
104
- let rayleigh_scattering = local_density.x * C_RAYLEIGH;
105
-
106
- let extinction = rayleigh_scattering + rayleigh_absorption + mie_scattering + mie_absorption + ozone_absorption;
107
-
108
-
109
- let sample_transmittance = exp(-dt * extinction);
110
-
111
- // Integrate within each segment.
112
- let scatteringNoPhase = rayleigh_scattering + mie_scattering;
113
- let scatteringF = (scatteringNoPhase - scatteringNoPhase * sample_transmittance) / extinction;
114
- lumFactor += transmittance * scatteringF;
115
-
116
- // This is slightly different from the paper, but I think the paper has a mistake?
117
- // In equation (6), I think S(x,w_s) should be S(x-tv,w_s).
118
- let sun_transmittance = sample_transmittance_lut(newPos, sunDir);
119
-
120
- let rayleighInScattering = rayleigh_scattering * rayleighPhaseValue;
121
- let mieInScattering = mie_scattering * miePhaseValue;
122
- let inScattering = (rayleighInScattering + mieInScattering) * sun_transmittance;
123
-
124
- // Integrated scattering within path segment.
125
- let scatteringIntegral = (inScattering - inScattering * sample_transmittance) / extinction;
126
-
127
- lum += scatteringIntegral * transmittance;
128
- transmittance *= sample_transmittance;
129
- }
130
-
131
- if (groundDist > 0.0) {
132
-
133
-
134
- let relative_pos = position_relative_to_planet_center(pos);
135
-
136
- if (dot(relative_pos, sunDir) > 0.0) {
137
-
138
- // sun is behind us, pick a point on the planet to sample
139
- let hitPos = normalize(relative_pos + groundDist*rayDir) * PLANET_RADIUS + PLANET_CENTER;
140
-
141
- lum += transmittance * groundAlbedo * sample_transmittance_lut(hitPos, sunDir);
142
-
143
- }
144
-
145
- }
146
-
147
- fms += lumFactor * inv_samples;
148
- lumTotal += lum * inv_samples;
149
- }
150
- }
151
-
152
- *out_fms = fms;
153
- *out_lumTotal = lumTotal;
154
-
155
- }
156
- `, [
157
- PI_DECLARATION,
158
- PLANET_CENTER_DECLARATION,
159
- PLANET_RADIUS_DECLARATION,
160
- ATMOSPHERE_HEIGHT_DECLARATION,
161
- C_OZONE_DECLARATION,
162
- C_MIE_SCATTERING_DECLARATION,
163
- C_MIE_ABSORPTION_DECLARATION,
164
- C_RAYLEIGH_DECLARATION,
165
- chunk_safe_acos,
166
- chunk_atmosphere_height,
167
- chunk_spherical_to_cartesian,
168
- chunk_sphere_intersection,
169
- chunk_atmosphere_intersection,
170
- chunk_atmosphere_density,
171
- chunk_phase_mie_cornette_shanks,
172
- chunk_phase_rayleigh,
173
- chunk_sample_transmittance_lut,
174
- chunk_sphere_intersection_nearest,
175
- chunk_position_relative_to_planet_center,
176
- ]
177
- )
1
+ import { ATMOSPHERE_RADII_DECLARATION } from "../shader/chunk/atmosphere/ATMOSPHERE_RADII_DECLARATION.js";
2
+ import {
3
+ C_MIE_ABSORPTION_DECLARATION,
4
+ C_MIE_SCATTERING_DECLARATION
5
+ } from "../shader/chunk/atmosphere/C_MIE_SCATTERING_DECLARATION.js";
6
+ import { C_OZONE_DECLARATION } from "../shader/chunk/atmosphere/C_OZONE_DECLARATION.js";
7
+ import { C_RAYLEIGH_DECLARATION } from "../shader/chunk/atmosphere/C_RAYLEIGH_DECLARATION.js";
8
+ import { chunk_atmosphere_density } from "../shader/chunk/atmosphere/chunk_atmosphere_density.js";
9
+ import { chunk_atmosphere_ray_bounds } from "../shader/chunk/atmosphere/chunk_atmosphere_ray_bounds.js";
10
+ import {
11
+ chunk_position_relative_to_planet_center
12
+ } from "../shader/chunk/atmosphere/chunk_position_relative_to_planet_center.js";
13
+ import {
14
+ chunk_phase_mie_cornette_shanks
15
+ } from "../shader/chunk/atmosphere/phase/chunk_phase_mie_cornette_shanks.js";
16
+ import { chunk_phase_rayleigh } from "../shader/chunk/atmosphere/phase/chunk_phase_rayleigh.js";
17
+ import { PI_DECLARATION } from "../shader/chunk/math/PI_DECLARATION.js";
18
+ import { CodeChunk } from "../shader/compiler/CodeChunk.js";
19
+ import { chunk_sample_transmittance_lut_params } from "./chunk_sample_transmittance_lut.js";
20
+ import { MIE_G } from "./MIE_G.js";
21
+ import { MULTISCATTER_LUT_STEPS } from "./MULTISCATTER_LUT_CONFIG.js";
22
+
23
+
24
+ /**
25
+ * One direction's contribution to Equations (5) and (7) from the paper: `out_lum` is the
26
+ * second-order in-scattered luminance along `rayDir`, `out_fms` the luminance that would
27
+ * come back if the medium scattered one unit of light isotropically. The caller integrates
28
+ * over the direction set -- see {@link chunk_multiscatter_sample_direction} -- by taking the
29
+ * mean, which is what the paper's uniform phase p_u = 1/(4*PI) reduces to.
30
+ *
31
+ * Splitting one direction out of the loop is what lets `shader_multiscatter_lut` put a
32
+ * thread on each of the 64 directions, the way Hillaire's `NewMultiScattCS` does.
33
+ *
34
+ * `pos` is assumed to be inside the atmosphere and at or above the surface, which is what
35
+ * makes the far root of the outer sphere the atmosphere exit.
36
+ *
37
+ * @see "A Scalable and Production Ready Sky and Atmosphere Rendering Technique", Hillaire (2020)
38
+ * @see https://www.shadertoy.com/view/slSXRW
39
+ * @type {CodeChunk}
40
+ */
41
+ export const chunk_get_multiscatter_values = CodeChunk.from(
42
+ //language=WGSL
43
+ `
44
+ const MULTISCATTER_GROUND_ALBEDO = vec3(0.3);
45
+ const MULTISCATTER_STEPS = ${MULTISCATTER_LUT_STEPS}u;
46
+ const MULTISCATTER_STEPS_F = f32(MULTISCATTER_STEPS);
47
+
48
+ fn get_multiscatter_values(
49
+ pos: vec3<f32>,
50
+ sunDir: vec3<f32>,
51
+ rayDir: vec3<f32>,
52
+ out_lum: ptr<function,vec3<f32>>,
53
+ out_fms: ptr<function,vec3<f32>>,
54
+ ) {
55
+ let rel = position_relative_to_planet_center(pos);
56
+
57
+ // one quadratic setup for both spheres; in case we're looking down, the ground is as far
58
+ // as the march goes
59
+ let bounds = atmosphere_ray_bounds(rel, rayDir);
60
+
61
+ let tMax = bounds.t_max;
62
+
63
+ let cosTheta = dot(rayDir, sunDir);
64
+
65
+ let miePhaseValue = phase_mie(cosTheta, ${MIE_G});
66
+ let rayleighPhaseValue = phase_rayleigh(-cosTheta);
67
+
68
+ var lum = vec3(0.0);
69
+ var lumFactor = vec3(0.0);
70
+ var transmittance = vec3(1.0);
71
+
72
+ var t = 0.0;
73
+ for (var stepI = 0u; stepI < MULTISCATTER_STEPS; stepI++) {
74
+ let newT = ( (f32(stepI) + 0.3) / MULTISCATTER_STEPS_F ) * tMax;
75
+ let dt = newT - t;
76
+ t = newT;
77
+
78
+ // Stepping the planet-relative position directly: building the world position only
79
+ // to have the LUT lookup subtract the planet centre back off it was the second of
80
+ // two square roots per step.
81
+ let step_rel = rel + t * rayDir;
82
+ let step_radius = length(step_rel);
83
+ let up = step_rel / step_radius;
84
+
85
+ let local_height = step_radius - ATMOSPHERE_GROUND_RADIUS;
86
+ let local_density = atmosphere_density(local_height);
87
+
88
+ let ozone_density = local_density.z;
89
+ let ozone_absorption = ozone_density * C_OZONE;
90
+
91
+ let mie_density = local_density.y;
92
+ let mie_absorption = mie_density * C_MIE_ABSORPTION;
93
+ let mie_scattering = mie_density * C_MIE_SCATTERING;
94
+
95
+ // note - taken from the Hillaire's atmosphere code: https://github.com/sebh/UnrealEngineSkyAtmosphere/blob/183ead5bdacc701b3b626347a680a2f3cd3d4fbd/Resources/RenderSkyCommon.hlsl#L248
96
+ let rayleigh_absorption = 0.0;
97
+ let rayleigh_scattering = local_density.x * C_RAYLEIGH;
98
+
99
+ let extinction = rayleigh_scattering + rayleigh_absorption + mie_scattering + mie_absorption + ozone_absorption;
100
+
101
+
102
+ let sample_transmittance = exp(-dt * extinction);
103
+
104
+ // Integrate within each segment.
105
+ let scatteringNoPhase = rayleigh_scattering + mie_scattering;
106
+ let scatteringF = (scatteringNoPhase - scatteringNoPhase * sample_transmittance) / extinction;
107
+ lumFactor += transmittance * scatteringF;
108
+
109
+ // This is slightly different from the paper, but I think the paper has a mistake?
110
+ // In equation (6), I think S(x,w_s) should be S(x-tv,w_s).
111
+ let sun_transmittance = sample_transmittance_lut_params(local_height, dot(sunDir, up));
112
+
113
+ let rayleighInScattering = rayleigh_scattering * rayleighPhaseValue;
114
+ let mieInScattering = mie_scattering * miePhaseValue;
115
+ let inScattering = (rayleighInScattering + mieInScattering) * sun_transmittance;
116
+
117
+ // Integrated scattering within path segment.
118
+ let scatteringIntegral = (inScattering - inScattering * sample_transmittance) / extinction;
119
+
120
+ lum += scatteringIntegral * transmittance;
121
+ transmittance *= sample_transmittance;
122
+ }
123
+
124
+ if (bounds.hits_ground) {
125
+
126
+ // Light bounced off the planet. Hillaire reaches this through
127
+ // IntegrateScatteredLuminance:
128
+ // L += ... * throughput * NdotL * Atmosphere.GroundAlbedo / PI
129
+ // The surface is Lambertian, hence albedo/PI, and the cosine belongs to the hit
130
+ // point rather than to \`pos\`: along a shallow ray the two are hundreds of
131
+ // kilometres apart and can sit on opposite sides of the terminator.
132
+ let hit_up = normalize(rel + bounds.ground_distance * rayDir);
133
+
134
+ let sun_cos_zenith_angle = dot(hit_up, sunDir);
135
+
136
+ // the hit lies on the surface by construction, so its LUT altitude is exactly zero
137
+ let sun_transmittance = sample_transmittance_lut_params(0.0, sun_cos_zenith_angle);
138
+
139
+ lum += transmittance
140
+ * saturate(sun_cos_zenith_angle)
141
+ * (MULTISCATTER_GROUND_ALBEDO / PI)
142
+ * sun_transmittance;
143
+ }
144
+
145
+ *out_fms = lumFactor;
146
+ *out_lum = lum;
147
+
148
+ }
149
+ `, [
150
+ PI_DECLARATION,
151
+ ATMOSPHERE_RADII_DECLARATION,
152
+ C_OZONE_DECLARATION,
153
+ C_MIE_SCATTERING_DECLARATION,
154
+ C_MIE_ABSORPTION_DECLARATION,
155
+ C_RAYLEIGH_DECLARATION,
156
+ chunk_atmosphere_density,
157
+ chunk_atmosphere_ray_bounds,
158
+ chunk_phase_mie_cornette_shanks,
159
+ chunk_phase_rayleigh,
160
+ chunk_position_relative_to_planet_center,
161
+ chunk_sample_transmittance_lut_params,
162
+ ]
163
+ )
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The direction set the multiple-scattering LUT integrates over, one direction per index in
3
+ * `[0, MULTISCATTER_LUT_DIRECTION_COUNT)`. Stratified: midpoints of a uniform grid in
4
+ * azimuth, and of a uniform grid in the cosine of the polar angle, so every sample carries
5
+ * the same solid angle and a plain mean over the set is the spherical average that
6
+ * Equations (5) and (7) ask for.
7
+ *
8
+ * PRECONDITION: only valid when the sun lies in the y-z plane (`sunDir.x == 0`) and the
9
+ * sample position is on the +y axis through the planet centre. Azimuth spans [0, PI), not
10
+ * [0, 2*PI), which covers only the x >= 0 hemisphere; the mean over that half equals the
11
+ * mean over the whole sphere because reflecting x -> -x leaves both the sun direction and a
12
+ * spherically symmetric atmosphere unchanged. Hillaire integrates the full 2*PI precisely
13
+ * because his formulation does not lean on that. `shader_multiscatter_lut` satisfies the
14
+ * precondition by construction; a caller that does not must widen the azimuth.
15
+ *
16
+ * @type {CodeChunk}
17
+ */
18
+ export const chunk_multiscatter_sample_direction: CodeChunk;
19
+ import { CodeChunk } from "../shader/compiler/CodeChunk.js";
20
+ //# sourceMappingURL=chunk_multiscatter_sample_direction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_multiscatter_sample_direction.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/atmosphere/chunk_multiscatter_sample_direction.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;GAgBG;AACH,kDAFU,SAAS,CAwBjB;0BA1CwB,iCAAiC"}
@@ -0,0 +1,46 @@
1
+ import { chunk_spherical_to_cartesian } from "../shader/chunk/geometry/sphere/chunk_spherical_to_cartesian.js";
2
+ import { chunk_safe_acos } from "../shader/chunk/math/chunk_safe_acos.js";
3
+ import { PI_DECLARATION } from "../shader/chunk/math/PI_DECLARATION.js";
4
+ import { CodeChunk } from "../shader/compiler/CodeChunk.js";
5
+ import { MULTISCATTER_LUT_SQRT_SAMPLES } from "./MULTISCATTER_LUT_CONFIG.js";
6
+
7
+ /**
8
+ * The direction set the multiple-scattering LUT integrates over, one direction per index in
9
+ * `[0, MULTISCATTER_LUT_DIRECTION_COUNT)`. Stratified: midpoints of a uniform grid in
10
+ * azimuth, and of a uniform grid in the cosine of the polar angle, so every sample carries
11
+ * the same solid angle and a plain mean over the set is the spherical average that
12
+ * Equations (5) and (7) ask for.
13
+ *
14
+ * PRECONDITION: only valid when the sun lies in the y-z plane (`sunDir.x == 0`) and the
15
+ * sample position is on the +y axis through the planet centre. Azimuth spans [0, PI), not
16
+ * [0, 2*PI), which covers only the x >= 0 hemisphere; the mean over that half equals the
17
+ * mean over the whole sphere because reflecting x -> -x leaves both the sun direction and a
18
+ * spherically symmetric atmosphere unchanged. Hillaire integrates the full 2*PI precisely
19
+ * because his formulation does not lean on that. `shader_multiscatter_lut` satisfies the
20
+ * precondition by construction; a caller that does not must widen the azimuth.
21
+ *
22
+ * @type {CodeChunk}
23
+ */
24
+ export const chunk_multiscatter_sample_direction = CodeChunk.from(
25
+ //language=WGSL
26
+ `
27
+ const MULTISCATTER_SQRT_SAMPLES = ${MULTISCATTER_LUT_SQRT_SAMPLES}u;
28
+ const MULTISCATTER_SQRT_SAMPLES_F = f32(MULTISCATTER_SQRT_SAMPLES);
29
+
30
+ fn multiscatter_sample_direction(index: u32) -> vec3<f32> {
31
+
32
+ let i = f32(index / MULTISCATTER_SQRT_SAMPLES);
33
+ let j = f32(index % MULTISCATTER_SQRT_SAMPLES);
34
+
35
+ // see the PRECONDITION note: half the azimuth, by symmetry about the sun plane
36
+ let theta = PI * (i + 0.5) / MULTISCATTER_SQRT_SAMPLES_F;
37
+ let phi = safe_acos(1.0 - 2.0 * (j + 0.5) / MULTISCATTER_SQRT_SAMPLES_F);
38
+
39
+ return spherical_to_cartesian(theta, phi);
40
+ }
41
+ `, [
42
+ PI_DECLARATION,
43
+ chunk_safe_acos,
44
+ chunk_spherical_to_cartesian,
45
+ ]
46
+ );
@@ -1,5 +1,15 @@
1
1
  /**
2
- * see {@link shader_multiscatter_lut}
2
+ * Assumes following in the context:
3
+ * tSkyLutMultiscatter: texture_2d<f32> (sample type "float", i.e. filterable)
4
+ * sSkyLut: sampler (see {@link SAMPLER_SKY_LUT})
5
+ *
6
+ * see {@link shader_multiscatter_lut}, and {@link chunk_sample_transmittance_lut_params} for
7
+ * why this filters in hardware and reads its own resolution.
8
+ * @type {CodeChunk}
9
+ */
10
+ export const chunk_sample_multiscatter_lut_params: CodeChunk;
11
+ /**
12
+ * {@link chunk_sample_multiscatter_lut_params} from a world-space position.
3
13
  * @type {CodeChunk}
4
14
  */
5
15
  export const chunk_sample_multiscatter_lut: CodeChunk;
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_sample_multiscatter_lut.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/atmosphere/chunk_sample_multiscatter_lut.js"],"names":[],"mappings":"AAMA;;;GAGG;AACH,4CAFU,SAAS,CAkBjB;0BAvBwB,iCAAiC"}
1
+ {"version":3,"file":"chunk_sample_multiscatter_lut.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/atmosphere/chunk_sample_multiscatter_lut.js"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,mDAFU,SAAS,CAsBjB;AAEF;;;GAGG;AACH,4CAFU,SAAS,CAmBjB;0BAxDwB,iCAAiC"}
@@ -1,27 +1,57 @@
1
- import {
2
- chunk_texture_sample_bilinear_uv
3
- } from "../shader/chunk/texture/sample/chunk_texture_sample_bilinear_uv.js";
4
- import { CodeChunk } from "../shader/compiler/CodeChunk.js";
5
- import { chunk_sky_lut_compute_uv } from "./chunk_sky_lut_compute_uv.js";
6
-
7
- /**
8
- * see {@link shader_multiscatter_lut}
9
- * @type {CodeChunk}
10
- */
11
- export const chunk_sample_multiscatter_lut = CodeChunk.from(
12
- //language=WGSL
13
- `
14
- fn sample_multiscatter_lut(
15
- pos:vec3<f32>,
16
- sunDir:vec3<f32>
17
- ) -> vec3<f32>{
18
-
19
- let uv = sky_lut_compute_uv(pos, sunDir);
20
-
21
- return texture_sample_bilinear_uv(tSkyLutMultiscatter, uv, 0).rgb;
22
- }
23
- `, [
24
- chunk_sky_lut_compute_uv,
25
- chunk_texture_sample_bilinear_uv
26
- ]
27
- );
1
+ import { CodeChunk } from "../shader/compiler/CodeChunk.js";
2
+ import { chunk_sky_lut_params } from "./chunk_sky_lut_params.js";
3
+ import { chunk_sky_lut_uv } from "./chunk_sky_lut_uv.js";
4
+
5
+ /**
6
+ * Assumes following in the context:
7
+ * tSkyLutMultiscatter: texture_2d<f32> (sample type "float", i.e. filterable)
8
+ * sSkyLut: sampler (see {@link SAMPLER_SKY_LUT})
9
+ *
10
+ * see {@link shader_multiscatter_lut}, and {@link chunk_sample_transmittance_lut_params} for
11
+ * why this filters in hardware and reads its own resolution.
12
+ * @type {CodeChunk}
13
+ */
14
+ export const chunk_sample_multiscatter_lut_params = CodeChunk.from(
15
+ //language=WGSL
16
+ `
17
+ fn sample_multiscatter_lut_params(
18
+ height: f32,
19
+ sun_cos_zenith_angle: f32
20
+ ) -> vec3<f32>{
21
+
22
+ let uv = sky_lut_uv(
23
+ height,
24
+ sun_cos_zenith_angle,
25
+ vec2<f32>(textureDimensions(tSkyLutMultiscatter))
26
+ );
27
+
28
+ return textureSampleLevel(tSkyLutMultiscatter, sSkyLut, uv, 0.0).rgb;
29
+
30
+ }
31
+ `, [
32
+ chunk_sky_lut_uv,
33
+ ]
34
+ );
35
+
36
+ /**
37
+ * {@link chunk_sample_multiscatter_lut_params} from a world-space position.
38
+ * @type {CodeChunk}
39
+ */
40
+ export const chunk_sample_multiscatter_lut = CodeChunk.from(
41
+ //language=WGSL
42
+ `
43
+ fn sample_multiscatter_lut(
44
+ pos:vec3<f32>,
45
+ sunDir:vec3<f32>
46
+ ) -> vec3<f32>{
47
+
48
+ let params = sky_lut_params(pos, sunDir);
49
+
50
+ return sample_multiscatter_lut_params(params.x, params.y);
51
+
52
+ }
53
+ `, [
54
+ chunk_sample_multiscatter_lut_params,
55
+ chunk_sky_lut_params,
56
+ ]
57
+ );
@@ -1,10 +1,28 @@
1
1
  /**
2
2
  * Assumes following in the context:
3
- * tSkyLutTransmittance: texture_2d<f32>
3
+ * tSkyLutTransmittance: texture_2d<f32> (sample type "float", i.e. filterable)
4
+ * sSkyLut: sampler (see {@link SAMPLER_SKY_LUT})
5
+ *
6
+ * The LUT is rgba16float, which is filterable in core WebGPU -- only the 32-bit float
7
+ * formats need the `float32-filterable` feature -- so this goes through the texture unit
8
+ * rather than the 4-tap `texture_sample_bilinear_uv`. Clamp-to-edge on the sampler
9
+ * reproduces that function's per-corner clamping.
10
+ *
11
+ * The half-texel inset {@link chunk_sky_lut_uv} applies needs the LUT's resolution, which is
12
+ * read from the binding rather than passed in: the texture is the authority on its own size,
13
+ * and a caller cannot get it wrong.
4
14
  *
5
15
  * see {@link shader_transmittance_lut}
6
16
  * @type {CodeChunk}
7
17
  */
18
+ export const chunk_sample_transmittance_lut_params: CodeChunk;
19
+ /**
20
+ * {@link chunk_sample_transmittance_lut_params} from a world-space position. A ray-march that
21
+ * already knows the altitude and the local up vector should build the pair itself and call
22
+ * the primitive, rather than have this recover them with another square root.
23
+ *
24
+ * @type {CodeChunk}
25
+ */
8
26
  export const chunk_sample_transmittance_lut: CodeChunk;
9
27
  import { CodeChunk } from "../shader/compiler/CodeChunk.js";
10
28
  //# sourceMappingURL=chunk_sample_transmittance_lut.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_sample_transmittance_lut.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/atmosphere/chunk_sample_transmittance_lut.js"],"names":[],"mappings":"AAMA;;;;;;GAMG;AACH,6CAFU,SAAS,CAoBjB;0BA5BwB,iCAAiC"}
1
+ {"version":3,"file":"chunk_sample_transmittance_lut.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/atmosphere/chunk_sample_transmittance_lut.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;GAgBG;AACH,oDAFU,SAAS,CAsBjB;AAEF;;;;;;GAMG;AACH,6CAFU,SAAS,CAoBjB;0BApEwB,iCAAiC"}