@forgeax/engine-render 0.1.23 → 0.1.25
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.
- package/README.md +231 -10
- package/dist/assembly/bundler-contract.d.ts +9 -0
- package/dist/assembly/bundler-contract.d.ts.map +1 -0
- package/dist/assembly/device-feature-admission.d.ts +8 -0
- package/dist/assembly/device-feature-admission.d.ts.map +1 -1
- package/dist/assembly/extended-lighting-fallback.d.ts +13 -0
- package/dist/assembly/extended-lighting-fallback.d.ts.map +1 -0
- package/dist/assembly/factory.d.ts +7 -243
- package/dist/assembly/factory.d.ts.map +1 -1
- package/dist/assembly/material/assembly.d.ts +3 -2
- package/dist/assembly/material/assembly.d.ts.map +1 -1
- package/dist/assembly/material/standard-layer-projection.d.ts +10 -0
- package/dist/assembly/material/standard-layer-projection.d.ts.map +1 -0
- package/dist/assembly/material/surface-projection.d.ts +24 -0
- package/dist/assembly/material/surface-projection.d.ts.map +1 -0
- package/dist/assembly/material-shader-policy.d.ts +188 -0
- package/dist/assembly/material-shader-policy.d.ts.map +1 -0
- package/dist/assembly/material-shader-prewarm.d.ts +21 -0
- package/dist/assembly/material-shader-prewarm.d.ts.map +1 -0
- package/dist/assembly/mesh-ssbo-grow.d.ts +88 -0
- package/dist/assembly/mesh-ssbo-grow.d.ts.map +1 -0
- package/dist/assembly/recovery/device-loss-fanout.d.ts +14 -0
- package/dist/assembly/recovery/device-loss-fanout.d.ts.map +1 -0
- package/dist/assembly/recovery/generation.d.ts +46 -0
- package/dist/assembly/recovery/generation.d.ts.map +1 -0
- package/dist/assembly/recovery/recovery-attempt.d.ts +63 -0
- package/dist/assembly/recovery/recovery-attempt.d.ts.map +1 -0
- package/dist/assembly/recovery/renderer-recover.d.ts +115 -0
- package/dist/assembly/recovery/renderer-recover.d.ts.map +1 -0
- package/dist/assembly/renderer-facade.d.ts +10 -0
- package/dist/assembly/renderer-facade.d.ts.map +1 -0
- package/dist/assembly/renderer-frame-transaction.d.ts +17 -0
- package/dist/assembly/renderer-frame-transaction.d.ts.map +1 -1
- package/dist/assembly/renderer-helpers.d.ts +19 -0
- package/dist/assembly/renderer-helpers.d.ts.map +1 -0
- package/dist/assembly/renderer-lifecycle.d.ts +34 -0
- package/dist/assembly/renderer-lifecycle.d.ts.map +1 -1
- package/dist/assembly/shader-prewarm-policy.d.ts +15 -0
- package/dist/assembly/shader-prewarm-policy.d.ts.map +1 -0
- package/dist/assembly/webgpu-ready-contract.d.ts +9 -0
- package/dist/assembly/webgpu-ready-contract.d.ts.map +1 -0
- package/dist/assembly/webgpu-ready.d.ts +55 -0
- package/dist/assembly/webgpu-ready.d.ts.map +1 -0
- package/dist/assembly/webgpu-renderer.d.ts +152 -0
- package/dist/assembly/webgpu-renderer.d.ts.map +1 -0
- package/dist/assembly/webgpu-vertex-layouts.d.ts +89 -0
- package/dist/assembly/webgpu-vertex-layouts.d.ts.map +1 -0
- package/dist/assets/asset-decoders.d.ts.map +1 -1
- package/dist/authoring.mjs +1 -1
- package/dist/{chunk-FF7K3FSO.mjs → chunk-ADHHVYLW.mjs} +89 -89
- package/dist/chunk-ADHHVYLW.mjs.map +1 -0
- package/dist/{chunk-YALPS44A.mjs → chunk-E34VL5VI.mjs} +47 -47
- package/dist/chunk-E34VL5VI.mjs.map +1 -0
- package/dist/{chunk-4L3P6DT5.mjs → chunk-GE3SDD72.mjs} +37 -5
- package/dist/chunk-GE3SDD72.mjs.map +1 -0
- package/dist/{chunk-HZUPSYW7.mjs → chunk-HKXTW355.mjs} +105 -15
- package/dist/chunk-HKXTW355.mjs.map +1 -0
- package/dist/chunk-JSEDTZYS.mjs +413 -0
- package/dist/chunk-JSEDTZYS.mjs.map +1 -0
- package/dist/{chunk-FBC4R44J.mjs → chunk-KM2NOX2I.mjs} +57 -57
- package/dist/chunk-KM2NOX2I.mjs.map +1 -0
- package/dist/{chunk-DIYW3M5D.mjs → chunk-N3RT2EUR.mjs} +2288 -2238
- package/dist/chunk-N3RT2EUR.mjs.map +1 -0
- package/dist/{chunk-ZUWKAZ2I.mjs → chunk-TCLDX7SZ.mjs} +1167 -368
- package/dist/chunk-TCLDX7SZ.mjs.map +1 -0
- package/dist/{chunk-QODA5UKU.mjs → chunk-ZZ4YQ474.mjs} +2 -2
- package/dist/chunk-ZZ4YQ474.mjs.map +1 -0
- package/dist/components/instances.d.ts +13 -31
- package/dist/components/instances.d.ts.map +1 -1
- package/dist/construct-renderer.mjs +20688 -16314
- package/dist/construct-renderer.mjs.map +1 -1
- package/dist/device/device-scope.d.ts +2 -0
- package/dist/device/device-scope.d.ts.map +1 -1
- package/dist/device/gpu-residency.d.ts +24 -4
- package/dist/device/gpu-residency.d.ts.map +1 -1
- package/dist/environment/frame.d.ts +5 -0
- package/dist/environment/frame.d.ts.map +1 -1
- package/dist/environment/inspection.d.ts +7 -0
- package/dist/environment/inspection.d.ts.map +1 -1
- package/dist/environment/lifecycle.d.ts +20 -2
- package/dist/environment/lifecycle.d.ts.map +1 -1
- package/dist/errors/recover.d.ts +58 -2
- package/dist/errors/recover.d.ts.map +1 -1
- package/dist/errors/render.d.ts +13 -0
- package/dist/errors/render.d.ts.map +1 -1
- package/dist/extract/contracts.d.ts +899 -0
- package/dist/extract/contracts.d.ts.map +1 -0
- package/dist/features/host.d.ts +2 -0
- package/dist/features/host.d.ts.map +1 -1
- package/dist/features/prepared-gpu-work.d.ts +3 -0
- package/dist/features/prepared-gpu-work.d.ts.map +1 -1
- package/dist/features/prepared-graphics-store.d.ts +2 -0
- package/dist/features/prepared-graphics-store.d.ts.map +1 -1
- package/dist/gpu-driven/production-raster.d.ts +34 -1
- package/dist/gpu-driven/production-raster.d.ts.map +1 -1
- package/dist/gpu-scene.d.ts +5 -0
- package/dist/gpu-scene.d.ts.map +1 -1
- package/dist/ibl/IblPipelineCache.d.ts +7 -6
- package/dist/ibl/IblPipelineCache.d.ts.map +1 -1
- package/dist/ibl/skylight-bind-group.d.ts +7 -1
- package/dist/ibl/skylight-bind-group.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +27 -9
- package/dist/index.mjs.map +1 -1
- package/dist/instance-buffer-cache.d.ts +7 -1
- package/dist/instance-buffer-cache.d.ts.map +1 -1
- package/dist/instances.d.ts +101 -0
- package/dist/instances.d.ts.map +1 -0
- package/dist/internal.mjs +6 -6
- package/dist/light-buffer-layout.d.ts +3 -0
- package/dist/light-buffer-layout.d.ts.map +1 -1
- package/dist/materials.d.ts +96 -11
- package/dist/materials.d.ts.map +1 -1
- package/dist/mesh-material-bindings.d.ts +56 -0
- package/dist/mesh-material-bindings.d.ts.map +1 -1
- package/dist/occlusion-proxy.d.ts +4 -0
- package/dist/occlusion-proxy.d.ts.map +1 -0
- package/dist/pbr-pipeline.d.ts +32 -9
- package/dist/pbr-pipeline.d.ts.map +1 -1
- package/dist/pipeline-builder.d.ts.map +1 -1
- package/dist/pipeline-spec.d.ts.map +1 -1
- package/dist/points-lines/prepare.d.ts +3 -0
- package/dist/points-lines/prepare.d.ts.map +1 -1
- package/dist/points-lines/standard-owner.d.ts +33 -0
- package/dist/points-lines/standard-owner.d.ts.map +1 -0
- package/dist/record/frame-snapshot.d.ts +18 -2
- package/dist/record/frame-snapshot.d.ts.map +1 -1
- package/dist/record/frame-targets.d.ts.map +1 -1
- package/dist/record/frame.d.ts +14 -2
- package/dist/record/frame.d.ts.map +1 -1
- package/dist/record/main-pass-geometry.d.ts +36 -4
- package/dist/record/main-pass-geometry.d.ts.map +1 -1
- package/dist/record/main-pass-material.d.ts +7 -17
- package/dist/record/main-pass-material.d.ts.map +1 -1
- package/dist/record/main-pass.d.ts.map +1 -1
- package/dist/record/mesh-ssbo.d.ts +11 -3
- package/dist/record/mesh-ssbo.d.ts.map +1 -1
- package/dist/record/recovery-pipeline.d.ts +30 -0
- package/dist/record/recovery-pipeline.d.ts.map +1 -0
- package/dist/record/render-context.d.ts +28 -5
- package/dist/record/render-context.d.ts.map +1 -1
- package/dist/record/shadow-pass.d.ts +11 -1
- package/dist/record/shadow-pass.d.ts.map +1 -1
- package/dist/record/typed-frame-graph.d.ts +1 -1
- package/dist/record/typed-frame-graph.d.ts.map +1 -1
- package/dist/recovery/render-system-candidate.d.ts +65 -0
- package/dist/recovery/render-system-candidate.d.ts.map +1 -0
- package/dist/render-contract.d.ts +68 -7
- package/dist/render-contract.d.ts.map +1 -1
- package/dist/render-system-extract-tail.d.ts +16 -0
- package/dist/render-system-extract-tail.d.ts.map +1 -0
- package/dist/render-system-extract.d.ts +180 -22
- package/dist/render-system-extract.d.ts.map +1 -1
- package/dist/render-system.d.ts +131 -4
- package/dist/render-system.d.ts.map +1 -1
- package/dist/scene/render-scene-types.d.ts +2 -0
- package/dist/scene/render-scene-types.d.ts.map +1 -1
- package/dist/scene/render-scene.d.ts +31 -1
- package/dist/scene/render-scene.d.ts.map +1 -1
- package/dist/systems/skin-palette-allocator.d.ts +6 -0
- package/dist/systems/skin-palette-allocator.d.ts.map +1 -1
- package/dist/temporal/frame-coordinator.d.ts.map +1 -1
- package/dist/temporal/index.mjs +6 -6
- package/dist/temporal/taa-history-store.d.ts +15 -1
- package/dist/temporal/taa-history-store.d.ts.map +1 -1
- package/dist/temporal/transaction.d.ts +5 -0
- package/dist/temporal/transaction.d.ts.map +1 -1
- package/package.json +20 -20
- package/src/__tests__/device-feature-admission.unit.test.ts +6 -0
- package/src/__tests__/device-loss-fanout.unit.test.ts +107 -0
- package/src/__tests__/device-scope-lifecycle.unit.test.ts +21 -0
- package/src/__tests__/environment-generation.integration.test.ts +23 -0
- package/src/__tests__/expose-renderer-errors.unit.test.ts +34 -0
- package/src/__tests__/factory-contract.integration.test.ts +122 -7
- package/src/__tests__/fallback-row-stride-surface.unit.test.ts +4 -1
- package/src/__tests__/gpu-scene.unit.test.ts +38 -2
- package/src/__tests__/ibl/face-uniforms.unit.test.ts +2 -0
- package/src/__tests__/ibl-residency-publication.unit.test.ts +113 -0
- package/src/__tests__/instances-store.unit.test.ts +46 -0
- package/src/__tests__/instances-world-ownership.integration.test.ts +62 -0
- package/src/__tests__/material-contract-inventory.unit.test.ts +29 -22
- package/src/__tests__/material-cooked-projection.unit.test.ts +19 -1
- package/src/__tests__/material-pass-policy.unit.test.ts +69 -0
- package/src/__tests__/material-snapshot-mutation.integration.test.ts +69 -0
- package/src/__tests__/material-static-dynamic-route.unit.test.ts +29 -0
- package/src/__tests__/material-stride-surface.unit.test.ts +7 -3
- package/src/__tests__/material-surface-authoring.test-d.ts +62 -0
- package/src/__tests__/materials-standard-contract.unit.test.ts +104 -0
- package/src/__tests__/materials-transmission-validation.unit.test.ts +24 -0
- package/src/__tests__/mesh-buffer-usage-surface.unit.test.ts +1 -5
- package/src/__tests__/physical-clearcoat.integration.test.ts +89 -0
- package/src/__tests__/prepared-gpu-driven-pbr.integration.test.ts +1 -1
- package/src/__tests__/prepared-graphics-pipeline-warmup.unit.test.ts +1 -1
- package/src/__tests__/recover-error-policy-owner.unit.test.ts +6 -3
- package/src/__tests__/recovery-candidate-prepare.contract.test.ts +140 -0
- package/src/__tests__/renderer-factory-material-contract.unit.test.ts +127 -18
- package/src/__tests__/renderer-frame-generation-fence.integration.test.ts +47 -0
- package/src/__tests__/renderer-generation-assembly.unit.test.ts +77 -0
- package/src/__tests__/renderer-generation-failure.unit.test.ts +108 -0
- package/src/__tests__/renderer-producer-root-matrix.integration.test.ts +33 -0
- package/src/__tests__/renderer-recovery-capability-matrix.unit.test.ts +59 -0
- package/src/__tests__/renderer-recovery-contract.unit.test.ts +73 -0
- package/src/__tests__/renderer-recovery-lifecycle.unit.test.ts +216 -0
- package/src/__tests__/renderer-target-history-recovery.integration.test.ts +80 -0
- package/src/__tests__/shader-manifest-fixture.ts +13 -16
- package/src/__tests__/shader-stage-surface.unit.test.ts +1 -1
- package/src/__tests__/skin-motion-regression.unit.test.ts +33 -0
- package/src/__tests__/skinned-shadow-caster.test.ts +30 -2
- package/src/__tests__/standard-layer-projection.unit.test.ts +23 -0
- package/src/__tests__/surface-adjacent-regressions.integration.test.ts +60 -0
- package/src/__tests__/surface-standard-pipeline.browser.test.ts +20 -0
- package/src/__tests__/surface-standard-pipeline.dawn.test.ts +20 -0
- package/src/__tests__/surface-standard-pipeline.fixture.ts +132 -0
- package/src/__tests__/surface-variant-provenance.integration.test.ts +33 -0
- package/src/__tests__/transmission-prewarm.unit.test.ts +95 -85
- package/src/__tests__/volumetric-fog-budget-recovery.integration.test.ts +1 -1
- package/src/__tests__/volumetric-fog-topology.unit.test.ts +3 -1
- package/src/assembly/bundler-contract.ts +9 -0
- package/src/assembly/device-feature-admission.ts +15 -5
- package/src/assembly/extended-lighting-fallback.ts +216 -0
- package/src/assembly/factory.ts +83 -10088
- package/src/assembly/material/__tests__/standard-layer-plan-projection.integration.test.ts +18 -0
- package/src/assembly/material/__tests__/surface-pass-projection.integration.test.ts +62 -0
- package/src/assembly/material/assembly.ts +18 -2
- package/src/assembly/material/standard-layer-projection.ts +16 -0
- package/src/assembly/material/surface-projection.ts +90 -0
- package/src/assembly/material-shader-policy.ts +932 -0
- package/src/assembly/material-shader-prewarm.ts +88 -0
- package/src/assembly/mesh-ssbo-grow.ts +270 -0
- package/src/assembly/recovery/device-loss-fanout.ts +89 -0
- package/src/assembly/recovery/generation.ts +141 -0
- package/src/assembly/recovery/recovery-attempt.ts +800 -0
- package/src/assembly/recovery/renderer-recover.ts +906 -0
- package/src/assembly/renderer-facade.ts +342 -0
- package/src/assembly/renderer-frame-transaction.ts +45 -0
- package/src/assembly/renderer-helpers.ts +99 -0
- package/src/assembly/renderer-lifecycle.ts +159 -0
- package/src/assembly/shader-prewarm-policy.ts +157 -0
- package/src/assembly/webgpu-ready-contract.ts +14 -0
- package/src/assembly/webgpu-ready.ts +4066 -0
- package/src/assembly/webgpu-renderer.ts +4027 -0
- package/src/assembly/webgpu-vertex-layouts.ts +132 -0
- package/src/assets/asset-decoders.ts +27 -4
- package/src/components/camera.ts +1 -1
- package/src/components/instances.ts +14 -197
- package/src/debug-draw-glue.ts +1 -1
- package/src/device/device-scope.ts +35 -6
- package/src/device/gpu-residency.ts +194 -26
- package/src/environment/frame.ts +6 -0
- package/src/environment/inspection.ts +10 -0
- package/src/environment/lifecycle.ts +114 -8
- package/src/errors/recover.ts +76 -5
- package/src/errors/render.ts +17 -0
- package/src/extract/contracts.ts +974 -0
- package/src/features/host.ts +16 -0
- package/src/features/prepared-gpu-work.ts +20 -2
- package/src/features/prepared-graphics-store.ts +17 -0
- package/src/gpu-driven/production-raster.ts +131 -3
- package/src/gpu-scene.ts +87 -31
- package/src/ibl/IblPipelineCache.ts +134 -50
- package/src/ibl/skylight-bind-group.ts +26 -0
- package/src/index.ts +10 -1
- package/src/instance-buffer-cache.ts +14 -1
- package/src/instances.ts +288 -0
- package/src/light-buffer-layout.ts +3 -0
- package/src/materials.ts +365 -53
- package/src/mesh-material-bindings.ts +59 -0
- package/src/occlusion-proxy.ts +64 -0
- package/src/pbr-pipeline.ts +139 -15
- package/src/pipeline-builder.ts +14 -10
- package/src/pipeline-spec.ts +6 -14
- package/src/points-lines/__tests__/cache-recovery.unit.test.ts +22 -0
- package/src/points-lines/prepare.ts +9 -0
- package/src/points-lines/standard-owner.ts +403 -0
- package/src/record/__tests__/frame-targets-recovery.unit.test.ts +60 -0
- package/src/record/__tests__/main-pass-geometry.unit.test.ts +26 -1
- package/src/record/__tests__/mesh-ssbo.unit.test.ts +38 -0
- package/src/record/__tests__/recovery-pipeline.unit.test.ts +124 -0
- package/src/record/__tests__/sprite-material-abi.unit.test.ts +28 -13
- package/src/record/__tests__/standard-pbr-ubo-layout.unit.test.ts +47 -4
- package/src/record/__tests__/temporal-payload.unit.test.ts +22 -43
- package/src/record/__tests__/typed-frame-graph-plan.unit.test.ts +1 -1
- package/src/record/frame-snapshot.ts +34 -2
- package/src/record/frame-targets.ts +11 -1
- package/src/record/frame.ts +37 -4
- package/src/record/helpers.ts +1 -1
- package/src/record/main-pass-geometry.ts +727 -63
- package/src/record/main-pass-material.ts +316 -209
- package/src/record/main-pass-sprite-draws.ts +7 -8
- package/src/record/main-pass.ts +94 -6
- package/src/record/mesh-ssbo.ts +32 -10
- package/src/record/recovery-pipeline.ts +695 -0
- package/src/record/render-context.ts +39 -4
- package/src/record/shadow-pass.ts +46 -99
- package/src/record/typed-frame-graph.ts +45 -1
- package/src/record/view-ubo.ts +3 -3
- package/src/recovery/render-system-candidate.ts +876 -0
- package/src/render-contract.ts +69 -7
- package/src/render-system-extract-tail.ts +3039 -0
- package/src/render-system-extract.ts +177 -3003
- package/src/render-system.ts +906 -662
- package/src/scene/render-scene-types.ts +2 -0
- package/src/scene/render-scene.ts +703 -37
- package/src/systems/skin-palette-allocator.ts +129 -7
- package/src/temporal/frame-coordinator.ts +4 -1
- package/src/temporal/taa-history-store.ts +46 -2
- package/src/temporal/temporal-view.ts +1 -1
- package/src/temporal/transaction.ts +9 -0
- package/src/tilemap-chunk-extract-system.ts +1 -1
- package/src/transmission/__tests__/standard-transmission.dawn.test.ts +19 -12
- package/src/transmission/__tests__/surface-compatibility.integration.test.ts +32 -0
- package/dist/chunk-4L3P6DT5.mjs.map +0 -1
- package/dist/chunk-4NPUASZR.mjs +0 -203
- package/dist/chunk-4NPUASZR.mjs.map +0 -1
- package/dist/chunk-DIYW3M5D.mjs.map +0 -1
- package/dist/chunk-FBC4R44J.mjs.map +0 -1
- package/dist/chunk-FF7K3FSO.mjs.map +0 -1
- package/dist/chunk-HZUPSYW7.mjs.map +0 -1
- package/dist/chunk-QODA5UKU.mjs.map +0 -1
- package/dist/chunk-YALPS44A.mjs.map +0 -1
- package/dist/chunk-ZUWKAZ2I.mjs.map +0 -1
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import { color } from '@forgeax/engine-math';
|
|
2
|
+
import { DEFAULT_STANDARD_PBR_PARAM_SCHEMA, DEFAULT_STANDARD_SURFACE_MODULE } from '@forgeax/engine-shader';
|
|
3
|
+
import { deriveStandardLayerPlan } from '@forgeax/engine-types';
|
|
4
|
+
|
|
5
|
+
// src/materials.ts
|
|
6
|
+
var STANDARD_MATERIAL_MODULE = "forgeax_material::standard";
|
|
7
|
+
function pass(name, options, fragmentEntry) {
|
|
8
|
+
const authoredState = options.renderState ?? {};
|
|
9
|
+
const authoredRecord = authoredState;
|
|
10
|
+
const tags = authoredRecord.tags ?? {};
|
|
11
|
+
const lightMode = name === "shadow-caster" ? "ShadowCaster" : name === "forward" ? "Forward" : "Deferred";
|
|
12
|
+
return {
|
|
13
|
+
name,
|
|
14
|
+
program: {
|
|
15
|
+
module: STANDARD_MATERIAL_MODULE,
|
|
16
|
+
fragmentEntry,
|
|
17
|
+
moduleSlots: { surface: options.surfaceModule }
|
|
18
|
+
},
|
|
19
|
+
renderState: {
|
|
20
|
+
...authoredState,
|
|
21
|
+
tags: options.surfaceModule === DEFAULT_STANDARD_SURFACE_MODULE ? { LightMode: lightMode, ...tags } : {
|
|
22
|
+
...tags,
|
|
23
|
+
LightMode: lightMode,
|
|
24
|
+
SurfaceModule: options.surfaceModule,
|
|
25
|
+
SurfaceKind: options.surfaceKind ?? "standard",
|
|
26
|
+
GeometryVariant: options.geometryVariant ?? "rigid",
|
|
27
|
+
LightingLane: options.lightingLane ?? "direct",
|
|
28
|
+
AlphaClip: options.alphaClip === true ? "enabled" : "disabled"
|
|
29
|
+
},
|
|
30
|
+
...options.queue === void 0 ? {} : { queue: options.queue }
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function projectStandardSurfacePasses(options) {
|
|
35
|
+
const authoredPasses = options.declaredPasses;
|
|
36
|
+
const passNames = options.surfaceKind === "full-custom" && authoredPasses !== void 0 ? [...authoredPasses] : ["forward"];
|
|
37
|
+
if (authoredPasses === void 0 || options.surfaceKind !== "full-custom") {
|
|
38
|
+
const blended = options.renderState?.blend !== void 0;
|
|
39
|
+
if (!blended && options.layerPlan?.mode !== "physical") passNames.push("deferred");
|
|
40
|
+
if (options.castShadow !== false) passNames.push("shadow-caster");
|
|
41
|
+
}
|
|
42
|
+
const entries = passNames.map(
|
|
43
|
+
(name) => pass(
|
|
44
|
+
name,
|
|
45
|
+
options,
|
|
46
|
+
name === "forward" ? "fs_main" : name === "deferred" ? "fs_gbuffer" : "fs_shadow"
|
|
47
|
+
)
|
|
48
|
+
);
|
|
49
|
+
const passes = entries;
|
|
50
|
+
return passes;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/materials.ts
|
|
54
|
+
var MaterialTransmissionContractError = class extends Error {
|
|
55
|
+
code = "material-transmission-contract-invalid";
|
|
56
|
+
expected = "transmission material values satisfy finite ranges and Forward depth rules";
|
|
57
|
+
hint = "repair the named transmission value or pass state before publishing the material";
|
|
58
|
+
detail;
|
|
59
|
+
constructor(parameter, reason, actual) {
|
|
60
|
+
super(`Materials.standard: ${parameter} violates the transmission contract (${reason})`);
|
|
61
|
+
this.name = "MaterialTransmissionContractError";
|
|
62
|
+
this.detail = {
|
|
63
|
+
code: "material-transmission-contract-invalid",
|
|
64
|
+
material: "Standard",
|
|
65
|
+
parameter,
|
|
66
|
+
reason,
|
|
67
|
+
...actual === void 0 ? {} : { actual }
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
var SPRITE_PREMULTIPLIED_ALPHA_BLEND = {
|
|
72
|
+
color: { srcFactor: "one", dstFactor: "one-minus-src-alpha", operation: "add" },
|
|
73
|
+
alpha: { srcFactor: "one", dstFactor: "one-minus-src-alpha", operation: "add" }
|
|
74
|
+
};
|
|
75
|
+
var UNLIT_MODULE = "forgeax_material::unlit";
|
|
76
|
+
function colorHexFromNumber(value) {
|
|
77
|
+
if (!Number.isInteger(value) || value < 0 || value > 16777215) {
|
|
78
|
+
throw new Error(`material color number must be an integer in [0, 0xffffff], got ${value}`);
|
|
79
|
+
}
|
|
80
|
+
return `#${value.toString(16).padStart(6, "0")}`;
|
|
81
|
+
}
|
|
82
|
+
function linearColorFromInput(input, channels) {
|
|
83
|
+
if (typeof input === "number" || typeof input === "string") {
|
|
84
|
+
const parsed = color.create();
|
|
85
|
+
color.fromCss(parsed, typeof input === "number" ? colorHexFromNumber(input) : input);
|
|
86
|
+
return channels === 3 ? [parsed[0], parsed[1], parsed[2]] : Array.from(parsed);
|
|
87
|
+
}
|
|
88
|
+
if (input.length !== channels) {
|
|
89
|
+
throw new Error(`material color tuple must contain ${channels} channels, got ${input.length}`);
|
|
90
|
+
}
|
|
91
|
+
return [...input];
|
|
92
|
+
}
|
|
93
|
+
function srgb(input) {
|
|
94
|
+
if (input.length !== 3 && input.length !== 4) {
|
|
95
|
+
throw new Error(`sRGB material color tuple must contain 3 or 4 channels, got ${input.length}`);
|
|
96
|
+
}
|
|
97
|
+
const parsed = color.create(input[0] ?? 0, input[1] ?? 0, input[2] ?? 0, input[3] ?? 1);
|
|
98
|
+
color.srgbToLinear(parsed, parsed);
|
|
99
|
+
return input.length === 3 ? [parsed[0], parsed[1], parsed[2]] : [parsed[0], parsed[1], parsed[2], parsed[3]];
|
|
100
|
+
}
|
|
101
|
+
function authoredColorParameter(name, type, colorSpace, optional = false) {
|
|
102
|
+
return {
|
|
103
|
+
name,
|
|
104
|
+
type,
|
|
105
|
+
...{ colorSpace },
|
|
106
|
+
...optional ? { optional: true } : {}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function standardParameters(colorSpace, opts) {
|
|
110
|
+
const physicalNames = /* @__PURE__ */ new Set();
|
|
111
|
+
const addPhysical = (...names) => {
|
|
112
|
+
for (const name of names) physicalNames.add(name);
|
|
113
|
+
};
|
|
114
|
+
if (opts.clearcoat !== void 0 || opts.clearcoatRoughness !== void 0 || opts.clearcoatNormalScale !== void 0 || opts.clearcoatTexture !== void 0 || opts.clearcoatRoughnessTexture !== void 0 || opts.clearcoatNormalTexture !== void 0) {
|
|
115
|
+
addPhysical(
|
|
116
|
+
"clearcoat",
|
|
117
|
+
"clearcoatRoughness",
|
|
118
|
+
"clearcoatNormalScale",
|
|
119
|
+
...opts.clearcoatTexture === void 0 ? [] : ["clearcoatTexture"],
|
|
120
|
+
...opts.clearcoatRoughnessTexture === void 0 ? [] : ["clearcoatRoughnessTexture"],
|
|
121
|
+
...opts.clearcoatNormalTexture === void 0 ? [] : ["clearcoatNormalTexture"]
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
if (opts.anisotropyStrength !== void 0 || opts.anisotropyRotation !== void 0 || opts.anisotropyTexture !== void 0) {
|
|
125
|
+
addPhysical("anisotropyStrength", "anisotropyRotation");
|
|
126
|
+
if (opts.anisotropyTexture !== void 0) addPhysical("anisotropyTexture");
|
|
127
|
+
}
|
|
128
|
+
if (opts.sheenColor !== void 0 || opts.sheenRoughness !== void 0 || opts.sheenColorTexture !== void 0 || opts.sheenRoughnessTexture !== void 0) {
|
|
129
|
+
addPhysical("sheenColor", "sheenRoughness");
|
|
130
|
+
if (opts.sheenColorTexture !== void 0) addPhysical("sheenColorTexture");
|
|
131
|
+
if (opts.sheenRoughnessTexture !== void 0) addPhysical("sheenRoughnessTexture");
|
|
132
|
+
}
|
|
133
|
+
if (opts.iridescence !== void 0 || opts.iridescenceIor !== void 0 || opts.iridescenceThicknessMinimum !== void 0 || opts.iridescenceThicknessMaximum !== void 0 || opts.iridescenceTexture !== void 0 || opts.iridescenceThicknessTexture !== void 0) {
|
|
134
|
+
addPhysical(
|
|
135
|
+
"iridescence",
|
|
136
|
+
"iridescenceIor",
|
|
137
|
+
"iridescenceThicknessMinimum",
|
|
138
|
+
"iridescenceThicknessMaximum",
|
|
139
|
+
...opts.iridescenceTexture === void 0 ? [] : ["iridescenceTexture"],
|
|
140
|
+
...opts.iridescenceThicknessTexture === void 0 ? [] : ["iridescenceThicknessTexture"]
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
const baseNames = /* @__PURE__ */ new Set([
|
|
144
|
+
"baseColor",
|
|
145
|
+
"metallic",
|
|
146
|
+
"roughness",
|
|
147
|
+
"metallicChannel",
|
|
148
|
+
"roughnessChannel",
|
|
149
|
+
"aoChannel",
|
|
150
|
+
"extraChannel",
|
|
151
|
+
"emissive",
|
|
152
|
+
"emissiveIntensity",
|
|
153
|
+
"occlusionStrength",
|
|
154
|
+
"alphaCutoff",
|
|
155
|
+
"normalScale",
|
|
156
|
+
"baseColorTexture",
|
|
157
|
+
"metallicRoughnessTexture",
|
|
158
|
+
"normalTexture",
|
|
159
|
+
"emissiveTexture",
|
|
160
|
+
"occlusionTexture",
|
|
161
|
+
"specular",
|
|
162
|
+
"specularColor",
|
|
163
|
+
// IOR is part of the always-present dielectric F0 contract. The
|
|
164
|
+
// transmission layer may be absent, but the Standard shader still
|
|
165
|
+
// consumes this scalar for the base reflection path.
|
|
166
|
+
"ior"
|
|
167
|
+
]);
|
|
168
|
+
if (opts.specularTexture !== void 0) baseNames.add("specularTexture");
|
|
169
|
+
if (opts.specularColorTexture !== void 0) baseNames.add("specularColorTexture");
|
|
170
|
+
if (opts.transmission !== void 0 || opts.ior !== void 0 || opts.thickness !== void 0 || opts.transmissionTexture !== void 0 || opts.thicknessTexture !== void 0 || opts.attenuationColor !== void 0 || opts.attenuationDistance !== void 0) {
|
|
171
|
+
for (const name of [
|
|
172
|
+
"transmission",
|
|
173
|
+
"ior",
|
|
174
|
+
"thickness",
|
|
175
|
+
"attenuationColor",
|
|
176
|
+
"attenuationDistance",
|
|
177
|
+
"transmissionTexture",
|
|
178
|
+
"thicknessTexture"
|
|
179
|
+
]) {
|
|
180
|
+
baseNames.add(name);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const availableSchema = DEFAULT_STANDARD_PBR_PARAM_SCHEMA;
|
|
184
|
+
const numericSchema = availableSchema.filter((entry) => !entry.type.startsWith("texture"));
|
|
185
|
+
const textureSchema = availableSchema.filter((entry) => entry.type.startsWith("texture"));
|
|
186
|
+
const orderedSchema = [...numericSchema, ...textureSchema];
|
|
187
|
+
return orderedSchema.filter((entry) => baseNames.has(entry.name) || physicalNames.has(entry.name)).map((entry) => {
|
|
188
|
+
const type = entry.type.startsWith("texture") ? "texture" : entry.type;
|
|
189
|
+
const isRequired = entry.name === "baseColor" || entry.name === "metallic" || entry.name === "roughness";
|
|
190
|
+
const authoredColor = entry.type === "color" || entry.type === "vec3" && entry.name !== "attenuationColor";
|
|
191
|
+
const schemaColorSpace = "colorSpace" in entry ? entry.colorSpace : void 0;
|
|
192
|
+
const colorSpaceProjection = {};
|
|
193
|
+
if (authoredColor && true) {
|
|
194
|
+
colorSpaceProjection.colorSpace = colorSpace;
|
|
195
|
+
} else if (!authoredColor && schemaColorSpace !== void 0) {
|
|
196
|
+
colorSpaceProjection.colorSpace = schemaColorSpace;
|
|
197
|
+
}
|
|
198
|
+
return {
|
|
199
|
+
name: entry.name,
|
|
200
|
+
type,
|
|
201
|
+
...colorSpaceProjection,
|
|
202
|
+
...isRequired ? {} : { optional: true }
|
|
203
|
+
};
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
function unlitParameters(colorSpace) {
|
|
207
|
+
return [
|
|
208
|
+
authoredColorParameter("baseColor", "color", colorSpace),
|
|
209
|
+
{ name: "alphaCutoff", type: "f32", optional: true },
|
|
210
|
+
{ name: "baseColorTexture", type: "texture", optional: true }
|
|
211
|
+
];
|
|
212
|
+
}
|
|
213
|
+
function pass2(name, module, renderState, fragmentEntry, queue) {
|
|
214
|
+
const lightMode = name === "shadow-caster" ? "ShadowCaster" : name === "deferred" ? "Deferred" : "Forward";
|
|
215
|
+
const authoredState = renderState ?? {};
|
|
216
|
+
const authoredTags = authoredState.tags;
|
|
217
|
+
return {
|
|
218
|
+
name,
|
|
219
|
+
program: {
|
|
220
|
+
module,
|
|
221
|
+
...{}
|
|
222
|
+
},
|
|
223
|
+
renderState: {
|
|
224
|
+
...authoredState,
|
|
225
|
+
tags: { LightMode: lightMode, ...authoredTags },
|
|
226
|
+
...queue === void 0 ? {} : { queue }
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
function shadowCasterRenderState(renderState) {
|
|
231
|
+
if (renderState?.cullMode === void 0 && renderState?.frontFace === void 0) return void 0;
|
|
232
|
+
return {
|
|
233
|
+
...renderState.cullMode === void 0 ? {} : { cullMode: renderState.cullMode },
|
|
234
|
+
...renderState.frontFace === void 0 ? {} : { frontFace: renderState.frontFace }
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
function unlit(rgba, opts) {
|
|
238
|
+
if (opts?.alphaCutoff !== void 0 && (opts.alphaCutoff < 0 || opts.alphaCutoff > 1)) {
|
|
239
|
+
throw new Error(`Materials.unlit: alphaCutoff must be in [0, 1], got ${opts.alphaCutoff}`);
|
|
240
|
+
}
|
|
241
|
+
const values = { baseColor: linearColorFromInput(rgba, 4) };
|
|
242
|
+
if (opts?.baseColorTexture !== void 0) values.baseColorTexture = opts.baseColorTexture;
|
|
243
|
+
if (opts?.alphaCutoff !== void 0) values.alphaCutoff = opts.alphaCutoff;
|
|
244
|
+
const passes = [
|
|
245
|
+
pass2("forward", UNLIT_MODULE, opts?.renderState, void 0, opts?.queue)
|
|
246
|
+
];
|
|
247
|
+
if (opts?.castShadow !== false) {
|
|
248
|
+
passes.push(pass2("shadow-caster", UNLIT_MODULE, shadowCasterRenderState(opts?.renderState)));
|
|
249
|
+
}
|
|
250
|
+
return {
|
|
251
|
+
kind: "material",
|
|
252
|
+
colorSpace: "linear",
|
|
253
|
+
passes,
|
|
254
|
+
parameters: unlitParameters("linear"),
|
|
255
|
+
values
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
function validateChannel(name, value) {
|
|
259
|
+
if (value !== void 0 && (!Number.isInteger(value) || value < 0 || value > 3)) {
|
|
260
|
+
throw new Error(`Materials.standard: ${name} must be an integer in [0, 3], got ${value}`);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
function validateFiniteRange(name, value, minimum, maximum) {
|
|
264
|
+
if (value === void 0 || !Number.isFinite(value)) {
|
|
265
|
+
if (value === void 0) return;
|
|
266
|
+
throw new MaterialTransmissionContractError(name, "non-finite", value);
|
|
267
|
+
}
|
|
268
|
+
if (value < minimum || maximum !== void 0 && value > maximum) {
|
|
269
|
+
throw new MaterialTransmissionContractError(name, "range", value);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
function standardDefault(opts) {
|
|
273
|
+
const occlusionStrength = opts.occlusionStrength ?? 1;
|
|
274
|
+
if (occlusionStrength < 0 || occlusionStrength > 1) {
|
|
275
|
+
throw new Error(
|
|
276
|
+
`Materials.standard: occlusionStrength must be in [0, 1], got ${occlusionStrength}`
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
if (opts.alphaCutoff !== void 0 && (opts.alphaCutoff < 0 || opts.alphaCutoff > 1)) {
|
|
280
|
+
throw new Error(`Materials.standard: alphaCutoff must be in [0, 1], got ${opts.alphaCutoff}`);
|
|
281
|
+
}
|
|
282
|
+
validateChannel("metallicChannel", opts.metallicChannel);
|
|
283
|
+
validateChannel("roughnessChannel", opts.roughnessChannel);
|
|
284
|
+
const transmission = opts.transmission ?? 0;
|
|
285
|
+
const ior = opts.ior ?? 1.5;
|
|
286
|
+
const thickness = opts.thickness ?? 0;
|
|
287
|
+
const attenuationColor = opts.attenuationColor ?? [1, 1, 1];
|
|
288
|
+
validateFiniteRange("transmission", transmission, 0, 1);
|
|
289
|
+
validateFiniteRange("ior", ior, 1);
|
|
290
|
+
validateFiniteRange("thickness", thickness, 0);
|
|
291
|
+
validateFiniteRange("attenuationDistance", opts.attenuationDistance, Number.MIN_VALUE);
|
|
292
|
+
if (attenuationColor.length !== 3 || attenuationColor.some((value) => !Number.isFinite(value) || value < 0 || value > 1)) {
|
|
293
|
+
throw new MaterialTransmissionContractError("attenuationColor", "shape", attenuationColor);
|
|
294
|
+
}
|
|
295
|
+
if (transmission > 0 && opts.renderState?.blend !== void 0) {
|
|
296
|
+
throw new MaterialTransmissionContractError("transmission", "blend", opts.renderState.blend);
|
|
297
|
+
}
|
|
298
|
+
if (transmission > 0 && opts.renderState?.depthWriteEnabled === true) {
|
|
299
|
+
throw new MaterialTransmissionContractError("transmission", "depth-write", true);
|
|
300
|
+
}
|
|
301
|
+
const values = {
|
|
302
|
+
baseColor: linearColorFromInput(opts.baseColor, 4),
|
|
303
|
+
metallic: opts.metallic ?? 0,
|
|
304
|
+
roughness: opts.roughness ?? 0.5,
|
|
305
|
+
occlusionStrength,
|
|
306
|
+
specular: opts.specular ?? 1,
|
|
307
|
+
specularColor: opts.specularColor === void 0 ? [1, 1, 1] : linearColorFromInput(opts.specularColor, 3),
|
|
308
|
+
transmission,
|
|
309
|
+
ior,
|
|
310
|
+
thickness,
|
|
311
|
+
attenuationColor
|
|
312
|
+
};
|
|
313
|
+
if (opts.metallicChannel !== void 0) values.metallicChannel = opts.metallicChannel;
|
|
314
|
+
if (opts.roughnessChannel !== void 0) values.roughnessChannel = opts.roughnessChannel;
|
|
315
|
+
if (opts.clearcoat !== void 0) values.clearcoat = opts.clearcoat;
|
|
316
|
+
if (opts.clearcoatRoughness !== void 0) values.clearcoatRoughness = opts.clearcoatRoughness;
|
|
317
|
+
if (opts.clearcoatTexture !== void 0) values.clearcoatTexture = opts.clearcoatTexture;
|
|
318
|
+
if (opts.clearcoatRoughnessTexture !== void 0) {
|
|
319
|
+
values.clearcoatRoughnessTexture = opts.clearcoatRoughnessTexture;
|
|
320
|
+
}
|
|
321
|
+
if (opts.clearcoatNormalTexture !== void 0) {
|
|
322
|
+
values.clearcoatNormalTexture = opts.clearcoatNormalTexture;
|
|
323
|
+
}
|
|
324
|
+
if (opts.clearcoatNormalScale !== void 0)
|
|
325
|
+
values.clearcoatNormalScale = opts.clearcoatNormalScale;
|
|
326
|
+
if (opts.anisotropyStrength !== void 0) values.anisotropyStrength = opts.anisotropyStrength;
|
|
327
|
+
if (opts.anisotropyRotation !== void 0) values.anisotropyRotation = opts.anisotropyRotation;
|
|
328
|
+
if (opts.anisotropyTexture !== void 0) values.anisotropyTexture = opts.anisotropyTexture;
|
|
329
|
+
if (opts.sheenColor !== void 0) values.sheenColor = linearColorFromInput(opts.sheenColor, 3);
|
|
330
|
+
if (opts.sheenRoughness !== void 0) values.sheenRoughness = opts.sheenRoughness;
|
|
331
|
+
if (opts.sheenColorTexture !== void 0) values.sheenColorTexture = opts.sheenColorTexture;
|
|
332
|
+
if (opts.sheenRoughnessTexture !== void 0) {
|
|
333
|
+
values.sheenRoughnessTexture = opts.sheenRoughnessTexture;
|
|
334
|
+
}
|
|
335
|
+
if (opts.iridescence !== void 0) values.iridescence = opts.iridescence;
|
|
336
|
+
if (opts.iridescenceIor !== void 0) values.iridescenceIor = opts.iridescenceIor;
|
|
337
|
+
if (opts.iridescenceThicknessMinimum !== void 0) {
|
|
338
|
+
values.iridescenceThicknessMinimum = opts.iridescenceThicknessMinimum;
|
|
339
|
+
}
|
|
340
|
+
if (opts.iridescenceThicknessMaximum !== void 0) {
|
|
341
|
+
values.iridescenceThicknessMaximum = opts.iridescenceThicknessMaximum;
|
|
342
|
+
}
|
|
343
|
+
if (opts.iridescenceTexture !== void 0) values.iridescenceTexture = opts.iridescenceTexture;
|
|
344
|
+
if (opts.iridescenceThicknessTexture !== void 0) {
|
|
345
|
+
values.iridescenceThicknessTexture = opts.iridescenceThicknessTexture;
|
|
346
|
+
}
|
|
347
|
+
if (opts.emissive !== void 0) values.emissive = linearColorFromInput(opts.emissive, 3);
|
|
348
|
+
if (opts.emissiveIntensity !== void 0) values.emissiveIntensity = opts.emissiveIntensity;
|
|
349
|
+
if (opts.emissiveTexture !== void 0) values.emissiveTexture = opts.emissiveTexture;
|
|
350
|
+
if (opts.baseColorTexture !== void 0) values.baseColorTexture = opts.baseColorTexture;
|
|
351
|
+
if (opts.metallicRoughnessTexture !== void 0) {
|
|
352
|
+
values.metallicRoughnessTexture = opts.metallicRoughnessTexture;
|
|
353
|
+
}
|
|
354
|
+
if (opts.normalTexture !== void 0) values.normalTexture = opts.normalTexture;
|
|
355
|
+
if (opts.occlusionTexture !== void 0) values.occlusionTexture = opts.occlusionTexture;
|
|
356
|
+
if (opts.specularTexture !== void 0) values.specularTexture = opts.specularTexture;
|
|
357
|
+
if (opts.specularColorTexture !== void 0) {
|
|
358
|
+
values.specularColorTexture = opts.specularColorTexture;
|
|
359
|
+
}
|
|
360
|
+
if (opts.alphaCutoff !== void 0) values.alphaCutoff = opts.alphaCutoff;
|
|
361
|
+
if (opts.transmissionTexture !== void 0) values.transmissionTexture = opts.transmissionTexture;
|
|
362
|
+
if (opts.thicknessTexture !== void 0) values.thicknessTexture = opts.thicknessTexture;
|
|
363
|
+
if (opts.attenuationDistance !== void 0) values.attenuationDistance = opts.attenuationDistance;
|
|
364
|
+
const forwardRenderState = transmission > 0 ? { ...opts.renderState ?? {}, depthWriteEnabled: false } : opts.renderState;
|
|
365
|
+
const parameters = standardParameters("linear", opts);
|
|
366
|
+
const declaredNames = new Set(parameters.map((parameter) => parameter.name));
|
|
367
|
+
for (const name of Object.keys(values)) {
|
|
368
|
+
if (!declaredNames.has(name)) delete values[name];
|
|
369
|
+
}
|
|
370
|
+
const layerPlan = deriveStandardLayerPlan(parameters);
|
|
371
|
+
const projected = projectStandardSurfacePasses({
|
|
372
|
+
surfaceModule: DEFAULT_STANDARD_SURFACE_MODULE,
|
|
373
|
+
...forwardRenderState === void 0 ? {} : { renderState: forwardRenderState },
|
|
374
|
+
...opts.castShadow === void 0 ? {} : { castShadow: opts.castShadow },
|
|
375
|
+
...opts.queue === void 0 ? {} : { queue: opts.queue },
|
|
376
|
+
layerPlan
|
|
377
|
+
});
|
|
378
|
+
const passes = transmission > 0 ? projected.filter((entry) => entry.name !== "deferred") : projected;
|
|
379
|
+
return {
|
|
380
|
+
kind: "material",
|
|
381
|
+
colorSpace: "linear",
|
|
382
|
+
passes,
|
|
383
|
+
parameters,
|
|
384
|
+
values
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
function standardCustom(opts) {
|
|
388
|
+
const layerPlan = deriveStandardLayerPlan(
|
|
389
|
+
opts.parameters.filter((parameter) => parameter.optional !== true)
|
|
390
|
+
);
|
|
391
|
+
return {
|
|
392
|
+
kind: "material",
|
|
393
|
+
...opts.colorSpace === void 0 || opts.colorSpace === "srgb" ? {} : { colorSpace: opts.colorSpace },
|
|
394
|
+
passes: projectStandardSurfacePasses({
|
|
395
|
+
surfaceModule: opts.surfaceModule,
|
|
396
|
+
values: opts.values,
|
|
397
|
+
...opts.renderState === void 0 ? {} : { renderState: opts.renderState },
|
|
398
|
+
...opts.castShadow === void 0 ? {} : { castShadow: opts.castShadow },
|
|
399
|
+
...opts.queue === void 0 ? {} : { queue: opts.queue },
|
|
400
|
+
layerPlan
|
|
401
|
+
}),
|
|
402
|
+
parameters: opts.parameters,
|
|
403
|
+
values: opts.values
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
function standard(options) {
|
|
407
|
+
return options.surfaceModule === void 0 ? standardDefault(options) : standardCustom(options);
|
|
408
|
+
}
|
|
409
|
+
var Materials = { unlit, standard, srgb };
|
|
410
|
+
|
|
411
|
+
export { MaterialTransmissionContractError, Materials, SPRITE_PREMULTIPLIED_ALPHA_BLEND, srgb };
|
|
412
|
+
//# sourceMappingURL=chunk-JSEDTZYS.mjs.map
|
|
413
|
+
//# sourceMappingURL=chunk-JSEDTZYS.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/assembly/material/surface-projection.ts","../src/materials.ts"],"names":["pass"],"mappings":";;;;;AAQO,IAAM,wBAAA,GAA2B,4BAAA;AAsBxC,SAAS,IAAA,CACP,IAAA,EACA,OAAA,EACA,aAAA,EACc;AACd,EAAA,MAAM,aAAA,GAAgB,OAAA,CAAQ,WAAA,IAAe,EAAC;AAC9C,EAAA,MAAM,cAAA,GAAiB,aAAA;AACvB,EAAA,MAAM,IAAA,GAAQ,cAAA,CAAe,IAAA,IAAQ,EAAC;AACtC,EAAA,MAAM,YACJ,IAAA,KAAS,eAAA,GAAkB,cAAA,GAAiB,IAAA,KAAS,YAAY,SAAA,GAAY,UAAA;AAC/E,EAAA,OAAO;AAAA,IACL,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A,OAAO,QAAQ,aAAA,KAAkB,MAAA,GAAY,gBAAgB,OAAO,CAAA,GAAI,eAAe,OAAO,CAAA;AAChG;AAEO,IAAM,SAAA,GAAY,EAAE,KAAA,EAAO,QAAA,EAAU,IAAA","file":"chunk-JSEDTZYS.mjs","sourcesContent":["import { DEFAULT_STANDARD_SURFACE_MODULE } from '@forgeax/engine-shader';\nimport type {\n MaterialPass,\n MaterialRenderState,\n MaterialValue,\n StandardLayerPlan,\n} from '@forgeax/engine-types';\n\nexport const STANDARD_MATERIAL_MODULE = 'forgeax_material::standard';\nexport { DEFAULT_STANDARD_SURFACE_MODULE };\n\nexport type StandardSurfacePassName = 'forward' | 'deferred' | 'shadow-caster';\nexport type StandardSurfaceGeometryVariant = 'rigid' | 'skinned' | 'instanced';\nexport type StandardSurfaceLightingLane = 'direct' | 'clustered';\nexport type StandardSurfaceKind = 'standard' | 'full-custom';\n\nexport interface StandardSurfaceProjectionOptions {\n readonly surfaceModule: string;\n readonly values: Readonly<Record<string, MaterialValue | null>>;\n readonly renderState?: MaterialRenderState;\n readonly castShadow?: boolean;\n readonly queue?: number;\n readonly geometryVariant?: StandardSurfaceGeometryVariant;\n readonly lightingLane?: StandardSurfaceLightingLane;\n readonly alphaClip?: boolean;\n readonly surfaceKind?: StandardSurfaceKind;\n readonly declaredPasses?: readonly StandardSurfacePassName[];\n readonly layerPlan?: StandardLayerPlan;\n}\n\nfunction pass(\n name: StandardSurfacePassName,\n options: StandardSurfaceProjectionOptions,\n fragmentEntry: string,\n): MaterialPass {\n const authoredState = options.renderState ?? {};\n const authoredRecord = authoredState as Readonly<Record<string, unknown>>;\n const tags = (authoredRecord.tags ?? {}) as Readonly<Record<string, string>>;\n const lightMode =\n name === 'shadow-caster' ? 'ShadowCaster' : name === 'forward' ? 'Forward' : 'Deferred';\n return {\n name,\n program: {\n module: STANDARD_MATERIAL_MODULE,\n fragmentEntry,\n moduleSlots: { surface: options.surfaceModule },\n },\n renderState: {\n ...authoredState,\n tags:\n options.surfaceModule === DEFAULT_STANDARD_SURFACE_MODULE\n ? { LightMode: lightMode, ...tags }\n : {\n ...tags,\n LightMode: lightMode,\n SurfaceModule: options.surfaceModule,\n SurfaceKind: options.surfaceKind ?? 'standard',\n GeometryVariant: options.geometryVariant ?? 'rigid',\n LightingLane: options.lightingLane ?? 'direct',\n AlphaClip: options.alphaClip === true ? 'enabled' : 'disabled',\n },\n ...(options.queue === undefined ? {} : { queue: options.queue }),\n },\n };\n}\n\n/** Project one custom or default Surface into the existing Standard pass family. */\nexport function projectStandardSurfacePasses(\n options: StandardSurfaceProjectionOptions,\n): [MaterialPass, ...MaterialPass[]] {\n const authoredPasses = options.declaredPasses;\n const passNames: StandardSurfacePassName[] =\n options.surfaceKind === 'full-custom' && authoredPasses !== undefined\n ? [...authoredPasses]\n : (['forward'] as StandardSurfacePassName[]);\n if (authoredPasses === undefined || options.surfaceKind !== 'full-custom') {\n const blended = options.renderState?.blend !== undefined;\n if (!blended && options.layerPlan?.mode !== 'physical') passNames.push('deferred');\n if (options.castShadow !== false) passNames.push('shadow-caster');\n }\n const entries = passNames.map((name) =>\n pass(\n name,\n options,\n name === 'forward' ? 'fs_main' : name === 'deferred' ? 'fs_gbuffer' : 'fs_shadow',\n ),\n );\n const passes = entries as [MaterialPass, ...MaterialPass[]];\n return passes;\n}\n","import { color } from '@forgeax/engine-math';\nimport { DEFAULT_STANDARD_PBR_PARAM_SCHEMA } from '@forgeax/engine-shader';\nimport type {\n MaterialAsset,\n MaterialColorSpace,\n MaterialParameter,\n MaterialPass,\n MaterialRenderState,\n MaterialValue,\n} from '@forgeax/engine-types';\nimport { deriveStandardLayerPlan } from '@forgeax/engine-types';\nimport {\n DEFAULT_STANDARD_SURFACE_MODULE,\n projectStandardSurfacePasses,\n} from './assembly/material/surface-projection';\n\nexport type MaterialTransmissionValidationReason =\n | 'non-finite'\n | 'range'\n | 'shape'\n | 'blend'\n | 'depth-write';\n\n/** Structured authoring failure for the Standard transmission contract. */\nexport class MaterialTransmissionContractError extends Error {\n readonly code = 'material-transmission-contract-invalid' as const;\n readonly expected = 'transmission material values satisfy finite ranges and Forward depth rules';\n readonly hint =\n 'repair the named transmission value or pass state before publishing the material';\n readonly detail: {\n readonly code: 'material-transmission-contract-invalid';\n readonly material: 'Standard';\n readonly parameter:\n | 'transmission'\n | 'ior'\n | 'thickness'\n | 'attenuationColor'\n | 'attenuationDistance';\n readonly reason: MaterialTransmissionValidationReason;\n readonly actual?: unknown;\n };\n\n constructor(\n parameter: (typeof MaterialTransmissionContractError.prototype.detail)['parameter'],\n reason: MaterialTransmissionValidationReason,\n actual?: unknown,\n ) {\n super(`Materials.standard: ${parameter} violates the transmission contract (${reason})`);\n this.name = 'MaterialTransmissionContractError';\n this.detail = {\n code: 'material-transmission-contract-invalid',\n material: 'Standard',\n parameter,\n reason,\n ...(actual === undefined ? {} : { actual }),\n };\n }\n}\n\nexport const SPRITE_PREMULTIPLIED_ALPHA_BLEND: GPUBlendState = {\n color: { srcFactor: 'one', dstFactor: 'one-minus-src-alpha', operation: 'add' },\n alpha: { srcFactor: 'one', dstFactor: 'one-minus-src-alpha', operation: 'add' },\n};\n\nconst UNLIT_MODULE = 'forgeax_material::unlit';\nconst SPRITE_MODULE = 'forgeax_material::sprite';\n\nexport type MaterialColorTuple3 = readonly [number, number, number];\nexport type MaterialColorTuple4 = readonly [number, number, number, number];\nexport type MaterialColorInput3 = MaterialColorTuple3 | string | number;\nexport type MaterialColorInput4 = MaterialColorTuple4 | string | number;\n\nfunction colorHexFromNumber(value: number): string {\n if (!Number.isInteger(value) || value < 0 || value > 0xffffff) {\n throw new Error(`material color number must be an integer in [0, 0xffffff], got ${value}`);\n }\n return `#${value.toString(16).padStart(6, '0')}`;\n}\n\nfunction linearColorFromInput(\n input: MaterialColorInput3 | MaterialColorInput4,\n channels: 3 | 4,\n): readonly number[] {\n if (typeof input === 'number' || typeof input === 'string') {\n const parsed = color.create();\n color.fromCss(parsed, typeof input === 'number' ? colorHexFromNumber(input) : input);\n return channels === 3\n ? [parsed[0] as number, parsed[1] as number, parsed[2] as number]\n : Array.from(parsed);\n }\n if (input.length !== channels) {\n throw new Error(`material color tuple must contain ${channels} channels, got ${input.length}`);\n }\n return [...input];\n}\n\n/** Convert an explicit sRGB numeric tuple into the linear tuple factories store. */\nexport function srgb(input: MaterialColorTuple3): MaterialColorTuple3;\nexport function srgb(input: MaterialColorTuple4): MaterialColorTuple4;\nexport function srgb(input: readonly number[]): readonly number[] {\n if (input.length !== 3 && input.length !== 4) {\n throw new Error(`sRGB material color tuple must contain 3 or 4 channels, got ${input.length}`);\n }\n const parsed = color.create(input[0] ?? 0, input[1] ?? 0, input[2] ?? 0, input[3] ?? 1);\n color.srgbToLinear(parsed, parsed);\n return input.length === 3\n ? [parsed[0] as number, parsed[1] as number, parsed[2] as number]\n : [parsed[0] as number, parsed[1] as number, parsed[2] as number, parsed[3] as number];\n}\n\nfunction authoredColorParameter(\n name: string,\n type: 'color' | 'vec3',\n colorSpace: MaterialColorSpace,\n optional = false,\n): MaterialParameter {\n return {\n name,\n type,\n ...(type === 'color' && colorSpace === 'srgb' ? {} : { colorSpace }),\n ...(optional ? { optional: true } : {}),\n };\n}\n\nfunction standardParameters(\n colorSpace: MaterialColorSpace,\n opts: StandardOpts,\n): readonly MaterialParameter[] {\n const physicalNames = new Set<string>();\n const addPhysical = (...names: readonly string[]) => {\n for (const name of names) physicalNames.add(name);\n };\n if (\n opts.clearcoat !== undefined ||\n opts.clearcoatRoughness !== undefined ||\n opts.clearcoatNormalScale !== undefined ||\n opts.clearcoatTexture !== undefined ||\n opts.clearcoatRoughnessTexture !== undefined ||\n opts.clearcoatNormalTexture !== undefined\n ) {\n addPhysical(\n 'clearcoat',\n 'clearcoatRoughness',\n 'clearcoatNormalScale',\n ...(opts.clearcoatTexture === undefined ? [] : ['clearcoatTexture']),\n ...(opts.clearcoatRoughnessTexture === undefined ? [] : ['clearcoatRoughnessTexture']),\n ...(opts.clearcoatNormalTexture === undefined ? [] : ['clearcoatNormalTexture']),\n );\n }\n if (\n opts.anisotropyStrength !== undefined ||\n opts.anisotropyRotation !== undefined ||\n opts.anisotropyTexture !== undefined\n ) {\n addPhysical('anisotropyStrength', 'anisotropyRotation');\n if (opts.anisotropyTexture !== undefined) addPhysical('anisotropyTexture');\n }\n if (\n opts.sheenColor !== undefined ||\n opts.sheenRoughness !== undefined ||\n opts.sheenColorTexture !== undefined ||\n opts.sheenRoughnessTexture !== undefined\n ) {\n addPhysical('sheenColor', 'sheenRoughness');\n if (opts.sheenColorTexture !== undefined) addPhysical('sheenColorTexture');\n if (opts.sheenRoughnessTexture !== undefined) addPhysical('sheenRoughnessTexture');\n }\n if (\n opts.iridescence !== undefined ||\n opts.iridescenceIor !== undefined ||\n opts.iridescenceThicknessMinimum !== undefined ||\n opts.iridescenceThicknessMaximum !== undefined ||\n opts.iridescenceTexture !== undefined ||\n opts.iridescenceThicknessTexture !== undefined\n ) {\n addPhysical(\n 'iridescence',\n 'iridescenceIor',\n 'iridescenceThicknessMinimum',\n 'iridescenceThicknessMaximum',\n ...(opts.iridescenceTexture === undefined ? [] : ['iridescenceTexture']),\n ...(opts.iridescenceThicknessTexture === undefined ? [] : ['iridescenceThicknessTexture']),\n );\n }\n const baseNames = new Set([\n 'baseColor',\n 'metallic',\n 'roughness',\n 'metallicChannel',\n 'roughnessChannel',\n 'aoChannel',\n 'extraChannel',\n 'emissive',\n 'emissiveIntensity',\n 'occlusionStrength',\n 'alphaCutoff',\n 'normalScale',\n 'baseColorTexture',\n 'metallicRoughnessTexture',\n 'normalTexture',\n 'emissiveTexture',\n 'occlusionTexture',\n 'specular',\n 'specularColor',\n // IOR is part of the always-present dielectric F0 contract. The\n // transmission layer may be absent, but the Standard shader still\n // consumes this scalar for the base reflection path.\n 'ior',\n ]);\n if (opts.specularTexture !== undefined) baseNames.add('specularTexture');\n if (opts.specularColorTexture !== undefined) baseNames.add('specularColorTexture');\n if (\n opts.transmission !== undefined ||\n opts.ior !== undefined ||\n opts.thickness !== undefined ||\n opts.transmissionTexture !== undefined ||\n opts.thicknessTexture !== undefined ||\n opts.attenuationColor !== undefined ||\n opts.attenuationDistance !== undefined\n ) {\n for (const name of [\n 'transmission',\n 'ior',\n 'thickness',\n 'attenuationColor',\n 'attenuationDistance',\n 'transmissionTexture',\n 'thicknessTexture',\n ]) {\n baseNames.add(name);\n }\n }\n // All Standard fields come from one root schema. Physical fields are\n // projected by the authored option membership above; appending a second\n // physical schema would create a parallel ABI authority.\n const availableSchema = DEFAULT_STANDARD_PBR_PARAM_SCHEMA;\n // Keep the generated Standard UBO's numeric run contiguous before any\n // texture coordinate records. The built-in WGSL places the complete\n // physical root (including clearcoat scalars) after the base numeric run\n // and before all coordinate pairs; appending physical entries after the\n // base texture records would otherwise derive a different ABI.\n const numericSchema = availableSchema.filter((entry) => !entry.type.startsWith('texture'));\n const textureSchema = availableSchema.filter((entry) => entry.type.startsWith('texture'));\n const orderedSchema = [...numericSchema, ...textureSchema];\n return orderedSchema\n .filter((entry) => baseNames.has(entry.name) || physicalNames.has(entry.name))\n .map((entry) => {\n const type = entry.type.startsWith('texture') ? 'texture' : entry.type;\n const isRequired =\n entry.name === 'baseColor' || entry.name === 'metallic' || entry.name === 'roughness';\n const authoredColor =\n entry.type === 'color' || (entry.type === 'vec3' && entry.name !== 'attenuationColor');\n const schemaColorSpace = 'colorSpace' in entry ? entry.colorSpace : undefined;\n const colorSpaceProjection: { colorSpace?: MaterialColorSpace } = {};\n if (authoredColor && !(type === 'color' && colorSpace === 'srgb')) {\n colorSpaceProjection.colorSpace = colorSpace;\n } else if (!authoredColor && schemaColorSpace !== undefined) {\n colorSpaceProjection.colorSpace = schemaColorSpace;\n }\n return {\n name: entry.name,\n type,\n ...colorSpaceProjection,\n ...(isRequired ? {} : { optional: true }),\n } as MaterialParameter;\n });\n}\n\nfunction unlitParameters(colorSpace: MaterialColorSpace): readonly MaterialParameter[] {\n return [\n authoredColorParameter('baseColor', 'color', colorSpace),\n { name: 'alphaCutoff', type: 'f32', optional: true },\n { name: 'baseColorTexture', type: 'texture', optional: true },\n ];\n}\n\nfunction pass(\n name: string,\n module: string,\n renderState: MaterialRenderState | undefined,\n fragmentEntry?: string,\n queue?: number,\n): MaterialPass {\n const lightMode =\n name === 'shadow-caster' ? 'ShadowCaster' : name === 'deferred' ? 'Deferred' : 'Forward';\n const authoredState = (renderState ?? {}) as Readonly<Record<string, unknown>>;\n const authoredTags = authoredState.tags as Readonly<Record<string, string>> | undefined;\n return {\n name,\n program: {\n module,\n ...(fragmentEntry === undefined ? {} : { fragmentEntry }),\n },\n renderState: {\n ...authoredState,\n tags: { LightMode: lightMode, ...authoredTags },\n ...(queue === undefined ? {} : { queue }),\n },\n };\n}\n\nfunction shadowCasterRenderState(\n renderState: MaterialRenderState | undefined,\n): MaterialRenderState | undefined {\n if (renderState?.cullMode === undefined && renderState?.frontFace === undefined) return undefined;\n return {\n ...(renderState.cullMode === undefined ? {} : { cullMode: renderState.cullMode }),\n ...(renderState.frontFace === undefined ? {} : { frontFace: renderState.frontFace }),\n };\n}\n\ninterface UnlitOpts {\n readonly castShadow?: boolean;\n readonly baseColorTexture?: MaterialValue;\n readonly alphaCutoff?: number;\n readonly renderState?: MaterialRenderState;\n readonly queue?: number;\n}\n\nfunction unlit(rgba: MaterialColorInput4, opts?: UnlitOpts): MaterialAsset {\n if (opts?.alphaCutoff !== undefined && (opts.alphaCutoff < 0 || opts.alphaCutoff > 1)) {\n throw new Error(`Materials.unlit: alphaCutoff must be in [0, 1], got ${opts.alphaCutoff}`);\n }\n const values: Record<string, MaterialValue> = { baseColor: linearColorFromInput(rgba, 4) };\n if (opts?.baseColorTexture !== undefined) values.baseColorTexture = opts.baseColorTexture;\n if (opts?.alphaCutoff !== undefined) values.alphaCutoff = opts.alphaCutoff;\n const passes: [MaterialPass, ...MaterialPass[]] = [\n pass('forward', UNLIT_MODULE, opts?.renderState, undefined, opts?.queue),\n ];\n if (opts?.castShadow !== false) {\n passes.push(pass('shadow-caster', UNLIT_MODULE, shadowCasterRenderState(opts?.renderState)));\n }\n return {\n kind: 'material',\n colorSpace: 'linear',\n passes,\n parameters: unlitParameters('linear'),\n values,\n };\n}\n\ninterface StandardOpts {\n /** Numeric tuples are linear; Hex/CSS strings and numbers are sRGB inputs. */\n readonly baseColor: MaterialColorInput4;\n readonly metallic?: number;\n readonly roughness?: number;\n /** Texture channel used for the metallic factor; glTF defaults to B (2). */\n readonly metallicChannel?: number;\n /** Texture channel used for the roughness factor; glTF defaults to G (1). */\n readonly roughnessChannel?: number;\n readonly clearcoat?: number;\n readonly clearcoatRoughness?: number;\n readonly clearcoatTexture?: MaterialValue;\n readonly clearcoatRoughnessTexture?: MaterialValue;\n readonly clearcoatNormalTexture?: MaterialValue;\n readonly clearcoatNormalScale?: number;\n readonly anisotropyStrength?: number;\n readonly anisotropyRotation?: number;\n readonly anisotropyTexture?: MaterialValue;\n readonly sheenColor?: MaterialColorInput3;\n readonly sheenRoughness?: number;\n readonly sheenColorTexture?: MaterialValue;\n readonly sheenRoughnessTexture?: MaterialValue;\n readonly iridescence?: number;\n readonly iridescenceIor?: number;\n readonly iridescenceThicknessMinimum?: number;\n readonly iridescenceThicknessMaximum?: number;\n readonly iridescenceTexture?: MaterialValue;\n readonly iridescenceThicknessTexture?: MaterialValue;\n readonly specular?: number;\n readonly specularColor?: MaterialColorInput3;\n readonly specularTexture?: MaterialValue;\n readonly specularColorTexture?: MaterialValue;\n readonly emissive?: MaterialColorInput3;\n readonly emissiveIntensity?: number;\n readonly emissiveTexture?: MaterialValue;\n readonly baseColorTexture?: MaterialValue;\n readonly metallicRoughnessTexture?: MaterialValue;\n readonly normalTexture?: MaterialValue;\n readonly occlusionTexture?: MaterialValue;\n readonly occlusionStrength?: number;\n readonly alphaCutoff?: number;\n readonly transmission?: number;\n readonly transmissionTexture?: MaterialValue;\n readonly ior?: number;\n readonly thickness?: number;\n readonly thicknessTexture?: MaterialValue;\n readonly attenuationColor?: readonly [number, number, number];\n readonly attenuationDistance?: number;\n readonly renderState?: MaterialRenderState;\n readonly castShadow?: boolean;\n readonly queue?: number;\n}\n\n/** Built-in Standard authoring surface with engine-owned parameter defaults. */\nexport interface DefaultStandardOptions extends StandardOpts {\n readonly surfaceModule?: never;\n readonly parameters?: never;\n readonly values?: never;\n}\n\n/** Import-first Standard Surface authoring; the root parameter contract stays caller-owned. */\nexport interface CustomStandardSurfaceOptions {\n readonly surfaceModule: string;\n readonly parameters: readonly MaterialParameter[];\n readonly values: Readonly<Record<string, MaterialValue>>;\n readonly colorSpace?: MaterialColorSpace;\n readonly renderState?: MaterialRenderState;\n readonly castShadow?: boolean;\n readonly queue?: number;\n readonly baseColor?: never;\n readonly metallic?: never;\n readonly roughness?: never;\n readonly metallicChannel?: never;\n readonly roughnessChannel?: never;\n readonly clearcoat?: never;\n readonly clearcoatRoughness?: never;\n readonly clearcoatTexture?: never;\n readonly clearcoatRoughnessTexture?: never;\n readonly clearcoatNormalTexture?: never;\n readonly clearcoatNormalScale?: never;\n readonly anisotropyStrength?: never;\n readonly anisotropyRotation?: never;\n readonly anisotropyTexture?: never;\n readonly sheenColor?: never;\n readonly sheenRoughness?: never;\n readonly sheenColorTexture?: never;\n readonly sheenRoughnessTexture?: never;\n readonly iridescence?: never;\n readonly iridescenceIor?: never;\n readonly iridescenceThicknessMinimum?: never;\n readonly iridescenceThicknessMaximum?: never;\n readonly iridescenceTexture?: never;\n readonly iridescenceThicknessTexture?: never;\n readonly specular?: never;\n readonly specularColor?: never;\n readonly specularTexture?: never;\n readonly specularColorTexture?: never;\n readonly emissive?: never;\n readonly emissiveIntensity?: never;\n readonly emissiveTexture?: never;\n readonly baseColorTexture?: never;\n readonly metallicRoughnessTexture?: never;\n readonly normalTexture?: never;\n readonly occlusionTexture?: never;\n readonly occlusionStrength?: never;\n readonly alphaCutoff?: never;\n readonly transmission?: never;\n readonly transmissionTexture?: never;\n readonly ior?: never;\n readonly thickness?: never;\n readonly thicknessTexture?: never;\n readonly attenuationColor?: never;\n readonly attenuationDistance?: never;\n}\n\nexport type StandardOptions = DefaultStandardOptions | CustomStandardSurfaceOptions;\n\nfunction validateChannel(\n name: 'metallicChannel' | 'roughnessChannel',\n value: number | undefined,\n): void {\n if (value !== undefined && (!Number.isInteger(value) || value < 0 || value > 3)) {\n throw new Error(`Materials.standard: ${name} must be an integer in [0, 3], got ${value}`);\n }\n}\n\nfunction validateFiniteRange(\n name: 'transmission' | 'ior' | 'thickness' | 'attenuationDistance',\n value: number | undefined,\n minimum: number,\n maximum?: number,\n): void {\n if (value === undefined || !Number.isFinite(value)) {\n if (value === undefined) return;\n throw new MaterialTransmissionContractError(name, 'non-finite', value);\n }\n if (value < minimum || (maximum !== undefined && value > maximum)) {\n throw new MaterialTransmissionContractError(name, 'range', value);\n }\n}\n\nfunction standardDefault(opts: DefaultStandardOptions): MaterialAsset {\n const occlusionStrength = opts.occlusionStrength ?? 1;\n if (occlusionStrength < 0 || occlusionStrength > 1) {\n throw new Error(\n `Materials.standard: occlusionStrength must be in [0, 1], got ${occlusionStrength}`,\n );\n }\n if (opts.alphaCutoff !== undefined && (opts.alphaCutoff < 0 || opts.alphaCutoff > 1)) {\n throw new Error(`Materials.standard: alphaCutoff must be in [0, 1], got ${opts.alphaCutoff}`);\n }\n validateChannel('metallicChannel', opts.metallicChannel);\n validateChannel('roughnessChannel', opts.roughnessChannel);\n const transmission = opts.transmission ?? 0;\n const ior = opts.ior ?? 1.5;\n const thickness = opts.thickness ?? 0;\n const attenuationColor = opts.attenuationColor ?? [1, 1, 1];\n validateFiniteRange('transmission', transmission, 0, 1);\n validateFiniteRange('ior', ior, 1);\n validateFiniteRange('thickness', thickness, 0);\n validateFiniteRange('attenuationDistance', opts.attenuationDistance, Number.MIN_VALUE);\n if (\n attenuationColor.length !== 3 ||\n attenuationColor.some((value) => !Number.isFinite(value) || value < 0 || value > 1)\n ) {\n throw new MaterialTransmissionContractError('attenuationColor', 'shape', attenuationColor);\n }\n if (transmission > 0 && opts.renderState?.blend !== undefined) {\n throw new MaterialTransmissionContractError('transmission', 'blend', opts.renderState.blend);\n }\n if (transmission > 0 && opts.renderState?.depthWriteEnabled === true) {\n throw new MaterialTransmissionContractError('transmission', 'depth-write', true);\n }\n const values: Record<string, MaterialValue> = {\n baseColor: linearColorFromInput(opts.baseColor, 4),\n metallic: opts.metallic ?? 0,\n roughness: opts.roughness ?? 0.5,\n occlusionStrength,\n specular: opts.specular ?? 1,\n specularColor:\n opts.specularColor === undefined ? [1, 1, 1] : linearColorFromInput(opts.specularColor, 3),\n transmission,\n ior,\n thickness,\n attenuationColor,\n };\n if (opts.metallicChannel !== undefined) values.metallicChannel = opts.metallicChannel;\n if (opts.roughnessChannel !== undefined) values.roughnessChannel = opts.roughnessChannel;\n if (opts.clearcoat !== undefined) values.clearcoat = opts.clearcoat;\n if (opts.clearcoatRoughness !== undefined) values.clearcoatRoughness = opts.clearcoatRoughness;\n if (opts.clearcoatTexture !== undefined) values.clearcoatTexture = opts.clearcoatTexture;\n if (opts.clearcoatRoughnessTexture !== undefined) {\n values.clearcoatRoughnessTexture = opts.clearcoatRoughnessTexture;\n }\n if (opts.clearcoatNormalTexture !== undefined) {\n values.clearcoatNormalTexture = opts.clearcoatNormalTexture;\n }\n if (opts.clearcoatNormalScale !== undefined)\n values.clearcoatNormalScale = opts.clearcoatNormalScale;\n if (opts.anisotropyStrength !== undefined) values.anisotropyStrength = opts.anisotropyStrength;\n if (opts.anisotropyRotation !== undefined) values.anisotropyRotation = opts.anisotropyRotation;\n if (opts.anisotropyTexture !== undefined) values.anisotropyTexture = opts.anisotropyTexture;\n if (opts.sheenColor !== undefined) values.sheenColor = linearColorFromInput(opts.sheenColor, 3);\n if (opts.sheenRoughness !== undefined) values.sheenRoughness = opts.sheenRoughness;\n if (opts.sheenColorTexture !== undefined) values.sheenColorTexture = opts.sheenColorTexture;\n if (opts.sheenRoughnessTexture !== undefined) {\n values.sheenRoughnessTexture = opts.sheenRoughnessTexture;\n }\n if (opts.iridescence !== undefined) values.iridescence = opts.iridescence;\n if (opts.iridescenceIor !== undefined) values.iridescenceIor = opts.iridescenceIor;\n if (opts.iridescenceThicknessMinimum !== undefined) {\n values.iridescenceThicknessMinimum = opts.iridescenceThicknessMinimum;\n }\n if (opts.iridescenceThicknessMaximum !== undefined) {\n values.iridescenceThicknessMaximum = opts.iridescenceThicknessMaximum;\n }\n if (opts.iridescenceTexture !== undefined) values.iridescenceTexture = opts.iridescenceTexture;\n if (opts.iridescenceThicknessTexture !== undefined) {\n values.iridescenceThicknessTexture = opts.iridescenceThicknessTexture;\n }\n if (opts.emissive !== undefined) values.emissive = linearColorFromInput(opts.emissive, 3);\n if (opts.emissiveIntensity !== undefined) values.emissiveIntensity = opts.emissiveIntensity;\n if (opts.emissiveTexture !== undefined) values.emissiveTexture = opts.emissiveTexture;\n if (opts.baseColorTexture !== undefined) values.baseColorTexture = opts.baseColorTexture;\n if (opts.metallicRoughnessTexture !== undefined) {\n values.metallicRoughnessTexture = opts.metallicRoughnessTexture;\n }\n if (opts.normalTexture !== undefined) values.normalTexture = opts.normalTexture;\n if (opts.occlusionTexture !== undefined) values.occlusionTexture = opts.occlusionTexture;\n if (opts.specularTexture !== undefined) values.specularTexture = opts.specularTexture;\n if (opts.specularColorTexture !== undefined) {\n values.specularColorTexture = opts.specularColorTexture;\n }\n if (opts.alphaCutoff !== undefined) values.alphaCutoff = opts.alphaCutoff;\n if (opts.transmissionTexture !== undefined) values.transmissionTexture = opts.transmissionTexture;\n if (opts.thicknessTexture !== undefined) values.thicknessTexture = opts.thicknessTexture;\n if (opts.attenuationDistance !== undefined) values.attenuationDistance = opts.attenuationDistance;\n const forwardRenderState =\n transmission > 0 ? { ...(opts.renderState ?? {}), depthWriteEnabled: false } : opts.renderState;\n const parameters = standardParameters('linear', opts);\n const declaredNames = new Set(parameters.map((parameter) => parameter.name));\n for (const name of Object.keys(values)) {\n if (!declaredNames.has(name)) delete values[name];\n }\n const layerPlan = deriveStandardLayerPlan(parameters);\n const projected = projectStandardSurfacePasses({\n surfaceModule: DEFAULT_STANDARD_SURFACE_MODULE,\n values,\n ...(forwardRenderState === undefined ? {} : { renderState: forwardRenderState }),\n ...(opts.castShadow === undefined ? {} : { castShadow: opts.castShadow }),\n ...(opts.queue === undefined ? {} : { queue: opts.queue }),\n layerPlan,\n });\n const passes = (\n transmission > 0 ? projected.filter((entry) => entry.name !== 'deferred') : projected\n ) as [MaterialPass, ...MaterialPass[]];\n return {\n kind: 'material',\n colorSpace: 'linear',\n passes,\n parameters,\n values,\n };\n}\n\nfunction standardCustom(opts: CustomStandardSurfaceOptions): MaterialAsset {\n const layerPlan = deriveStandardLayerPlan(\n opts.parameters.filter((parameter) => parameter.optional !== true),\n );\n return {\n kind: 'material',\n ...(opts.colorSpace === undefined || opts.colorSpace === 'srgb'\n ? {}\n : { colorSpace: opts.colorSpace }),\n passes: projectStandardSurfacePasses({\n surfaceModule: opts.surfaceModule,\n values: opts.values,\n ...(opts.renderState === undefined ? {} : { renderState: opts.renderState }),\n ...(opts.castShadow === undefined ? {} : { castShadow: opts.castShadow }),\n ...(opts.queue === undefined ? {} : { queue: opts.queue }),\n layerPlan,\n }),\n parameters: opts.parameters,\n values: opts.values,\n };\n}\n\nexport function standard(options: StandardOptions): MaterialAsset {\n return options.surfaceModule === undefined ? standardDefault(options) : standardCustom(options);\n}\n\nexport const Materials = { unlit, standard, srgb } as const;\n\nexport { SPRITE_MODULE };\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CUBE_CAMERA_FACE_ORDER, createVisibilityBudget, PointShapeValue, pointShapeFromU32 } from './chunk-
|
|
2
|
-
import { PointsLinesBudgetExceededError, PointsLinesStyleUnsupportedError, PointsLinesMaterialUnsupportedError, PointsLinesInvalidStyleError, PointsLinesTopologyMismatchError } from './chunk-
|
|
1
|
+
import { CUBE_CAMERA_FACE_ORDER, createVisibilityBudget, PointShapeValue, pointShapeFromU32 } from './chunk-ADHHVYLW.mjs';
|
|
2
|
+
import { PointsLinesBudgetExceededError, PointsLinesStyleUnsupportedError, PointsLinesMaterialUnsupportedError, PointsLinesInvalidStyleError, PointsLinesTopologyMismatchError } from './chunk-ZZ4YQ474.mjs';
|
|
3
3
|
import { err, ok } from '@forgeax/engine-types';
|
|
4
4
|
import { mat4 } from '@forgeax/engine-math';
|
|
5
5
|
import { validateR32FloatReceipt } from '@forgeax/engine-rhi';
|
|
@@ -142,6 +142,59 @@ function admitPointsLines(input) {
|
|
|
142
142
|
}
|
|
143
143
|
return ok({ ...style.value, ...topology.value });
|
|
144
144
|
}
|
|
145
|
+
|
|
146
|
+
// src/point-shadow-inspection.ts
|
|
147
|
+
function inspectPointShadow(snapshots, shadowAtlasCapacity) {
|
|
148
|
+
const requested = snapshots.length;
|
|
149
|
+
const admitted = snapshots.reduce(
|
|
150
|
+
(count, snapshot) => snapshot.shadowAtlasLayer >= 0 && snapshot.shadowAtlasLayer < shadowAtlasCapacity ? count + 1 : count,
|
|
151
|
+
0
|
|
152
|
+
);
|
|
153
|
+
const status = requested === 0 ? "inactive" : requested > shadowAtlasCapacity || admitted !== requested ? "over-budget" : "ready";
|
|
154
|
+
return Object.freeze({
|
|
155
|
+
status,
|
|
156
|
+
requested,
|
|
157
|
+
admitted,
|
|
158
|
+
// A point shadow only samples an atlas after it owns an atlas layer. Keep
|
|
159
|
+
// these names explicit for AI diagnostics while deriving both from the
|
|
160
|
+
// one layer projection above.
|
|
161
|
+
shadowed: admitted,
|
|
162
|
+
shadowAtlasOccupancy: admitted,
|
|
163
|
+
shadowAtlasCapacity
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// src/volume/inspection.ts
|
|
168
|
+
function resourceStage(input) {
|
|
169
|
+
if (!input.authored || input.recovery === void 0) return "none";
|
|
170
|
+
if (input.recovery.status === "candidate") return "candidate";
|
|
171
|
+
if (input.recovery.status === "recovering") return "recovering";
|
|
172
|
+
if (input.recovery.status === "degraded") return "lkg";
|
|
173
|
+
return "accepted";
|
|
174
|
+
}
|
|
175
|
+
function inspectVolumetricFog(input) {
|
|
176
|
+
const recovery = input.recovery;
|
|
177
|
+
const status = !input.authored ? "off" : input.capability === "unavailable" ? "unavailable" : input.degraded === true || recovery?.status === "degraded" ? "degraded" : "available";
|
|
178
|
+
return Object.freeze({
|
|
179
|
+
status,
|
|
180
|
+
resourceStage: resourceStage(input),
|
|
181
|
+
guid: recovery?.guid,
|
|
182
|
+
generation: recovery?.generation,
|
|
183
|
+
digest: input.acceptedDigest,
|
|
184
|
+
candidateGeneration: recovery?.candidateGeneration,
|
|
185
|
+
candidateDigest: recovery?.candidateDigest,
|
|
186
|
+
lkgGeneration: recovery?.lkgGeneration,
|
|
187
|
+
candidateFailure: recovery?.candidateFailure,
|
|
188
|
+
deviceEpoch: recovery?.deviceEpoch ?? 0,
|
|
189
|
+
format: input.format,
|
|
190
|
+
passCount: input.passCount ?? 0,
|
|
191
|
+
sampleCount: input.sampleCount ?? 0,
|
|
192
|
+
memoryBytes: input.memoryBytes ?? 0,
|
|
193
|
+
resourceFacts: input.resourceFacts,
|
|
194
|
+
selectedLight: recovery?.selectedLight,
|
|
195
|
+
candidateSelectedLight: recovery?.candidateSelectedLight
|
|
196
|
+
});
|
|
197
|
+
}
|
|
145
198
|
var FACE_ORIENTATION = [
|
|
146
199
|
{ direction: [1, 0, 0], up: [0, 1, 0] },
|
|
147
200
|
{ direction: [-1, 0, 0], up: [0, 1, 0] },
|
|
@@ -557,59 +610,6 @@ var ReflectionProbeProjection = class {
|
|
|
557
610
|
}
|
|
558
611
|
};
|
|
559
612
|
|
|
560
|
-
// src/volume/inspection.ts
|
|
561
|
-
function resourceStage(input) {
|
|
562
|
-
if (!input.authored || input.recovery === void 0) return "none";
|
|
563
|
-
if (input.recovery.status === "candidate") return "candidate";
|
|
564
|
-
if (input.recovery.status === "recovering") return "recovering";
|
|
565
|
-
if (input.recovery.status === "degraded") return "lkg";
|
|
566
|
-
return "accepted";
|
|
567
|
-
}
|
|
568
|
-
function inspectVolumetricFog(input) {
|
|
569
|
-
const recovery = input.recovery;
|
|
570
|
-
const status = !input.authored ? "off" : input.capability === "unavailable" ? "unavailable" : input.degraded === true || recovery?.status === "degraded" ? "degraded" : "available";
|
|
571
|
-
return Object.freeze({
|
|
572
|
-
status,
|
|
573
|
-
resourceStage: resourceStage(input),
|
|
574
|
-
guid: recovery?.guid,
|
|
575
|
-
generation: recovery?.generation,
|
|
576
|
-
digest: input.acceptedDigest,
|
|
577
|
-
candidateGeneration: recovery?.candidateGeneration,
|
|
578
|
-
candidateDigest: recovery?.candidateDigest,
|
|
579
|
-
lkgGeneration: recovery?.lkgGeneration,
|
|
580
|
-
candidateFailure: recovery?.candidateFailure,
|
|
581
|
-
deviceEpoch: recovery?.deviceEpoch ?? 0,
|
|
582
|
-
format: input.format,
|
|
583
|
-
passCount: input.passCount ?? 0,
|
|
584
|
-
sampleCount: input.sampleCount ?? 0,
|
|
585
|
-
memoryBytes: input.memoryBytes ?? 0,
|
|
586
|
-
resourceFacts: input.resourceFacts,
|
|
587
|
-
selectedLight: recovery?.selectedLight,
|
|
588
|
-
candidateSelectedLight: recovery?.candidateSelectedLight
|
|
589
|
-
});
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
// src/point-shadow-inspection.ts
|
|
593
|
-
function inspectPointShadow(snapshots, shadowAtlasCapacity) {
|
|
594
|
-
const requested = snapshots.length;
|
|
595
|
-
const admitted = snapshots.reduce(
|
|
596
|
-
(count, snapshot) => snapshot.shadowAtlasLayer >= 0 && snapshot.shadowAtlasLayer < shadowAtlasCapacity ? count + 1 : count,
|
|
597
|
-
0
|
|
598
|
-
);
|
|
599
|
-
const status = requested === 0 ? "inactive" : requested > shadowAtlasCapacity || admitted !== requested ? "over-budget" : "ready";
|
|
600
|
-
return Object.freeze({
|
|
601
|
-
status,
|
|
602
|
-
requested,
|
|
603
|
-
admitted,
|
|
604
|
-
// A point shadow only samples an atlas after it owns an atlas layer. Keep
|
|
605
|
-
// these names explicit for AI diagnostics while deriving both from the
|
|
606
|
-
// one layer projection above.
|
|
607
|
-
shadowed: admitted,
|
|
608
|
-
shadowAtlasOccupancy: admitted,
|
|
609
|
-
shadowAtlasCapacity
|
|
610
|
-
});
|
|
611
|
-
}
|
|
612
|
-
|
|
613
613
|
// src/scene/visibility/inspection.ts
|
|
614
614
|
var LOD_OCCLUSION_INSPECTION_SCHEMA = "forgeax::lod-occlusion-inspection::v2";
|
|
615
615
|
var LOD_OCCLUSION_INSPECTION_MAX_BYTES = 16 * 1024;
|
|
@@ -999,5 +999,5 @@ function resolveSsrAdmissionGeneration(previousGeneration, nextGeneration) {
|
|
|
999
999
|
}
|
|
1000
1000
|
|
|
1001
1001
|
export { DEFAULT_REFLECTION_PROBE_LIMITS, LOD_OCCLUSION_INSPECTION_MAX_BYTES, LOD_OCCLUSION_INSPECTION_SCHEMA, ReflectionProbeProjection, SSR_FORMAT_PROFILE, SSR_FORMAT_STAGES, admitPointsLines, admitReflectionProbe, admitSsrM0, advanceProbeFilter, boxProjectReflectionDirection, buildCubeCameraFaceViews, buildReflectionProbeTable, commitProbeFilterStep, consumeLodOcclusionInspection, createProbeFilterState, deriveReflectionFallbackProjection, estimateReflectionProbeBytes, inspectLodOcclusion, inspectPointShadow, inspectReflectionFallback, inspectVolumetricFog, probeFilterIsSteady, projectSsrDependencies, reflectionFallbackCoverage, reflectionFallbackProjectionSignature, reflectionFallbackSourceKey, reflectionProbeTableBytes, resolveReflectionFallbackSource, resolveSsrAdmissionGeneration, selectReflectionProbe, serializeLodOcclusionInspection, validateReflectionProbeInput, zeroSsrAdmissionWork };
|
|
1002
|
-
//# sourceMappingURL=chunk-
|
|
1003
|
-
//# sourceMappingURL=chunk-
|
|
1002
|
+
//# sourceMappingURL=chunk-KM2NOX2I.mjs.map
|
|
1003
|
+
//# sourceMappingURL=chunk-KM2NOX2I.mjs.map
|