@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
@@ -0,0 +1,290 @@
1
+ import { CAMERA_UNIFORM_STRUCT } from "../camera/CAMERA_UNIFORM_STRUCT.js";
2
+ import { chunk_texel_coordinate_to_uv } from "../shader/chunk/texture/chunk_texel_coordinate_to_uv.js";
3
+ import { CodeChunk } from "../shader/compiler/CodeChunk.js";
4
+ import { ComputeShader } from "../shader/ComputeShader.js";
5
+ import { ShaderResourceSetDescriptor } from "../shader/resource/ShaderResourceSetDescriptor.js";
6
+ import { u32 } from "../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
7
+ import { WebGPUStruct } from "../shader/type/WebGPUStruct.js";
8
+ import { SAMPLER_LINEAR_UPSCALE } from "../texture/SAMPLER_LINEAR_UPSCALE.js";
9
+ import { chunk_volumetrics_sample_froxel_extinction } from "./chunk_volumetrics_sample_froxel_extinction.js";
10
+ import { VOLUMETRICS_SUN_SHADOW_WORKGROUP_RESOLUTION } from "./VOLUMETRICS_SUN_SHADOW_RESOLUTION.js";
11
+ import { VOLUMETRICS_METADATA_STRUCT } from "./VOLUMETRICS_METADATA_STRUCT.js";
12
+
13
+ /**
14
+ * Q-04. Builds one cascade of the sun's optical-depth volume so the lighting pass can read a
15
+ * froxel's media self-shadowing in one fetch instead of marching 16 steps toward the sun for it.
16
+ *
17
+ * The structure is a light-aligned voxel grid holding a prefix sum of extinction along the sun
18
+ * axis — in the shadow-map taxonomy an opacity shadow map (Kim & Neumann 2001) with enough slices
19
+ * and hardware trilinear reconstruction that the slice artefacts it is remembered for do not
20
+ * appear, and exact rather than approximate for the piecewise-constant field a voxel grid is.
21
+ * Enshrouded (GPC 2024) ships the same thing, cascaded: 3D volumes with their z axis on the primary
22
+ * light, initialised from the participating media and then integrated by a 2D dispatch per column,
23
+ * each cascade seeded from the one outside it. Frostbite (SIGGRAPH 2015) cascades its extinction
24
+ * volume the same way, three clip-map levels of it, for the same reason.
25
+ *
26
+ * Fourier Opacity Mapping is the better-known answer and is the wrong one here. It exists because
27
+ * the medium usually arrives as unordered rasterized particles, where the only thing you can do is
28
+ * accumulate a fixed-size, order-independent, additively-blendable summary — and it pays for that
29
+ * with ringing at sharp density transitions. This engine's medium is already a 3D texture with a
30
+ * defined order along any axis, so the scan is available, exact, and has nothing to ring.
31
+ *
32
+ * Two shaders, written out: the outermost cascade, whose scan starts at zero, and every cascade
33
+ * inside it, whose scan starts from the cascade outside. That is a difference in *bindings* — the
34
+ * second reads a texture the first does not have — so it cannot be data. Which cascade is being
35
+ * built can be, and is: it arrives as immediate data, so the inner cascades share one pipeline.
36
+ *
37
+ * @see chunk_volumetrics_sun_optical_depth for the read side
38
+ * @see build_volumetrics_sun_shadow_transform for where each box is placed, and why it is stable
39
+ */
40
+
41
+ /**
42
+ * Which cascade a dispatch is building.
43
+ *
44
+ * Per-dispatch, uniform, read-only and eight bytes, which is the shape immediate data exists for:
45
+ * no pooled buffer, no staging copy, no bind group.
46
+ *
47
+ * `sub_steps` travels with it rather than being derived in the shader because it is a property of
48
+ * the cascade ladder rather than of the box: {@link volumetrics_sun_shadow_sub_steps} is where the
49
+ * rule that it is even and at least two lives, and nothing in the metadata lets the shader
50
+ * re-derive it.
51
+ *
52
+ * @type {WebGPUStruct}
53
+ */
54
+ export const VOLUMETRICS_SUN_SHADOW_BUILD_SETTINGS = WebGPUStruct.from({
55
+ cascade: u32,
56
+ sub_steps: u32,
57
+ }, 'VolumetricsSunShadowBuildSettings');
58
+
59
+ const outermost_resources = new ShaderResourceSetDescriptor();
60
+
61
+ outermost_resources.setImmediate("settings", VOLUMETRICS_SUN_SHADOW_BUILD_SETTINGS);
62
+
63
+ outermost_resources.createGroup()
64
+ .addUniform("volumetrics_metadata", VOLUMETRICS_METADATA_STRUCT)
65
+ .addUniform("camera", CAMERA_UNIFORM_STRUCT)
66
+ .addSampler("sLinear", "filtering", SAMPLER_LINEAR_UPSCALE)
67
+ .addTexture("tParticipatingMedia1", "float", "3d")
68
+ .addStorageTexture("tSunShadowVolume", "rgba16float", "3d", "write-only");
69
+
70
+ /**
71
+ * The outermost cascade. Nothing is outside it, so its scan starts from zero and it binds no outer
72
+ * volume.
73
+ *
74
+ * @type {ComputeShader}
75
+ */
76
+ export const shader_volumetrics_build_sun_shadow_volume_outermost = ComputeShader.from({
77
+ label: 'Volumetrics / build sun shadow volume (outermost)',
78
+ resources: outermost_resources,
79
+ body: CodeChunk.from(
80
+ //language=WGSL
81
+ `
82
+ @compute @workgroup_size(${VOLUMETRICS_SUN_SHADOW_WORKGROUP_RESOLUTION.join(",")})
83
+ fn main(
84
+ @builtin(global_invocation_id) column : vec3<u32>
85
+ ){
86
+ let resolution = textureDimensions(tSunShadowVolume);
87
+
88
+ if(any(column.xy >= resolution.xy)){
89
+ // overflow
90
+ return;
91
+ }
92
+
93
+ // The volume's z axis is the direction light TRAVELS, so this column is one sun ray and slice 0
94
+ // is its end nearest the sun. Walking it in order turns the per-froxel integral into a running
95
+ // sum: every voxel's optical depth is its predecessor's plus one slab. That is the whole point
96
+ // of the pass — the same information the 16-step march produces, in O(voxels) instead of
97
+ // O(froxels * steps), and produced once rather than once per froxel that happens to lie on the
98
+ // ray.
99
+ //
100
+ // One invocation per column rather than a cooperative scan. The dependency chain is one
101
+ // cascade's depth long and each link is a texture fetch, so a Hillis-Steele or Blinn-Sengupta
102
+ // scan would trade this pass's perfectly coherent, register-resident accumulator for log(n)
103
+ // rounds of shared memory and barriers to speed up something that is already bandwidth-bound.
104
+ // The aerial pass has the same shape for the same reason.
105
+ //
106
+ // Immediate data, so this is uniform across the dispatch.
107
+ let cascade = settings.cascade;
108
+
109
+ let uvw_to_ws = volumetrics_metadata.sun_shadow_uvw_to_ws[cascade];
110
+
111
+ // What a voxel must hold is the medium's INTEGRAL across its slab, not the medium's value at
112
+ // its centre, and one point sample per voxel is not that. A fog volume three units thick
113
+ // crossed by a 2.3-unit lattice has its entire optical depth resting on one or two samples:
114
+ // whether they land inside it, on its fade, or just outside swings the answer by the whole
115
+ // shadow, and the per-frame column jitter under them turns that into a strobe.
116
+ //
117
+ // So sample the slab several times and store the storage-resolution result. The sampling rate
118
+ // and the resolution are separate knobs and only the first one has to beat the medium's
119
+ // features. The count is per cascade — see volumetrics_sun_shadow_sub_steps — so that every
120
+ // cascade samples at the same world-space spacing rather than at the same count per voxel.
121
+ let sub_steps = settings.sub_steps;
122
+
123
+ let sub_steps_half = sub_steps / 2u;
124
+
125
+ let sub_step_ws = volumetrics_metadata.sun_shadow_step_ws[cascade] / f32(sub_steps);
126
+
127
+ let w_per_slice = 1.0 / f32(resolution.z);
128
+ let w_per_sub_step = w_per_slice / f32(sub_steps);
129
+
130
+ let column_uv = texel_coordinate_to_uv(vec2<f32>(column.xy), resolution.xy);
131
+
132
+ // The outermost cascade's box contains the whole frustum, and the medium exists only inside
133
+ // the frustum, so the slab its scan starts on is empty and zero is the whole of the truth about
134
+ // what is between it and the sun.
135
+ var optical_depth = vec3<f32>(0.0);
136
+
137
+ for(var slice = 0u; slice < resolution.z; slice++){
138
+
139
+ let voxel = vec3<u32>(column.xy, slice);
140
+
141
+ let w_slice = f32(slice) * w_per_slice;
142
+
143
+ for(var sub = 0u; sub < sub_steps; sub++){
144
+
145
+ // Halfway through the slab, so the value stored at slice k is the integral from the
146
+ // box's sun-side face to the voxel's CENTRE. Linear interpolation between two stored
147
+ // values then reproduces the true integral exactly wherever extinction is constant
148
+ // across the pair. Storing the integral to the far face instead — a right-endpoint sum,
149
+ // which is what the march this replaces does — biases every reading by half a slab.
150
+ if(sub == sub_steps_half){
151
+ textureStore(tSunShadowVolume, voxel, vec4<f32>(optical_depth, 0.0));
152
+ }
153
+
154
+ let w = w_slice + (f32(sub) + 0.5) * w_per_sub_step;
155
+
156
+ let position_ws = (uvw_to_ws * vec4<f32>(column_uv, w, 1.0)).xyz;
157
+
158
+ optical_depth += volumetrics_sample_froxel_extinction(position_ws) * sub_step_ws;
159
+ }
160
+ }
161
+ }
162
+ `, [
163
+ CAMERA_UNIFORM_STRUCT.declaration_chunk,
164
+ chunk_texel_coordinate_to_uv,
165
+ chunk_volumetrics_sample_froxel_extinction,
166
+ ]
167
+ )
168
+ });
169
+
170
+ const seeded_resources = new ShaderResourceSetDescriptor();
171
+
172
+ seeded_resources.setImmediate("settings", VOLUMETRICS_SUN_SHADOW_BUILD_SETTINGS);
173
+
174
+ seeded_resources.createGroup()
175
+ .addUniform("volumetrics_metadata", VOLUMETRICS_METADATA_STRUCT)
176
+ .addUniform("camera", CAMERA_UNIFORM_STRUCT)
177
+ .addSampler("sLinear", "filtering", SAMPLER_LINEAR_UPSCALE)
178
+ .addTexture("tParticipatingMedia1", "float", "3d")
179
+ .addTexture("tSunShadowOuter", "float", "3d")
180
+ .addStorageTexture("tSunShadowVolume", "rgba16float", "3d", "write-only");
181
+
182
+ /**
183
+ * Every cascade but the outermost, seeded from the one outside it. Which one that is arrives as
184
+ * immediate data, so the whole inner ladder shares this pipeline.
185
+ *
186
+ * @type {ComputeShader}
187
+ */
188
+ export const shader_volumetrics_build_sun_shadow_volume_seeded = ComputeShader.from({
189
+ label: 'Volumetrics / build sun shadow volume (seeded)',
190
+ resources: seeded_resources,
191
+ body: CodeChunk.from(
192
+ //language=WGSL
193
+ `
194
+ @compute @workgroup_size(${VOLUMETRICS_SUN_SHADOW_WORKGROUP_RESOLUTION.join(",")})
195
+ fn main(
196
+ @builtin(global_invocation_id) column : vec3<u32>
197
+ ){
198
+ let resolution = textureDimensions(tSunShadowVolume);
199
+
200
+ if(any(column.xy >= resolution.xy)){
201
+ // overflow
202
+ return;
203
+ }
204
+
205
+ // The volume's z axis is the direction light TRAVELS, so this column is one sun ray and slice 0
206
+ // is its end nearest the sun. Walking it in order turns the per-froxel integral into a running
207
+ // sum: every voxel's optical depth is its predecessor's plus one slab. That is the whole point
208
+ // of the pass — the same information the 16-step march produces, in O(voxels) instead of
209
+ // O(froxels * steps), and produced once rather than once per froxel that happens to lie on the
210
+ // ray.
211
+ //
212
+ // One invocation per column rather than a cooperative scan. The dependency chain is one
213
+ // cascade's depth long and each link is a texture fetch, so a Hillis-Steele or Blinn-Sengupta
214
+ // scan would trade this pass's perfectly coherent, register-resident accumulator for log(n)
215
+ // rounds of shared memory and barriers to speed up something that is already bandwidth-bound.
216
+ // The aerial pass has the same shape for the same reason.
217
+ //
218
+ // Immediate data, so this is uniform across the dispatch.
219
+ let cascade = settings.cascade;
220
+
221
+ let uvw_to_ws = volumetrics_metadata.sun_shadow_uvw_to_ws[cascade];
222
+
223
+ // What a voxel must hold is the medium's INTEGRAL across its slab, not the medium's value at
224
+ // its centre, and one point sample per voxel is not that. A fog volume three units thick
225
+ // crossed by a 2.3-unit lattice has its entire optical depth resting on one or two samples:
226
+ // whether they land inside it, on its fade, or just outside swings the answer by the whole
227
+ // shadow, and the per-frame column jitter under them turns that into a strobe.
228
+ //
229
+ // So sample the slab several times and store the storage-resolution result. The sampling rate
230
+ // and the resolution are separate knobs and only the first one has to beat the medium's
231
+ // features. The count is per cascade — see volumetrics_sun_shadow_sub_steps — so that every
232
+ // cascade samples at the same world-space spacing rather than at the same count per voxel.
233
+ let sub_steps = settings.sub_steps;
234
+
235
+ let sub_steps_half = sub_steps / 2u;
236
+
237
+ let sub_step_ws = volumetrics_metadata.sun_shadow_step_ws[cascade] / f32(sub_steps);
238
+
239
+ let w_per_slice = 1.0 / f32(resolution.z);
240
+ let w_per_sub_step = w_per_slice / f32(sub_steps);
241
+
242
+ let column_uv = texel_coordinate_to_uv(vec2<f32>(column.xy), resolution.xy);
243
+
244
+ // Seeded from the cascade outside this one, at the world position where this column enters
245
+ // this box. Everything between the sun and that plane has already been integrated out there, at
246
+ // that cascade's resolution, so the scan here starts from it rather than from zero and an inner
247
+ // cascade is a refinement of the outer rather than a truncation of the medium. Enshrouded
248
+ // describes exactly this: "each cascade as an initial shadow value reads the upper cascade".
249
+ //
250
+ // The clamp is a statement about the domain rather than a guard that fires: the outer box
251
+ // contains the whole frustum and this box's entry plane is a face of a box sized from a
252
+ // sub-frustum of it.
253
+ let entry_ws = (uvw_to_ws * vec4<f32>(column_uv, 0.0, 1.0)).xyz;
254
+
255
+ let outer_uvw = (volumetrics_metadata.sun_shadow_ws_to_uvw[cascade + 1u] * vec4<f32>(entry_ws, 1.0)).xyz;
256
+
257
+ var optical_depth = textureSampleLevel(tSunShadowOuter, sLinear, saturate(outer_uvw), 0.0).rgb;
258
+
259
+ for(var slice = 0u; slice < resolution.z; slice++){
260
+
261
+ let voxel = vec3<u32>(column.xy, slice);
262
+
263
+ let w_slice = f32(slice) * w_per_slice;
264
+
265
+ for(var sub = 0u; sub < sub_steps; sub++){
266
+
267
+ // Halfway through the slab, so the value stored at slice k is the integral from the
268
+ // box's sun-side face to the voxel's CENTRE. Linear interpolation between two stored
269
+ // values then reproduces the true integral exactly wherever extinction is constant
270
+ // across the pair. Storing the integral to the far face instead — a right-endpoint sum,
271
+ // which is what the march this replaces does — biases every reading by half a slab.
272
+ if(sub == sub_steps_half){
273
+ textureStore(tSunShadowVolume, voxel, vec4<f32>(optical_depth, 0.0));
274
+ }
275
+
276
+ let w = w_slice + (f32(sub) + 0.5) * w_per_sub_step;
277
+
278
+ let position_ws = (uvw_to_ws * vec4<f32>(column_uv, w, 1.0)).xyz;
279
+
280
+ optical_depth += volumetrics_sample_froxel_extinction(position_ws) * sub_step_ws;
281
+ }
282
+ }
283
+ }
284
+ `, [
285
+ CAMERA_UNIFORM_STRUCT.declaration_chunk,
286
+ chunk_texel_coordinate_to_uv,
287
+ chunk_volumetrics_sample_froxel_extinction,
288
+ ]
289
+ )
290
+ });
@@ -77,6 +77,16 @@ export class CPUBitmapData {
77
77
  * @param {number} [depth]
78
78
  */
79
79
  static float32(item_size: number, width: number, height?: number, depth?: number): CPUBitmapData;
80
+ /**
81
+ * Single-channel f32 bitmap flagged as a `texture_depth_*` binding — see {@link is_depth}.
82
+ * `textureLoad` on it yields a scalar, the way it does on a device.
83
+ *
84
+ * @param {number} width
85
+ * @param {number} [height]
86
+ * @param {number} [depth]
87
+ * @returns {CPUBitmapData}
88
+ */
89
+ static depth32(width: number, height?: number, depth?: number): CPUBitmapData;
80
90
  /**
81
91
  * @param {ArrayLike<number>} data
82
92
  * @param {number} item_size
@@ -101,6 +111,21 @@ export class CPUBitmapData {
101
111
  * @type {Uint32Array}
102
112
  */
103
113
  size: Uint32Array;
114
+ /**
115
+ * Marks this as backing a `texture_depth_*` binding rather than a `texture_2d<f32>`.
116
+ *
117
+ * The two differ in WGSL at the call site, not in storage: `textureLoad` on a depth texture
118
+ * returns a bare `f32`, while on a colour texture it returns `vec4<f32>`. Shader code written
119
+ * against a depth texture therefore uses the result as a scalar, and an emulator that always
120
+ * hands back a vec4 turns every such expression into a silent component-wise broadcast —
121
+ * arithmetic that neither throws nor resembles what the GPU does.
122
+ *
123
+ * Off by default, so nothing that does not opt in changes behaviour. Set it, or use
124
+ * {@link CPUBitmapData.depth32}, when binding a texture the shader declares as `depth`.
125
+ *
126
+ * @type {boolean}
127
+ */
128
+ is_depth: boolean;
104
129
  /** @returns {number} */
105
130
  get width(): number;
106
131
  /** @returns {number} */
@@ -1 +1 @@
1
- {"version":3,"file":"CPUBitmapData.d.ts","sourceRoot":"","sources":["../../../../../src/shade/wgsl/emulator/CPUBitmapData.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;IA6HI;;;;;OAKG;IACH,wBALW,MAAM,SACN,MAAM,WACN,MAAM,UACN,MAAM,iBAIhB;IAED;;;;;OAKG;IACH,yBALW,MAAM,SACN,MAAM,WACN,MAAM,UACN,MAAM,iBAIhB;IAED;;;;;OAKG;IACH,yBALW,MAAM,SACN,MAAM,WACN,MAAM,UACN,MAAM,iBAIhB;IAED;;;;;OAKG;IACH,uBALW,MAAM,SACN,MAAM,WACN,MAAM,UACN,MAAM,iBAIhB;IAED;;;;;OAKG;IACH,wBALW,MAAM,SACN,MAAM,WACN,MAAM,UACN,MAAM,iBAIhB;IAED;;;;;OAKG;IACH,wBALW,MAAM,SACN,MAAM,WACN,MAAM,UACN,MAAM,iBAIhB;IAED;;;;;OAKG;IACH,0BALW,MAAM,SACN,MAAM,WACN,MAAM,UACN,MAAM,iBAIhB;IAED;;;;;OAKG;IACH,0BALW,MAAM,SACN,MAAM,WACN,MAAM,UACN,MAAM,iBAIhB;IAvLD;;;;;;OAMG;IACH,kBANW,UAAU,MAAM,CAAC,aACjB,MAAM,SACN,MAAM,WACN,MAAM,UACN,MAAM,EAmBhB;IA3CD;;;OAGG;IACH,MAFU,YAAY,kBAAkB,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,GAAG,WAAW,GAAG,MAAM,EAAE,CAE1H;IAEL;;;OAGG;IACH,WAFU,MAAM,CAEN;IAEV;;;;OAIG;IACH,MAFU,WAAW,CAEhB;IA4BL,wBAAwB;IACxB,oBAAoC;IACpC,wBAAwB;IACxB,qBAAqC;IACrC,wBAAwB;IACxB,oBAAoC;IAEpC;;;;;;OAMG;IACH,gCAIC;IAED;;;;;;;OAOG;IACH,gBALW,MAAM,KACN,MAAM,KACN,MAAM,GACJ,MAAM,CAMlB;IAED;;;;;;;;;OASG;IACH,QANW,MAAM,KACN,MAAM,KACN,MAAM;;oBAEN,MAAM,QAWhB;IAED;;;;;;;;;OASG;IACH,SANW,MAAM,KACN,MAAM,KACN,MAAM,OACN,UAAU,MAAM,CAAC,eACjB,MAAM,QAQhB;CAuFJ"}
1
+ {"version":3,"file":"CPUBitmapData.d.ts","sourceRoot":"","sources":["../../../../../src/shade/wgsl/emulator/CPUBitmapData.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;IA6II;;;;;OAKG;IACH,wBALW,MAAM,SACN,MAAM,WACN,MAAM,UACN,MAAM,iBAIhB;IAED;;;;;OAKG;IACH,yBALW,MAAM,SACN,MAAM,WACN,MAAM,UACN,MAAM,iBAIhB;IAED;;;;;OAKG;IACH,yBALW,MAAM,SACN,MAAM,WACN,MAAM,UACN,MAAM,iBAIhB;IAED;;;;;OAKG;IACH,uBALW,MAAM,SACN,MAAM,WACN,MAAM,UACN,MAAM,iBAIhB;IAED;;;;;OAKG;IACH,wBALW,MAAM,SACN,MAAM,WACN,MAAM,UACN,MAAM,iBAIhB;IAED;;;;;OAKG;IACH,wBALW,MAAM,SACN,MAAM,WACN,MAAM,UACN,MAAM,iBAIhB;IAED;;;;;OAKG;IACH,0BALW,MAAM,SACN,MAAM,WACN,MAAM,UACN,MAAM,iBAIhB;IAED;;;;;OAKG;IACH,0BALW,MAAM,SACN,MAAM,WACN,MAAM,UACN,MAAM,iBAIhB;IAED;;;;;;;;OAQG;IACH,sBALW,MAAM,WACN,MAAM,UACN,MAAM,GACJ,aAAa,CAQzB;IAxMD;;;;;;OAMG;IACH,kBANW,UAAU,MAAM,CAAC,aACjB,MAAM,SACN,MAAM,WACN,MAAM,UACN,MAAM,EAmBhB;IA3DD;;;OAGG;IACH,MAFU,YAAY,kBAAkB,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,GAAG,WAAW,GAAG,MAAM,EAAE,CAE1H;IAEL;;;OAGG;IACH,WAFU,MAAM,CAEN;IAEV;;;;OAIG;IACH,MAFU,WAAW,CAEhB;IAEL;;;;;;;;;;;;;OAaG;IACH,UAFU,OAAO,CAEA;IA4BjB,wBAAwB;IACxB,oBAAoC;IACpC,wBAAwB;IACxB,qBAAqC;IACrC,wBAAwB;IACxB,oBAAoC;IAEpC;;;;;;OAMG;IACH,gCAIC;IAED;;;;;;;OAOG;IACH,gBALW,MAAM,KACN,MAAM,KACN,MAAM,GACJ,MAAM,CAMlB;IAED;;;;;;;;;OASG;IACH,QANW,MAAM,KACN,MAAM,KACN,MAAM;;oBAEN,MAAM,QAWhB;IAED;;;;;;;;;OASG;IACH,SANW,MAAM,KACN,MAAM,KACN,MAAM,OACN,UAAU,MAAM,CAAC,eACjB,MAAM,QAQhB;CAwGJ"}
@@ -42,6 +42,22 @@ export class CPUBitmapData {
42
42
  */
43
43
  size;
44
44
 
45
+ /**
46
+ * Marks this as backing a `texture_depth_*` binding rather than a `texture_2d<f32>`.
47
+ *
48
+ * The two differ in WGSL at the call site, not in storage: `textureLoad` on a depth texture
49
+ * returns a bare `f32`, while on a colour texture it returns `vec4<f32>`. Shader code written
50
+ * against a depth texture therefore uses the result as a scalar, and an emulator that always
51
+ * hands back a vec4 turns every such expression into a silent component-wise broadcast —
52
+ * arithmetic that neither throws nor resembles what the GPU does.
53
+ *
54
+ * Off by default, so nothing that does not opt in changes behaviour. Set it, or use
55
+ * {@link CPUBitmapData.depth32}, when binding a texture the shader declares as `depth`.
56
+ *
57
+ * @type {boolean}
58
+ */
59
+ is_depth = false;
60
+
45
61
  /**
46
62
  * @param {ArrayLike<number>} data
47
63
  * @param {number} item_size
@@ -226,4 +242,21 @@ export class CPUBitmapData {
226
242
  static float32(item_size, width, height = 1, depth = 1) {
227
243
  return new CPUBitmapData(new Float32Array(item_size * width * height * depth), item_size, width, height, depth);
228
244
  }
245
+
246
+ /**
247
+ * Single-channel f32 bitmap flagged as a `texture_depth_*` binding — see {@link is_depth}.
248
+ * `textureLoad` on it yields a scalar, the way it does on a device.
249
+ *
250
+ * @param {number} width
251
+ * @param {number} [height]
252
+ * @param {number} [depth]
253
+ * @returns {CPUBitmapData}
254
+ */
255
+ static depth32(width, height = 1, depth = 1) {
256
+ const result = CPUBitmapData.float32(1, width, height, depth);
257
+
258
+ result.is_depth = true;
259
+
260
+ return result;
261
+ }
229
262
  }