@woosh/meep-engine 3.63.2 → 3.64.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 (148) 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/physics/constraint/soft_spring_coefficients.d.ts +24 -0
  18. package/src/engine/physics/constraint/soft_spring_coefficients.d.ts.map +1 -0
  19. package/src/engine/physics/constraint/soft_spring_coefficients.js +38 -0
  20. package/src/engine/physics/constraint/solve_constraints.d.ts.map +1 -1
  21. package/src/engine/physics/constraint/solve_constraints.js +16 -8
  22. package/src/engine/physics/ecs/PhysicsSystem.d.ts +54 -0
  23. package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
  24. package/src/engine/physics/ecs/PhysicsSystem.js +192 -7
  25. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  26. package/src/engine/physics/inertia/world_inverse_inertia.d.ts +3 -5
  27. package/src/engine/physics/inertia/world_inverse_inertia.d.ts.map +1 -1
  28. package/src/engine/physics/inertia/world_inverse_inertia.js +3 -5
  29. package/src/engine/physics/vehicle/RaycastVehicle.d.ts +183 -12
  30. package/src/engine/physics/vehicle/RaycastVehicle.d.ts.map +1 -1
  31. package/src/engine/physics/vehicle/RaycastVehicle.js +1046 -121
  32. package/src/shade/device/mock/SoftwareGPUCommandEncoder.d.ts +17 -0
  33. package/src/shade/device/mock/SoftwareGPUCommandEncoder.d.ts.map +1 -1
  34. package/src/shade/device/mock/SoftwareGPUCommandEncoder.js +46 -0
  35. package/src/shade/playground/tonemap_sdr/README.md +11 -8
  36. package/src/shade/playground/tonemap_sdr/ToneMapCompare.js +2 -2
  37. package/src/shade/renderer/Renderer.d.ts +5 -6
  38. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  39. package/src/shade/renderer/Renderer.js +15 -88
  40. package/src/shade/renderer/animation/chunk_animation_curve_evaluate_keys.d.ts +14 -0
  41. package/src/shade/renderer/animation/chunk_animation_curve_evaluate_keys.d.ts.map +1 -0
  42. package/src/shade/renderer/animation/chunk_animation_curve_evaluate_keys.js +62 -0
  43. package/src/shade/renderer/buffer/table/GPUDatabase.d.ts +12 -0
  44. package/src/shade/renderer/buffer/table/GPUDatabase.d.ts.map +1 -1
  45. package/src/shade/renderer/buffer/table/GPUDatabase.js +85 -0
  46. package/src/shade/renderer/buffer/table/GPUDatabaseDefinition.d.ts +2 -1
  47. package/src/shade/renderer/buffer/table/GPUDatabaseDefinition.d.ts.map +1 -1
  48. package/src/shade/renderer/buffer/table/GPUDatabaseDefinition.js +2 -1
  49. package/src/shade/renderer/deferred/tonemap/ColorGrade.d.ts +158 -0
  50. package/src/shade/renderer/deferred/tonemap/ColorGrade.d.ts.map +1 -0
  51. package/src/shade/renderer/deferred/tonemap/ColorGrade.js +337 -0
  52. package/src/shade/renderer/deferred/tonemap/SAMPLER_TONEMAP_LUT.d.ts +9 -0
  53. package/src/shade/renderer/deferred/tonemap/SAMPLER_TONEMAP_LUT.d.ts.map +1 -0
  54. package/src/shade/renderer/deferred/tonemap/SAMPLER_TONEMAP_LUT.js +15 -0
  55. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_ACES.d.ts +6 -0
  56. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_ACES.d.ts.map +1 -0
  57. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_ACES.js +84 -0
  58. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_GT7.d.ts +10 -0
  59. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_GT7.d.ts.map +1 -0
  60. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_GT7.js +25 -0
  61. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_NONE.d.ts +9 -0
  62. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_NONE.d.ts.map +1 -0
  63. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_NONE.js +20 -0
  64. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_PBR_NEUTRAL.d.ts +14 -0
  65. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_PBR_NEUTRAL.d.ts.map +1 -0
  66. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_PBR_NEUTRAL.js +30 -0
  67. package/src/shade/renderer/deferred/tonemap/ToneMapOperator.d.ts +54 -0
  68. package/src/shade/renderer/deferred/tonemap/ToneMapOperator.d.ts.map +1 -0
  69. package/src/shade/renderer/deferred/tonemap/ToneMapOperator.js +63 -0
  70. package/src/shade/renderer/deferred/tonemap/ToneMapper.d.ts +106 -0
  71. package/src/shade/renderer/deferred/tonemap/ToneMapper.d.ts.map +1 -0
  72. package/src/shade/renderer/deferred/tonemap/ToneMapper.js +474 -0
  73. package/src/shade/renderer/deferred/tonemap/TonemapAces2Tables.d.ts +5 -13
  74. package/src/shade/renderer/deferred/tonemap/TonemapAces2Tables.d.ts.map +1 -1
  75. package/src/shade/renderer/deferred/tonemap/TonemapAces2Tables.js +5 -44
  76. package/src/shade/renderer/deferred/tonemap/TonemapDisplaySettings.d.ts +7 -25
  77. package/src/shade/renderer/deferred/tonemap/TonemapDisplaySettings.d.ts.map +1 -1
  78. package/src/shade/renderer/deferred/tonemap/TonemapDisplaySettings.js +11 -51
  79. package/src/shade/renderer/deferred/tonemap/m3_white_balance_rec709.d.ts +20 -0
  80. package/src/shade/renderer/deferred/tonemap/m3_white_balance_rec709.d.ts.map +1 -0
  81. package/src/shade/renderer/deferred/tonemap/m3_white_balance_rec709.js +103 -0
  82. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_lut.d.ts +9 -0
  83. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_lut.d.ts.map +1 -0
  84. package/src/shade/renderer/deferred/tonemap/{shader_tonemap_HDR_none.js → shader_tonemap_HDR_lut.js} +22 -18
  85. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_lut.d.ts +9 -0
  86. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_lut.d.ts.map +1 -0
  87. package/src/shade/renderer/deferred/tonemap/{shader_tonemap_LDR_aces.js → shader_tonemap_LDR_lut.js} +24 -24
  88. package/src/shade/renderer/deferred/tonemap/shader_tonemap_lut_bake.d.ts +23 -0
  89. package/src/shade/renderer/deferred/tonemap/shader_tonemap_lut_bake.d.ts.map +1 -0
  90. package/src/shade/renderer/deferred/tonemap/shader_tonemap_lut_bake.js +92 -0
  91. package/src/shade/renderer/deferred/tonemap/shader_tonemap_lut_sdr_from_hdr.d.ts +15 -0
  92. package/src/shade/renderer/deferred/tonemap/shader_tonemap_lut_sdr_from_hdr.d.ts.map +1 -0
  93. package/src/shade/renderer/deferred/tonemap/shader_tonemap_lut_sdr_from_hdr.js +73 -0
  94. package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
  95. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
  96. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +6 -6
  97. package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
  98. package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
  99. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +1 -1
  100. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  101. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  102. package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.d.ts +22 -0
  103. package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.d.ts.map +1 -0
  104. package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.js +62 -0
  105. package/src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.d.ts +13 -0
  106. package/src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.d.ts.map +1 -0
  107. package/src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.js +140 -0
  108. package/src/shade/renderer/shader/chunk/color/oklab/chunk_oklab_compute_max_saturation.d.ts +11 -0
  109. package/src/shade/renderer/shader/chunk/color/oklab/chunk_oklab_compute_max_saturation.d.ts.map +1 -0
  110. package/src/shade/renderer/shader/chunk/color/oklab/chunk_oklab_compute_max_saturation.js +65 -0
  111. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_bt2390_eetf.d.ts +14 -0
  112. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_bt2390_eetf.d.ts.map +1 -0
  113. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_bt2390_eetf.js +38 -0
  114. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_lut.d.ts +16 -0
  115. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_lut.d.ts.map +1 -0
  116. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_lut.js +41 -0
  117. package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
  118. package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.js +8 -8
  119. package/src/shade/wgsl/emulator/WGSLLanguageCore.d.ts.map +1 -1
  120. package/src/shade/wgsl/emulator/WGSLLanguageCore.js +2 -0
  121. package/src/shade/renderer/ShadeToneMappingMode.d.ts +0 -15
  122. package/src/shade/renderer/ShadeToneMappingMode.d.ts.map +0 -1
  123. package/src/shade/renderer/ShadeToneMappingMode.js +0 -41
  124. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR.d.ts +0 -9
  125. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR.d.ts.map +0 -1
  126. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR.js +0 -79
  127. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_aces.d.ts +0 -17
  128. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_aces.d.ts.map +0 -1
  129. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_aces.js +0 -101
  130. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_none.d.ts +0 -9
  131. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_none.d.ts.map +0 -1
  132. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_pbr_neutral.d.ts +0 -10
  133. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_pbr_neutral.d.ts.map +0 -1
  134. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_pbr_neutral.js +0 -80
  135. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR.d.ts +0 -9
  136. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR.d.ts.map +0 -1
  137. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR.js +0 -80
  138. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_aces.d.ts +0 -10
  139. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_aces.d.ts.map +0 -1
  140. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_none.d.ts +0 -9
  141. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_none.d.ts.map +0 -1
  142. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_none.js +0 -71
  143. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_pbr_neutral.d.ts +0 -10
  144. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_pbr_neutral.d.ts.map +0 -1
  145. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_pbr_neutral.js +0 -76
  146. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_hdr_bt2390.d.ts +0 -3
  147. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_hdr_bt2390.d.ts.map +0 -1
  148. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_hdr_bt2390.js +0 -44
@@ -0,0 +1,25 @@
1
+ import { chunk_CRM_FROM_REC709_TO_REC2020 } from "../../shader/chunk/color/conversion/chunk_CRM_FROM_REC709_TO_REC2020.js";
2
+ import { chunk_PAPER_WHITE_NITS } from "../../shader/chunk/color/tonemap/chunk_PAPER_WHITE_NITS.js";
3
+ import { chunk_tonemap_gt7 } from "../../shader/chunk/color/tonemap/gt7/chunk_tonemap_gt7.js";
4
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
5
+ import { ToneMapOperator } from "./ToneMapOperator.js";
6
+
7
+ /**
8
+ * GT7 tone mapping (Polyphony Digital, SIGGRAPH 2025), in its own Rec.2020. An exposed 1.0 shows at the paper white
9
+ * on every display. On SDR the peak is the paper white, the curve's SDR mode, which clips there; HDR rolls off to the
10
+ * display's peak.
11
+ *
12
+ * @type {ToneMapOperator}
13
+ */
14
+ export const TONE_MAP_OPERATOR_GT7 = new ToneMapOperator("gt7", CodeChunk.from(
15
+ //language=WGSL
16
+ `
17
+ fn tone_map_operator(scene: vec3<f32>, peak_nits: f32) -> vec3<f32> {
18
+ return tonemap_gt7_rec2020(CRM_FROM_REC709_TO_REC2020 * scene, peak_nits, PAPER_WHITE_NITS);
19
+ }
20
+ `, [
21
+ chunk_tonemap_gt7,
22
+ chunk_CRM_FROM_REC709_TO_REC2020,
23
+ chunk_PAPER_WHITE_NITS,
24
+ ]
25
+ ));
@@ -0,0 +1,9 @@
1
+ /**
2
+ * No tone mapping: the exposed colour as it is, with 1.0 at the paper white. An SDR output clips everything above
3
+ * it, and an HDR output shows it as far as the display reaches.
4
+ *
5
+ * @type {ToneMapOperator}
6
+ */
7
+ export const TONE_MAP_OPERATOR_NONE: ToneMapOperator;
8
+ import { ToneMapOperator } from "./ToneMapOperator.js";
9
+ //# sourceMappingURL=TONE_MAP_OPERATOR_NONE.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TONE_MAP_OPERATOR_NONE.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_NONE.js"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,qCAFU,eAAe,CAWtB;gCAjB6B,sBAAsB"}
@@ -0,0 +1,20 @@
1
+ import { chunk_CRM_FROM_REC709_TO_REC2020 } from "../../shader/chunk/color/conversion/chunk_CRM_FROM_REC709_TO_REC2020.js";
2
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
3
+ import { ToneMapOperator } from "./ToneMapOperator.js";
4
+
5
+ /**
6
+ * No tone mapping: the exposed colour as it is, with 1.0 at the paper white. An SDR output clips everything above
7
+ * it, and an HDR output shows it as far as the display reaches.
8
+ *
9
+ * @type {ToneMapOperator}
10
+ */
11
+ export const TONE_MAP_OPERATOR_NONE = new ToneMapOperator("none", CodeChunk.from(
12
+ //language=WGSL
13
+ `
14
+ fn tone_map_operator(scene: vec3<f32>, peak_nits: f32) -> vec3<f32> {
15
+ return CRM_FROM_REC709_TO_REC2020 * scene;
16
+ }
17
+ `, [
18
+ chunk_CRM_FROM_REC709_TO_REC2020,
19
+ ]
20
+ ));
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Khronos PBR Neutral (Lalish, 2024). Base colours under 0.8 come out as they are, less a 0.04 Fresnel offset, and
3
+ * hues never shift: made for showing products. SDR is the specification, which rolls highlights off to SDR white
4
+ * and toward white. HDR puts the display's peak over the paper white in place of the specification's 1, so
5
+ * everything below the compression start looks the same on both outputs; a display under the paper white gets the
6
+ * SDR form.
7
+ *
8
+ * An exposed 0.18 shows at 0.14 of SDR white, where GT7 shows it at 0.179.
9
+ *
10
+ * @type {ToneMapOperator}
11
+ */
12
+ export const TONE_MAP_OPERATOR_PBR_NEUTRAL: ToneMapOperator;
13
+ import { ToneMapOperator } from "./ToneMapOperator.js";
14
+ //# sourceMappingURL=TONE_MAP_OPERATOR_PBR_NEUTRAL.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TONE_MAP_OPERATOR_PBR_NEUTRAL.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_PBR_NEUTRAL.js"],"names":[],"mappings":"AAMA;;;;;;;;;;GAUG;AACH,4CAFU,eAAe,CActB;gCAzB6B,sBAAsB"}
@@ -0,0 +1,30 @@
1
+ import { chunk_CRM_FROM_REC709_TO_REC2020 } from "../../shader/chunk/color/conversion/chunk_CRM_FROM_REC709_TO_REC2020.js";
2
+ import { chunk_PAPER_WHITE_NITS } from "../../shader/chunk/color/tonemap/chunk_PAPER_WHITE_NITS.js";
3
+ import { chunk_tonemap_khronos_pbr } from "../../shader/chunk/color/tonemap/chunk_tonemap_khronos_pbr.js";
4
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
5
+ import { ToneMapOperator } from "./ToneMapOperator.js";
6
+
7
+ /**
8
+ * Khronos PBR Neutral (Lalish, 2024). Base colours under 0.8 come out as they are, less a 0.04 Fresnel offset, and
9
+ * hues never shift: made for showing products. SDR is the specification, which rolls highlights off to SDR white
10
+ * and toward white. HDR puts the display's peak over the paper white in place of the specification's 1, so
11
+ * everything below the compression start looks the same on both outputs; a display under the paper white gets the
12
+ * SDR form.
13
+ *
14
+ * An exposed 0.18 shows at 0.14 of SDR white, where GT7 shows it at 0.179.
15
+ *
16
+ * @type {ToneMapOperator}
17
+ */
18
+ export const TONE_MAP_OPERATOR_PBR_NEUTRAL = new ToneMapOperator("pbr neutral", CodeChunk.from(
19
+ //language=WGSL
20
+ `
21
+ fn tone_map_operator(scene: vec3<f32>, peak_nits: f32) -> vec3<f32> {
22
+ let peak = max(peak_nits / PAPER_WHITE_NITS, 1.0);
23
+ return CRM_FROM_REC709_TO_REC2020 * tonemap_khronos_pbr(max(scene, vec3<f32>(0.0)), peak);
24
+ }
25
+ `, [
26
+ chunk_tonemap_khronos_pbr,
27
+ chunk_CRM_FROM_REC709_TO_REC2020,
28
+ chunk_PAPER_WHITE_NITS,
29
+ ]
30
+ ));
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @typedef {import("../../shader/compiler/CodeChunk.js").CodeChunk} CodeChunk
3
+ * @typedef {import("../../shader/resource/ShaderResourceGroupDescriptor.js").ShaderResourceGroupDescriptor} ShaderResourceGroupDescriptor
4
+ * @typedef {import("../../../../engine/graphics/render/frame_graph/FrameGraph.js").FrameGraph} FrameGraph
5
+ */
6
+ /**
7
+ * A tone-mapping function, in WGSL, that {@link ToneMapper} bakes into its LUTs.
8
+ *
9
+ * {@link chunk} defines
10
+ *
11
+ * fn tone_map_operator(scene: vec3<f32>, peak_nits: f32) -> vec3<f32>
12
+ *
13
+ * - `scene`: exposed linear Rec.709, 1 at the paper white. Not negative; the LUT's encoding clamps at zero.
14
+ * - `peak_nits`: the display's peak in cd/m². An SDR display is `PAPER_WHITE_NITS`.
15
+ * - returns linear Rec.2020 display light, 1 at the paper white (`PAPER_WHITE_NITS`).
16
+ *
17
+ * An operator whose chunk reads bindings of its own adds them in {@link declare} and supplies them in {@link bind}.
18
+ * The chunk is linked once into its bake shader, so its text must not change after first use.
19
+ */
20
+ export class ToneMapOperator {
21
+ /**
22
+ * @param {string} label
23
+ * @param {CodeChunk} chunk defines `tone_map_operator`, see the class
24
+ */
25
+ constructor(label: string, chunk: CodeChunk);
26
+ /**
27
+ * @readonly
28
+ * @type {string}
29
+ */
30
+ readonly label: string;
31
+ /**
32
+ * @readonly
33
+ * @type {CodeChunk}
34
+ */
35
+ readonly chunk: CodeChunk;
36
+ /**
37
+ * Add the bindings {@link chunk} reads to the bake shader's group. None by default.
38
+ *
39
+ * @param {ShaderResourceGroupDescriptor} group
40
+ */
41
+ declare(group: ShaderResourceGroupDescriptor): void;
42
+ /**
43
+ * Supply the bindings {@link declare} added, for a bake at `peak_nits`. None by default.
44
+ *
45
+ * @param {FrameGraph} graph the frame the bake is recorded into
46
+ * @param {number} peak_nits
47
+ * @param {Object} bindings the bake pass's bindings, to add to by name
48
+ */
49
+ bind(graph: FrameGraph, peak_nits: number, bindings: any): void;
50
+ }
51
+ export type CodeChunk = import("../../shader/compiler/CodeChunk.js").CodeChunk;
52
+ export type ShaderResourceGroupDescriptor = import("../../shader/resource/ShaderResourceGroupDescriptor.js").ShaderResourceGroupDescriptor;
53
+ export type FrameGraph = import("../../../../engine/graphics/render/frame_graph/FrameGraph.js").FrameGraph;
54
+ //# sourceMappingURL=ToneMapOperator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToneMapOperator.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/deferred/tonemap/ToneMapOperator.js"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH;;;;;;;;;;;;;GAaG;AACH;IACI;;;OAGG;IACH,mBAHW,MAAM,SACN,SAAS,EAkBnB;IAXG;;;OAGG;IACH,gBAFU,MAAM,CAEE;IAElB;;;OAGG;IACH,gBAFU,SAAS,CAED;IAGtB;;;;OAIG;IACH,eAFW,6BAA6B,QAGvC;IAED;;;;;;OAMG;IACH,YAJW,UAAU,aACV,MAAM,uBAIhB;CACJ;wBA3DY,OAAO,oCAAoC,EAAE,SAAS;4CACtD,OAAO,wDAAwD,EAAE,6BAA6B;yBAC9F,OAAO,8DAA8D,EAAE,UAAU"}
@@ -0,0 +1,63 @@
1
+ import { assert } from "../../../../core/assert.js";
2
+
3
+ /**
4
+ * @typedef {import("../../shader/compiler/CodeChunk.js").CodeChunk} CodeChunk
5
+ * @typedef {import("../../shader/resource/ShaderResourceGroupDescriptor.js").ShaderResourceGroupDescriptor} ShaderResourceGroupDescriptor
6
+ * @typedef {import("../../../../engine/graphics/render/frame_graph/FrameGraph.js").FrameGraph} FrameGraph
7
+ */
8
+
9
+ /**
10
+ * A tone-mapping function, in WGSL, that {@link ToneMapper} bakes into its LUTs.
11
+ *
12
+ * {@link chunk} defines
13
+ *
14
+ * fn tone_map_operator(scene: vec3<f32>, peak_nits: f32) -> vec3<f32>
15
+ *
16
+ * - `scene`: exposed linear Rec.709, 1 at the paper white. Not negative; the LUT's encoding clamps at zero.
17
+ * - `peak_nits`: the display's peak in cd/m². An SDR display is `PAPER_WHITE_NITS`.
18
+ * - returns linear Rec.2020 display light, 1 at the paper white (`PAPER_WHITE_NITS`).
19
+ *
20
+ * An operator whose chunk reads bindings of its own adds them in {@link declare} and supplies them in {@link bind}.
21
+ * The chunk is linked once into its bake shader, so its text must not change after first use.
22
+ */
23
+ export class ToneMapOperator {
24
+ /**
25
+ * @param {string} label
26
+ * @param {CodeChunk} chunk defines `tone_map_operator`, see the class
27
+ */
28
+ constructor(label, chunk) {
29
+ assert.isString(label, 'label');
30
+ assert.defined(chunk, 'chunk');
31
+ assert.equal(chunk.isCodeChunk, true, 'chunk.isCodeChunk !== true');
32
+
33
+ /**
34
+ * @readonly
35
+ * @type {string}
36
+ */
37
+ this.label = label;
38
+
39
+ /**
40
+ * @readonly
41
+ * @type {CodeChunk}
42
+ */
43
+ this.chunk = chunk;
44
+ }
45
+
46
+ /**
47
+ * Add the bindings {@link chunk} reads to the bake shader's group. None by default.
48
+ *
49
+ * @param {ShaderResourceGroupDescriptor} group
50
+ */
51
+ declare(group) {
52
+ }
53
+
54
+ /**
55
+ * Supply the bindings {@link declare} added, for a bake at `peak_nits`. None by default.
56
+ *
57
+ * @param {FrameGraph} graph the frame the bake is recorded into
58
+ * @param {number} peak_nits
59
+ * @param {Object} bindings the bake pass's bindings, to add to by name
60
+ */
61
+ bind(graph, peak_nits, bindings) {
62
+ }
63
+ }
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Turns the exposed scene colour into the canvas's colour, through a 3D LUT for each output.
3
+ *
4
+ * Each LUT maps exposed scene-linear Rec.709 to linear Rec.2020 display light, both as PQ (ST 2084) signals with 1 at
5
+ * the paper white, `PAPER_WHITE_NITS`; see `chunk_tonemap_lut`. Texel i of a LUT of N³ holds the scene signal
6
+ * i / (N - 1) along each axis, red fastest. Scene colour past 10000 cd/m², 49.3 × the paper white, reads the last
7
+ * texel. The apply passes take the LUT's output to the canvas's primaries and transfer curve.
8
+ *
9
+ * A LUT comes from {@link grade} and {@link operator}, baked at {@link lut_resolution} and baked again when any of them
10
+ * changes or, for the HDR LUT, when the display's peak does; or from the user, by {@link set_lut_sdr} and
11
+ * {@link set_lut_hdr}, which takes the place of the bake for that output until cleared. A user's LUT is not graded.
12
+ */
13
+ export class ToneMapper {
14
+ /**
15
+ * @param {GPUDevice} device
16
+ */
17
+ constructor(device: GPUDevice);
18
+ /**
19
+ * The tone-mapping function the LUTs are baked from. Unreal's default look unless set. Read every frame.
20
+ * @type {ToneMapOperator}
21
+ */
22
+ operator: ToneMapOperator;
23
+ /**
24
+ * Texels along each edge of a baked LUT. At least 2, and at most the device's `maxTextureDimension3D`. Read every
25
+ * frame.
26
+ * @type {number}
27
+ */
28
+ lut_resolution: number;
29
+ /**
30
+ * The colour grade ahead of {@link operator}, neutral unless changed. Read every frame; a change bakes again.
31
+ * @readonly
32
+ * @type {ColorGrade}
33
+ */
34
+ readonly grade: ColorGrade;
35
+ /**
36
+ * The canvas's primaries and the display's peak, which the Renderer writes.
37
+ * @readonly
38
+ * @type {TonemapDisplaySettings}
39
+ */
40
+ readonly display: TonemapDisplaySettings;
41
+ /**
42
+ * Supply the SDR LUT, in place of the one baked from {@link operator}.
43
+ *
44
+ * @param {number} resolution texels along each edge
45
+ * @param {Float32Array} data resolution³ RGB triples, red fastest, as the class describes
46
+ */
47
+ set_lut_sdr(resolution: number, data: Float32Array): void;
48
+ /**
49
+ * Supply the HDR LUT, in place of the one baked from {@link operator}. It shows as graded: a display under
50
+ * `peak_nits` clips what it cannot reach.
51
+ *
52
+ * @param {number} resolution texels along each edge
53
+ * @param {Float32Array} data resolution³ RGB triples, red fastest, as the class describes
54
+ * @param {number} peak_nits the peak the LUT was graded for, cd/m²
55
+ */
56
+ set_lut_hdr(resolution: number, data: Float32Array, peak_nits: number): void;
57
+ /**
58
+ * Go back to the SDR LUT baked from {@link operator}.
59
+ */
60
+ clear_lut_sdr(): void;
61
+ /**
62
+ * Go back to the HDR LUT baked from {@link operator}.
63
+ */
64
+ clear_lut_hdr(): void;
65
+ /**
66
+ * Make the SDR LUT from the HDR LUT supplied by {@link set_lut_hdr}, at its resolution: each texel through the
67
+ * BT.2390 EETF from the HDR LUT's graded peak down to the paper white, which keeps the hue and never passes SDR
68
+ * white. Built on the GPU in the next {@link render}, from the HDR LUT as it is then. Stays until
69
+ * {@link set_lut_sdr} or {@link clear_lut_sdr}.
70
+ */
71
+ build_lut_sdr_from_hdr(): void;
72
+ /**
73
+ * Offer the pipelines the next frame on this output needs.
74
+ *
75
+ * @param {PipelineEnquiry} enquiry
76
+ * @param {boolean} hdr
77
+ * @param {GPUTextureFormat} format the canvas's
78
+ */
79
+ enquire_pipelines(enquiry: PipelineEnquiry, hdr: boolean, format: GPUTextureFormat): void;
80
+ /**
81
+ * Record the tone mapping of a frame: any LUT work it needs first, then the pass writing `target`.
82
+ *
83
+ * @param {Object} options
84
+ * @param {FrameGraph} options.graph
85
+ * @param {number} options.input_color the scene colour, linear Rec.709
86
+ * @param {number} options.exposure the exposure multiplier, a uniform
87
+ * @param {boolean} options.hdr whether the output is HDR
88
+ * @param {number} options.target the texture to write
89
+ * @returns {number} `target`, written
90
+ */
91
+ render({ graph, input_color, exposure, hdr, target }: {
92
+ graph: FrameGraph;
93
+ input_color: number;
94
+ exposure: number;
95
+ hdr: boolean;
96
+ target: number;
97
+ }): number;
98
+ destroy(): void;
99
+ #private;
100
+ }
101
+ export type ToneMapOperator = import("./ToneMapOperator.js").ToneMapOperator;
102
+ export type PipelineEnquiry = import("../../../device/pipeline/PipelineEnquiry.js").PipelineEnquiry;
103
+ export type FrameGraph = import("../../../../engine/graphics/render/frame_graph/FrameGraph.js").FrameGraph;
104
+ import { ColorGrade } from "./ColorGrade.js";
105
+ import { TonemapDisplaySettings } from "./TonemapDisplaySettings.js";
106
+ //# sourceMappingURL=ToneMapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToneMapper.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/deferred/tonemap/ToneMapper.js"],"names":[],"mappings":"AA6FA;;;;;;;;;;;GAWG;AACH;IAmEI;;OAEG;IACH,+BAMC;IA3ED;;;OAGG;IACH,UAFU,eAAe,CAES;IAElC;;;;OAIG;IACH,gBAFU,MAAM,CAEI;IAEpB;;;;OAIG;IACH,gBAFU,UAAU,CAEK;IAEzB;;;;OAIG;IACH,kBAFU,sBAAsB,CAEO;IAoDvC;;;;;OAKG;IACH,wBAHW,MAAM,QACN,YAAY,QAKtB;IAED;;;;;;;OAOG;IACH,wBAJW,MAAM,QACN,YAAY,aACZ,MAAM,QAQhB;IAED;;OAEG;IACH,sBAIC;IAED;;OAEG;IACH,sBAGC;IAED;;;;;OAKG;IACH,+BASC;IAED;;;;;;OAMG;IACH,2BAJW,eAAe,OACf,OAAO,kCAMjB;IAED;;;;;;;;;;OAUG;IACH;QAP+B,KAAK,EAAzB,UAAU;QACM,WAAW,EAA3B,MAAM;QACU,QAAQ,EAAxB,MAAM;QACW,GAAG,EAApB,OAAO;QACS,MAAM,EAAtB,MAAM;QACJ,MAAM,CAyElB;IAED,gBAGC;;CAkIJ;8BAzcY,OAAO,sBAAsB,EAAE,eAAe;8BAC9C,OAAO,6CAA6C,EAAE,eAAe;yBACrE,OAAO,8DAA8D,EAAE,UAAU;2BAXxC,iBAAiB;uCAMhC,6BAA6B"}