@forgeax/engine-render 0.1.30 → 0.1.32

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 (118) hide show
  1. package/README.md +68 -1
  2. package/dist/assembly/webgpu-ready.d.ts +2 -1
  3. package/dist/assembly/webgpu-ready.d.ts.map +1 -1
  4. package/dist/assembly/webgpu-renderer.d.ts.map +1 -1
  5. package/dist/{chunk-C3DDSXYK.mjs → chunk-4NNZQCL3.mjs} +110 -35
  6. package/dist/chunk-4NNZQCL3.mjs.map +1 -0
  7. package/dist/{chunk-JRBDO2KB.mjs → chunk-6TFBXLRJ.mjs} +19 -7
  8. package/dist/chunk-6TFBXLRJ.mjs.map +1 -0
  9. package/dist/{chunk-FUUO4UND.mjs → chunk-DRR7D3KX.mjs} +3 -3
  10. package/dist/chunk-DRR7D3KX.mjs.map +1 -0
  11. package/dist/{chunk-S5UE2T5P.mjs → chunk-GWCEMDVR.mjs} +380 -4
  12. package/dist/chunk-GWCEMDVR.mjs.map +1 -0
  13. package/dist/{chunk-MDQJPY3T.mjs → chunk-JCIRYQ4V.mjs} +3 -3
  14. package/dist/{chunk-MDQJPY3T.mjs.map → chunk-JCIRYQ4V.mjs.map} +1 -1
  15. package/dist/{chunk-PSEQ6QPH.mjs → chunk-JRIPCMYC.mjs} +17 -10
  16. package/dist/chunk-JRIPCMYC.mjs.map +1 -0
  17. package/dist/{chunk-7MQ3XBSP.mjs → chunk-LULCA3OF.mjs} +4 -4
  18. package/dist/{chunk-7MQ3XBSP.mjs.map → chunk-LULCA3OF.mjs.map} +1 -1
  19. package/dist/{chunk-NO4WZCAH.mjs → chunk-S665NJNF.mjs} +3 -3
  20. package/dist/{chunk-NO4WZCAH.mjs.map → chunk-S665NJNF.mjs.map} +1 -1
  21. package/dist/components/depth-of-field.d.ts +28 -0
  22. package/dist/components/depth-of-field.d.ts.map +1 -0
  23. package/dist/components/directional-light.d.ts +2 -1
  24. package/dist/components/directional-light.d.ts.map +1 -1
  25. package/dist/components/index.d.ts +1 -0
  26. package/dist/components/index.d.ts.map +1 -1
  27. package/dist/construct-renderer.mjs +898 -328
  28. package/dist/construct-renderer.mjs.map +1 -1
  29. package/dist/extract/camera.d.ts.map +1 -1
  30. package/dist/features/depth-of-field/depth-of-field-assembly.d.ts +19 -0
  31. package/dist/features/depth-of-field/depth-of-field-assembly.d.ts.map +1 -0
  32. package/dist/features/depth-of-field/depth-of-field-feature.d.ts +43 -0
  33. package/dist/features/depth-of-field/depth-of-field-feature.d.ts.map +1 -0
  34. package/dist/features/depth-of-field/depth-of-field-inspection.d.ts +34 -0
  35. package/dist/features/depth-of-field/depth-of-field-inspection.d.ts.map +1 -0
  36. package/dist/features/depth-of-field/depth-of-field-params.d.ts +83 -0
  37. package/dist/features/depth-of-field/depth-of-field-params.d.ts.map +1 -0
  38. package/dist/features/types.d.ts +19 -1
  39. package/dist/features/types.d.ts.map +1 -1
  40. package/dist/index.d.ts +4 -2
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.mjs +6 -5
  43. package/dist/index.mjs.map +1 -1
  44. package/dist/inspection-types.d.ts +35 -0
  45. package/dist/inspection-types.d.ts.map +1 -1
  46. package/dist/instances.d.ts +7 -0
  47. package/dist/instances.d.ts.map +1 -1
  48. package/dist/internal.mjs +6 -6
  49. package/dist/mesh-material-bindings.d.ts +3 -0
  50. package/dist/mesh-material-bindings.d.ts.map +1 -1
  51. package/dist/pipeline/standard-output/graph.d.ts.map +1 -1
  52. package/dist/pipeline/standard-output/types.d.ts +4 -2
  53. package/dist/pipeline/standard-output/types.d.ts.map +1 -1
  54. package/dist/pipeline/standard-post.d.ts.map +1 -1
  55. package/dist/plugin.d.ts.map +1 -1
  56. package/dist/record/frame-snapshot.d.ts +21 -1
  57. package/dist/record/frame-snapshot.d.ts.map +1 -1
  58. package/dist/record/frame.d.ts.map +1 -1
  59. package/dist/record/main-pass.d.ts.map +1 -1
  60. package/dist/record/typed-frame-graph.d.ts +7 -0
  61. package/dist/record/typed-frame-graph.d.ts.map +1 -1
  62. package/dist/recovery/render-system-candidate.d.ts.map +1 -1
  63. package/dist/render-contract.d.ts +8 -1
  64. package/dist/render-contract.d.ts.map +1 -1
  65. package/dist/render-graph-primitives.d.ts +2 -0
  66. package/dist/render-graph-primitives.d.ts.map +1 -1
  67. package/dist/render-pipeline.d.ts +13 -1
  68. package/dist/render-pipeline.d.ts.map +1 -1
  69. package/dist/render-system-extract-tail.d.ts.map +1 -1
  70. package/dist/render-system-extract.d.ts +18 -4
  71. package/dist/render-system-extract.d.ts.map +1 -1
  72. package/dist/render-system.d.ts +2 -1
  73. package/dist/render-system.d.ts.map +1 -1
  74. package/dist/temporal/index.mjs +5 -5
  75. package/dist/typed-render-graph-primitives.d.ts.map +1 -1
  76. package/package.json +21 -21
  77. package/src/__tests__/gpu-driven-baseline.characterization.test.ts +12 -0
  78. package/src/__tests__/gpu-driven-production.integration.test.ts +27 -1
  79. package/src/__tests__/instances-store.unit.test.ts +15 -0
  80. package/src/__tests__/prepared-gpu-driven-pbr.integration.test.ts +28 -0
  81. package/src/assembly/webgpu-ready.ts +5 -5
  82. package/src/assembly/webgpu-renderer.ts +14 -14
  83. package/src/components/depth-of-field.ts +45 -0
  84. package/src/components/directional-light.ts +2 -1
  85. package/src/components/index.ts +1 -0
  86. package/src/extract/camera.ts +22 -2
  87. package/src/features/depth-of-field/__tests__/depth-of-field-params.unit.test.ts +943 -0
  88. package/src/features/depth-of-field/depth-of-field-assembly.ts +100 -0
  89. package/src/features/depth-of-field/depth-of-field-feature.ts +295 -0
  90. package/src/features/depth-of-field/depth-of-field-inspection.ts +237 -0
  91. package/src/features/depth-of-field/depth-of-field-params.ts +556 -0
  92. package/src/features/host.ts +1 -1
  93. package/src/features/types.ts +18 -1
  94. package/src/index.ts +32 -0
  95. package/src/inspection-types.ts +38 -0
  96. package/src/instances.ts +19 -5
  97. package/src/mesh-material-bindings.ts +4 -0
  98. package/src/pipeline/standard-output/graph.ts +3 -0
  99. package/src/pipeline/standard-output/types.ts +4 -1
  100. package/src/pipeline/standard-post.ts +21 -2
  101. package/src/plugin.ts +2 -0
  102. package/src/record/frame-snapshot.ts +26 -1
  103. package/src/record/frame.ts +39 -6
  104. package/src/record/main-pass.ts +1 -5
  105. package/src/record/typed-frame-graph.ts +106 -6
  106. package/src/recovery/render-system-candidate.ts +6 -0
  107. package/src/render-contract.ts +11 -0
  108. package/src/render-graph-primitives.ts +8 -1
  109. package/src/render-pipeline.ts +17 -1
  110. package/src/render-system-extract-tail.ts +87 -13
  111. package/src/render-system-extract.ts +103 -25
  112. package/src/render-system.ts +78 -0
  113. package/src/typed-render-graph-primitives.ts +3 -0
  114. package/dist/chunk-C3DDSXYK.mjs.map +0 -1
  115. package/dist/chunk-FUUO4UND.mjs.map +0 -1
  116. package/dist/chunk-JRBDO2KB.mjs.map +0 -1
  117. package/dist/chunk-PSEQ6QPH.mjs.map +0 -1
  118. package/dist/chunk-S5UE2T5P.mjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { RenderIntentInvalidError, DynamicResolutionRequiresTaaError, ShadowInvalidConfigError, VolumeOwnerConflictError, VolumeDensityShapeMismatchError, VolumeInvalidBoundsError, VolumeInvalidParametersError, DynamicResolutionInvalidParameterError } from './chunk-JRBDO2KB.mjs';
1
+ import { RenderIntentInvalidError, DynamicResolutionRequiresTaaError, ShadowInvalidConfigError, VolumeOwnerConflictError, VolumeDensityShapeMismatchError, VolumeInvalidBoundsError, VolumeInvalidParametersError, DynamicResolutionInvalidParameterError } from './chunk-6TFBXLRJ.mjs';
2
2
  import { defineComponent, Entity } from '@forgeax/engine-ecs';
3
3
  import { TONEMAP_SHADER_MODE } from '@forgeax/engine-shader';
4
4
  import { R_MIN, err, ok } from '@forgeax/engine-types';
@@ -390,6 +390,36 @@ var CubeCamera = defineComponent("CubeCamera", {
390
390
  requestVersion: { type: "u32", default: 0 },
391
391
  faceBudget: { type: "u32", default: 1 }
392
392
  });
393
+ var DepthOfFieldQualityValue = Object.freeze({
394
+ low: 0,
395
+ medium: 1,
396
+ high: 2
397
+ });
398
+ var DepthOfFieldSideValue = Object.freeze({
399
+ both: 0,
400
+ near: 1,
401
+ far: 2
402
+ });
403
+ var DepthOfField = defineComponent("DepthOfField", {
404
+ focusDistance: { type: "f32", default: 8 },
405
+ fStop: { type: "f32", default: 2.8 },
406
+ sensorHeight: { type: "f32", default: 0.024 },
407
+ maxRadiusPixels: { type: "f32", default: 16 },
408
+ quality: { type: "f32", default: DepthOfFieldQualityValue.medium },
409
+ blurSide: { type: "f32", default: DepthOfFieldSideValue.both }
410
+ });
411
+ function depthOfFieldQualityFromF32(value) {
412
+ if (value === DepthOfFieldQualityValue.low) return "low";
413
+ if (value === DepthOfFieldQualityValue.medium) return "medium";
414
+ if (value === DepthOfFieldQualityValue.high) return "high";
415
+ return void 0;
416
+ }
417
+ function depthOfFieldSideFromF32(value) {
418
+ if (value === DepthOfFieldSideValue.both) return "both";
419
+ if (value === DepthOfFieldSideValue.near) return "near";
420
+ if (value === DepthOfFieldSideValue.far) return "far";
421
+ return void 0;
422
+ }
393
423
 
394
424
  // src/components/directional-shadow-filter.ts
395
425
  var DirectionalShadowFilterValue = Object.freeze({
@@ -943,6 +973,351 @@ var Visibility = defineComponent(
943
973
  }
944
974
  }
945
975
  );
976
+ var DEPTH_OF_FIELD_PARAMS_BYTE_SIZE = 64;
977
+ var MIN_F_STOP = Math.fround(0.7);
978
+ var MAX_F_STOP = Math.fround(32);
979
+ var MAX_LINEAR_DEPTH_RAW = Math.fround(1 - 2 ** -24);
980
+ var DEFAULT_DEPTH_OF_FIELD_PARAMS = Object.freeze({
981
+ focusDistance: 8,
982
+ fStop: 2.8,
983
+ sensorHeight: 0.024,
984
+ maxRadiusPixels: 16,
985
+ quality: "medium",
986
+ blurSide: "both",
987
+ focalLength: 0
988
+ });
989
+ function quantizeF32(value) {
990
+ return Math.fround(value);
991
+ }
992
+ var DepthOfFieldValidationError = class extends Error {
993
+ code;
994
+ expected;
995
+ hint;
996
+ detail;
997
+ constructor(code, detail, expected, hint) {
998
+ super(`${code}: ${expected}`);
999
+ this.name = "DepthOfFieldValidationError";
1000
+ this.code = code;
1001
+ this.expected = expected;
1002
+ this.hint = hint;
1003
+ this.detail = detail;
1004
+ }
1005
+ };
1006
+ function depthOfFieldRequestFailure(error) {
1007
+ return Object.freeze({
1008
+ code: error.code,
1009
+ detail: error.detail,
1010
+ expected: error.expected,
1011
+ hint: error.hint
1012
+ });
1013
+ }
1014
+ function resolveDepthOfFieldFrameParams(requested, requestFailure, accepted) {
1015
+ if (requested !== void 0) return requested;
1016
+ if (requestFailure === void 0 || requestFailure.code === "depth-of-field-orthographic-unsupported") {
1017
+ return void 0;
1018
+ }
1019
+ return accepted;
1020
+ }
1021
+ function invalid2(field, value, expected, bound) {
1022
+ return new DepthOfFieldValidationError(
1023
+ "depth-of-field-invalid-params",
1024
+ { field, value, expected, ...bound === void 0 ? {} : { bound } },
1025
+ expected,
1026
+ `set ${field} to ${expected}`
1027
+ );
1028
+ }
1029
+ function focalLength(sensorHeight, fov) {
1030
+ return sensorHeight / (2 * Math.tan(fov / 2));
1031
+ }
1032
+ function opticalCocScale(params) {
1033
+ return params.focalLength / params.sensorHeight / (2 * params.fStop) * (params.focalLength / (params.focusDistance - params.focalLength));
1034
+ }
1035
+ function frameCocCoefficient(params, outputHeight) {
1036
+ return quantizeF32(quantizeF32(outputHeight) * opticalCocScale(params));
1037
+ }
1038
+ function resolveDepthOfFieldFrameValues(params, input) {
1039
+ const focusDistance = quantizeF32(params.focusDistance);
1040
+ const fStop = quantizeF32(params.fStop);
1041
+ const sensorHeight = quantizeF32(params.sensorHeight);
1042
+ const focal = quantizeF32(params.focalLength);
1043
+ const maxRadiusPixels = quantizeF32(params.maxRadiusPixels);
1044
+ const outputHeight = quantizeF32(input.outputHeight);
1045
+ const near = quantizeF32(input.near);
1046
+ const far = quantizeF32(input.far);
1047
+ const finitePositiveFields = [
1048
+ ["focusDistance", focusDistance, params.focusDistance],
1049
+ ["sensorHeight", sensorHeight, params.sensorHeight],
1050
+ ["focalLength", focal, params.focalLength],
1051
+ ["near", near, input.near],
1052
+ ["far", far, input.far]
1053
+ ];
1054
+ for (const [field, value, raw] of finitePositiveFields) {
1055
+ if (!Number.isFinite(value) || value <= 0) {
1056
+ return err(invalid2(field, raw, "a finite positive f32 value"));
1057
+ }
1058
+ }
1059
+ if (!Number.isFinite(fStop) || fStop < MIN_F_STOP || fStop > MAX_F_STOP) {
1060
+ return err(
1061
+ invalid2("fStop", params.fStop, "a finite f32 value in [0.7, 32]", [MIN_F_STOP, MAX_F_STOP])
1062
+ );
1063
+ }
1064
+ if (!Number.isFinite(maxRadiusPixels) || maxRadiusPixels < 0 || maxRadiusPixels > 32) {
1065
+ return err(
1066
+ invalid2("maxRadiusPixels", params.maxRadiusPixels, "a finite f32 value in [0, 32]", [0, 32])
1067
+ );
1068
+ }
1069
+ if (!Number.isFinite(outputHeight) || outputHeight <= 0) {
1070
+ return err(invalid2("outputHeight", input.outputHeight, "a finite positive f32 value"));
1071
+ }
1072
+ if (far <= near) {
1073
+ return err(invalid2("near/far", [input.near, input.far], "finite f32 near > 0 and far > near"));
1074
+ }
1075
+ if (focusDistance <= focal) {
1076
+ return err(invalid2("focusDistance", params.focusDistance, "greater than focalLength in f32"));
1077
+ }
1078
+ const depthRatio = quantizeF32(near / far);
1079
+ if (!Number.isFinite(depthRatio) || depthRatio <= 0) {
1080
+ return err(invalid2("near/far ratio", depthRatio, "a finite positive f32 value"));
1081
+ }
1082
+ for (const raw of [quantizeF32(2 ** -149), 0.5, MAX_LINEAR_DEPTH_RAW]) {
1083
+ const oneMinusRaw = quantizeF32(1 - raw);
1084
+ const weightedRatio = quantizeF32(raw * depthRatio);
1085
+ const denominator = quantizeF32(oneMinusRaw + weightedRatio);
1086
+ const distance = quantizeF32(near / denominator);
1087
+ if (!Number.isFinite(oneMinusRaw) || oneMinusRaw <= 0 || !Number.isFinite(weightedRatio) || !Number.isFinite(denominator) || denominator <= 0 || !Number.isFinite(distance) || distance <= 0) {
1088
+ return err(invalid2("linearDepth", distance, "finite positive f32 reconstruction"));
1089
+ }
1090
+ }
1091
+ const cocCoefficient = frameCocCoefficient(
1092
+ {
1093
+ focusDistance,
1094
+ fStop,
1095
+ sensorHeight,
1096
+ focalLength: focal
1097
+ },
1098
+ outputHeight
1099
+ );
1100
+ if (!Number.isFinite(cocCoefficient) || cocCoefficient <= 0) {
1101
+ return err(
1102
+ invalid2("cocCoefficient", cocCoefficient, "a finite positive value representable as f32")
1103
+ );
1104
+ }
1105
+ for (const [field, depth] of [
1106
+ ["near", near],
1107
+ ["far", far]
1108
+ ]) {
1109
+ const focusOverDepth = quantizeF32(focusDistance / depth);
1110
+ const depthFactor = quantizeF32(1 - focusOverDepth);
1111
+ const radius = quantizeF32(cocCoefficient * depthFactor);
1112
+ if (!Number.isFinite(focusOverDepth) || !Number.isFinite(depthFactor) || !Number.isFinite(radius)) {
1113
+ return err(invalid2(`coc.${field}`, radius, "a finite value representable as f32"));
1114
+ }
1115
+ }
1116
+ return ok({
1117
+ focusDistance,
1118
+ fStop,
1119
+ sensorHeight,
1120
+ focalLength: focal,
1121
+ maxRadiusPixels,
1122
+ outputHeight,
1123
+ near,
1124
+ far,
1125
+ cocCoefficient
1126
+ });
1127
+ }
1128
+ function validateDepthOfFieldFrameParams(params, input) {
1129
+ const resolved = resolveDepthOfFieldFrameValues(params, input);
1130
+ return resolved.ok ? ok(void 0) : resolved;
1131
+ }
1132
+ function validateDepthOfFieldParams(input, camera) {
1133
+ if (camera?.projection === "orthographic") {
1134
+ return err(
1135
+ new DepthOfFieldValidationError(
1136
+ "depth-of-field-orthographic-unsupported",
1137
+ { projection: "orthographic" },
1138
+ "DepthOfField requires a perspective Camera",
1139
+ "use a perspective Camera or remove the DepthOfField component"
1140
+ )
1141
+ );
1142
+ }
1143
+ const value = input ?? {};
1144
+ const focusDistance = quantizeF32(
1145
+ value.focusDistance ?? DEFAULT_DEPTH_OF_FIELD_PARAMS.focusDistance
1146
+ );
1147
+ const fStop = quantizeF32(value.fStop ?? DEFAULT_DEPTH_OF_FIELD_PARAMS.fStop);
1148
+ const sensorHeight = quantizeF32(
1149
+ value.sensorHeight ?? DEFAULT_DEPTH_OF_FIELD_PARAMS.sensorHeight
1150
+ );
1151
+ const maxRadiusPixels = quantizeF32(
1152
+ value.maxRadiusPixels ?? DEFAULT_DEPTH_OF_FIELD_PARAMS.maxRadiusPixels
1153
+ );
1154
+ const qualityValue = quantizeF32(value.quality ?? DepthOfFieldQualityValue.medium);
1155
+ const blurSideValue = quantizeF32(value.blurSide ?? DepthOfFieldSideValue.both);
1156
+ const quality = depthOfFieldQualityFromF32(qualityValue);
1157
+ const blurSide = depthOfFieldSideFromF32(blurSideValue);
1158
+ if (!Number.isFinite(focusDistance) || focusDistance <= 0) {
1159
+ return err(
1160
+ invalid2("focusDistance", value.focusDistance ?? focusDistance, "a finite positive f32 value")
1161
+ );
1162
+ }
1163
+ if (!Number.isFinite(fStop) || fStop < MIN_F_STOP || fStop > MAX_F_STOP) {
1164
+ return err(
1165
+ invalid2("fStop", value.fStop ?? fStop, "a finite f32 value in [0.7, 32]", [
1166
+ MIN_F_STOP,
1167
+ MAX_F_STOP
1168
+ ])
1169
+ );
1170
+ }
1171
+ if (!Number.isFinite(sensorHeight) || sensorHeight <= 0) {
1172
+ return err(
1173
+ invalid2("sensorHeight", value.sensorHeight ?? sensorHeight, "a finite positive f32 value")
1174
+ );
1175
+ }
1176
+ if (!Number.isFinite(maxRadiusPixels) || maxRadiusPixels < 0 || maxRadiusPixels > 32) {
1177
+ return err(
1178
+ invalid2(
1179
+ "maxRadiusPixels",
1180
+ value.maxRadiusPixels ?? maxRadiusPixels,
1181
+ "a finite f32 value in [0, 32]",
1182
+ [0, 32]
1183
+ )
1184
+ );
1185
+ }
1186
+ if (quality === void 0) {
1187
+ return err(invalid2("quality", qualityValue, "DepthOfFieldQualityValue.low, medium, or high"));
1188
+ }
1189
+ if (blurSide === void 0) {
1190
+ return err(invalid2("blurSide", blurSideValue, "DepthOfFieldSideValue.both, near, or far"));
1191
+ }
1192
+ let focal = DEFAULT_DEPTH_OF_FIELD_PARAMS.focalLength;
1193
+ if (camera !== void 0) {
1194
+ const fov = quantizeF32(camera.fov);
1195
+ const near = quantizeF32(camera.near);
1196
+ const far = quantizeF32(camera.far);
1197
+ if (!Number.isFinite(fov) || fov <= 0 || fov >= Math.PI) {
1198
+ return err(invalid2("fov", camera.fov, "a finite f32 value in (0, PI)"));
1199
+ }
1200
+ if (!Number.isFinite(near) || !Number.isFinite(far) || near <= 0 || far <= near) {
1201
+ return err(
1202
+ invalid2("near/far", [camera.near, camera.far], "finite f32 near > 0 and far > near")
1203
+ );
1204
+ }
1205
+ focal = quantizeF32(focalLength(sensorHeight, fov));
1206
+ if (!Number.isFinite(focal) || focal <= 0) {
1207
+ return err(invalid2("focalLength", focal, "a finite positive f32 value"));
1208
+ }
1209
+ if (focusDistance < near || focusDistance > far) {
1210
+ return err(
1211
+ invalid2("focusDistance", focusDistance, `a value in [${near}, ${far}]`, [near, far])
1212
+ );
1213
+ }
1214
+ if (focusDistance <= focal) {
1215
+ return err(
1216
+ invalid2("focusDistance", focusDistance, `greater than focalLength in f32 (${focal})`)
1217
+ );
1218
+ }
1219
+ }
1220
+ return ok(
1221
+ Object.freeze({
1222
+ focusDistance,
1223
+ fStop,
1224
+ sensorHeight,
1225
+ maxRadiusPixels,
1226
+ quality,
1227
+ blurSide,
1228
+ focalLength: focal
1229
+ })
1230
+ );
1231
+ }
1232
+ function resolveDepthOfFieldParams(input, camera) {
1233
+ if (input === void 0) return ok(void 0);
1234
+ return validateDepthOfFieldParams(input, camera);
1235
+ }
1236
+ function depthOfFieldTapCount(quality) {
1237
+ switch (quality) {
1238
+ case "low":
1239
+ return 16;
1240
+ case "medium":
1241
+ return 32;
1242
+ case "high":
1243
+ return 64;
1244
+ }
1245
+ }
1246
+ function depthOfFieldSideCode(side) {
1247
+ switch (side) {
1248
+ case "both":
1249
+ return DepthOfFieldSideValue.both;
1250
+ case "near":
1251
+ return DepthOfFieldSideValue.near;
1252
+ case "far":
1253
+ return DepthOfFieldSideValue.far;
1254
+ }
1255
+ }
1256
+ function depthOfFieldQualityCode(quality) {
1257
+ switch (quality) {
1258
+ case "low":
1259
+ return DepthOfFieldQualityValue.low;
1260
+ case "medium":
1261
+ return DepthOfFieldQualityValue.medium;
1262
+ case "high":
1263
+ return DepthOfFieldQualityValue.high;
1264
+ }
1265
+ }
1266
+ function signedDepthOfFieldCoC(params, viewDepth, outputHeight) {
1267
+ if (!Number.isFinite(viewDepth) || viewDepth <= 0 || !Number.isFinite(outputHeight) || outputHeight <= 0 || !Number.isFinite(params.focalLength) || params.focalLength <= 0 || !Number.isFinite(params.sensorHeight) || params.sensorHeight <= 0 || !Number.isFinite(params.fStop) || params.fStop <= 0 || !Number.isFinite(params.focusDistance) || params.focusDistance <= params.focalLength) {
1268
+ return 0;
1269
+ }
1270
+ const focusDistance = quantizeF32(params.focusDistance);
1271
+ const depth = quantizeF32(viewDepth);
1272
+ const focalLength2 = quantizeF32(params.focalLength);
1273
+ const sensorHeight = quantizeF32(params.sensorHeight);
1274
+ const fStop = quantizeF32(params.fStop);
1275
+ const coefficient = frameCocCoefficient(
1276
+ { focusDistance, focalLength: focalLength2, sensorHeight, fStop },
1277
+ outputHeight
1278
+ );
1279
+ const depthFactor = quantizeF32(1 - quantizeF32(focusDistance / depth));
1280
+ const radius = quantizeF32(coefficient * depthFactor);
1281
+ const limit = Number.isFinite(params.maxRadiusPixels) ? quantizeF32(params.maxRadiusPixels) : Number.POSITIVE_INFINITY;
1282
+ return Math.max(-limit, Math.min(limit, Number.isFinite(radius) ? radius : 0));
1283
+ }
1284
+ function packDepthOfFieldParams(params, input) {
1285
+ const frameValues = resolveDepthOfFieldFrameValues(params, input);
1286
+ if (!frameValues.ok) throw frameValues.error;
1287
+ const {
1288
+ focusDistance,
1289
+ fStop,
1290
+ sensorHeight,
1291
+ focalLength: focal,
1292
+ outputHeight,
1293
+ maxRadiusPixels,
1294
+ near,
1295
+ far,
1296
+ cocCoefficient
1297
+ } = frameValues.value;
1298
+ const payload = new Float32Array(DEPTH_OF_FIELD_PARAMS_BYTE_SIZE / 4);
1299
+ payload.set([
1300
+ focusDistance,
1301
+ fStop,
1302
+ sensorHeight,
1303
+ focal,
1304
+ outputHeight,
1305
+ maxRadiusPixels,
1306
+ depthOfFieldSideCode(params.blurSide),
1307
+ depthOfFieldQualityCode(params.quality),
1308
+ near,
1309
+ far,
1310
+ input.useTemporalDepth ? 1 : 0,
1311
+ 0,
1312
+ // row2.w reserved
1313
+ cocCoefficient,
1314
+ // row3.x / WGSL reserved.x
1315
+ 0,
1316
+ 0,
1317
+ 0
1318
+ ]);
1319
+ return new Uint8Array(payload.buffer);
1320
+ }
946
1321
  function hasVolumetricFogCapability(caps, shaders) {
947
1322
  return caps.compute && caps.storageTexture && shaders !== void 0;
948
1323
  }
@@ -1095,6 +1470,7 @@ function projectMeshMaterialBindingObservation(input) {
1095
1470
  });
1096
1471
  return {
1097
1472
  worldId: input.worldId,
1473
+ ...input.worldIdentity === void 0 ? {} : { worldIdentity: input.worldIdentity },
1098
1474
  entityKey: input.entityKey,
1099
1475
  bindings: Object.freeze([...input.bindings]),
1100
1476
  diagnostics: Object.freeze([...input.diagnostics]),
@@ -1301,6 +1677,6 @@ function extractVolumetricFog(inputs) {
1301
1677
  return ok({ status: "available", fog: validated.value });
1302
1678
  }
1303
1679
 
1304
- export { ANTIALIAS_FXAA, ANTIALIAS_MSAA, ANTIALIAS_NONE, ANTIALIAS_TAA, Atmosphere, BLOOM_DISABLED, BLOOM_ENABLED, CAMERA_EXPOSURE_MODE_AUTO, CAMERA_EXPOSURE_MODE_MANUAL, CAMERA_PROJECTION_ORTHOGRAPHIC, CAMERA_PROJECTION_PERSPECTIVE, CAMERA_TEMPERATURE_MAX, CAMERA_TEMPERATURE_MIN, CAMERA_TINT_MAX, CAMERA_TINT_MIN, CUBE_CAMERA_FACE_ORDER, CUBE_CAMERA_UPDATE_CONTINUOUS, CUBE_CAMERA_UPDATE_ONCE, CUBE_CAMERA_UPDATE_ON_DEMAND, Camera, CameraError, CubeCamera, DirectionalLight, DirectionalShadowFilterValue, DynamicResolution, Fog, Instances, Layer, LightProbe, Lines, MeshFilter, MeshRenderer, MotionBlur, PointLight, PointLightShadow, PointShapeValue, Points, PostProcessParams, REFLECTION_PROBE_UPDATE_CONTINUOUS, REFLECTION_PROBE_UPDATE_ONCE, REFLECTION_PROBE_UPDATE_ON_CHANGE, RectAreaLight, ReflectionProbe, SKYBOX_MODE_CUBEMAP, SceneInstance, ScreenSpaceReflection, SkyboxBackground, Skylight, SortKey, SpotLight, TONEMAP_ACES_FILMIC, TONEMAP_AGX, TONEMAP_CINEON, TONEMAP_LINEAR, TONEMAP_NEUTRAL, TONEMAP_NONE, TONEMAP_REINHARD, TONEMAP_REINHARD_EXTENDED, Visibility, VisibilityStateValue, VolumetricFog, antialiasFromF32, bloomEnabledFromF32, buildCubeCameraFaceViews, cameraExposureFromColumns, cameraProjectionFromF32, computeInvRangeSquared, cubeCameraUpdateIntentFromF32, cubeCameraUpdateIntentToF32, degToCos, directionalShadowQualityFromF32, extractVolumetricFog, hasVolumetricFogCapability, orthographic, perspective, pointShapeFromU32, projectMeshMaterialBindingObservation, reflectionProbeUpdateIntentFromF32, reflectionProbeUpdateIntentToF32, resolveIntegratedVolumeConsumer, resolveMeshMaterialBindings, resolveSelectedVolumetricLight, resolveVisibility, resolveVolumetricFogLightPair, summarizeMeshMaterialBindings, tonemapFromF32, tonemapToU32, validateCameraColorGrading, validateCameraExposure, validateDirection, validateDirectionalLightData, validateDynamicResolutionCamera, validateDynamicResolutionParameters, validateLightProbeData, validatePointLightData, validatePointLightShadowData, validateRectAreaLightData, validateSpotLightData, validateVolumetricFog, visibilityStateFromU32 };
1305
- //# sourceMappingURL=chunk-S5UE2T5P.mjs.map
1306
- //# sourceMappingURL=chunk-S5UE2T5P.mjs.map
1680
+ export { ANTIALIAS_FXAA, ANTIALIAS_MSAA, ANTIALIAS_NONE, ANTIALIAS_TAA, Atmosphere, BLOOM_DISABLED, BLOOM_ENABLED, CAMERA_EXPOSURE_MODE_AUTO, CAMERA_EXPOSURE_MODE_MANUAL, CAMERA_PROJECTION_ORTHOGRAPHIC, CAMERA_PROJECTION_PERSPECTIVE, CAMERA_TEMPERATURE_MAX, CAMERA_TEMPERATURE_MIN, CAMERA_TINT_MAX, CAMERA_TINT_MIN, CUBE_CAMERA_FACE_ORDER, CUBE_CAMERA_UPDATE_CONTINUOUS, CUBE_CAMERA_UPDATE_ONCE, CUBE_CAMERA_UPDATE_ON_DEMAND, Camera, CameraError, CubeCamera, DEFAULT_DEPTH_OF_FIELD_PARAMS, DEPTH_OF_FIELD_PARAMS_BYTE_SIZE, DepthOfField, DepthOfFieldQualityValue, DepthOfFieldSideValue, DepthOfFieldValidationError, DirectionalLight, DirectionalShadowFilterValue, DynamicResolution, Fog, Instances, Layer, LightProbe, Lines, MeshFilter, MeshRenderer, MotionBlur, PointLight, PointLightShadow, PointShapeValue, Points, PostProcessParams, REFLECTION_PROBE_UPDATE_CONTINUOUS, REFLECTION_PROBE_UPDATE_ONCE, REFLECTION_PROBE_UPDATE_ON_CHANGE, RectAreaLight, ReflectionProbe, SKYBOX_MODE_CUBEMAP, SceneInstance, ScreenSpaceReflection, SkyboxBackground, Skylight, SortKey, SpotLight, TONEMAP_ACES_FILMIC, TONEMAP_AGX, TONEMAP_CINEON, TONEMAP_LINEAR, TONEMAP_NEUTRAL, TONEMAP_NONE, TONEMAP_REINHARD, TONEMAP_REINHARD_EXTENDED, Visibility, VisibilityStateValue, VolumetricFog, antialiasFromF32, bloomEnabledFromF32, buildCubeCameraFaceViews, cameraExposureFromColumns, cameraProjectionFromF32, computeInvRangeSquared, cubeCameraUpdateIntentFromF32, cubeCameraUpdateIntentToF32, degToCos, depthOfFieldQualityCode, depthOfFieldQualityFromF32, depthOfFieldRequestFailure, depthOfFieldSideCode, depthOfFieldSideFromF32, depthOfFieldTapCount, directionalShadowQualityFromF32, extractVolumetricFog, hasVolumetricFogCapability, orthographic, packDepthOfFieldParams, perspective, pointShapeFromU32, projectMeshMaterialBindingObservation, reflectionProbeUpdateIntentFromF32, reflectionProbeUpdateIntentToF32, resolveDepthOfFieldFrameParams, resolveDepthOfFieldParams, resolveIntegratedVolumeConsumer, resolveMeshMaterialBindings, resolveSelectedVolumetricLight, resolveVisibility, resolveVolumetricFogLightPair, signedDepthOfFieldCoC, summarizeMeshMaterialBindings, tonemapFromF32, tonemapToU32, validateCameraColorGrading, validateCameraExposure, validateDepthOfFieldFrameParams, validateDepthOfFieldParams, validateDirection, validateDirectionalLightData, validateDynamicResolutionCamera, validateDynamicResolutionParameters, validateLightProbeData, validatePointLightData, validatePointLightShadowData, validateRectAreaLightData, validateSpotLightData, validateVolumetricFog, visibilityStateFromU32 };
1681
+ //# sourceMappingURL=chunk-GWCEMDVR.mjs.map
1682
+ //# sourceMappingURL=chunk-GWCEMDVR.mjs.map