@luma.gl/engine 10.0.0-alpha.10 → 10.0.0-alpha.11
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/dist/animation/node-animation-binding.cjs +10 -0
- package/dist/animation/node-animation-binding.d.ts +1 -1
- package/dist/animation/node-animation-binding.d.ts.map +1 -1
- package/dist/animation/node-animation-binding.js +10 -0
- package/dist/animation/node-animation-binding.js.map +1 -1
- package/dist/dist.dev.js +325 -80
- package/dist/dist.min.js +58 -58
- package/dist/gltf/gltf/animations/animations.d.ts +1 -1
- package/dist/gltf/gltf/animations/animations.d.ts.map +1 -1
- package/dist/gltf/gltf/create-scenegraph-from-gltf.cjs +80 -12
- package/dist/gltf/gltf/create-scenegraph-from-gltf.d.ts +8 -1
- package/dist/gltf/gltf/create-scenegraph-from-gltf.d.ts.map +1 -1
- package/dist/gltf/gltf/create-scenegraph-from-gltf.js +82 -14
- package/dist/gltf/gltf/create-scenegraph-from-gltf.js.map +1 -1
- package/dist/gltf/gltf/gltf-billboard.cjs +6 -1
- package/dist/gltf/gltf/gltf-billboard.d.ts.map +1 -1
- package/dist/gltf/gltf/gltf-billboard.js +6 -1
- package/dist/gltf/gltf/gltf-billboard.js.map +1 -1
- package/dist/gltf/gltf/gltf-extension-support.cjs +2 -2
- package/dist/gltf/gltf/gltf-extension-support.js +2 -2
- package/dist/gltf/gltf/gltf-extension-support.js.map +1 -1
- package/dist/gltf/index.cjs +2 -0
- package/dist/gltf/index.cjs.map +3 -3
- package/dist/gltf/index.d.ts +1 -1
- package/dist/gltf/index.d.ts.map +1 -1
- package/dist/gltf/index.js +1 -1
- package/dist/gltf/index.js.map +1 -1
- package/dist/gltf/parsers/parse-gltf-animations.cjs +8 -5
- package/dist/gltf/parsers/parse-gltf-animations.js +20 -5
- package/dist/gltf/parsers/parse-gltf-animations.js.map +1 -1
- package/dist/gltf/parsers/parse-gltf-lights.cjs +36 -72
- package/dist/gltf/parsers/parse-gltf-lights.d.ts +6 -2
- package/dist/gltf/parsers/parse-gltf-lights.d.ts.map +1 -1
- package/dist/gltf/parsers/parse-gltf-lights.js +34 -91
- package/dist/gltf/parsers/parse-gltf-lights.js.map +1 -1
- package/dist/gltf/parsers/parse-gltf-metadata.cjs +60 -0
- package/dist/gltf/parsers/parse-gltf-metadata.d.ts +5 -0
- package/dist/gltf/parsers/parse-gltf-metadata.d.ts.map +1 -0
- package/dist/gltf/parsers/parse-gltf-metadata.js +39 -0
- package/dist/gltf/parsers/parse-gltf-metadata.js.map +1 -0
- package/dist/gltf/parsers/parse-gltf.cjs +4 -1
- package/dist/gltf/parsers/parse-gltf.d.ts +4 -0
- package/dist/gltf/parsers/parse-gltf.d.ts.map +1 -1
- package/dist/gltf/parsers/parse-gltf.js +3 -0
- package/dist/gltf/parsers/parse-gltf.js.map +1 -1
- package/dist/gltf/pbr/pbr-environment.cjs +21 -3
- package/dist/gltf/pbr/pbr-environment.d.ts +3 -0
- package/dist/gltf/pbr/pbr-environment.d.ts.map +1 -1
- package/dist/gltf/pbr/pbr-environment.js +19 -1
- package/dist/gltf/pbr/pbr-environment.js.map +1 -1
- package/dist/graph/models/index.cjs.map +1 -1
- package/dist/graph/models/path/path-attribute-model.cjs +1 -1
- package/dist/graph/models/path/path-attribute-model.js +1 -1
- package/dist/graph/models/path/path-attribute-model.js.map +1 -1
- package/dist/graph/models/path/path-storage-model.cjs +1 -1
- package/dist/graph/models/path/path-storage-model.js +1 -1
- package/dist/graph/models/path/path-storage-model.js.map +1 -1
- package/dist/graph/physics/index.cjs.map +1 -1
- package/dist/graph/tables/index.cjs.map +1 -1
- package/dist/index.cjs +13 -0
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/lighting/ambient-occlusion-pass.cjs +126 -0
- package/dist/lighting/ambient-occlusion-pass.d.ts +31 -0
- package/dist/lighting/ambient-occlusion-pass.d.ts.map +1 -0
- package/dist/lighting/ambient-occlusion-pass.js +108 -0
- package/dist/lighting/ambient-occlusion-pass.js.map +1 -0
- package/dist/lighting/clustered-light-grid.cjs +378 -0
- package/dist/lighting/clustered-light-grid.d.ts +94 -0
- package/dist/lighting/clustered-light-grid.d.ts.map +1 -0
- package/dist/lighting/clustered-light-grid.js +370 -0
- package/dist/lighting/clustered-light-grid.js.map +1 -0
- package/dist/lighting/contact-shadow-composite.cjs +80 -0
- package/dist/lighting/contact-shadow-composite.d.ts +6 -0
- package/dist/lighting/contact-shadow-composite.d.ts.map +1 -0
- package/dist/lighting/contact-shadow-composite.js +59 -0
- package/dist/lighting/contact-shadow-composite.js.map +1 -0
- package/dist/lighting/contact-shadow-pass.cjs +102 -0
- package/dist/lighting/contact-shadow-pass.d.ts +23 -0
- package/dist/lighting/contact-shadow-pass.d.ts.map +1 -0
- package/dist/lighting/contact-shadow-pass.js +85 -0
- package/dist/lighting/contact-shadow-pass.js.map +1 -0
- package/dist/lighting/index.cjs +98 -0
- package/dist/lighting/index.cjs.map +6 -0
- package/dist/lighting/index.d.ts +23 -0
- package/dist/lighting/index.d.ts.map +1 -0
- package/dist/lighting/index.js +16 -0
- package/dist/lighting/index.js.map +1 -0
- package/dist/lighting/pbr-environment.cjs +45 -0
- package/dist/lighting/pbr-environment.d.ts +25 -0
- package/dist/lighting/pbr-environment.d.ts.map +1 -0
- package/dist/lighting/pbr-environment.js +30 -0
- package/dist/lighting/pbr-environment.js.map +1 -0
- package/dist/lighting/pbr-material.cjs +75 -0
- package/dist/lighting/pbr-material.d.ts +33 -0
- package/dist/lighting/pbr-material.d.ts.map +1 -0
- package/dist/lighting/pbr-material.js +52 -0
- package/dist/lighting/pbr-material.js.map +1 -0
- package/dist/lighting/pbr-model.cjs +509 -0
- package/dist/lighting/pbr-model.d.ts +41 -0
- package/dist/lighting/pbr-model.d.ts.map +1 -0
- package/dist/lighting/pbr-model.js +475 -0
- package/dist/lighting/pbr-model.js.map +1 -0
- package/dist/lighting/pbr-surface-pass.cjs +116 -0
- package/dist/lighting/pbr-surface-pass.d.ts +35 -0
- package/dist/lighting/pbr-surface-pass.d.ts.map +1 -0
- package/dist/lighting/pbr-surface-pass.js +98 -0
- package/dist/lighting/pbr-surface-pass.js.map +1 -0
- package/dist/lighting/prefiltered-environment.cjs +275 -0
- package/dist/lighting/prefiltered-environment.d.ts +56 -0
- package/dist/lighting/prefiltered-environment.d.ts.map +1 -0
- package/dist/lighting/prefiltered-environment.js +264 -0
- package/dist/lighting/prefiltered-environment.js.map +1 -0
- package/dist/lighting/shadow-map-renderer.cjs +627 -0
- package/dist/lighting/shadow-map-renderer.d.ts +92 -0
- package/dist/lighting/shadow-map-renderer.d.ts.map +1 -0
- package/dist/lighting/shadow-map-renderer.js +617 -0
- package/dist/lighting/shadow-map-renderer.js.map +1 -0
- package/dist/lighting/shadow-quality.cjs +58 -0
- package/dist/lighting/shadow-quality.d.ts +13 -0
- package/dist/lighting/shadow-quality.d.ts.map +1 -0
- package/dist/lighting/shadow-quality.js +37 -0
- package/dist/lighting/shadow-quality.js.map +1 -0
- package/dist/material/material.cjs +3 -0
- package/dist/material/material.d.ts +2 -0
- package/dist/material/material.d.ts.map +1 -1
- package/dist/material/material.js +3 -0
- package/dist/material/material.js.map +1 -1
- package/dist/model/gpu-vector-model.cjs +11 -1
- package/dist/model/gpu-vector-model.d.ts +4 -2
- package/dist/model/gpu-vector-model.d.ts.map +1 -1
- package/dist/model/gpu-vector-model.js +12 -1
- package/dist/model/gpu-vector-model.js.map +1 -1
- package/dist/scenegraph/controllers/punctual-light-controller.cjs +121 -0
- package/dist/scenegraph/controllers/punctual-light-controller.d.ts +31 -0
- package/dist/scenegraph/controllers/punctual-light-controller.d.ts.map +1 -0
- package/dist/scenegraph/controllers/punctual-light-controller.js +117 -0
- package/dist/scenegraph/controllers/punctual-light-controller.js.map +1 -0
- package/dist/scenegraph/scene-metadata.cjs +43 -0
- package/dist/scenegraph/scene-metadata.d.ts +9 -0
- package/dist/scenegraph/scene-metadata.d.ts.map +1 -0
- package/dist/scenegraph/scene-metadata.js +21 -0
- package/dist/scenegraph/scene-metadata.js.map +1 -0
- package/dist/scenegraph/scenegraph-interaction.cjs +99 -0
- package/dist/scenegraph/scenegraph-interaction.d.ts +47 -0
- package/dist/scenegraph/scenegraph-interaction.d.ts.map +1 -0
- package/dist/scenegraph/scenegraph-interaction.js +79 -0
- package/dist/scenegraph/scenegraph-interaction.js.map +1 -0
- package/dist/scenegraph/scenegraph-node.cjs +10 -0
- package/dist/scenegraph/scenegraph-node.d.ts +10 -0
- package/dist/scenegraph/scenegraph-node.d.ts.map +1 -1
- package/dist/scenegraph/scenegraph-node.js +10 -0
- package/dist/scenegraph/scenegraph-node.js.map +1 -1
- package/dist/text/experimental.cjs.map +1 -1
- package/dist/text/fonts/atlas/text-utils.cjs +1 -1
- package/dist/text/fonts/atlas/text-utils.js +1 -1
- package/dist/text/fonts/atlas/text-utils.js.map +1 -1
- package/dist/text/fonts/index.cjs.map +1 -1
- package/dist/text/index.cjs.map +1 -1
- package/dist/text/text-2d/models/text-attribute-model.cjs +1 -1
- package/dist/text/text-2d/models/text-attribute-model.js +1 -1
- package/dist/text/text-2d/models/text-attribute-model.js.map +1 -1
- package/dist/text/text-2d/models/text-dictionary-model.cjs +1 -1
- package/dist/text/text-2d/models/text-dictionary-model.js +1 -1
- package/dist/text/text-2d/models/text-dictionary-model.js.map +1 -1
- package/dist/text/text-2d/models/text-storage-model.cjs +1 -1
- package/dist/text/text-2d/models/text-storage-model.js +1 -1
- package/dist/text/text-2d/models/text-storage-model.js.map +1 -1
- package/package.json +13 -8
- package/src/animation/node-animation-binding.ts +18 -1
- package/src/gltf/gltf/animations/animations.ts +8 -1
- package/src/gltf/gltf/create-scenegraph-from-gltf.ts +98 -17
- package/src/gltf/gltf/gltf-billboard.ts +6 -1
- package/src/gltf/gltf/gltf-extension-support.ts +2 -2
- package/src/gltf/index.ts +1 -0
- package/src/gltf/parsers/parse-gltf-animations.ts +22 -8
- package/src/gltf/parsers/parse-gltf-lights.ts +42 -130
- package/src/gltf/parsers/parse-gltf-metadata.ts +40 -0
- package/src/gltf/parsers/parse-gltf.ts +5 -0
- package/src/gltf/pbr/pbr-environment.ts +27 -1
- package/src/graph/models/path/path-attribute-model.ts +1 -1
- package/src/graph/models/path/path-storage-model.ts +1 -1
- package/src/index.ts +16 -0
- package/src/lighting/ambient-occlusion-pass.ts +130 -0
- package/src/lighting/clustered-light-grid.ts +481 -0
- package/src/lighting/contact-shadow-composite.ts +67 -0
- package/src/lighting/contact-shadow-pass.ts +107 -0
- package/src/lighting/index.ts +88 -0
- package/src/lighting/pbr-environment.ts +55 -0
- package/src/lighting/pbr-material.ts +85 -0
- package/src/lighting/pbr-model.ts +531 -0
- package/src/lighting/pbr-surface-pass.ts +122 -0
- package/src/lighting/prefiltered-environment.ts +354 -0
- package/src/lighting/shadow-map-renderer.ts +909 -0
- package/src/lighting/shadow-quality.ts +50 -0
- package/src/material/material.ts +3 -0
- package/src/model/gpu-vector-model.ts +18 -3
- package/src/scenegraph/controllers/punctual-light-controller.ts +172 -0
- package/src/scenegraph/scene-metadata.ts +23 -0
- package/src/scenegraph/scenegraph-interaction.ts +131 -0
- package/src/scenegraph/scenegraph-node.ts +12 -0
- package/src/text/fonts/atlas/text-utils.ts +1 -1
- package/src/text/text-2d/models/text-attribute-model.ts +1 -1
- package/src/text/text-2d/models/text-dictionary-model.ts +1 -1
- package/src/text/text-2d/models/text-storage-model.ts +1 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
createPrefilteredEnvironment,
|
|
7
|
+
PrefilteredEnvironmentGenerator,
|
|
8
|
+
PrefilteredEnvironment
|
|
9
|
+
} from './prefiltered-environment';
|
|
10
|
+
export type {
|
|
11
|
+
PrefilteredEnvironmentOptions,
|
|
12
|
+
PrefilteredEnvironmentTextures
|
|
13
|
+
} from './prefiltered-environment';
|
|
14
|
+
export {createAreaLightLTCTextures} from './ltc-textures';
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
createPBRMaterial,
|
|
18
|
+
createPBRMaterialFactory,
|
|
19
|
+
getPBRMaterialMapUniforms
|
|
20
|
+
} from './pbr-material';
|
|
21
|
+
export type {CreatePBRMaterialOptions, PBRMaterial, PBRMaterialResources} from './pbr-material';
|
|
22
|
+
export {getPBREnvironmentBindings, getPBREnvironmentUniforms} from './pbr-environment';
|
|
23
|
+
export type {PBRLightingEnvironment, PBRLightingEnvironmentOptions} from './pbr-environment';
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
createPBRModel,
|
|
27
|
+
createPBRShadowModel,
|
|
28
|
+
createPBRSurfaceModel,
|
|
29
|
+
getPBRGeometryDefines,
|
|
30
|
+
getPBRTextureDefines,
|
|
31
|
+
getPBRModelWGSL,
|
|
32
|
+
PBR_MODEL_WGSL_SHADER
|
|
33
|
+
} from './pbr-model';
|
|
34
|
+
export type {CreatePBRModelOptions, PBRModelShaderHooks} from './pbr-model';
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
ShadowMapRenderer,
|
|
38
|
+
getDirectionalCascadeViews,
|
|
39
|
+
getPointShadowViews,
|
|
40
|
+
getPracticalCascadeSplits,
|
|
41
|
+
getSpotShadowView
|
|
42
|
+
} from './shadow-map-renderer';
|
|
43
|
+
export type {
|
|
44
|
+
DirectionalShadowLight,
|
|
45
|
+
PointShadowFace,
|
|
46
|
+
PointShadowLight,
|
|
47
|
+
ShadowCamera,
|
|
48
|
+
ShadowMapRendererProps,
|
|
49
|
+
ShadowRenderOptions,
|
|
50
|
+
ShadowRenderView,
|
|
51
|
+
ShadowShaderProps,
|
|
52
|
+
SpotShadowLight
|
|
53
|
+
} from './shadow-map-renderer';
|
|
54
|
+
export {SHADOW_QUALITY_SETTINGS} from './shadow-quality';
|
|
55
|
+
export type {ShadowQualitySettings} from './shadow-quality';
|
|
56
|
+
|
|
57
|
+
export {PBRSurfacePass} from './pbr-surface-pass';
|
|
58
|
+
export type {
|
|
59
|
+
PBRSurfacePassProps,
|
|
60
|
+
PBRSurfaceRenderOptions,
|
|
61
|
+
PBRSurfaceRenderView
|
|
62
|
+
} from './pbr-surface-pass';
|
|
63
|
+
|
|
64
|
+
export {createContactShadowCompositeShaderPass} from './contact-shadow-composite';
|
|
65
|
+
|
|
66
|
+
export {ContactShadowPass} from './contact-shadow-pass';
|
|
67
|
+
export type {ContactShadowPassProps, ContactShadowRenderOptions} from './contact-shadow-pass';
|
|
68
|
+
|
|
69
|
+
export {
|
|
70
|
+
ClusteredLightGrid,
|
|
71
|
+
CLUSTERED_POINT_LIGHT_LAYOUT,
|
|
72
|
+
MAX_CLUSTERED_POINT_LIGHTS,
|
|
73
|
+
DEFAULT_CLUSTER_DIMENSIONS,
|
|
74
|
+
DEFAULT_MAX_LIGHTS_PER_CLUSTER
|
|
75
|
+
} from './clustered-light-grid';
|
|
76
|
+
export type {
|
|
77
|
+
ClusteredLightGridProps,
|
|
78
|
+
ClusteredLightGridEncodeOptions,
|
|
79
|
+
ClusteredLightGridBindings,
|
|
80
|
+
ClusteredLightGridUniforms,
|
|
81
|
+
ClusteredLightGridShaderPassUniforms
|
|
82
|
+
} from './clustered-light-grid';
|
|
83
|
+
export {AmbientOcclusionPass} from './ambient-occlusion-pass';
|
|
84
|
+
export type {
|
|
85
|
+
AmbientOcclusionMode,
|
|
86
|
+
AmbientOcclusionPassProps,
|
|
87
|
+
AmbientOcclusionRenderOptions
|
|
88
|
+
} from './ambient-occlusion-pass';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
3
|
+
|
|
4
|
+
import {assert, type Texture} from '@luma.gl/core';
|
|
5
|
+
import type {PBRSceneUniforms} from '@luma.gl/shaders';
|
|
6
|
+
|
|
7
|
+
/** Scene-level lighting controls; rotation is around the vertical axis in radians. */
|
|
8
|
+
export type PBRLightingEnvironmentOptions = {
|
|
9
|
+
intensity?: number;
|
|
10
|
+
rotation?: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/** Complete, borrowed linear-light environment resources for PBR rendering. */
|
|
14
|
+
export type PBRLightingEnvironment = PBRLightingEnvironmentOptions & {
|
|
15
|
+
/** Normalized diffuse irradiance (E / pi). */
|
|
16
|
+
diffuseTexture: Texture;
|
|
17
|
+
/** GGX-prefiltered cubemap with the consumer's roughness-to-mip convention. */
|
|
18
|
+
specularTexture: Texture;
|
|
19
|
+
/** Split-sum BRDF integration lookup matching the consumer's convention. */
|
|
20
|
+
brdfLUTTexture: Texture;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** Returns shared IBL bindings without copying textures or transferring ownership. */
|
|
24
|
+
export function getPBREnvironmentBindings(environment: PBRLightingEnvironment) {
|
|
25
|
+
const {diffuseTexture, specularTexture, brdfLUTTexture} = environment;
|
|
26
|
+
// Environment resources must be live, on one device, with cube/cube/2D dimensions.
|
|
27
|
+
assert(
|
|
28
|
+
!diffuseTexture.destroyed &&
|
|
29
|
+
!specularTexture.destroyed &&
|
|
30
|
+
!brdfLUTTexture.destroyed &&
|
|
31
|
+
diffuseTexture.device === specularTexture.device &&
|
|
32
|
+
diffuseTexture.device === brdfLUTTexture.device &&
|
|
33
|
+
diffuseTexture.dimension === 'cube' &&
|
|
34
|
+
specularTexture.dimension === 'cube' &&
|
|
35
|
+
brdfLUTTexture.dimension === '2d'
|
|
36
|
+
);
|
|
37
|
+
return {
|
|
38
|
+
pbr_diffuseEnvSampler: diffuseTexture,
|
|
39
|
+
pbr_specularEnvSampler: specularTexture,
|
|
40
|
+
pbr_brdfLUT: brdfLUTTexture
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Returns scene uniforms. Call again after replacing a texture or changing lighting controls. */
|
|
45
|
+
export function getPBREnvironmentUniforms(
|
|
46
|
+
environment: PBRLightingEnvironment
|
|
47
|
+
): Required<
|
|
48
|
+
Pick<PBRSceneUniforms, 'environmentIntensity' | 'environmentRotation' | 'environmentMipCount'>
|
|
49
|
+
> {
|
|
50
|
+
return {
|
|
51
|
+
environmentIntensity: environment.intensity ?? 1,
|
|
52
|
+
environmentRotation: environment.rotation ?? 0,
|
|
53
|
+
environmentMipCount: environment.specularTexture.mipLevels
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Binding, Device, Texture} from '@luma.gl/core';
|
|
6
|
+
import type {Material} from '../material/material';
|
|
7
|
+
import {MaterialFactory} from '../material/material-factory';
|
|
8
|
+
import {type TextureBindingSource} from '@luma.gl/core/dynamic';
|
|
9
|
+
import {type PBRMaterialBindings, type PBRMaterialUniforms, pbrMaterial} from '@luma.gl/shaders';
|
|
10
|
+
|
|
11
|
+
/** Concrete or deferred texture resources accepted by the shared PBR material factory. */
|
|
12
|
+
export type PBRMaterialResources = Record<string, Binding | TextureBindingSource>;
|
|
13
|
+
|
|
14
|
+
/** Typed material instance backed by the canonical shaders PBR module. */
|
|
15
|
+
export type PBRMaterial = Material<{pbrMaterial: PBRMaterialUniforms}, PBRMaterialResources>;
|
|
16
|
+
|
|
17
|
+
/** Options used to create a reusable physically based material. */
|
|
18
|
+
export type CreatePBRMaterialOptions = {
|
|
19
|
+
/** Optional application-provided material identifier. */
|
|
20
|
+
id?: string;
|
|
21
|
+
/** Canonical glTF-compatible physically based material uniforms. */
|
|
22
|
+
uniforms?: PBRMaterialUniforms;
|
|
23
|
+
/** Material-scoped borrowed texture bindings; absent maps do not allocate fallback resources. */
|
|
24
|
+
bindings?: Partial<PBRMaterialBindings<Texture>> | PBRMaterialResources;
|
|
25
|
+
/** Existing compatible factory reused across materials in the same scene. */
|
|
26
|
+
factory?: MaterialFactory<{pbrMaterial: PBRMaterialUniforms}, PBRMaterialResources>;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** Creates a material factory that owns the canonical PBR group-3 binding schema. */
|
|
30
|
+
export function createPBRMaterialFactory(
|
|
31
|
+
device: Device
|
|
32
|
+
): MaterialFactory<{pbrMaterial: PBRMaterialUniforms}, PBRMaterialResources> {
|
|
33
|
+
return new MaterialFactory(device, {modules: [pbrMaterial]});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Creates a typed shared PBR material without introducing a format-specific material runtime. */
|
|
37
|
+
export function createPBRMaterial(
|
|
38
|
+
device: Device,
|
|
39
|
+
options: CreatePBRMaterialOptions = {}
|
|
40
|
+
): PBRMaterial {
|
|
41
|
+
const materialFactory = options.factory || createPBRMaterialFactory(device);
|
|
42
|
+
const bindings: PBRMaterialResources = {};
|
|
43
|
+
|
|
44
|
+
for (const [bindingName, binding] of Object.entries(options.bindings || {})) {
|
|
45
|
+
if (binding && materialFactory.ownsBinding(bindingName)) {
|
|
46
|
+
bindings[bindingName] = binding;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const material = materialFactory.createMaterial({id: options.id, bindings});
|
|
51
|
+
material.setProps({
|
|
52
|
+
pbrMaterial: {
|
|
53
|
+
...getPBRMaterialMapUniforms(bindings),
|
|
54
|
+
...options.uniforms
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return material;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Returns texture-presence flags matching the canonical PBR shader bindings. */
|
|
61
|
+
export function getPBRMaterialMapUniforms(
|
|
62
|
+
bindings: Partial<PBRMaterialBindings<Texture>> | PBRMaterialResources
|
|
63
|
+
): Partial<PBRMaterialUniforms> {
|
|
64
|
+
return {
|
|
65
|
+
baseColorMapEnabled: Boolean(bindings.pbr_baseColorSampler),
|
|
66
|
+
normalMapEnabled: Boolean(bindings.pbr_normalSampler),
|
|
67
|
+
lightmapMapEnabled: Boolean(bindings.pbr_lightmapSampler),
|
|
68
|
+
emissiveMapEnabled: Boolean(bindings.pbr_emissiveSampler),
|
|
69
|
+
metallicRoughnessMapEnabled: Boolean(bindings.pbr_metallicRoughnessSampler),
|
|
70
|
+
occlusionMapEnabled: Boolean(bindings.pbr_occlusionSampler),
|
|
71
|
+
specularColorMapEnabled: Boolean(bindings.pbr_specularColorSampler),
|
|
72
|
+
specularIntensityMapEnabled: Boolean(bindings.pbr_specularIntensitySampler),
|
|
73
|
+
transmissionMapEnabled: Boolean(bindings.pbr_transmissionSampler),
|
|
74
|
+
clearcoatMapEnabled: Boolean(bindings.pbr_clearcoatSampler),
|
|
75
|
+
clearcoatRoughnessMapEnabled: Boolean(bindings.pbr_clearcoatRoughnessSampler),
|
|
76
|
+
sheenColorMapEnabled: Boolean(bindings.pbr_sheenColorSampler),
|
|
77
|
+
sheenRoughnessMapEnabled: Boolean(bindings.pbr_sheenRoughnessSampler),
|
|
78
|
+
iridescenceMapEnabled: Boolean(bindings.pbr_iridescenceSampler),
|
|
79
|
+
anisotropyMapEnabled: Boolean(bindings.pbr_anisotropySampler),
|
|
80
|
+
bumpMapEnabled: Boolean(bindings.pbr_bumpSampler),
|
|
81
|
+
diffuseTransmissionMapEnabled: Boolean(bindings.pbr_diffuseTransmissionSampler),
|
|
82
|
+
diffuseTransmissionColorMapEnabled: Boolean(bindings.pbr_diffuseTransmissionColorSampler),
|
|
83
|
+
multiscatterColorMapEnabled: Boolean(bindings.pbr_multiscatterColorSampler)
|
|
84
|
+
};
|
|
85
|
+
}
|