@woosh/meep-engine 3.63.3 → 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 (139) 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/playground/tonemap_sdr/README.md +11 -8
  33. package/src/shade/playground/tonemap_sdr/ToneMapCompare.js +2 -2
  34. package/src/shade/renderer/Renderer.d.ts +5 -6
  35. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  36. package/src/shade/renderer/Renderer.js +15 -88
  37. package/src/shade/renderer/animation/chunk_animation_curve_evaluate_keys.d.ts +14 -0
  38. package/src/shade/renderer/animation/chunk_animation_curve_evaluate_keys.d.ts.map +1 -0
  39. package/src/shade/renderer/animation/chunk_animation_curve_evaluate_keys.js +62 -0
  40. package/src/shade/renderer/deferred/tonemap/ColorGrade.d.ts +158 -0
  41. package/src/shade/renderer/deferred/tonemap/ColorGrade.d.ts.map +1 -0
  42. package/src/shade/renderer/deferred/tonemap/ColorGrade.js +337 -0
  43. package/src/shade/renderer/deferred/tonemap/SAMPLER_TONEMAP_LUT.d.ts +9 -0
  44. package/src/shade/renderer/deferred/tonemap/SAMPLER_TONEMAP_LUT.d.ts.map +1 -0
  45. package/src/shade/renderer/deferred/tonemap/SAMPLER_TONEMAP_LUT.js +15 -0
  46. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_ACES.d.ts +6 -0
  47. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_ACES.d.ts.map +1 -0
  48. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_ACES.js +84 -0
  49. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_GT7.d.ts +10 -0
  50. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_GT7.d.ts.map +1 -0
  51. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_GT7.js +25 -0
  52. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_NONE.d.ts +9 -0
  53. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_NONE.d.ts.map +1 -0
  54. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_NONE.js +20 -0
  55. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_PBR_NEUTRAL.d.ts +14 -0
  56. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_PBR_NEUTRAL.d.ts.map +1 -0
  57. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_PBR_NEUTRAL.js +30 -0
  58. package/src/shade/renderer/deferred/tonemap/ToneMapOperator.d.ts +54 -0
  59. package/src/shade/renderer/deferred/tonemap/ToneMapOperator.d.ts.map +1 -0
  60. package/src/shade/renderer/deferred/tonemap/ToneMapOperator.js +63 -0
  61. package/src/shade/renderer/deferred/tonemap/ToneMapper.d.ts +106 -0
  62. package/src/shade/renderer/deferred/tonemap/ToneMapper.d.ts.map +1 -0
  63. package/src/shade/renderer/deferred/tonemap/ToneMapper.js +474 -0
  64. package/src/shade/renderer/deferred/tonemap/TonemapAces2Tables.d.ts +5 -13
  65. package/src/shade/renderer/deferred/tonemap/TonemapAces2Tables.d.ts.map +1 -1
  66. package/src/shade/renderer/deferred/tonemap/TonemapAces2Tables.js +5 -44
  67. package/src/shade/renderer/deferred/tonemap/TonemapDisplaySettings.d.ts +7 -25
  68. package/src/shade/renderer/deferred/tonemap/TonemapDisplaySettings.d.ts.map +1 -1
  69. package/src/shade/renderer/deferred/tonemap/TonemapDisplaySettings.js +11 -51
  70. package/src/shade/renderer/deferred/tonemap/m3_white_balance_rec709.d.ts +20 -0
  71. package/src/shade/renderer/deferred/tonemap/m3_white_balance_rec709.d.ts.map +1 -0
  72. package/src/shade/renderer/deferred/tonemap/m3_white_balance_rec709.js +103 -0
  73. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_lut.d.ts +9 -0
  74. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_lut.d.ts.map +1 -0
  75. package/src/shade/renderer/deferred/tonemap/{shader_tonemap_HDR_none.js → shader_tonemap_HDR_lut.js} +22 -18
  76. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_lut.d.ts +9 -0
  77. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_lut.d.ts.map +1 -0
  78. package/src/shade/renderer/deferred/tonemap/{shader_tonemap_LDR_aces.js → shader_tonemap_LDR_lut.js} +24 -24
  79. package/src/shade/renderer/deferred/tonemap/shader_tonemap_lut_bake.d.ts +23 -0
  80. package/src/shade/renderer/deferred/tonemap/shader_tonemap_lut_bake.d.ts.map +1 -0
  81. package/src/shade/renderer/deferred/tonemap/shader_tonemap_lut_bake.js +92 -0
  82. package/src/shade/renderer/deferred/tonemap/shader_tonemap_lut_sdr_from_hdr.d.ts +15 -0
  83. package/src/shade/renderer/deferred/tonemap/shader_tonemap_lut_sdr_from_hdr.d.ts.map +1 -0
  84. package/src/shade/renderer/deferred/tonemap/shader_tonemap_lut_sdr_from_hdr.js +73 -0
  85. package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
  86. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
  87. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +6 -6
  88. package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
  89. package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
  90. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +1 -1
  91. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  92. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  93. package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.d.ts +22 -0
  94. package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.d.ts.map +1 -0
  95. package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.js +62 -0
  96. package/src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.d.ts +13 -0
  97. package/src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.d.ts.map +1 -0
  98. package/src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.js +140 -0
  99. package/src/shade/renderer/shader/chunk/color/oklab/chunk_oklab_compute_max_saturation.d.ts +11 -0
  100. package/src/shade/renderer/shader/chunk/color/oklab/chunk_oklab_compute_max_saturation.d.ts.map +1 -0
  101. package/src/shade/renderer/shader/chunk/color/oklab/chunk_oklab_compute_max_saturation.js +65 -0
  102. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_bt2390_eetf.d.ts +14 -0
  103. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_bt2390_eetf.d.ts.map +1 -0
  104. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_bt2390_eetf.js +38 -0
  105. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_lut.d.ts +16 -0
  106. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_lut.d.ts.map +1 -0
  107. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_lut.js +41 -0
  108. package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
  109. package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.js +8 -8
  110. package/src/shade/wgsl/emulator/WGSLLanguageCore.d.ts.map +1 -1
  111. package/src/shade/wgsl/emulator/WGSLLanguageCore.js +2 -0
  112. package/src/shade/renderer/ShadeToneMappingMode.d.ts +0 -15
  113. package/src/shade/renderer/ShadeToneMappingMode.d.ts.map +0 -1
  114. package/src/shade/renderer/ShadeToneMappingMode.js +0 -41
  115. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR.d.ts +0 -9
  116. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR.d.ts.map +0 -1
  117. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR.js +0 -79
  118. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_aces.d.ts +0 -17
  119. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_aces.d.ts.map +0 -1
  120. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_aces.js +0 -101
  121. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_none.d.ts +0 -9
  122. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_none.d.ts.map +0 -1
  123. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_pbr_neutral.d.ts +0 -10
  124. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_pbr_neutral.d.ts.map +0 -1
  125. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_pbr_neutral.js +0 -80
  126. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR.d.ts +0 -9
  127. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR.d.ts.map +0 -1
  128. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR.js +0 -80
  129. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_aces.d.ts +0 -10
  130. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_aces.d.ts.map +0 -1
  131. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_none.d.ts +0 -9
  132. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_none.d.ts.map +0 -1
  133. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_none.js +0 -71
  134. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_pbr_neutral.d.ts +0 -10
  135. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_pbr_neutral.d.ts.map +0 -1
  136. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_pbr_neutral.js +0 -76
  137. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_hdr_bt2390.d.ts +0 -3
  138. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_hdr_bt2390.d.ts.map +0 -1
  139. package/src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_hdr_bt2390.js +0 -44
@@ -0,0 +1,38 @@
1
+ import { CodeChunk } from "../../../compiler/CodeChunk.js";
2
+
3
+ /**
4
+ * The EETF of ITU-R BT.2390 (§5.4.1): maps a PQ signal mastered for a display reaching `source_peak` onto one
5
+ * reaching `target_peak`, all three PQ signals, with black at zero on both.
6
+ *
7
+ * The signal is first normalised to the source's range. Up to the knee, KS = 1.5 × maxLum − 0.5, it passes
8
+ * through; past it, a Hermite spline carries it to maxLum, the target's peak in the same normalisation, which the
9
+ * source's peak reaches with zero slope. The spline meets the identity at the knee with slope 1. A signal past
10
+ * `source_peak` is held at it. A target at or above the source passes every signal through.
11
+ *
12
+ * @type {CodeChunk}
13
+ */
14
+ export const chunk_bt2390_eetf = CodeChunk.from(
15
+ //language=WGSL
16
+ `
17
+ fn bt2390_eetf(signal: f32, source_peak: f32, target_peak: f32) -> f32 {
18
+ let e1 = clamp(signal / source_peak, 0.0, 1.0);
19
+
20
+ let max_lum = target_peak / source_peak;
21
+ let ks = 1.5 * max_lum - 0.5;
22
+
23
+ if (e1 < ks || ks >= 1.0) {
24
+ return e1 * source_peak;
25
+ }
26
+
27
+ let t = (e1 - ks) / (1.0 - ks);
28
+ let t2 = t * t;
29
+ let t3 = t2 * t;
30
+
31
+ let e2 = (2.0 * t3 - 3.0 * t2 + 1.0) * ks
32
+ + (t3 - 2.0 * t2 + t) * (1.0 - ks)
33
+ + (-2.0 * t3 + 3.0 * t2) * max_lum;
34
+
35
+ return e2 * source_peak;
36
+ }
37
+ `
38
+ );
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The encoding of a tone-mapping LUT, on both of its sides.
3
+ *
4
+ * - `tonemap_lut_pq_encode`: linear light with 1 at the paper white to its ST 2084 (PQ) signal, per channel. A
5
+ * negative component reads as zero. 10000 cd/m², 49.3 × the paper white, encodes to 1.
6
+ * - `tonemap_lut_pq_decode`: the inverse, clamping the signal to [0, 1].
7
+ * - `tonemap_lut_coordinate`: where a LUT of `resolution`³ texels holds exposed scene colour `scene`, as a texture
8
+ * coordinate. Texel i holds the signal i / (resolution - 1); a colour past 10000 cd/m² lands on the last texel.
9
+ *
10
+ * A LUT maps the PQ signal of exposed scene-linear Rec.709 to the PQ signal of linear Rec.2020 display light.
11
+ *
12
+ * @type {CodeChunk}
13
+ */
14
+ export const chunk_tonemap_lut: CodeChunk;
15
+ import { CodeChunk } from "../../../compiler/CodeChunk.js";
16
+ //# sourceMappingURL=chunk_tonemap_lut.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_tonemap_lut.d.ts","sourceRoot":"","sources":["../../../../../../../../src/shade/renderer/shader/chunk/color/tonemap/chunk_tonemap_lut.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;GAYG;AACH,gCAFU,SAAS,CAwBjB;0BAxCwB,gCAAgC"}
@@ -0,0 +1,41 @@
1
+ import { CodeChunk } from "../../../compiler/CodeChunk.js";
2
+ import { chunk_eotfSt2084 } from "../iCtCp/chunk_eotf_st2084.js";
3
+ import { chunk_inverseEotfSt2084 } from "../iCtCp/chunk_inverse_eotf_st2084.js";
4
+ import { chunk_PAPER_WHITE_NITS } from "./chunk_PAPER_WHITE_NITS.js";
5
+
6
+ /**
7
+ * The encoding of a tone-mapping LUT, on both of its sides.
8
+ *
9
+ * - `tonemap_lut_pq_encode`: linear light with 1 at the paper white to its ST 2084 (PQ) signal, per channel. A
10
+ * negative component reads as zero. 10000 cd/m², 49.3 × the paper white, encodes to 1.
11
+ * - `tonemap_lut_pq_decode`: the inverse, clamping the signal to [0, 1].
12
+ * - `tonemap_lut_coordinate`: where a LUT of `resolution`³ texels holds exposed scene colour `scene`, as a texture
13
+ * coordinate. Texel i holds the signal i / (resolution - 1); a colour past 10000 cd/m² lands on the last texel.
14
+ *
15
+ * A LUT maps the PQ signal of exposed scene-linear Rec.709 to the PQ signal of linear Rec.2020 display light.
16
+ *
17
+ * @type {CodeChunk}
18
+ */
19
+ export const chunk_tonemap_lut = CodeChunk.from(
20
+ //language=WGSL
21
+ `
22
+ fn tonemap_lut_pq_encode(v: vec3<f32>) -> vec3<f32> {
23
+ // the ST 2084 chunks count in units of 100 cd/m²
24
+ let n = max(v, vec3<f32>(0.0)) * (PAPER_WHITE_NITS / 100.0);
25
+ return vec3<f32>(inverseEotfSt2084(n.x), inverseEotfSt2084(n.y), inverseEotfSt2084(n.z));
26
+ }
27
+
28
+ fn tonemap_lut_pq_decode(e: vec3<f32>) -> vec3<f32> {
29
+ return vec3<f32>(eotfSt2084(e.x), eotfSt2084(e.y), eotfSt2084(e.z)) * (100.0 / PAPER_WHITE_NITS);
30
+ }
31
+
32
+ fn tonemap_lut_coordinate(scene: vec3<f32>, resolution: f32) -> vec3<f32> {
33
+ let e = min(tonemap_lut_pq_encode(scene), vec3<f32>(1.0));
34
+ return e * ((resolution - 1.0) / resolution) + 0.5 / resolution;
35
+ }
36
+ `, [
37
+ chunk_eotfSt2084,
38
+ chunk_inverseEotfSt2084,
39
+ chunk_PAPER_WHITE_NITS,
40
+ ]
41
+ );
@@ -24,7 +24,7 @@ export class GPUWaterQueries {
24
24
  * @param {PipelineEnquiry} enquiry
25
25
  */
26
26
  static enquirePipelines(enquiry: PipelineEnquiry): void;
27
- static "__#282@#execute"(pass: any, resources: any, context: any): void;
27
+ static "__#285@#execute"(pass: any, resources: any, context: any): void;
28
28
  /**
29
29
  * @param {object} options
30
30
  * @param {GPUDevice} options.device
@@ -3141,7 +3141,7 @@ const INTEGER_TYPED_BUILTIN = new Set(['abs', 'firstLeadingBit', 'firstTrailingB
3141
3141
  */
3142
3142
  const ELEMENT_WISE_BUILTIN = new Set([
3143
3143
  'abs', 'sign', 'floor', 'ceil', 'round', 'trunc', 'fract', 'sqrt', 'inverseSqrt',
3144
- 'exp', 'exp2', 'log', 'log2', 'sin', 'cos', 'tan', 'asin', 'acos', 'atan',
3144
+ 'exp', 'exp2', 'log', 'log2', 'sin', 'cos', 'tan', 'asin', 'acos', 'atan', 'degrees', 'radians',
3145
3145
  'pow', 'atan2', 'min', 'max', 'step', 'clamp', 'saturate', 'mix', 'smoothstep',
3146
3146
  'normalize', 'reflect', 'fma', 'quantizeToF16',
3147
3147
  'subgroupBroadcastFirst', 'subgroupAdd', 'subgroupMul', 'subgroupMin', 'subgroupMax',
@@ -3232,13 +3232,13 @@ function inferBuiltinReturnType(name, args) {
3232
3232
  // Both gathers return the four texels of a 2x2 footprint. Saying so here matters more than
3233
3233
  // for most builtins: the shadow chunks immediately swizzle the result (`samples.wzxy`), and
3234
3234
  // an unknown type degrades swizzle codegen downstream.
3235
- if (name === 'textureGather') {
3236
- const first = args[0] !== undefined ? args[0].type : null;
3237
- const texture = first !== null && first.kind === 'texture' ? first : (args[1] !== undefined ? args[1].type : null);
3238
- const scalar = texture !== null && texture.kind === 'texture' ? texture.scalar : 'f32';
3239
- return { kind: 'vec', size: 4, scalar: scalar === 'u32' || /uint$/.test(scalar) ? 'u32'
3240
- : scalar === 'i32' || /sint$/.test(scalar) ? 'i32' : 'f32' };
3241
- }
3235
+ if (name === 'textureGather') {
3236
+ const first = args[0] !== undefined ? args[0].type : null;
3237
+ const texture = first !== null && first.kind === 'texture' ? first : (args[1] !== undefined ? args[1].type : null);
3238
+ const scalar = texture !== null && texture.kind === 'texture' ? texture.scalar : 'f32';
3239
+ return { kind: 'vec', size: 4, scalar: scalar === 'u32' || /uint$/.test(scalar) ? 'u32'
3240
+ : scalar === 'i32' || /sint$/.test(scalar) ? 'i32' : 'f32' };
3241
+ }
3242
3242
  if (name === 'textureGatherCompare') {
3243
3243
  return { kind: 'vec', size: 4, scalar: 'f32' };
3244
3244
  }
@@ -1 +1 @@
1
- {"version":3,"file":"WGSLLanguageCore.d.ts","sourceRoot":"","sources":["../../../../../src/shade/wgsl/emulator/WGSLLanguageCore.js"],"names":[],"mappings":";IAk6DA;;;;;;;;;;;;;OAaG;IACH,+DAyFC"}
1
+ {"version":3,"file":"WGSLLanguageCore.d.ts","sourceRoot":"","sources":["../../../../../src/shade/wgsl/emulator/WGSLLanguageCore.js"],"names":[],"mappings":";IAo6DA;;;;;;;;;;;;;OAaG;IACH,+DAyFC"}
@@ -883,6 +883,8 @@ export const WGSLLanguageCore = {
883
883
  asin: (a) => unop(a, Math.asin),
884
884
  acos: (a) => unop(a, Math.acos),
885
885
  atan: (a) => unop(a, Math.atan),
886
+ degrees: (a) => unop(a, x => x * (180 / Math.PI)),
887
+ radians: (a) => unop(a, x => x * (Math.PI / 180)),
886
888
 
887
889
  pow: (a, b) => binop(a, b, Math.pow),
888
890
  atan2: (a, b) => binop(a, b, Math.atan2),
@@ -1,15 +0,0 @@
1
- /**
2
- * How the exposed scene colour becomes display colour.
3
- *
4
- * One choice for every display. The same mode runs on an SDR and an HDR output, so a scene looks the same on both up
5
- * to the SDR display's limits. That is the reason Polyphony give for GT7's operator, and Epic's for how Unreal 5.8
6
- * takes its Filmic picture to HDR, and there is no per-output setting on purpose.
7
- */
8
- export type ShadeToneMappingMode = number;
9
- export namespace ShadeToneMappingMode {
10
- let GT7: number;
11
- let NONE: number;
12
- let PBR_NEUTRAL: number;
13
- let ACES: number;
14
- }
15
- //# sourceMappingURL=ShadeToneMappingMode.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ShadeToneMappingMode.d.ts","sourceRoot":"","sources":["../../../../src/shade/renderer/ShadeToneMappingMode.js"],"names":[],"mappings":";;;;;;;mCAOU,MAAM"}
@@ -1,41 +0,0 @@
1
- /**
2
- * How the exposed scene colour becomes display colour.
3
- *
4
- * One choice for every display. The same mode runs on an SDR and an HDR output, so a scene looks the same on both up
5
- * to the SDR display's limits. That is the reason Polyphony give for GT7's operator, and Epic's for how Unreal 5.8
6
- * takes its Filmic picture to HDR, and there is no per-output setting on purpose.
7
- *
8
- * @enum {number}
9
- */
10
- export const ShadeToneMappingMode = {
11
- /**
12
- * GT7 tone mapping (Polyphony Digital, SIGGRAPH 2025). An exposed 1.0 shows at the paper white on both outputs.
13
- * SDR clips at that paper white, the curve's SDR mode, and HDR rolls off to the display's peak.
14
- */
15
- GT7: 0,
16
- /**
17
- * No tone mapping: the exposed colour as it is, with 1.0 at SDR white. An SDR output clips everything above 1.0,
18
- * and an HDR output shows it as far as the display reaches.
19
- */
20
- NONE: 1,
21
- /**
22
- * Khronos PBR Neutral (Lalish, 2024). Base colours under 0.8 come out as they are, less a 0.04 Fresnel offset, and
23
- * hues never shift: made for showing products. SDR is the specification, which rolls highlights off to SDR white
24
- * and toward white. HDR puts the display's peak in place of the specification's 1, so everything below the
25
- * compression start looks the same on both outputs, and a highlight rolls off to the display's peak instead.
26
- *
27
- * An exposed 0.18 shows at 0.14 of SDR white, where {@link GT7} shows it at 0.179.
28
- */
29
- PBR_NEUTRAL: 2,
30
- /**
31
- * Unreal Engine's default look, the default here too. SDR is UE's "Filmic" tone mapper at its default settings,
32
- * the ACES-derived curve every Unreal title ships with unless it chose otherwise. HDR is what Unreal 5.8 does with
33
- * the same method: the SDR picture, taken back to the scene through the inverse ACES 2.0 output transform for an
34
- * SDR display, and rendered again with the ACES 2.0 output transform for the display's headroom.
35
- *
36
- * An exposed 0.18 shows at 0.18 of SDR white, as with {@link GT7}, with a mid-tone contrast of 1.36 against GT7's
37
- * 1.05. On HDR the picture expands into the headroom and mid-grey rises with it, by ACES 2.0's design: 0.26 of SDR
38
- * white at a 1000 cd/m² display.
39
- */
40
- ACES: 3,
41
- };
@@ -1,9 +0,0 @@
1
- /**
2
- * The HDR output with {@link ShadeToneMappingMode.GT7}: GT7 at the display's peak, with the same paper white as
3
- * {@link shader_tonemap_LDR}, written in the canvas's primaries, extended, where 1.0 is SDR white.
4
- *
5
- * @type {ImageShader}
6
- */
7
- export const shader_tonemap_HDR: ImageShader;
8
- import { ImageShader } from "../../shader/ImageShader.js";
9
- //# sourceMappingURL=shader_tonemap_HDR.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shader_tonemap_HDR.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/deferred/tonemap/shader_tonemap_HDR.js"],"names":[],"mappings":"AA4DA;;;;;GAKG;AACH,iCAFU,WAAW,CAclB;4BAvEyB,6BAA6B"}
@@ -1,79 +0,0 @@
1
- import { F32_CONTAINER_STRUCT } from "../../shader/type/F32_CONTAINER_STRUCT.js";
2
- import { TONEMAP_SETTINGS_REC2020_PEAK } from "./TonemapDisplaySettings.js";
3
- import { chunk_CRM_FROM_REC709_TO_REC2020 } from "../../shader/chunk/color/conversion/chunk_CRM_FROM_REC709_TO_REC2020.js";
4
- import { chunk_sRGBTransferOETF } from "../../shader/chunk/color/sRGB/chunk_sRGBTransferOETF.js";
5
- import { chunk_PAPER_WHITE_NITS } from "../../shader/chunk/color/tonemap/chunk_PAPER_WHITE_NITS.js";
6
- import { chunk_tonemap_gt7 } from "../../shader/chunk/color/tonemap/gt7/chunk_tonemap_gt7.js";
7
- import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
8
- import { ImageShader } from "../../shader/ImageShader.js";
9
- import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
10
- import { ShaderDescriptor } from "../../shader/ShaderDescriptor.js";
11
-
12
- const resources = new ShaderResourceSetDescriptor();
13
-
14
- // per-pass, four bytes, read-only: immediate data rather than a uniform buffer. exposure stays
15
- // bound - it is computed on the GPU, so there is no CPU value to write.
16
- resources.setImmediate("settings", TONEMAP_SETTINGS_REC2020_PEAK);
17
- resources.createGroup()
18
- .addTexture("input_color", "float")
19
- .addUniform("exposure", F32_CONTAINER_STRUCT)
20
-
21
- const body = CodeChunk.from(
22
- //language=WGSL
23
- `
24
- @fragment
25
- fn main(
26
- @builtin(position) coord : vec4<f32>,
27
- ) -> @location(0) vec4<f32> {
28
-
29
- // scene color in linear Rec. 709
30
- var color = textureLoad(input_color, vec2i(coord.xy), 0).rgb;
31
-
32
- // Apply exposure
33
- color *= exposure.value;
34
-
35
- // Finally tonemap, in the operator's own Rec.2020
36
- let color_2020 = tonemap_gt7_rec2020(CRM_FROM_REC709_TO_REC2020 * color, settings.peak_nits, PAPER_WHITE_NITS);
37
-
38
- // NOTE: no dithering, colorspace is wide
39
-
40
- // into the primaries the canvas reports it was configured with (Renderer#configure_context): Display P3, or
41
- // sRGB where the browser would not configure P3
42
- let color_display = mat3x3<f32>(
43
- settings.display_from_rec2020_c0,
44
- settings.display_from_rec2020_c1,
45
- settings.display_from_rec2020_c2
46
- ) * color_2020;
47
-
48
- // apply gamma. Note that gamma is the same for "Display P3" and "sRGB"
49
- let color_gamma = sRGBTransferOETF(color_display);
50
-
51
- return vec4(color_gamma, 1.0);
52
- }
53
- `, [
54
- chunk_tonemap_gt7,
55
- chunk_PAPER_WHITE_NITS,
56
- chunk_CRM_FROM_REC709_TO_REC2020,
57
- chunk_sRGBTransferOETF,
58
- ]
59
- );
60
-
61
- /**
62
- * The HDR output with {@link ShadeToneMappingMode.GT7}: GT7 at the display's peak, with the same paper white as
63
- * {@link shader_tonemap_LDR}, written in the canvas's primaries, extended, where 1.0 is SDR white.
64
- *
65
- * @type {ImageShader}
66
- */
67
- export const shader_tonemap_HDR = new ImageShader({
68
- descriptor: ShaderDescriptor.from({
69
- label: "Tonemap/HDR",
70
- resources,
71
- body
72
- }),
73
- targets: [
74
- {
75
- label: "tone-mapped",
76
- format: "rgba16float"
77
- }
78
- ]
79
- });
@@ -1,17 +0,0 @@
1
- /**
2
- * The HDR output with {@link ShadeToneMappingMode.ACES}, as Unreal Engine 5.8 does it with its default "Filmic" method
3
- * on a display past 100 cd/m²: the SDR picture of {@link shader_tonemap_LDR_aces}, taken back to the scene through the
4
- * inverse ACES 2.0 output transform for an SDR display, and rendered again with the ACES 2.0 output transform for this
5
- * display, limited to Rec.709 as the SDR picture is. Written in the canvas's primaries, extended, where 1.0 is SDR
6
- * white.
7
- *
8
- * A display at or under the paper white shows the SDR picture.
9
- *
10
- * Binds `aces2_tables`, the two transforms' parameters and gamut tables, which {@link TonemapAces2Tables} builds for
11
- * the display.
12
- *
13
- * @type {ImageShader}
14
- */
15
- export const shader_tonemap_HDR_aces: ImageShader;
16
- import { ImageShader } from "../../shader/ImageShader.js";
17
- //# sourceMappingURL=shader_tonemap_HDR_aces.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shader_tonemap_HDR_aces.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_aces.js"],"names":[],"mappings":"AA0EA;;;;;;;;;;;;;GAaG;AACH,sCAFU,WAAW,CAclB;4BA1FyB,6BAA6B"}
@@ -1,101 +0,0 @@
1
- import { F32_CONTAINER_STRUCT } from "../../shader/type/F32_CONTAINER_STRUCT.js";
2
- import { f32 } from "../../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
3
- import { WebGPUArray } from "../../shader/type/WebGPUArray.js";
4
- import { TONEMAP_SETTINGS_REC709_PEAK } from "./TonemapDisplaySettings.js";
5
- import { chunk_sRGBTransferOETF } from "../../shader/chunk/color/sRGB/chunk_sRGBTransferOETF.js";
6
- import { ACES2_BLOCK_FLOATS } from "../../shader/chunk/color/tonemap/aces/aces2_transform_block.js";
7
- import { chunk_aces2_output_transform } from "../../shader/chunk/color/tonemap/aces/chunk_aces2_output_transform.js";
8
- import { chunk_tonemap_ue_filmic } from "../../shader/chunk/color/tonemap/aces/chunk_tonemap_ue_filmic.js";
9
- import { chunk_PAPER_WHITE_NITS } from "../../shader/chunk/color/tonemap/chunk_PAPER_WHITE_NITS.js";
10
- import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
11
- import { ImageShader } from "../../shader/ImageShader.js";
12
- import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
13
- import { ShaderDescriptor } from "../../shader/ShaderDescriptor.js";
14
-
15
- const resources = new ShaderResourceSetDescriptor();
16
-
17
- resources.setImmediate("settings", TONEMAP_SETTINGS_REC709_PEAK);
18
- resources.createGroup()
19
- .addTexture("input_color", "float")
20
- .addUniform("exposure", F32_CONTAINER_STRUCT)
21
- // two ACES 2.0 output transforms, TonemapAces2Tables: 100 cd/m² first, then the display's headroom
22
- .addStorageBuffer("aces2_tables", WebGPUArray.from(f32))
23
-
24
- const body = CodeChunk.from(
25
- //language=WGSL
26
- `
27
- const ACES2_SDR_BLOCK: u32 = 0u;
28
- const ACES2_DISPLAY_BLOCK: u32 = ${ACES2_BLOCK_FLOATS}u;
29
-
30
- @fragment
31
- fn main(
32
- @builtin(position) coord : vec4<f32>,
33
- ) -> @location(0) vec4<f32> {
34
-
35
- // scene color in linear Rec. 709
36
- var color = textureLoad(input_color, vec2i(coord.xy), 0).rgb;
37
-
38
- // Apply exposure
39
- color *= exposure.value;
40
-
41
- // the SDR picture first, which is what Unreal 5.8 does with Filmic on any display
42
- let film = tonemap_ue_filmic(color);
43
-
44
- var picture = film;
45
-
46
- if (settings.peak_nits > PAPER_WHITE_NITS) {
47
- // back to the scene through ACES 2.0 at SDR white, then out again through ACES 2.0 at the display's peak over
48
- // the paper white. Both transforms take SDR white for 100 cd/m² and both are limited to Rec.709, the SDR
49
- // picture's own gamut, so as the headroom shrinks to none the picture becomes the SDR one.
50
- let aces = aces2_inverse(ACES2_SDR_BLOCK, film);
51
- picture = aces2_forward(ACES2_DISPLAY_BLOCK, aces);
52
- }
53
-
54
- // into the primaries the canvas reports it was configured with (Renderer#configure_context): Display P3, or
55
- // sRGB where the browser would not configure P3
56
- let color_display = mat3x3<f32>(
57
- settings.display_from_rec709_c0,
58
- settings.display_from_rec709_c1,
59
- settings.display_from_rec709_c2
60
- ) * picture;
61
-
62
- // NOTE: no dithering, colorspace is wide
63
-
64
- // apply gamma. Note that gamma is the same for "Display P3" and "sRGB"
65
- return vec4(sRGBTransferOETF(color_display), 1.0);
66
- }
67
- `, [
68
- chunk_tonemap_ue_filmic,
69
- chunk_aces2_output_transform,
70
- chunk_PAPER_WHITE_NITS,
71
- chunk_sRGBTransferOETF,
72
- ]
73
- );
74
-
75
- /**
76
- * The HDR output with {@link ShadeToneMappingMode.ACES}, as Unreal Engine 5.8 does it with its default "Filmic" method
77
- * on a display past 100 cd/m²: the SDR picture of {@link shader_tonemap_LDR_aces}, taken back to the scene through the
78
- * inverse ACES 2.0 output transform for an SDR display, and rendered again with the ACES 2.0 output transform for this
79
- * display, limited to Rec.709 as the SDR picture is. Written in the canvas's primaries, extended, where 1.0 is SDR
80
- * white.
81
- *
82
- * A display at or under the paper white shows the SDR picture.
83
- *
84
- * Binds `aces2_tables`, the two transforms' parameters and gamut tables, which {@link TonemapAces2Tables} builds for
85
- * the display.
86
- *
87
- * @type {ImageShader}
88
- */
89
- export const shader_tonemap_HDR_aces = new ImageShader({
90
- descriptor: ShaderDescriptor.from({
91
- label: "Tonemap/HDR/aces",
92
- resources,
93
- body
94
- }),
95
- targets: [
96
- {
97
- label: "tone-mapped",
98
- format: "rgba16float"
99
- }
100
- ]
101
- });
@@ -1,9 +0,0 @@
1
- /**
2
- * The HDR output with {@link ShadeToneMappingMode.NONE}: exposure and the canvas's primaries, extended, where 1.0 is
3
- * SDR white, and nothing in between.
4
- *
5
- * @type {ImageShader}
6
- */
7
- export const shader_tonemap_HDR_none: ImageShader;
8
- import { ImageShader } from "../../shader/ImageShader.js";
9
- //# sourceMappingURL=shader_tonemap_HDR_none.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shader_tonemap_HDR_none.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_none.js"],"names":[],"mappings":"AA+CA;;;;;GAKG;AACH,sCAFU,WAAW,CAclB;4BA7DyB,6BAA6B"}
@@ -1,10 +0,0 @@
1
- /**
2
- * The HDR output with {@link ShadeToneMappingMode.PBR_NEUTRAL}: Khronos PBR Neutral with the display's peak over the
3
- * paper white in place of the specification's 1, written in the canvas's primaries, extended, where 1.0 is SDR white.
4
- * Below the compression start it writes what {@link shader_tonemap_LDR_pbr_neutral} writes.
5
- *
6
- * @type {ImageShader}
7
- */
8
- export const shader_tonemap_HDR_pbr_neutral: ImageShader;
9
- import { ImageShader } from "../../shader/ImageShader.js";
10
- //# sourceMappingURL=shader_tonemap_HDR_pbr_neutral.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shader_tonemap_HDR_pbr_neutral.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_pbr_neutral.js"],"names":[],"mappings":"AA4DA;;;;;;GAMG;AACH,6CAFU,WAAW,CAclB;4BAzEyB,6BAA6B"}
@@ -1,80 +0,0 @@
1
- import { F32_CONTAINER_STRUCT } from "../../shader/type/F32_CONTAINER_STRUCT.js";
2
- import { TONEMAP_SETTINGS_REC709_PEAK } from "./TonemapDisplaySettings.js";
3
- import { chunk_sRGBTransferOETF } from "../../shader/chunk/color/sRGB/chunk_sRGBTransferOETF.js";
4
- import { chunk_PAPER_WHITE_NITS } from "../../shader/chunk/color/tonemap/chunk_PAPER_WHITE_NITS.js";
5
- import { chunk_tonemap_khronos_pbr } from "../../shader/chunk/color/tonemap/chunk_tonemap_khronos_pbr.js";
6
- import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
7
- import { ImageShader } from "../../shader/ImageShader.js";
8
- import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
9
- import { ShaderDescriptor } from "../../shader/ShaderDescriptor.js";
10
-
11
- const resources = new ShaderResourceSetDescriptor();
12
-
13
- // per-pass, four bytes, read-only: immediate data rather than a uniform buffer. exposure stays
14
- // bound - it is computed on the GPU, so there is no CPU value to write.
15
- resources.setImmediate("settings", TONEMAP_SETTINGS_REC709_PEAK);
16
- resources.createGroup()
17
- .addTexture("input_color", "float")
18
- .addUniform("exposure", F32_CONTAINER_STRUCT)
19
-
20
- const body = CodeChunk.from(
21
- //language=WGSL
22
- `
23
- @fragment
24
- fn main(
25
- @builtin(position) coord : vec4<f32>,
26
- ) -> @location(0) vec4<f32> {
27
-
28
- // scene color in linear Rec. 709
29
- var color = textureLoad(input_color, vec2i(coord.xy), 0).rgb;
30
-
31
- // Apply exposure
32
- color *= exposure.value;
33
-
34
- // the display's peak in units of SDR white. A display under the paper white gets the SDR form, which is where
35
- // the operator is defined.
36
- let peak = max(settings.peak_nits / PAPER_WHITE_NITS, 1.0);
37
-
38
- // It takes non-negative input.
39
- color = tonemap_khronos_pbr(max(color, vec3<f32>(0.0)), peak);
40
-
41
- // NOTE: no dithering, colorspace is wide
42
-
43
- // into the primaries the canvas reports it was configured with (Renderer#configure_context): Display P3, or
44
- // sRGB where the browser would not configure P3
45
- let color_display = mat3x3<f32>(
46
- settings.display_from_rec709_c0,
47
- settings.display_from_rec709_c1,
48
- settings.display_from_rec709_c2
49
- ) * color;
50
-
51
- // apply gamma. Note that gamma is the same for "Display P3" and "sRGB"
52
- return vec4(sRGBTransferOETF(color_display), 1.0);
53
- }
54
- `, [
55
- chunk_tonemap_khronos_pbr,
56
- chunk_PAPER_WHITE_NITS,
57
- chunk_sRGBTransferOETF,
58
- ]
59
- );
60
-
61
- /**
62
- * The HDR output with {@link ShadeToneMappingMode.PBR_NEUTRAL}: Khronos PBR Neutral with the display's peak over the
63
- * paper white in place of the specification's 1, written in the canvas's primaries, extended, where 1.0 is SDR white.
64
- * Below the compression start it writes what {@link shader_tonemap_LDR_pbr_neutral} writes.
65
- *
66
- * @type {ImageShader}
67
- */
68
- export const shader_tonemap_HDR_pbr_neutral = new ImageShader({
69
- descriptor: ShaderDescriptor.from({
70
- label: "Tonemap/HDR/pbr_neutral",
71
- resources,
72
- body
73
- }),
74
- targets: [
75
- {
76
- label: "tone-mapped",
77
- format: "rgba16float"
78
- }
79
- ]
80
- });
@@ -1,9 +0,0 @@
1
- /**
2
- * The SDR output with {@link ShadeToneMappingMode.GT7}: exposure, GT7 in its SDR mode, the canvas's primaries, the sRGB
3
- * transfer curve and an 8-bit dither. {@link shader_tonemap_HDR} is the same operator for an HDR display.
4
- *
5
- * @type {ImageShader}
6
- */
7
- export const shader_tonemap_LDR: ImageShader;
8
- import { ImageShader } from "../../shader/ImageShader.js";
9
- //# sourceMappingURL=shader_tonemap_LDR.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shader_tonemap_LDR.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/deferred/tonemap/shader_tonemap_LDR.js"],"names":[],"mappings":"AA6DA;;;;;GAKG;AACH,iCAFU,WAAW,CAclB;4BArEyB,6BAA6B"}
@@ -1,80 +0,0 @@
1
- import { F32_CONTAINER_STRUCT } from "../../shader/type/F32_CONTAINER_STRUCT.js";
2
- import { TONEMAP_SETTINGS_REC2020 } from "./TonemapDisplaySettings.js";
3
- import { chunk_CRM_FROM_REC709_TO_REC2020 } from "../../shader/chunk/color/conversion/chunk_CRM_FROM_REC709_TO_REC2020.js";
4
- import { chunk_sRGBTransferOETF } from "../../shader/chunk/color/sRGB/chunk_sRGBTransferOETF.js";
5
- import { chunk_PAPER_WHITE_NITS } from "../../shader/chunk/color/tonemap/chunk_PAPER_WHITE_NITS.js";
6
- import { chunk_tonemap_gt7 } from "../../shader/chunk/color/tonemap/gt7/chunk_tonemap_gt7.js";
7
- import {
8
- chunk_dither_color_8bit_triangle_noise
9
- } from "../../shader/chunk/texture/dither/chunk_dither_color_8bit_triangle_noise.js";
10
- import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
11
- import { ImageShader } from "../../shader/ImageShader.js";
12
- import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
13
- import { ShaderDescriptor } from "../../shader/ShaderDescriptor.js";
14
-
15
- const resources = new ShaderResourceSetDescriptor();
16
- resources.setImmediate("settings", TONEMAP_SETTINGS_REC2020);
17
- resources.createGroup()
18
- .addTexture("input_color", "float")
19
- .addUniform("exposure", F32_CONTAINER_STRUCT)
20
-
21
- const body = CodeChunk.from(
22
- //language=WGSL
23
- `
24
- @fragment
25
- fn main(
26
- @builtin(position) coord : vec4<f32>,
27
- ) -> @location(0) vec4<f32> {
28
-
29
- var color = textureLoad(input_color, vec2i(coord.xy), 0).rgb;
30
-
31
- color *= exposure.value;
32
-
33
- // GT7's SDR mode: the peak is the paper white, so the result tops out at 1.0. The HDR pass keeps the same paper
34
- // white, so below the shoulder the two write the same colour.
35
- let color_2020 = tonemap_gt7_rec2020(CRM_FROM_REC709_TO_REC2020 * color, PAPER_WHITE_NITS, PAPER_WHITE_NITS);
36
-
37
- // into the primaries the canvas reports it was configured with (Renderer#configure_context): Display P3, or
38
- // sRGB where the browser would not configure P3
39
- let color_display = mat3x3<f32>(
40
- settings.display_from_rec2020_c0,
41
- settings.display_from_rec2020_c1,
42
- settings.display_from_rec2020_c2
43
- ) * color_2020;
44
-
45
- // apply gamma. Note that gamma is the same for "Display P3" and "sRGB"
46
- color = sRGBTransferOETF(color_display);
47
-
48
- // apply dither to remove color banding
49
- color += dither_color_8bit_triangle_noise(coord.xy);
50
-
51
- return vec4(color, 1.0);
52
- }
53
- `, [
54
- chunk_tonemap_gt7,
55
- chunk_PAPER_WHITE_NITS,
56
- chunk_CRM_FROM_REC709_TO_REC2020,
57
- chunk_dither_color_8bit_triangle_noise,
58
- chunk_sRGBTransferOETF,
59
- ]
60
- );
61
-
62
- /**
63
- * The SDR output with {@link ShadeToneMappingMode.GT7}: exposure, GT7 in its SDR mode, the canvas's primaries, the sRGB
64
- * transfer curve and an 8-bit dither. {@link shader_tonemap_HDR} is the same operator for an HDR display.
65
- *
66
- * @type {ImageShader}
67
- */
68
- export const shader_tonemap_LDR = new ImageShader({
69
- descriptor: ShaderDescriptor.from({
70
- label: "Tonemap/LDR",
71
- resources,
72
- body
73
- }),
74
- targets: [
75
- {
76
- label: "tone-mapped",
77
- format: "rgba8unorm"
78
- }
79
- ]
80
- });