@woosh/meep-engine 3.34.0 → 3.36.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 (161) hide show
  1. package/package.json +1 -1
  2. package/src/engine/Engine.d.ts +2 -0
  3. package/src/engine/Engine.d.ts.map +1 -1
  4. package/src/engine/Engine.js +5 -1
  5. package/src/engine/input/devices/XRInputDevice.d.ts +63 -0
  6. package/src/engine/input/devices/XRInputDevice.d.ts.map +1 -0
  7. package/src/engine/input/devices/XRInputDevice.js +386 -0
  8. package/src/engine/input/devices/xr/XRInputAction.d.ts +37 -0
  9. package/src/engine/input/devices/xr/XRInputAction.d.ts.map +1 -0
  10. package/src/engine/input/devices/xr/XRInputAction.js +85 -0
  11. package/src/engine/input/devices/xr/XRInputButton.d.ts +28 -0
  12. package/src/engine/input/devices/xr/XRInputButton.d.ts.map +1 -0
  13. package/src/engine/input/devices/xr/XRInputButton.js +43 -0
  14. package/src/engine/input/devices/xr/XRInputCoordinates.d.ts +15 -0
  15. package/src/engine/input/devices/xr/XRInputCoordinates.d.ts.map +1 -0
  16. package/src/engine/input/devices/xr/XRInputCoordinates.js +21 -0
  17. package/src/engine/input/devices/xr/XRInputHandle.d.ts +63 -0
  18. package/src/engine/input/devices/xr/XRInputHandle.d.ts.map +1 -0
  19. package/src/engine/input/devices/xr/XRInputHandle.js +171 -0
  20. package/src/engine/input/devices/xr/XRInputPose.d.ts +23 -0
  21. package/src/engine/input/devices/xr/XRInputPose.d.ts.map +1 -0
  22. package/src/engine/input/devices/xr/XRInputPose.js +36 -0
  23. package/src/engine/input/devices/xr/XRInputTypes.d.ts +76 -0
  24. package/src/engine/input/devices/xr/XRInputTypes.d.ts.map +1 -0
  25. package/src/engine/input/devices/xr/XRInputTypes.js +31 -0
  26. package/src/engine/input/devices/xr/XRInputValueSource.d.ts +11 -0
  27. package/src/engine/input/devices/xr/XRInputValueSource.d.ts.map +1 -0
  28. package/src/engine/input/devices/xr/XRInputValueSource.js +11 -0
  29. package/src/engine/input/ecs/ism/coordinate/InputCoordinateChannel.d.ts +15 -1
  30. package/src/engine/input/ecs/ism/coordinate/InputCoordinateChannel.d.ts.map +1 -1
  31. package/src/engine/input/ecs/ism/coordinate/InputCoordinateChannel.js +9 -0
  32. package/src/engine/input/ecs/ism/coordinate/InputCoordinateDevice.d.ts +15 -4
  33. package/src/engine/input/ecs/ism/coordinate/InputCoordinateDevice.d.ts.map +1 -1
  34. package/src/engine/input/ecs/ism/coordinate/InputCoordinateDevice.js +22 -0
  35. package/src/engine/input/ecs/ism/coordinate/InputCoordinateSwitches.d.ts +17 -2
  36. package/src/engine/input/ecs/ism/coordinate/InputCoordinateSwitches.d.ts.map +1 -1
  37. package/src/engine/input/ecs/ism/device/GamepadInputDeviceAdapter.d.ts +5 -0
  38. package/src/engine/input/ecs/ism/device/GamepadInputDeviceAdapter.d.ts.map +1 -1
  39. package/src/engine/input/ecs/ism/device/InputDeviceAdapter.d.ts +2 -0
  40. package/src/engine/input/ecs/ism/device/InputDeviceAdapter.d.ts.map +1 -1
  41. package/src/engine/input/ecs/ism/device/InputDeviceAdapter.js +2 -0
  42. package/src/engine/input/ecs/ism/device/KeyboardInputDeviceAdapter.d.ts +7 -0
  43. package/src/engine/input/ecs/ism/device/KeyboardInputDeviceAdapter.d.ts.map +1 -1
  44. package/src/engine/input/ecs/ism/device/ManualInputDeviceAdapter.d.ts +5 -0
  45. package/src/engine/input/ecs/ism/device/ManualInputDeviceAdapter.d.ts.map +1 -1
  46. package/src/engine/input/ecs/ism/device/PointerInputDeviceAdapter.d.ts +5 -0
  47. package/src/engine/input/ecs/ism/device/PointerInputDeviceAdapter.d.ts.map +1 -1
  48. package/src/engine/input/ecs/ism/device/XRInputDeviceAdapter.d.ts +16 -0
  49. package/src/engine/input/ecs/ism/device/XRInputDeviceAdapter.d.ts.map +1 -0
  50. package/src/engine/input/ecs/ism/device/XRInputDeviceAdapter.js +54 -0
  51. package/src/engine/input/ecs/ism/device/XR_INPUT_DEVICE_IDS.d.ts +9 -0
  52. package/src/engine/input/ecs/ism/device/XR_INPUT_DEVICE_IDS.d.ts.map +1 -0
  53. package/src/engine/input/ecs/ism/device/XR_INPUT_DEVICE_IDS.js +12 -0
  54. package/src/engine/input/ecs/ism/trigger/InputTrigger.d.ts +11 -1
  55. package/src/engine/input/ecs/ism/trigger/InputTrigger.d.ts.map +1 -1
  56. package/src/engine/input/ecs/ism/trigger/InputTrigger.js +7 -0
  57. package/src/engine/input/ecs/ism/trigger/InputTriggerChord.d.ts +16 -2
  58. package/src/engine/input/ecs/ism/trigger/InputTriggerChord.d.ts.map +1 -1
  59. package/src/engine/input/ecs/ism/trigger/InputTriggerHold.d.ts +22 -2
  60. package/src/engine/input/ecs/ism/trigger/InputTriggerHold.d.ts.map +1 -1
  61. package/src/engine/input/ecs/ism/trigger/InputTriggerRelease.d.ts +16 -2
  62. package/src/engine/input/ecs/ism/trigger/InputTriggerRelease.d.ts.map +1 -1
  63. package/src/engine/input/ecs/ism/trigger/InputTriggerSequence.d.ts +24 -4
  64. package/src/engine/input/ecs/ism/trigger/InputTriggerSequence.d.ts.map +1 -1
  65. package/src/engine/input/ecs/ism/trigger/InputTriggerSwitch.d.ts +6 -8
  66. package/src/engine/input/ecs/ism/trigger/InputTriggerSwitch.d.ts.map +1 -1
  67. package/src/engine/input/ecs/ism/trigger/InputTriggerSwitch.js +5 -0
  68. package/src/engine/input/ecs/ism/trigger/InputTriggerXRButton.d.ts +7 -0
  69. package/src/engine/input/ecs/ism/trigger/InputTriggerXRButton.d.ts.map +1 -0
  70. package/src/engine/input/ecs/ism/trigger/InputTriggerXRButton.js +15 -0
  71. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  72. package/src/shade/device/timing/profile/GPUProfileSession.d.ts +25 -11
  73. package/src/shade/device/timing/profile/GPUProfileSession.d.ts.map +1 -1
  74. package/src/shade/device/timing/profile/GPUProfileSession.js +553 -474
  75. package/src/shade/playground/avboit/main.d.ts.map +1 -1
  76. package/src/shade/playground/avboit/main.js +888 -916
  77. package/src/shade/playground/particle_ecs/README.md +13 -7
  78. package/src/shade/playground/particle_ecs/bonfire_effects.d.ts +5 -5
  79. package/src/shade/playground/particle_ecs/bonfire_effects.js +5 -5
  80. package/src/shade/playground/particle_ecs/effects/smoke.json +1859 -1859
  81. package/src/shade/playground/particle_ecs/effects/soot.json +1605 -1605
  82. package/src/shade/playground/particle_system/README.md +1 -2
  83. package/src/shade/playground/profile_hotkey.d.ts.map +1 -1
  84. package/src/shade/playground/profile_hotkey.js +4 -40
  85. package/src/shade/playground/skinned_blas_refit/main.d.ts.map +1 -1
  86. package/src/shade/playground/skinned_blas_refit/main.js +4 -39
  87. package/src/shade/playground/volumetrics_froxel/main.d.ts.map +1 -1
  88. package/src/shade/playground/volumetrics_froxel/main.js +4 -39
  89. package/src/shade/playground/volumetrics_froxel/measure.d.ts.map +1 -1
  90. package/src/shade/playground/volumetrics_froxel/measure.js +2 -4
  91. package/src/shade/renderer/Renderer.d.ts +1 -1
  92. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  93. package/src/shade/renderer/Renderer.js +3 -1
  94. package/src/shade/renderer/light/GPULightCollection.d.ts +9 -1
  95. package/src/shade/renderer/light/GPULightCollection.d.ts.map +1 -1
  96. package/src/shade/renderer/light/GPULightCollection.js +41 -0
  97. package/src/shade/renderer/light/environment/shader_project_environment_sh.d.ts +37 -0
  98. package/src/shade/renderer/light/environment/shader_project_environment_sh.d.ts.map +1 -0
  99. package/src/shade/renderer/light/environment/shader_project_environment_sh.js +105 -0
  100. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  101. package/src/shade/renderer/particles/DESIGN.md +65 -8
  102. package/src/shade/renderer/particles/GPUParticleSystem.d.ts +7 -1
  103. package/src/shade/renderer/particles/GPUParticleSystem.d.ts.map +1 -1
  104. package/src/shade/renderer/particles/GPUParticleSystem.js +1247 -1244
  105. package/src/shade/renderer/particles/graph_particles_avboit.d.ts +7 -1
  106. package/src/shade/renderer/particles/graph_particles_avboit.d.ts.map +1 -1
  107. package/src/shade/renderer/particles/graph_particles_avboit.js +9 -0
  108. package/src/shade/renderer/particles/shaders/chunk_particle_billboard_vertex.d.ts.map +1 -1
  109. package/src/shade/renderer/particles/shaders/chunk_particle_billboard_vertex.js +4 -2
  110. package/src/shade/renderer/particles/shaders/chunk_particle_lighting.d.ts +15 -9
  111. package/src/shade/renderer/particles/shaders/chunk_particle_lighting.d.ts.map +1 -1
  112. package/src/shade/renderer/particles/shaders/chunk_particle_lighting.js +29 -11
  113. package/src/shade/renderer/particles/shaders/chunk_particle_lighting_model.d.ts +24 -0
  114. package/src/shade/renderer/particles/shaders/chunk_particle_lighting_model.d.ts.map +1 -0
  115. package/src/shade/renderer/particles/shaders/chunk_particle_lighting_model.js +45 -0
  116. package/src/shade/renderer/particles/shaders/chunk_particle_render_math.d.ts +3 -0
  117. package/src/shade/renderer/particles/shaders/chunk_particle_render_math.d.ts.map +1 -1
  118. package/src/shade/renderer/particles/shaders/chunk_particle_render_math.js +38 -0
  119. package/src/shade/renderer/particles/shaders/shader_particle_avboit_draw.d.ts.map +1 -1
  120. package/src/shade/renderer/particles/shaders/shader_particle_avboit_draw.js +190 -185
  121. package/src/shade/renderer/rasterize/native/avboit/AVBOITSideChannel.d.ts +8 -0
  122. package/src/shade/renderer/rasterize/native/avboit/AVBOITSideChannel.d.ts.map +1 -1
  123. package/src/shade/renderer/rasterize/native/avboit/AVBOITSideChannel.js +5 -0
  124. package/src/shade/renderer/rasterize/native/avboit/graph_rasterize_meshes_transparent_avboit.d.ts +8 -1
  125. package/src/shade/renderer/rasterize/native/avboit/graph_rasterize_meshes_transparent_avboit.d.ts.map +1 -1
  126. package/src/shade/renderer/rasterize/native/avboit/graph_rasterize_meshes_transparent_avboit.js +9 -0
  127. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.d.ts +13 -3
  128. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.d.ts.map +1 -1
  129. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.js +9 -1
  130. package/src/shade/renderer/volumetrics/chunk_volumetrics_irradiance_sh.d.ts +39 -0
  131. package/src/shade/renderer/volumetrics/chunk_volumetrics_irradiance_sh.d.ts.map +1 -0
  132. package/src/shade/renderer/volumetrics/chunk_volumetrics_irradiance_sh.js +107 -0
  133. package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_froxel_centre_ws.d.ts +15 -0
  134. package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_froxel_centre_ws.d.ts.map +1 -0
  135. package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_froxel_centre_ws.js +44 -0
  136. package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi.d.ts +19 -0
  137. package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi.d.ts.map +1 -0
  138. package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi.js +48 -0
  139. package/src/shade/renderer/volumetrics/gi/graph_build_froxel_gi.d.ts +29 -0
  140. package/src/shade/renderer/volumetrics/gi/graph_build_froxel_gi.d.ts.map +1 -0
  141. package/src/shade/renderer/volumetrics/gi/graph_build_froxel_gi.js +90 -0
  142. package/src/shade/renderer/volumetrics/gi/shader_volumetrics_gi_brick4.d.ts +10 -0
  143. package/src/shade/renderer/volumetrics/gi/shader_volumetrics_gi_brick4.d.ts.map +1 -0
  144. package/src/shade/renderer/volumetrics/gi/shader_volumetrics_gi_brick4.js +55 -0
  145. package/src/shade/renderer/volumetrics/gi/shader_volumetrics_gi_ibl.d.ts +10 -0
  146. package/src/shade/renderer/volumetrics/gi/shader_volumetrics_gi_ibl.d.ts.map +1 -0
  147. package/src/shade/renderer/volumetrics/gi/shader_volumetrics_gi_ibl.js +47 -0
  148. package/src/shade/renderer/volumetrics/gi/shader_volumetrics_gi_lpv.d.ts +10 -0
  149. package/src/shade/renderer/volumetrics/gi/shader_volumetrics_gi_lpv.d.ts.map +1 -0
  150. package/src/shade/renderer/volumetrics/gi/shader_volumetrics_gi_lpv.js +63 -0
  151. package/src/shade/renderer/volumetrics/gi/volumetrics_gi_resources.d.ts +17 -0
  152. package/src/shade/renderer/volumetrics/gi/volumetrics_gi_resources.d.ts.map +1 -0
  153. package/src/shade/renderer/volumetrics/gi/volumetrics_gi_resources.js +26 -0
  154. package/src/shade/renderer/volumetrics/graph_build_volumetrics.d.ts +8 -1
  155. package/src/shade/renderer/volumetrics/graph_build_volumetrics.d.ts.map +1 -1
  156. package/src/shade/renderer/volumetrics/graph_build_volumetrics.js +50 -2
  157. package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.d.ts.map +1 -1
  158. package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.js +488 -436
  159. package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.d.ts +1 -1
  160. package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.d.ts.map +1 -1
  161. package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.js +254 -63
@@ -70,6 +70,8 @@ export function graph_particle_avboit_splat({ graph, camera, warp, depth_texture
70
70
  * @param {number} params.integral graph handle of the integral texture
71
71
  * @param {number} params.volumetrics_lut graph handle
72
72
  * @param {number} params.volumetrics_metadata graph handle
73
+ * @param {{Y: number, CoCg: number}} params.volumetrics_irradiance graph handles of the froxel
74
+ * irradiance volume a lit emitter's particles are lit by
73
75
  * @param {{color: number, norm: number, extinction: number, emission: number}} params.accumulators to add to
74
76
  * @param {GPUTextureView} params.atlas
75
77
  * @param {GPUSampler} params.atlas_sampler
@@ -79,7 +81,7 @@ export function graph_particle_avboit_splat({ graph, camera, warp, depth_texture
79
81
  * @param {number} params.draw_args graph handle of the indirect draw args
80
82
  * @returns {{color: number, norm: number, extinction: number, emission: number}} the accumulators after the draw
81
83
  */
82
- export function graph_particle_avboit_draw({ graph, view_ctx, camera, depth_texture, warp, integral, volumetrics_lut, volumetrics_metadata, accumulators, atlas, atlas_sampler, pool, alive, emitter_database, draw_args, }: {
84
+ export function graph_particle_avboit_draw({ graph, view_ctx, camera, depth_texture, warp, integral, volumetrics_lut, volumetrics_metadata, volumetrics_irradiance, accumulators, atlas, atlas_sampler, pool, alive, emitter_database, draw_args, }: {
83
85
  graph: import("../../../engine/graphics/render/frame_graph/FrameGraph.js").FrameGraph;
84
86
  view_ctx: import("../view/GPUViewContext.js").GPUViewContext;
85
87
  camera: number;
@@ -88,6 +90,10 @@ export function graph_particle_avboit_draw({ graph, view_ctx, camera, depth_text
88
90
  integral: number;
89
91
  volumetrics_lut: number;
90
92
  volumetrics_metadata: number;
93
+ volumetrics_irradiance: {
94
+ Y: number;
95
+ CoCg: number;
96
+ };
91
97
  accumulators: {
92
98
  color: number;
93
99
  norm: number;
@@ -1 +1 @@
1
- {"version":3,"file":"graph_particles_avboit.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/particles/graph_particles_avboit.js"],"names":[],"mappings":"AAuCA;;;;;;;;;;;;;;;GAeG;AACH;IARkG,KAAK,EAA5F,OAAO,2DAA2D,EAAE,UAAU;IAC/D,MAAM,EAArB,MAAM;IACoB,kBAAkB,EAA5C,UAAU,MAAM,CAAC;IACF,SAAS,EAAxB,MAAM;IACS,gBAAgB,EAA/B,MAAM;IACS,mBAAmB,EAAlC,MAAM;IACJ,MAAM,CA8ClB;AAED;;;;;;;;;;;;;;;GAeG;AACH;IAZkG,KAAK,EAA5F,OAAO,2DAA2D,EAAE,UAAU;IAC/D,MAAM,EAArB,MAAM;IACS,IAAI,EAAnB,MAAM;IACwD,MAAM,EAApE;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC;IAC9B,KAAK;IACT,aAAa;IACjB,IAAI,EAAnB,MAAM;IACS,KAAK,EAApB,MAAM;IACS,gBAAgB,EAA/B,MAAM;IACS,SAAS,EAAxB,MAAM;IACJ;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,CA8EjE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;IAjBkG,KAAK,EAA5F,OAAO,2DAA2D,EAAE,UAAU;IACnB,QAAQ,EAAnE,OAAO,2BAA2B,EAAE,cAAc;IACnC,MAAM,EAArB,MAAM;IACS,aAAa,EAA5B,MAAM;IACS,IAAI,EAAnB,MAAM;IACS,QAAQ,EAAvB,MAAM;IACS,eAAe,EAA9B,MAAM;IACS,oBAAoB,EAAnC,MAAM;IACsE,YAAY,EAAxF;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC;IAC5C,KAAK;IACT,aAAa;IACjB,IAAI,EAAnB,MAAM;IACS,KAAK,EAApB,MAAM;IACS,gBAAgB,EAA/B,MAAM;IACS,SAAS,EAAxB,MAAM;IACJ;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CA2G/E"}
1
+ {"version":3,"file":"graph_particles_avboit.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/particles/graph_particles_avboit.js"],"names":[],"mappings":"AAuCA;;;;;;;;;;;;;;;GAeG;AACH;IARkG,KAAK,EAA5F,OAAO,2DAA2D,EAAE,UAAU;IAC/D,MAAM,EAArB,MAAM;IACoB,kBAAkB,EAA5C,UAAU,MAAM,CAAC;IACF,SAAS,EAAxB,MAAM;IACS,gBAAgB,EAA/B,MAAM;IACS,mBAAmB,EAAlC,MAAM;IACJ,MAAM,CA8ClB;AAED;;;;;;;;;;;;;;;GAeG;AACH;IAZkG,KAAK,EAA5F,OAAO,2DAA2D,EAAE,UAAU;IAC/D,MAAM,EAArB,MAAM;IACS,IAAI,EAAnB,MAAM;IACwD,MAAM,EAApE;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC;IAC9B,KAAK;IACT,aAAa;IACjB,IAAI,EAAnB,MAAM;IACS,KAAK,EAApB,MAAM;IACS,gBAAgB,EAA/B,MAAM;IACS,SAAS,EAAxB,MAAM;IACJ;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,CA8EjE;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH;IAnBkG,KAAK,EAA5F,OAAO,2DAA2D,EAAE,UAAU;IACnB,QAAQ,EAAnE,OAAO,2BAA2B,EAAE,cAAc;IACnC,MAAM,EAArB,MAAM;IACS,aAAa,EAA5B,MAAM;IACS,IAAI,EAAnB,MAAM;IACS,QAAQ,EAAvB,MAAM;IACS,eAAe,EAA9B,MAAM;IACS,oBAAoB,EAAnC,MAAM;IAC4B,sBAAsB,EAAxD;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC;IAEmD,YAAY,EAAxF;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC;IAC5C,KAAK;IACT,aAAa;IACjB,IAAI,EAAnB,MAAM;IACS,KAAK,EAApB,MAAM;IACS,gBAAgB,EAA/B,MAAM;IACS,SAAS,EAAxB,MAAM;IACJ;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CAkH/E"}
@@ -205,6 +205,8 @@ export function graph_particle_avboit_splat({
205
205
  * @param {number} params.integral graph handle of the integral texture
206
206
  * @param {number} params.volumetrics_lut graph handle
207
207
  * @param {number} params.volumetrics_metadata graph handle
208
+ * @param {{Y: number, CoCg: number}} params.volumetrics_irradiance graph handles of the froxel
209
+ * irradiance volume a lit emitter's particles are lit by
208
210
  * @param {{color: number, norm: number, extinction: number, emission: number}} params.accumulators to add to
209
211
  * @param {GPUTextureView} params.atlas
210
212
  * @param {GPUSampler} params.atlas_sampler
@@ -223,6 +225,7 @@ export function graph_particle_avboit_draw({
223
225
  integral,
224
226
  volumetrics_lut,
225
227
  volumetrics_metadata,
228
+ volumetrics_irradiance,
226
229
  accumulators,
227
230
  atlas,
228
231
  atlas_sampler,
@@ -234,6 +237,8 @@ export function graph_particle_avboit_draw({
234
237
  assert.defined(accumulators, "accumulators");
235
238
  assert.isNonNegativeInteger(depth_texture, "depth_texture");
236
239
  assert.isNonNegativeInteger(integral, "integral");
240
+ assert.isNonNegativeInteger(volumetrics_irradiance.Y, "volumetrics_irradiance.Y");
241
+ assert.isNonNegativeInteger(volumetrics_irradiance.CoCg, "volumetrics_irradiance.CoCg");
237
242
 
238
243
  function execute(data, resources, context) {
239
244
  const encoder = context.encoder;
@@ -258,6 +263,8 @@ export function graph_particle_avboit_draw({
258
263
  volumetrics_metadata: resources.get(data.volumetrics_metadata),
259
264
  tVolumetrics: resources.get(data.volumetrics_lut).obtainView(),
260
265
  tSTBN_vec3: graphics.textures.obtain(STATIC_GRAPHICS_ENGINE_ASSETS.stbn_vec3).obtainView(),
266
+ tIrradianceY: resources.get(data.irradiance_Y).obtainView(),
267
+ tIrradianceCoCg: resources.get(data.irradiance_CoCg).obtainView(),
261
268
  }, encoder);
262
269
 
263
270
  const attachment = (handle) => ({
@@ -303,6 +310,8 @@ export function graph_particle_avboit_draw({
303
310
  pass_data.integral = pass.read(integral);
304
311
  pass_data.volumetrics_lut = pass.read(volumetrics_lut);
305
312
  pass_data.volumetrics_metadata = pass.read(volumetrics_metadata);
313
+ pass_data.irradiance_Y = pass.read(volumetrics_irradiance.Y);
314
+ pass_data.irradiance_CoCg = pass.read(volumetrics_irradiance.CoCg);
306
315
  pass_data.pool = pass.read(pool);
307
316
  pass_data.alive = pass.read(alive);
308
317
  pass_data.emitter_database = pass.read(emitter_database);
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_particle_billboard_vertex.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/particles/shaders/chunk_particle_billboard_vertex.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;GAgBG;AACH,8CAFU,SAAS,CAuE6D;0BA7FtD,oCAAoC"}
1
+ {"version":3,"file":"chunk_particle_billboard_vertex.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/particles/shaders/chunk_particle_billboard_vertex.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;GAgBG;AACH,8CAFU,SAAS,CAyE6D;0BA/FtD,oCAAoC"}
@@ -76,8 +76,10 @@ fn particle_billboard_vertex(vi : u32, ii : u32) -> ParticleVertexOut {
76
76
  let cam_right = camera.transform[0].xyz;
77
77
  let cam_up = camera.transform[1].xyz;
78
78
  let cam_forward = -camera.transform[2].xyz;
79
+ let cam_position = camera.transform[3].xyz;
79
80
 
80
- let offset = particle_billboard_offset(corner, size, rotation, cam_right, cam_up, cam_forward, velocity, particle_emitter_projection(em.flags));
81
+ let projection = particle_emitter_projection(em.flags);
82
+ let offset = particle_billboard_offset(corner, size, rotation, cam_right, cam_up, cam_forward, velocity, projection);
81
83
  let world = world_center + offset;
82
84
 
83
85
  var out : ParticleVertexOut;
@@ -85,7 +87,7 @@ fn particle_billboard_vertex(vi : u32, ii : u32) -> ParticleVertexOut {
85
87
  out.uv = particle_atlas_uv(corner * 0.5 + vec2<f32>(0.5), em.atlas_region, em.flipbook, frame);
86
88
  out.color = color;
87
89
  out.world_position = world;
88
- out.normal = -cam_forward;
90
+ out.normal = particle_billboard_normal(offset, cam_position - world, cam_forward, projection);
89
91
  out.view_depth = -(camera.view_matrix * vec4<f32>(world, 1.0)).z;
90
92
  out.flags = em.flags;
91
93
  out.blend = particle_emitter_blend(em.flags);
@@ -1,16 +1,22 @@
1
1
  /**
2
- * Pluggable lighting hook for every particle fragment shader — the AVBOIT draw and the blended
3
- * billboard pipeline alike. `particle_apply_lighting(color, world, normal)` returns the lit colour;
4
- * the default is a pass-through (unlit / emissive).
2
+ * How an emitter flagged `EMITTER_FLAG.LIGHTING` is lit, per fragment:
3
+ * `particle_apply_lighting(color, world, normal)` treats the particle's colour as a diffuse albedo and
4
+ * returns what it reflects and transmits (`chunk_particle_lighting_model`), from the froxel
5
+ * irradiance volume (`chunk_volumetrics_irradiance_sh`) at the fragment: the renderer's indirect
6
+ * lighting, whichever mode it runs (the froxel GI stage, `volumetrics/gi/`), plus every directional,
7
+ * point and spot light, shadowed, and attenuated by the fog on its way in. One trilinear read of each
8
+ * of its two textures, so the cost grows with neither the lights nor the GI; the price is resolution —
9
+ * a froxel is 16 pixels across and a slice deep, and light and shadow edges inside a particle are that
10
+ * soft.
5
11
  *
6
- * A caller swaps this for a chunk that binds
7
- * {@link ../../deferred/SHADING_LIGHT_RESOURCE_GROUP.js} and calls `shade_standard_material_direct` + IBL —
8
- * i.e. billboards reuse the exact same lighting path as opaque surfaces when an emitter opts in via
9
- * its `lighting` flag. Keeping it a hook means unlit emitters compile without pulling in the whole
10
- * clustered-lighting resource group.
12
+ * The normal is whatever the vertex stage bent it to (`particle_billboard_normal`), so a camera-facing
13
+ * sprite reads as a rounded puff rather than a card.
14
+ *
15
+ * The enclosing shader binds `camera`, `volumetrics_metadata`, `sLinear`, `tIrradianceY` and
16
+ * `tIrradianceCoCg` under those names.
11
17
  *
12
18
  * @type {CodeChunk}
13
19
  */
14
- export const chunk_particle_lighting_unlit: CodeChunk;
20
+ export const chunk_particle_lighting: CodeChunk;
15
21
  import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
16
22
  //# sourceMappingURL=chunk_particle_lighting.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_particle_lighting.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/particles/shaders/chunk_particle_lighting.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,4CAFU,SAAS,CAQhB;0BArBuB,oCAAoC"}
1
+ {"version":3,"file":"chunk_particle_lighting.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/particles/shaders/chunk_particle_lighting.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;GAkBG;AACH,sCAFU,SAAS,CAgBZ;0BAvCmB,oCAAoC"}
@@ -1,22 +1,40 @@
1
1
  import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
2
+ import {
3
+ volumetrics_position_world_to_froxel_uvw
4
+ } from "../../volumetrics/volumetrics_position_world_to_froxel_uvw.js";
5
+ import { chunk_particle_lighting_model } from "./chunk_particle_lighting_model.js";
2
6
 
3
7
  /**
4
- * Pluggable lighting hook for every particle fragment shader — the AVBOIT draw and the blended
5
- * billboard pipeline alike. `particle_apply_lighting(color, world, normal)` returns the lit colour;
6
- * the default is a pass-through (unlit / emissive).
8
+ * How an emitter flagged `EMITTER_FLAG.LIGHTING` is lit, per fragment:
9
+ * `particle_apply_lighting(color, world, normal)` treats the particle's colour as a diffuse albedo and
10
+ * returns what it reflects and transmits (`chunk_particle_lighting_model`), from the froxel
11
+ * irradiance volume (`chunk_volumetrics_irradiance_sh`) at the fragment: the renderer's indirect
12
+ * lighting, whichever mode it runs (the froxel GI stage, `volumetrics/gi/`), plus every directional,
13
+ * point and spot light, shadowed, and attenuated by the fog on its way in. One trilinear read of each
14
+ * of its two textures, so the cost grows with neither the lights nor the GI; the price is resolution —
15
+ * a froxel is 16 pixels across and a slice deep, and light and shadow edges inside a particle are that
16
+ * soft.
7
17
  *
8
- * A caller swaps this for a chunk that binds
9
- * {@link ../../deferred/SHADING_LIGHT_RESOURCE_GROUP.js} and calls `shade_standard_material_direct` + IBL —
10
- * i.e. billboards reuse the exact same lighting path as opaque surfaces when an emitter opts in via
11
- * its `lighting` flag. Keeping it a hook means unlit emitters compile without pulling in the whole
12
- * clustered-lighting resource group.
18
+ * The normal is whatever the vertex stage bent it to (`particle_billboard_normal`), so a camera-facing
19
+ * sprite reads as a rounded puff rather than a card.
20
+ *
21
+ * The enclosing shader binds `camera`, `volumetrics_metadata`, `sLinear`, `tIrradianceY` and
22
+ * `tIrradianceCoCg` under those names.
13
23
  *
14
24
  * @type {CodeChunk}
15
25
  */
16
- export const chunk_particle_lighting_unlit = CodeChunk.from(
26
+ export const chunk_particle_lighting = CodeChunk.from(
17
27
  /* language=wgsl */
18
28
  `
19
29
  fn particle_apply_lighting(color : vec4<f32>, world_position : vec3<f32>, normal : vec3<f32>) -> vec4<f32> {
20
- return color;
30
+ let uvw = volumetrics_position_world_to_froxel_uvw(world_position);
31
+
32
+ let sh_Y = textureSampleLevel(tIrradianceY, sLinear, uvw, 0.0);
33
+ let sh_CoCg = textureSampleLevel(tIrradianceCoCg, sLinear, uvw, 0.0).xy;
34
+
35
+ return particle_lit(color, sh_Y, sh_CoCg, normal);
21
36
  }
22
- `);
37
+ `, [
38
+ volumetrics_position_world_to_froxel_uvw,
39
+ chunk_particle_lighting_model,
40
+ ]);
@@ -0,0 +1,24 @@
1
+ /**
2
+ * What a lit particle reflects, given what it is lit by — no bindings, so the emulator can run it.
3
+ * `chunk_particle_lighting` fetches the input: one sample of the froxel irradiance volume
4
+ * (`chunk_volumetrics_irradiance_sh`), which holds the scene's lights and whatever indirect lighting
5
+ * the renderer runs, in one encoding.
6
+ *
7
+ * - `particle_lighting_received(sh_Y, sh_CoCg, normal)` — the sample evaluated at the normal, the
8
+ * irradiance clamped at zero, over pi. One light gives `E max(0, 1/4 + cos/2)`, SH2's band-limited
9
+ * clamped cosine. What SH2 cannot do is keep two lights apart: a light's lobe is `-E/4` facing
10
+ * directly away from it, so a light behind a particle subtracts from the ones in front before the
11
+ * clamp sees a total — measured on the bonfire, the moon behind the smoke brings what the fire gives
12
+ * the smoke's lit side down to about half.
13
+ * - `particle_lit(color, sh_Y, sh_CoCg, normal)` — `color` is the particle's albedo and coverage. It
14
+ * reflects what falls on its front, and passes on what falls on its back where it is thin:
15
+ * back-face transmission (Persson, "Practical Particle Lighting", GDC 2012, pp.34-37), the same
16
+ * light evaluated at `-normal` and scaled by `1 - alpha`. The dense core of a puff holds light from
17
+ * behind back and its thin edges let it through, which is the silver lining a backlit cloud of
18
+ * smoke has and a surface lit from one side cannot.
19
+ *
20
+ * @type {CodeChunk}
21
+ */
22
+ export const chunk_particle_lighting_model: CodeChunk;
23
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
24
+ //# sourceMappingURL=chunk_particle_lighting_model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_particle_lighting_model.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/particles/shaders/chunk_particle_lighting_model.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,4CAFU,SAAS,CAoBZ;0BAzCmB,oCAAoC"}
@@ -0,0 +1,45 @@
1
+ import {
2
+ chunk_resolve_irradiance_sh_to_diffuse
3
+ } from "../../shader/chunk/spherical_harmonics/l1i/chunk_resolve_irradiance_sh_to_diffuse.js";
4
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
5
+
6
+ /**
7
+ * What a lit particle reflects, given what it is lit by — no bindings, so the emulator can run it.
8
+ * `chunk_particle_lighting` fetches the input: one sample of the froxel irradiance volume
9
+ * (`chunk_volumetrics_irradiance_sh`), which holds the scene's lights and whatever indirect lighting
10
+ * the renderer runs, in one encoding.
11
+ *
12
+ * - `particle_lighting_received(sh_Y, sh_CoCg, normal)` — the sample evaluated at the normal, the
13
+ * irradiance clamped at zero, over pi. One light gives `E max(0, 1/4 + cos/2)`, SH2's band-limited
14
+ * clamped cosine. What SH2 cannot do is keep two lights apart: a light's lobe is `-E/4` facing
15
+ * directly away from it, so a light behind a particle subtracts from the ones in front before the
16
+ * clamp sees a total — measured on the bonfire, the moon behind the smoke brings what the fire gives
17
+ * the smoke's lit side down to about half.
18
+ * - `particle_lit(color, sh_Y, sh_CoCg, normal)` — `color` is the particle's albedo and coverage. It
19
+ * reflects what falls on its front, and passes on what falls on its back where it is thin:
20
+ * back-face transmission (Persson, "Practical Particle Lighting", GDC 2012, pp.34-37), the same
21
+ * light evaluated at `-normal` and scaled by `1 - alpha`. The dense core of a puff holds light from
22
+ * behind back and its thin edges let it through, which is the silver lining a backlit cloud of
23
+ * smoke has and a surface lit from one side cannot.
24
+ *
25
+ * @type {CodeChunk}
26
+ */
27
+ export const chunk_particle_lighting_model = CodeChunk.from(
28
+ /* language=wgsl */
29
+ `
30
+ fn particle_lighting_received(sh_Y : vec4<f32>, sh_CoCg : vec2<f32>, normal : vec3<f32>) -> vec3<f32> {
31
+ // E / pi, clamped at zero; the volume is scaled for exactly this read
32
+ return resolve_irradiance_sh_to_diffuse(sh_Y, sh_CoCg, normal);
33
+ }
34
+
35
+ fn particle_lit(color : vec4<f32>, sh_Y : vec4<f32>, sh_CoCg : vec2<f32>, normal : vec3<f32>) -> vec4<f32> {
36
+ let front = particle_lighting_received(sh_Y, sh_CoCg, normal);
37
+ let back = particle_lighting_received(sh_Y, sh_CoCg, -normal);
38
+
39
+ let transmitted = back * (1.0 - saturate(color.a));
40
+
41
+ return vec4<f32>(color.rgb * (front + transmitted), color.a);
42
+ }
43
+ `, [
44
+ chunk_resolve_irradiance_sh_to_diffuse,
45
+ ]);
@@ -8,6 +8,9 @@
8
8
  * every roll angle and every camera. What a bounds pass has to dilate a particle's centre by to
9
9
  * hold its quad, and the reason it sits next to the function it bounds rather than with the bounds
10
10
  * pass: the two are one statement, and they drift the moment they are written apart.
11
+ * - `particle_billboard_normal` — the normal a lit particle is shaded with at a corner: the plane
12
+ * that function lays the quad in, turned to the side the camera sees and bent out toward the
13
+ * corner.
11
14
  * - `particle_atlas_uv` — map a local quad uv into an atlas sub-rect, honouring a flipbook grid +
12
15
  * frame index (mirrors meep's AtlasPatch offset/scale convention).
13
16
  * - `particle_soft_fade` — soft-particle alpha fade from scene-vs-particle view depth.
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_particle_render_math.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/particles/shaders/chunk_particle_render_math.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;GAkBG;AACH,yCAFU,SAAS,CA2HhB;0BA/IuB,oCAAoC"}
1
+ {"version":3,"file":"chunk_particle_render_math.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/particles/shaders/chunk_particle_render_math.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,yCAFU,SAAS,CA8JhB;0BArLuB,oCAAoC"}
@@ -11,6 +11,9 @@ import { EMITTER_BLEND, EMITTER_PROJECTION } from "../data/PARTICLE_EMITTER_STRU
11
11
  * every roll angle and every camera. What a bounds pass has to dilate a particle's centre by to
12
12
  * hold its quad, and the reason it sits next to the function it bounds rather than with the bounds
13
13
  * pass: the two are one statement, and they drift the moment they are written apart.
14
+ * - `particle_billboard_normal` — the normal a lit particle is shaded with at a corner: the plane
15
+ * that function lays the quad in, turned to the side the camera sees and bent out toward the
16
+ * corner.
14
17
  * - `particle_atlas_uv` — map a local quad uv into an atlas sub-rect, honouring a flipbook grid +
15
18
  * frame index (mirrors meep's AtlasPatch offset/scale convention).
16
19
  * - `particle_soft_fade` — soft-particle alpha fade from scene-vs-particle view depth.
@@ -105,6 +108,41 @@ fn particle_billboard_radius(size : f32, velocity_ws : vec3<f32>, projection : u
105
108
  return abs(size) * 1.4142135623730951 * (1.0 + stretch);
106
109
  }
107
110
 
111
+ // How far a corner's normal leans out of the quad's plane toward the corner: 1 is 45 degrees.
112
+ // Interpolated across the quad that is flat at the centre and rounding off toward the edges, so a
113
+ // sprite of a puff shades like a puff instead of like the card it is drawn on.
114
+ const PARTICLE_NORMAL_CURVATURE : f32 = 1.0;
115
+
116
+ // The shading normal at a corner that particle_billboard_offset put at offset from the centre.
117
+ //
118
+ // Each projection mode lays the quad on two fixed axes, and the face normal is theirs: the camera
119
+ // plane for BILLBOARD and STRETCHED, world up for HORIZONTAL, the camera direction flattened onto
120
+ // the ground for VERTICAL (world Z when the camera looks straight down, as the offset falls back to
121
+ // world X there), world Z for FACING_WORLD. A quad has two sides and is drawn from both, so the face
122
+ // is turned toward to_camera, the vector from the corner to the eye, not the camera's axis: a
123
+ // camera tilted up at a quad lying on the ground below it still sees its top.
124
+ fn particle_billboard_normal(offset : vec3<f32>, to_camera : vec3<f32>, cam_forward : vec3<f32>, projection : u32) -> vec3<f32> {
125
+ var face = -cam_forward;
126
+
127
+ if (projection == PARTICLE_PROJ_HORIZONTAL) {
128
+ face = vec3<f32>(0.0, 1.0, 0.0);
129
+ } else if (projection == PARTICLE_PROJ_VERTICAL) {
130
+ let horizontal = vec3<f32>(cam_forward.x, 0.0, cam_forward.z);
131
+ let hl = length(horizontal);
132
+ face = select(vec3<f32>(0.0, 0.0, 1.0), horizontal / hl, hl > 1e-5);
133
+ } else if (projection == PARTICLE_PROJ_FACING_WORLD) {
134
+ face = vec3<f32>(0.0, 0.0, 1.0);
135
+ }
136
+
137
+ face = select(face, -face, dot(face, to_camera) < 0.0);
138
+
139
+ // a zero-size particle has no corner to lean toward
140
+ let ol = length(offset);
141
+ let outward = select(vec3<f32>(0.0), offset / ol, ol > 0.0);
142
+
143
+ return normalize(face + outward * PARTICLE_NORMAL_CURVATURE);
144
+ }
145
+
108
146
  // Map a local quad uv (0..1) into an atlas sub-rect + flipbook cell.
109
147
  fn particle_atlas_uv(local_uv : vec2<f32>, region : vec4<f32>, flipbook : vec2<f32>, frame : f32) -> vec2<f32> {
110
148
  let cols = max(flipbook.x, 1.0);
@@ -1 +1 @@
1
- {"version":3,"file":"shader_particle_avboit_draw.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/particles/shaders/shader_particle_avboit_draw.js"],"names":[],"mappings":"AAgLA,2EAAsI;AACtI,8EAA2I;AAC3I,6EAA8I;AAE9I,mEAAmE;AACnE,yEAAwD;AAExD,mDAAmD;AACnD,2DAAsD;yCAxLb,iEAAiE;4CAW9D,sDAAsD;iCAFjE,kCAAkC"}
1
+ {"version":3,"file":"shader_particle_avboit_draw.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/particles/shaders/shader_particle_avboit_draw.js"],"names":[],"mappings":"AAqLA,2EAAsI;AACtI,8EAA2I;AAC3I,6EAA8I;AAE9I,mEAAmE;AACnE,yEAAwD;AAExD,mDAAmD;AACnD,2DAAsD;yCA7Lb,iEAAiE;4CAW9D,sDAAsD;iCAFjE,kCAAkC"}