@woosh/meep-engine 3.63.3 → 3.64.1

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 (190) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/package.json +1 -1
  3. package/src/core/color/xyz/m3_chromatic_adaptation_bradford.d.ts +14 -0
  4. package/src/core/color/xyz/m3_chromatic_adaptation_bradford.d.ts.map +1 -0
  5. package/src/core/color/xyz/m3_chromatic_adaptation_bradford.js +51 -0
  6. package/src/core/math/linalg/eigen/matrix_symmetric_3x3_eigen.d.ts +2 -1
  7. package/src/core/math/linalg/eigen/matrix_symmetric_3x3_eigen.d.ts.map +1 -1
  8. package/src/core/math/linalg/eigen/matrix_symmetric_3x3_eigen.js +51 -70
  9. package/src/core/math/linalg/eigen/matrix_symmetric_4x4_eigen.d.ts.map +1 -1
  10. package/src/core/math/linalg/eigen/matrix_symmetric_4x4_eigen.js +8 -64
  11. package/src/core/math/linalg/eigen/matrix_symmetric_jacobi_rotate_in_place.d.ts +17 -0
  12. package/src/core/math/linalg/eigen/matrix_symmetric_jacobi_rotate_in_place.d.ts.map +1 -0
  13. package/src/core/math/linalg/eigen/matrix_symmetric_jacobi_rotate_in_place.js +64 -0
  14. package/src/core/math/linalg/solve_box_constrained_qp.d.ts +30 -0
  15. package/src/core/math/linalg/solve_box_constrained_qp.d.ts.map +1 -0
  16. package/src/core/math/linalg/solve_box_constrained_qp.js +205 -0
  17. package/src/engine/graphics/texture/sampler/exr_to_sampler2d.d.ts +27 -0
  18. package/src/engine/graphics/texture/sampler/exr_to_sampler2d.d.ts.map +1 -0
  19. package/src/engine/graphics/texture/sampler/exr_to_sampler2d.js +91 -0
  20. package/src/engine/graphics/texture/sampler/sampler2d_to_exr.d.ts +23 -0
  21. package/src/engine/graphics/texture/sampler/sampler2d_to_exr.d.ts.map +1 -0
  22. package/src/engine/graphics/texture/sampler/sampler2d_to_exr.js +64 -0
  23. package/src/engine/physics/constraint/soft_spring_coefficients.d.ts +24 -0
  24. package/src/engine/physics/constraint/soft_spring_coefficients.d.ts.map +1 -0
  25. package/src/engine/physics/constraint/soft_spring_coefficients.js +38 -0
  26. package/src/engine/physics/constraint/solve_constraints.d.ts.map +1 -1
  27. package/src/engine/physics/constraint/solve_constraints.js +16 -8
  28. package/src/engine/physics/ecs/PhysicsSystem.d.ts +54 -0
  29. package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
  30. package/src/engine/physics/ecs/PhysicsSystem.js +192 -7
  31. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  32. package/src/engine/physics/inertia/world_inverse_inertia.d.ts +3 -5
  33. package/src/engine/physics/inertia/world_inverse_inertia.d.ts.map +1 -1
  34. package/src/engine/physics/inertia/world_inverse_inertia.js +3 -5
  35. package/src/engine/physics/vehicle/RaycastVehicle.d.ts +183 -12
  36. package/src/engine/physics/vehicle/RaycastVehicle.d.ts.map +1 -1
  37. package/src/engine/physics/vehicle/RaycastVehicle.js +1046 -121
  38. package/src/format/image/exr/ExrCompression.d.ts +22 -0
  39. package/src/format/image/exr/ExrCompression.d.ts.map +1 -0
  40. package/src/format/image/exr/ExrCompression.js +27 -0
  41. package/src/format/image/exr/ExrImage.d.ts +32 -0
  42. package/src/format/image/exr/ExrImage.d.ts.map +1 -0
  43. package/src/format/image/exr/ExrImage.js +32 -0
  44. package/src/format/image/exr/ExrPixelType.d.ts +13 -0
  45. package/src/format/image/exr/ExrPixelType.d.ts.map +1 -0
  46. package/src/format/image/exr/ExrPixelType.js +18 -0
  47. package/src/format/image/exr/exr_compare_names.d.ts +16 -0
  48. package/src/format/image/exr/exr_compare_names.d.ts.map +1 -0
  49. package/src/format/image/exr/exr_compare_names.js +25 -0
  50. package/src/format/image/exr/exr_constants.d.ts +49 -0
  51. package/src/format/image/exr/exr_constants.d.ts.map +1 -0
  52. package/src/format/image/exr/exr_constants.js +56 -0
  53. package/src/format/image/exr/exr_read.d.ts +32 -0
  54. package/src/format/image/exr/exr_read.d.ts.map +1 -0
  55. package/src/format/image/exr/exr_read.js +531 -0
  56. package/src/format/image/exr/exr_sample_bits.d.ts +16 -0
  57. package/src/format/image/exr/exr_sample_bits.d.ts.map +1 -0
  58. package/src/format/image/exr/exr_sample_bits.js +21 -0
  59. package/src/format/image/exr/exr_scanlines_per_chunk.d.ts +17 -0
  60. package/src/format/image/exr/exr_scanlines_per_chunk.d.ts.map +1 -0
  61. package/src/format/image/exr/exr_scanlines_per_chunk.js +31 -0
  62. package/src/format/image/exr/exr_write.d.ts +27 -0
  63. package/src/format/image/exr/exr_write.d.ts.map +1 -0
  64. package/src/format/image/exr/exr_write.js +378 -0
  65. package/src/shade/playground/probe_clipmap/index.html +5 -0
  66. package/src/shade/playground/probe_clipmap/main.d.ts.map +1 -1
  67. package/src/shade/playground/probe_clipmap/main.js +34 -1
  68. package/src/shade/playground/tonemap_sdr/README.md +11 -8
  69. package/src/shade/playground/tonemap_sdr/ToneMapCompare.js +2 -2
  70. package/src/shade/renderer/Renderer.d.ts +5 -6
  71. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  72. package/src/shade/renderer/Renderer.js +15 -88
  73. package/src/shade/renderer/animation/chunk_animation_curve_evaluate_keys.d.ts +14 -0
  74. package/src/shade/renderer/animation/chunk_animation_curve_evaluate_keys.d.ts.map +1 -0
  75. package/src/shade/renderer/animation/chunk_animation_curve_evaluate_keys.js +62 -0
  76. package/src/shade/renderer/deferred/tonemap/ColorGrade.d.ts +158 -0
  77. package/src/shade/renderer/deferred/tonemap/ColorGrade.d.ts.map +1 -0
  78. package/src/shade/renderer/deferred/tonemap/ColorGrade.js +337 -0
  79. package/src/shade/renderer/deferred/tonemap/SAMPLER_TONEMAP_LUT.d.ts +9 -0
  80. package/src/shade/renderer/deferred/tonemap/SAMPLER_TONEMAP_LUT.d.ts.map +1 -0
  81. package/src/shade/renderer/deferred/tonemap/SAMPLER_TONEMAP_LUT.js +15 -0
  82. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_ACES.d.ts +6 -0
  83. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_ACES.d.ts.map +1 -0
  84. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_ACES.js +84 -0
  85. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_GT7.d.ts +10 -0
  86. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_GT7.d.ts.map +1 -0
  87. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_GT7.js +25 -0
  88. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_NONE.d.ts +9 -0
  89. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_NONE.d.ts.map +1 -0
  90. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_NONE.js +20 -0
  91. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_PBR_NEUTRAL.d.ts +14 -0
  92. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_PBR_NEUTRAL.d.ts.map +1 -0
  93. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_PBR_NEUTRAL.js +30 -0
  94. package/src/shade/renderer/deferred/tonemap/ToneMapOperator.d.ts +54 -0
  95. package/src/shade/renderer/deferred/tonemap/ToneMapOperator.d.ts.map +1 -0
  96. package/src/shade/renderer/deferred/tonemap/ToneMapOperator.js +63 -0
  97. package/src/shade/renderer/deferred/tonemap/ToneMapper.d.ts +106 -0
  98. package/src/shade/renderer/deferred/tonemap/ToneMapper.d.ts.map +1 -0
  99. package/src/shade/renderer/deferred/tonemap/ToneMapper.js +474 -0
  100. package/src/shade/renderer/deferred/tonemap/TonemapAces2Tables.d.ts +5 -13
  101. package/src/shade/renderer/deferred/tonemap/TonemapAces2Tables.d.ts.map +1 -1
  102. package/src/shade/renderer/deferred/tonemap/TonemapAces2Tables.js +5 -44
  103. package/src/shade/renderer/deferred/tonemap/TonemapDisplaySettings.d.ts +7 -25
  104. package/src/shade/renderer/deferred/tonemap/TonemapDisplaySettings.d.ts.map +1 -1
  105. package/src/shade/renderer/deferred/tonemap/TonemapDisplaySettings.js +11 -51
  106. package/src/shade/renderer/deferred/tonemap/m3_white_balance_rec709.d.ts +20 -0
  107. package/src/shade/renderer/deferred/tonemap/m3_white_balance_rec709.d.ts.map +1 -0
  108. package/src/shade/renderer/deferred/tonemap/m3_white_balance_rec709.js +103 -0
  109. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_lut.d.ts +9 -0
  110. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_lut.d.ts.map +1 -0
  111. package/src/shade/renderer/deferred/tonemap/{shader_tonemap_HDR_none.js → shader_tonemap_HDR_lut.js} +22 -18
  112. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_lut.d.ts +9 -0
  113. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_lut.d.ts.map +1 -0
  114. package/src/shade/renderer/deferred/tonemap/{shader_tonemap_LDR_aces.js → shader_tonemap_LDR_lut.js} +24 -24
  115. package/src/shade/renderer/deferred/tonemap/shader_tonemap_lut_bake.d.ts +23 -0
  116. package/src/shade/renderer/deferred/tonemap/shader_tonemap_lut_bake.d.ts.map +1 -0
  117. package/src/shade/renderer/deferred/tonemap/shader_tonemap_lut_bake.js +92 -0
  118. package/src/shade/renderer/deferred/tonemap/shader_tonemap_lut_sdr_from_hdr.d.ts +15 -0
  119. package/src/shade/renderer/deferred/tonemap/shader_tonemap_lut_sdr_from_hdr.d.ts.map +1 -0
  120. package/src/shade/renderer/deferred/tonemap/shader_tonemap_lut_sdr_from_hdr.js +73 -0
  121. package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
  122. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
  123. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +6 -6
  124. package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
  125. package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
  126. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +1 -1
  127. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.d.ts +3 -15
  128. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.d.ts.map +1 -1
  129. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.js +4 -17
  130. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.d.ts +3 -3
  131. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.d.ts.map +1 -1
  132. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.js +15 -13
  133. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_accumulate.d.ts +7 -3
  134. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_accumulate.d.ts.map +1 -1
  135. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_accumulate.js +28 -17
  136. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_project.d.ts +18 -18
  137. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_project.d.ts.map +1 -1
  138. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_project.js +44 -48
  139. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  140. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  141. package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.d.ts +22 -0
  142. package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.d.ts.map +1 -0
  143. package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.js +62 -0
  144. package/src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.d.ts +13 -0
  145. package/src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.d.ts.map +1 -0
  146. package/src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.js +140 -0
  147. package/src/shade/renderer/shader/chunk/color/oklab/chunk_oklab_compute_max_saturation.d.ts +11 -0
  148. package/src/shade/renderer/shader/chunk/color/oklab/chunk_oklab_compute_max_saturation.d.ts.map +1 -0
  149. package/src/shade/renderer/shader/chunk/color/oklab/chunk_oklab_compute_max_saturation.js +65 -0
  150. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_bt2390_eetf.d.ts +14 -0
  151. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_bt2390_eetf.d.ts.map +1 -0
  152. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_bt2390_eetf.js +38 -0
  153. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_lut.d.ts +16 -0
  154. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_lut.d.ts.map +1 -0
  155. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_lut.js +41 -0
  156. package/src/shade/renderer/shader/chunk/filter/chunk_multiscale_mean.d.ts +8 -0
  157. package/src/shade/renderer/shader/chunk/filter/chunk_multiscale_mean.d.ts.map +1 -1
  158. package/src/shade/renderer/shader/chunk/filter/chunk_multiscale_mean.js +21 -3
  159. package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
  160. package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.js +8 -8
  161. package/src/shade/wgsl/emulator/WGSLLanguageCore.d.ts.map +1 -1
  162. package/src/shade/wgsl/emulator/WGSLLanguageCore.js +2 -0
  163. package/src/shade/renderer/ShadeToneMappingMode.d.ts +0 -15
  164. package/src/shade/renderer/ShadeToneMappingMode.d.ts.map +0 -1
  165. package/src/shade/renderer/ShadeToneMappingMode.js +0 -41
  166. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR.d.ts +0 -9
  167. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR.d.ts.map +0 -1
  168. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR.js +0 -79
  169. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_aces.d.ts +0 -17
  170. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_aces.d.ts.map +0 -1
  171. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_aces.js +0 -101
  172. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_none.d.ts +0 -9
  173. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_none.d.ts.map +0 -1
  174. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_pbr_neutral.d.ts +0 -10
  175. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_pbr_neutral.d.ts.map +0 -1
  176. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_pbr_neutral.js +0 -80
  177. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR.d.ts +0 -9
  178. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR.d.ts.map +0 -1
  179. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR.js +0 -80
  180. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_aces.d.ts +0 -10
  181. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_aces.d.ts.map +0 -1
  182. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_none.d.ts +0 -9
  183. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_none.d.ts.map +0 -1
  184. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_none.js +0 -71
  185. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_pbr_neutral.d.ts +0 -10
  186. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_pbr_neutral.d.ts.map +0 -1
  187. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_pbr_neutral.js +0 -76
  188. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_hdr_bt2390.d.ts +0 -3
  189. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_hdr_bt2390.d.ts.map +0 -1
  190. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_hdr_bt2390.js +0 -44
@@ -22,16 +22,7 @@ import { shader_composite_volumetrics } from "./deferred/shader_composite_volume
22
22
  import { shader_deferred_main } from "./deferred/shader_deferred_main.js";
23
23
  import { LOCAL_LIGHT_SHADING } from "./deferred/LOCAL_LIGHT_SHADING.js";
24
24
  import { LocalLightShading } from "./deferred/LocalLightShading.js";
25
- import { shader_tonemap_HDR } from "./deferred/tonemap/shader_tonemap_HDR.js";
26
- import { shader_tonemap_HDR_aces } from "./deferred/tonemap/shader_tonemap_HDR_aces.js";
27
- import { shader_tonemap_HDR_none } from "./deferred/tonemap/shader_tonemap_HDR_none.js";
28
- import { shader_tonemap_HDR_pbr_neutral } from "./deferred/tonemap/shader_tonemap_HDR_pbr_neutral.js";
29
- import { shader_tonemap_LDR } from "./deferred/tonemap/shader_tonemap_LDR.js";
30
- import { shader_tonemap_LDR_aces } from "./deferred/tonemap/shader_tonemap_LDR_aces.js";
31
- import { shader_tonemap_LDR_none } from "./deferred/tonemap/shader_tonemap_LDR_none.js";
32
- import { shader_tonemap_LDR_pbr_neutral } from "./deferred/tonemap/shader_tonemap_LDR_pbr_neutral.js";
33
- import { TonemapAces2Tables } from "./deferred/tonemap/TonemapAces2Tables.js";
34
- import { TonemapDisplaySettings } from "./deferred/tonemap/TonemapDisplaySettings.js";
25
+ import { ToneMapper } from "./deferred/tonemap/ToneMapper.js";
35
26
  import { FrameContext } from "./extension/FrameContext.js";
36
27
  import { FramePhase } from "./extension/FramePhase.js";
37
28
  import { GBufferTextures } from "./extension/GBufferTextures.js";
@@ -102,7 +93,6 @@ import { GPUParticleSystem } from "./particles/GPUParticleSystem.js";
102
93
  import { SceneManager } from "./scene/SceneManager.js";
103
94
  import { ShadeIndirectLightingMode } from "./ShadeIndirectLightingMode.js";
104
95
  import { MaterialDispatch } from "./material/dispatch/MaterialDispatch.js";
105
- import { ShadeToneMappingMode } from "./ShadeToneMappingMode.js";
106
96
  import { ShadeTransparencyMode } from "./ShadeTransparencyMode.js";
107
97
  import { AVBOITSettings } from "./rasterize/native/avboit/AVBOITSettings.js";
108
98
  import { ShaderSwitchSet } from "./shader/compiler/ShaderSwitchSet.js";
@@ -264,12 +254,11 @@ export class Renderer {
264
254
  transparency_mode = ShadeTransparencyMode.AVBOIT;
265
255
 
266
256
  /**
267
- * How the exposed scene colour becomes display colour, on every output. An SDR and an HDR display run the same
268
- * mode, so a scene looks alike on both; see {@link ShadeToneMappingMode}. ACES, Unreal's default look, unless set. Read every frame, so it can be flipped
269
- * at runtime. A mode not in use at {@link initialize} compiles its pass on the first frame that draws with it.
270
- * @type {ShadeToneMappingMode}
257
+ * How the exposed scene colour becomes display colour, on every output: its operator, the resolution of its LUTs,
258
+ * and LUTs of the user's own. Made by {@link initialize}.
259
+ * @type {ToneMapper}
271
260
  */
272
- tone_mapping_mode = ShadeToneMappingMode.ACES;
261
+ tone_mapper;
273
262
 
274
263
  /**
275
264
  * Switches of the AVBOIT mode, read every frame while {@link transparency_mode} selects it.
@@ -1651,21 +1640,6 @@ export class Renderer {
1651
1640
 
1652
1641
  #hdr_supported = false;
1653
1642
 
1654
- /**
1655
- * What every tonemap pass is told about the display: the primaries the canvas was actually configured with, and
1656
- * the peak brightness, which only the HDR passes read.
1657
- *
1658
- * @type {TonemapDisplaySettings}
1659
- */
1660
- #tonemap_settings = new TonemapDisplaySettings();
1661
-
1662
- /**
1663
- * The ACES HDR pass's two output transforms, built for the display in {@link #tonemap_settings}.
1664
- *
1665
- * @type {TonemapAces2Tables}
1666
- */
1667
- #tonemap_aces2_tables = new TonemapAces2Tables();
1668
-
1669
1643
  #update_presentation_format() {
1670
1644
 
1671
1645
  const format8bit = navigator.gpu.getPreferredCanvasFormat();
@@ -1690,16 +1664,9 @@ export class Renderer {
1690
1664
  const previous_value = this.#hdr_supported;
1691
1665
 
1692
1666
 
1667
+ // the browser has no way to report the display's peak, so the tone mapper keeps its assumption
1693
1668
  this.#hdr_supported = isHDR;
1694
1669
 
1695
- if (isHDR) {
1696
- // Currently, there is no way to interrogate this from the browser, so going with an assumption
1697
- this.#tonemap_settings.peak_nits = 1000;
1698
- } else {
1699
- // Assume SDR nits
1700
- this.#tonemap_settings.peak_nits = 80;
1701
- }
1702
-
1703
1670
  if (isHDR === previous_value) {
1704
1671
  // no change
1705
1672
  return;
@@ -1842,6 +1809,8 @@ export class Renderer {
1842
1809
  this.context = context;
1843
1810
  this.device = device;
1844
1811
 
1812
+ this.tone_mapper = new ToneMapper(device);
1813
+
1845
1814
  this.#pixel_ratio = pixelRatio;
1846
1815
 
1847
1816
  // clientWidth/clientHeight are 0 for a canvas that is not attached to the DOM,
@@ -2014,31 +1983,7 @@ export class Renderer {
2014
1983
 
2015
1984
  this.#extensions.enquirePipelines(enquiry);
2016
1985
 
2017
- enquiry.render.push(this.#tonemap_shader().pipeline_for([this.#presentation_format]));
2018
- }
2019
-
2020
- /**
2021
- * The pass that writes the canvas: the output's dynamic range picks the SDR or the HDR form, and
2022
- * {@link tone_mapping_mode} picks the operator.
2023
- *
2024
- * @returns {import("./shader/ImageShader.js").ImageShader}
2025
- */
2026
- #tonemap_shader() {
2027
- assert.enum(this.tone_mapping_mode, ShadeToneMappingMode, 'tone_mapping_mode');
2028
-
2029
- if (this.tone_mapping_mode === ShadeToneMappingMode.NONE) {
2030
- return this.#hdr_supported ? shader_tonemap_HDR_none : shader_tonemap_LDR_none;
2031
- }
2032
-
2033
- if (this.tone_mapping_mode === ShadeToneMappingMode.ACES) {
2034
- return this.#hdr_supported ? shader_tonemap_HDR_aces : shader_tonemap_LDR_aces;
2035
- }
2036
-
2037
- if (this.tone_mapping_mode === ShadeToneMappingMode.PBR_NEUTRAL) {
2038
- return this.#hdr_supported ? shader_tonemap_HDR_pbr_neutral : shader_tonemap_LDR_pbr_neutral;
2039
- }
2040
-
2041
- return this.#hdr_supported ? shader_tonemap_HDR : shader_tonemap_LDR;
1986
+ this.tone_mapper.enquire_pipelines(enquiry, this.#hdr_supported, this.#presentation_format);
2042
1987
  }
2043
1988
 
2044
1989
  /**
@@ -2115,7 +2060,7 @@ export class Renderer {
2115
2060
  this.#scene_sdfs.clear();
2116
2061
 
2117
2062
  this.#autoexposure?.destroy();
2118
- this.#tonemap_aces2_tables.destroy();
2063
+ this.tone_mapper?.destroy();
2119
2064
  this.#depth_of_field?.destroy();
2120
2065
  this.#depth_of_field_unreal?.destroy();
2121
2066
  this.#restir_di?.destroy();
@@ -2242,7 +2187,7 @@ export class Renderer {
2242
2187
  configured_color_space = configuration.colorSpace ?? 'srgb';
2243
2188
  }
2244
2189
 
2245
- this.#tonemap_settings.set_canvas_color_space(configured_color_space);
2190
+ this.tone_mapper.display.set_canvas_color_space(configured_color_space);
2246
2191
  }
2247
2192
 
2248
2193
  #apply_size() {
@@ -3525,30 +3470,12 @@ export class Renderer {
3525
3470
 
3526
3471
  current_color_out = record_scene_color.color;
3527
3472
 
3528
- const tonemap_shader = this.#tonemap_shader();
3529
-
3530
- // every pass reads from the settings only the members its immediate struct names: the canvas's primaries
3531
- // from its working space, and, on an HDR display, the peak
3532
- const tonemap_inputs = {
3473
+ current_color_out = this.tone_mapper.render({
3474
+ graph,
3533
3475
  input_color: current_color_out,
3534
- settings: this.#tonemap_settings,
3535
3476
  exposure,
3536
- };
3537
-
3538
- if (tonemap_shader === shader_tonemap_HDR_aces) {
3539
- // the two ACES 2.0 transforms for this display, rebuilt only when the display changed
3540
- const display = this.#tonemap_settings;
3541
- const tables = this.#tonemap_aces2_tables;
3542
-
3543
- tables.update(display.peak_nits);
3544
- tonemap_inputs.aces2_tables = graph_import_buffer(graph, tables.gpu_buffer(this.device), "tonemap/aces2 tables");
3545
- }
3546
-
3547
- [current_color_out] = graph_image_pass({
3548
- graph,
3549
- shader: tonemap_shader,
3550
- inputs: tonemap_inputs,
3551
- output: [gr_texture_canvas]
3477
+ hdr: this.#hdr_supported,
3478
+ target: gr_texture_canvas,
3552
3479
  });
3553
3480
 
3554
3481
  /*
@@ -0,0 +1,14 @@
1
+ /**
2
+ * `animation_curve_evaluate_keys(keys, first, count, time)`: one curve at `time`, as `AnimationCurve.evaluate`
3
+ * evaluates it, from a run of `count` keyframes of a plain storage array, `first` onwards, in ascending time order.
4
+ * `count` is at least 1.
5
+ *
6
+ * The same answer as {@link chunk_animation_curve_evaluate}, which reads its keyframes from the animation database:
7
+ * the first key's value at or before the first key, the last key's at or past the last, and between them the Hermite
8
+ * piece from the last key at or before `time`, so two keys at one time are a step there. ⌈log2(count - 1)⌉ probes.
9
+ *
10
+ * @type {CodeChunk}
11
+ */
12
+ export const chunk_animation_curve_evaluate_keys: CodeChunk;
13
+ import { CodeChunk } from "../shader/compiler/CodeChunk.js";
14
+ //# sourceMappingURL=chunk_animation_curve_evaluate_keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_animation_curve_evaluate_keys.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/animation/chunk_animation_curve_evaluate_keys.js"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AACH,kDAFU,SAAS,CA+CjB;0BA5DwB,iCAAiC"}
@@ -0,0 +1,62 @@
1
+ import { chunk_inverse_lerp } from "../shader/chunk/math/chunk_inverse_lerp.js";
2
+ import { CodeChunk } from "../shader/compiler/CodeChunk.js";
3
+ import { ANIMATION_CURVE_KEYFRAME_STRUCT } from "./ANIMATION_CURVE_KEYFRAME_STRUCT.js";
4
+ import { chunk_animation_curve_evaluate_piece } from "./chunk_animation_curve_evaluate_piece.js";
5
+
6
+ /**
7
+ * `animation_curve_evaluate_keys(keys, first, count, time)`: one curve at `time`, as `AnimationCurve.evaluate`
8
+ * evaluates it, from a run of `count` keyframes of a plain storage array, `first` onwards, in ascending time order.
9
+ * `count` is at least 1.
10
+ *
11
+ * The same answer as {@link chunk_animation_curve_evaluate}, which reads its keyframes from the animation database:
12
+ * the first key's value at or before the first key, the last key's at or past the last, and between them the Hermite
13
+ * piece from the last key at or before `time`, so two keys at one time are a step there. ⌈log2(count - 1)⌉ probes.
14
+ *
15
+ * @type {CodeChunk}
16
+ */
17
+ export const chunk_animation_curve_evaluate_keys = CodeChunk.from(
18
+ //language=WGSL
19
+ `
20
+ fn animation_curve_evaluate_keys(
21
+ keys: ptr<storage, array<${ANIMATION_CURVE_KEYFRAME_STRUCT.wgsl_ref}>, read>,
22
+ first: u32,
23
+ count: u32,
24
+ time: f32,
25
+ ) -> f32 {
26
+ if (count <= 1u || time <= (*keys)[first].time) {
27
+ return (*keys)[first].value;
28
+ }
29
+
30
+ let last = first + count - 1u;
31
+
32
+ if (time >= (*keys)[last].time) {
33
+ return (*keys)[last].value;
34
+ }
35
+
36
+ // time(lo) <= time < time(hi), closed in until they are neighbours
37
+ var lo = first;
38
+ var hi = last;
39
+
40
+ loop {
41
+ if (hi - lo <= 1u) { break; }
42
+
43
+ let mid = lo + ((hi - lo) >> 1u);
44
+
45
+ if ((*keys)[mid].time <= time) {
46
+ lo = mid;
47
+ } else {
48
+ hi = mid;
49
+ }
50
+ }
51
+
52
+ let key0 = (*keys)[lo];
53
+ let key1 = (*keys)[hi];
54
+
55
+ return animation_curve_evaluate_piece(inverse_lerp(key0.time, key1.time, time), key0, key1);
56
+ }
57
+ `, [
58
+ ANIMATION_CURVE_KEYFRAME_STRUCT.declaration_chunk,
59
+ chunk_animation_curve_evaluate_piece,
60
+ chunk_inverse_lerp,
61
+ ]
62
+ );
@@ -0,0 +1,158 @@
1
+ /**
2
+ * The grade as the bake reads it, a uniform. Every field is 16 bytes, in this order, never packed: field i is at byte
3
+ * 16 · i, which is how {@link ColorGrade#pack} writes it.
4
+ *
5
+ * - `white_balance_c0..c2`: the white-balance matrix on linear Rec.709, by column.
6
+ * - per zone, `{zone}_saturation`, `_contrast`, `_gamma`, `_gain`, `_offset`: the zone's values with the global ones
7
+ * folded in and each vector's fourth component applied to the first three, as Unreal's `ColorCorrectAll` combines
8
+ * them.
9
+ * - `zone_bounds`: `shadows_max`, `highlights_min`, `highlights_max`.
10
+ * - `curve_counts`: the keys of the hue, saturation and lightness curves. They follow the uniform in `grade_keys`, in
11
+ * that order.
12
+ */
13
+ export const COLOR_GRADE_STRUCT: WebGPUStruct;
14
+ /**
15
+ * Floats of {@link COLOR_GRADE_STRUCT} at the head of {@link ColorGrade#pack}'s data.
16
+ * @type {number}
17
+ */
18
+ export const COLOR_GRADE_HEADER_FLOATS: number;
19
+ /**
20
+ * Floats of one keyframe in `grade_keys`: time, value, in tangent, out tangent.
21
+ * @type {number}
22
+ */
23
+ export const COLOR_GRADE_KEY_FLOATS: number;
24
+ /**
25
+ * One zone of Unreal's primary grade: shadows, midtones, highlights, or all of them. Each vector is RGB and a master
26
+ * value that scales (or, for the offset, adds to) all three.
27
+ */
28
+ export class ColorGradeZone {
29
+ /**
30
+ * Blend between the luma and the colour; 0 is grey, 1 leaves it.
31
+ * @readonly
32
+ * @type {Vector4}
33
+ */
34
+ readonly saturation: Vector4;
35
+ /**
36
+ * Power about 0.18.
37
+ * @readonly
38
+ * @type {Vector4}
39
+ */
40
+ readonly contrast: Vector4;
41
+ /**
42
+ * The colour is raised to 1 / gamma.
43
+ * @readonly
44
+ * @type {Vector4}
45
+ */
46
+ readonly gamma: Vector4;
47
+ /**
48
+ * @readonly
49
+ * @type {Vector4}
50
+ */
51
+ readonly gain: Vector4;
52
+ /**
53
+ * Added last.
54
+ * @readonly
55
+ * @type {Vector4}
56
+ */
57
+ readonly offset: Vector4;
58
+ }
59
+ /**
60
+ * A colour grade on the exposed scene colour, ahead of the tone-mapping operator, baked into the tone mapper's LUTs.
61
+ * Neutral as constructed. In order:
62
+ *
63
+ * 1. **White balance**, Unreal's temperature white balance on linear Rec.709; see `m3_white_balance_rec709`.
64
+ * 2. **Primaries**, Unreal's `ColorCorrectAll` in AP1: saturation, contrast, gamma, gain and offset for {@link global},
65
+ * {@link shadows}, {@link midtones} and {@link highlights}, the zones blended by AP1 luma between
66
+ * {@link shadows_max}, {@link highlights_min} and {@link highlights_max}. Values from an Unreal project's post-process
67
+ * settings give the same result. The colour is clamped at zero in Rec.709 after it, as the operator takes it.
68
+ * 3. **Hue curves**, in OkLCh. Each curve's time is the colour's OkLCh hue in degrees, 0 to 360, and is evaluated as
69
+ * {@link AnimationCurve#evaluate} would; a curve with no keys does nothing. The curve holds its end keys' values
70
+ * outside them, so for a seamless circle key 0 and 360 with the same value and tangent.
71
+ * - {@link hue_shift}: degrees added to the hue.
72
+ * - {@link hue_saturation}: a multiplier on the chroma.
73
+ * - {@link hue_lightness}: stops of exposure, the light multiplied by 2^stops at the same chromaticity, weighted by
74
+ * the colour's saturation relative to the most saturated Rec.709 colour of its hue. A grey never moves, and a
75
+ * colour on the gamut's edge takes the full value.
76
+ * All three are read at the colour's hue before any of them applies.
77
+ *
78
+ * Read by the tone mapper every frame; any change bakes the LUTs again. A LUT the user supplies is not graded.
79
+ */
80
+ export class ColorGrade {
81
+ /**
82
+ * Colour temperature of the white the grade makes neutral, K. 6500 does nothing.
83
+ * @type {number}
84
+ */
85
+ white_temperature: number;
86
+ /**
87
+ * Offset of that white along its isotherm, -1 to 1 as in Unreal. 0 does nothing.
88
+ * @type {number}
89
+ */
90
+ white_tint: number;
91
+ /**
92
+ * Applies in every zone, under the zone's own values.
93
+ * @readonly
94
+ * @type {ColorGradeZone}
95
+ */
96
+ readonly global: ColorGradeZone;
97
+ /**
98
+ * @readonly
99
+ * @type {ColorGradeZone}
100
+ */
101
+ readonly shadows: ColorGradeZone;
102
+ /**
103
+ * @readonly
104
+ * @type {ColorGradeZone}
105
+ */
106
+ readonly midtones: ColorGradeZone;
107
+ /**
108
+ * @readonly
109
+ * @type {ColorGradeZone}
110
+ */
111
+ readonly highlights: ColorGradeZone;
112
+ /**
113
+ * AP1 luma at which the shadows' weight reaches 0. Unreal's default.
114
+ * @type {number}
115
+ */
116
+ shadows_max: number;
117
+ /**
118
+ * AP1 luma at which the highlights' weight starts to rise from 0. Unreal's default.
119
+ * @type {number}
120
+ */
121
+ highlights_min: number;
122
+ /**
123
+ * AP1 luma at which the highlights' weight reaches 1. Unreal's default.
124
+ * @type {number}
125
+ */
126
+ highlights_max: number;
127
+ /**
128
+ * Degrees added to the OkLCh hue, against the hue in degrees.
129
+ * @readonly
130
+ * @type {AnimationCurve}
131
+ */
132
+ readonly hue_shift: AnimationCurve;
133
+ /**
134
+ * Multiplier on the OkLCh chroma, against the hue in degrees.
135
+ * @readonly
136
+ * @type {AnimationCurve}
137
+ */
138
+ readonly hue_saturation: AnimationCurve;
139
+ /**
140
+ * Stops of exposure, against the hue in degrees.
141
+ * @readonly
142
+ * @type {AnimationCurve}
143
+ */
144
+ readonly hue_lightness: AnimationCurve;
145
+ /**
146
+ * The grade as the bake reads it: {@link COLOR_GRADE_STRUCT}, then the three curves' keys, each
147
+ * {@link COLOR_GRADE_KEY_FLOATS} floats, with room for one key when there are none. The array is reused while the
148
+ * key count stays the same.
149
+ *
150
+ * @returns {Float32Array}
151
+ */
152
+ pack(): Float32Array;
153
+ #private;
154
+ }
155
+ import { WebGPUStruct } from "../../shader/type/WebGPUStruct.js";
156
+ import { Vector4 } from "../../../../core/geom/Vector4.js";
157
+ import { AnimationCurve } from "../../../../engine/animation/curve/AnimationCurve.js";
158
+ //# sourceMappingURL=ColorGrade.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorGrade.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/deferred/tonemap/ColorGrade.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;GAWG;AACH,8CAyBG;AAEH;;;GAGG;AACH,wCAFU,MAAM,CAE4B;AAE5C;;;GAGG;AACH,qCAFU,MAAM,CAEwB;AAExC;;;GAGG;AACH;IACI;;;;OAIG;IACH,qBAFU,OAAO,CAEoB;IAErC;;;;OAIG;IACH,mBAFU,OAAO,CAEkB;IAEnC;;;;OAIG;IACH,gBAFU,OAAO,CAEe;IAEhC;;;OAGG;IACH,eAFU,OAAO,CAEc;IAE/B;;;;OAIG;IACH,iBAFU,OAAO,CAEgB;CACpC;AAwED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;IACI;;;OAGG;IACH,mBAFU,MAAM,CAEsC;IAEtD;;;OAGG;IACH,YAFU,MAAM,CAEwB;IAExC;;;;OAIG;IACH,iBAFU,cAAc,CAEM;IAE9B;;;OAGG;IACH,kBAFU,cAAc,CAEO;IAE/B;;;OAGG;IACH,mBAFU,cAAc,CAEQ;IAEhC;;;OAGG;IACH,qBAFU,cAAc,CAEU;IAElC;;;OAGG;IACH,aAFU,MAAM,CAEG;IAEnB;;;OAGG;IACH,gBAFU,MAAM,CAEK;IAErB;;;OAGG;IACH,gBAFU,MAAM,CAEG;IAEnB;;;;OAIG;IACH,oBAFU,cAAc,CAES;IAEjC;;;;OAIG;IACH,yBAFU,cAAc,CAEc;IAEtC;;;;OAIG;IACH,wBAFU,cAAc,CAEa;IAarC;;;;;;OAMG;IACH,QAFa,YAAY,CAqDxB;;CACJ;6BA5U4B,mCAAmC;wBAHxC,kCAAkC;+BAC3B,sDAAsD"}