@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,509 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var pbr_model_exports = {};
|
|
19
|
+
__export(pbr_model_exports, {
|
|
20
|
+
PBR_MODEL_WGSL_SHADER: () => PBR_MODEL_WGSL_SHADER,
|
|
21
|
+
createPBRModel: () => createPBRModel,
|
|
22
|
+
createPBRShadowModel: () => createPBRShadowModel,
|
|
23
|
+
createPBRSurfaceModel: () => createPBRSurfaceModel,
|
|
24
|
+
getPBRGeometryDefines: () => getPBRGeometryDefines,
|
|
25
|
+
getPBRModelWGSL: () => getPBRModelWGSL,
|
|
26
|
+
getPBRTextureDefines: () => getPBRTextureDefines
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(pbr_model_exports);
|
|
29
|
+
var import_model = require("../model/model.cjs");
|
|
30
|
+
var import_shaders = require("@luma.gl/shaders");
|
|
31
|
+
function getPBRModelWGSL(hooks = {}) {
|
|
32
|
+
return (
|
|
33
|
+
/* wgsl */
|
|
34
|
+
`
|
|
35
|
+
struct PBRModelVertexInputs {
|
|
36
|
+
@location(0) positions: vec3f,
|
|
37
|
+
#ifdef HAS_NORMALS
|
|
38
|
+
@location(1) normals: vec3f,
|
|
39
|
+
#endif
|
|
40
|
+
#ifdef HAS_TANGENTS
|
|
41
|
+
@location(2) TANGENT: vec4f,
|
|
42
|
+
#endif
|
|
43
|
+
#ifdef HAS_UV
|
|
44
|
+
@location(3) texCoords: vec2f,
|
|
45
|
+
#endif
|
|
46
|
+
#ifdef HAS_UV_1
|
|
47
|
+
@location(4) texCoords1: vec2f,
|
|
48
|
+
#endif
|
|
49
|
+
#ifdef HAS_SKIN
|
|
50
|
+
@location(5) JOINTS_0: vec4u,
|
|
51
|
+
@location(6) WEIGHTS_0: vec4f,
|
|
52
|
+
#endif
|
|
53
|
+
#ifdef HAS_COLORS
|
|
54
|
+
#ifdef HAS_RGBA_COLORS
|
|
55
|
+
@location(7) colors: vec4f,
|
|
56
|
+
#else
|
|
57
|
+
@location(7) colors: vec3f,
|
|
58
|
+
#endif
|
|
59
|
+
#endif
|
|
60
|
+
${hooks.vertexInputs ?? ""}
|
|
61
|
+
#ifdef HAS_INSTANCING
|
|
62
|
+
@location(8) instanceModelMatrixCol0: vec4f,
|
|
63
|
+
@location(9) instanceModelMatrixCol1: vec4f,
|
|
64
|
+
@location(10) instanceModelMatrixCol2: vec4f,
|
|
65
|
+
@location(11) instanceModelMatrixCol3: vec4f,
|
|
66
|
+
#endif
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
struct PBRModelFragmentInputs {
|
|
70
|
+
@builtin(position) position: vec4f,
|
|
71
|
+
@location(0) pbrPosition: vec3f,
|
|
72
|
+
@location(1) pbrUV0: vec2f,
|
|
73
|
+
@location(2) pbrUV1: vec2f,
|
|
74
|
+
@location(3) pbrNormal: vec3f,
|
|
75
|
+
@location(4) pbrColor: vec4f,
|
|
76
|
+
${hooks.fragmentInputs ?? ""}
|
|
77
|
+
#ifdef HAS_TANGENTS
|
|
78
|
+
@location(5) pbrTangent: vec4f,
|
|
79
|
+
#endif
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
fn getPBRInstanceNormalMatrix(matrix: mat3x3f) -> mat3x3f {
|
|
83
|
+
let firstCofactor = cross(matrix[1], matrix[2]);
|
|
84
|
+
let inverseDeterminant = 1.0 / dot(matrix[0], firstCofactor);
|
|
85
|
+
return mat3x3f(
|
|
86
|
+
firstCofactor,
|
|
87
|
+
cross(matrix[2], matrix[0]),
|
|
88
|
+
cross(matrix[0], matrix[1])
|
|
89
|
+
) * inverseDeterminant;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@vertex
|
|
93
|
+
fn vertexMain(inputs: PBRModelVertexInputs) -> PBRModelFragmentInputs {
|
|
94
|
+
var outputs: PBRModelFragmentInputs;
|
|
95
|
+
var position = vec4f(inputs.positions, 1.0);
|
|
96
|
+
var normal = vec3f(0.0, 0.0, 1.0);
|
|
97
|
+
var tangent = vec4f(1.0, 0.0, 0.0, 1.0);
|
|
98
|
+
var textureCoordinates = vec2f(0.0);
|
|
99
|
+
var secondTextureCoordinates = vec2f(0.0);
|
|
100
|
+
var vertexColor = vec4f(1.0);
|
|
101
|
+
|
|
102
|
+
#ifdef HAS_NORMALS
|
|
103
|
+
normal = inputs.normals;
|
|
104
|
+
#endif
|
|
105
|
+
#ifdef HAS_UV
|
|
106
|
+
textureCoordinates = inputs.texCoords;
|
|
107
|
+
#endif
|
|
108
|
+
#ifdef HAS_UV_1
|
|
109
|
+
secondTextureCoordinates = inputs.texCoords1;
|
|
110
|
+
#endif
|
|
111
|
+
#ifdef HAS_TANGENTS
|
|
112
|
+
tangent = inputs.TANGENT;
|
|
113
|
+
#endif
|
|
114
|
+
#ifdef HAS_COLORS
|
|
115
|
+
#ifdef HAS_RGBA_COLORS
|
|
116
|
+
vertexColor = inputs.colors;
|
|
117
|
+
#else
|
|
118
|
+
vertexColor = vec4f(inputs.colors, 1.0);
|
|
119
|
+
#endif
|
|
120
|
+
#endif
|
|
121
|
+
|
|
122
|
+
#ifdef HAS_SKIN
|
|
123
|
+
let skinMatrix = getSkinMatrix(inputs.WEIGHTS_0, inputs.JOINTS_0);
|
|
124
|
+
position = skinMatrix * position;
|
|
125
|
+
normal = normalize(getPBRInstanceNormalMatrix(mat3x3f(skinMatrix[0].xyz, skinMatrix[1].xyz, skinMatrix[2].xyz)) * normal);
|
|
126
|
+
#ifdef HAS_TANGENTS
|
|
127
|
+
tangent = vec4f(normalize((skinMatrix * vec4f(tangent.xyz, 0.0)).xyz), tangent.w * sign(determinant(mat3x3f(skinMatrix[0].xyz, skinMatrix[1].xyz, skinMatrix[2].xyz))));
|
|
128
|
+
#endif
|
|
129
|
+
#endif
|
|
130
|
+
|
|
131
|
+
#ifdef HAS_INSTANCING
|
|
132
|
+
var instanceMatrix = mat4x4f(
|
|
133
|
+
inputs.instanceModelMatrixCol0,
|
|
134
|
+
inputs.instanceModelMatrixCol1,
|
|
135
|
+
inputs.instanceModelMatrixCol2,
|
|
136
|
+
inputs.instanceModelMatrixCol3
|
|
137
|
+
);
|
|
138
|
+
${hooks.instanceTransform ?? ""} position = instanceMatrix * position;
|
|
139
|
+
let instanceNormalMatrix = getPBRInstanceNormalMatrix(mat3x3f(
|
|
140
|
+
instanceMatrix[0].xyz, instanceMatrix[1].xyz, instanceMatrix[2].xyz
|
|
141
|
+
));
|
|
142
|
+
normal = normalize(instanceNormalMatrix * normal);
|
|
143
|
+
#ifdef HAS_TANGENTS
|
|
144
|
+
tangent = vec4f(normalize((instanceMatrix * vec4f(tangent.xyz, 0.0)).xyz), tangent.w * sign(determinant(mat3x3f(instanceMatrix[0].xyz, instanceMatrix[1].xyz, instanceMatrix[2].xyz))));
|
|
145
|
+
#endif
|
|
146
|
+
#endif
|
|
147
|
+
let worldPosition = pbrProjection.modelMatrix * position;
|
|
148
|
+
normal = normalize((pbrProjection.normalMatrix * vec4f(normal, 0.0)).xyz);
|
|
149
|
+
#ifdef HAS_TANGENTS
|
|
150
|
+
tangent = vec4f(normalize((pbrProjection.modelMatrix * vec4f(tangent.xyz, 0.0)).xyz), tangent.w * sign(determinant(mat3x3f(pbrProjection.modelMatrix[0].xyz, pbrProjection.modelMatrix[1].xyz, pbrProjection.modelMatrix[2].xyz))));
|
|
151
|
+
#endif
|
|
152
|
+
outputs.position = pbrProjection.modelViewProjectionMatrix * position;
|
|
153
|
+
${hooks.vertexOutput ?? ""}
|
|
154
|
+
outputs.pbrPosition = worldPosition.xyz / worldPosition.w;
|
|
155
|
+
outputs.pbrUV0 = textureCoordinates;
|
|
156
|
+
outputs.pbrUV1 = secondTextureCoordinates;
|
|
157
|
+
outputs.pbrNormal = normal;
|
|
158
|
+
outputs.pbrColor = vertexColor;
|
|
159
|
+
#ifdef HAS_TANGENTS
|
|
160
|
+
outputs.pbrTangent = tangent;
|
|
161
|
+
#endif
|
|
162
|
+
return outputs;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
${hooks.fragmentDeclarations ?? ""}
|
|
166
|
+
@fragment
|
|
167
|
+
fn fragmentMain(inputs: PBRModelFragmentInputs, @builtin(front_facing) frontFacing: bool)
|
|
168
|
+
${hooks.fragmentReturnType ?? `#ifndef PBR_SHADOW_PASS
|
|
169
|
+
-> @location(0) vec4f
|
|
170
|
+
#endif`}
|
|
171
|
+
{
|
|
172
|
+
#ifdef DOUBLE_SIDED
|
|
173
|
+
pbr_frontFacing = frontFacing;
|
|
174
|
+
#endif
|
|
175
|
+
fragmentInputs.pbr_vPosition = inputs.pbrPosition;
|
|
176
|
+
fragmentInputs.pbr_vUV0 = inputs.pbrUV0;
|
|
177
|
+
fragmentInputs.pbr_vUV1 = inputs.pbrUV1;
|
|
178
|
+
fragmentInputs.pbr_vNormal = inputs.pbrNormal;
|
|
179
|
+
#ifdef HAS_TANGENTS
|
|
180
|
+
let tangent = normalize(inputs.pbrTangent.xyz);
|
|
181
|
+
let bitangent = normalize(cross(inputs.pbrNormal, tangent)) * inputs.pbrTangent.w;
|
|
182
|
+
fragmentInputs.pbr_vTBN = mat3x3f(tangent, bitangent, inputs.pbrNormal);
|
|
183
|
+
#endif
|
|
184
|
+
${hooks.fragmentBody ?? `
|
|
185
|
+
#ifdef PBR_SHADOW_PASS
|
|
186
|
+
pbr_discardMaskedFragment(inputs.pbrColor);
|
|
187
|
+
#else
|
|
188
|
+
#ifdef PBR_SURFACE_PASS
|
|
189
|
+
pbr_discardMaskedFragment(inputs.pbrColor);
|
|
190
|
+
return pbrSurface_getColor();
|
|
191
|
+
#else
|
|
192
|
+
#ifdef DEBUG_NORMALS
|
|
193
|
+
return vec4f(normalize(inputs.pbrNormal) * 0.5 + vec3f(0.5), 1.0);
|
|
194
|
+
#else
|
|
195
|
+
#ifdef DEBUG_DEPTH
|
|
196
|
+
return vec4f(vec3f(inputs.position.z), 1.0);
|
|
197
|
+
#else
|
|
198
|
+
#ifdef PBR_RECEIVE_AMBIENT_OCCLUSION
|
|
199
|
+
pbrAmbientOcclusion_setFactor(inputs.position.xy);
|
|
200
|
+
#endif
|
|
201
|
+
#ifdef PBR_RECEIVE_SHADOWS
|
|
202
|
+
#ifdef HAS_NORMALS
|
|
203
|
+
let shadowNormal = inputs.pbrNormal;
|
|
204
|
+
#else
|
|
205
|
+
let shadowNormal = normalize(cross(dpdy(inputs.pbrPosition), dpdx(inputs.pbrPosition)));
|
|
206
|
+
#endif
|
|
207
|
+
#ifdef PBR_RECEIVE_CONTACT_SHADOWS
|
|
208
|
+
return pbrShadow_filterColorWithDirectionalContact(inputs.pbrColor, inputs.pbrPosition, shadowNormal, pbrContactShadow_getFactor(inputs.position.xy));
|
|
209
|
+
#else
|
|
210
|
+
return pbrShadow_filterColor(inputs.pbrColor, inputs.pbrPosition, shadowNormal);
|
|
211
|
+
#endif
|
|
212
|
+
#else
|
|
213
|
+
#ifdef PBR_RECEIVE_CONTACT_SHADOWS
|
|
214
|
+
return pbrContactShadow_filterColor(inputs.pbrColor, inputs.position.xy);
|
|
215
|
+
#else
|
|
216
|
+
return pbr_filterColor(inputs.pbrColor);
|
|
217
|
+
#endif
|
|
218
|
+
#endif
|
|
219
|
+
#endif
|
|
220
|
+
#endif
|
|
221
|
+
#endif
|
|
222
|
+
#endif
|
|
223
|
+
`}
|
|
224
|
+
}
|
|
225
|
+
`
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
const PBR_MODEL_WGSL_SHADER = /* @__PURE__ */ getPBRModelWGSL();
|
|
229
|
+
const PBR_VERTEX_SHADER = (
|
|
230
|
+
/* glsl */
|
|
231
|
+
`#version 300 es
|
|
232
|
+
in vec3 positions;
|
|
233
|
+
#ifdef HAS_NORMALS
|
|
234
|
+
in vec3 normals;
|
|
235
|
+
#endif
|
|
236
|
+
#ifdef HAS_TANGENTS
|
|
237
|
+
in vec4 TANGENT;
|
|
238
|
+
#endif
|
|
239
|
+
#ifdef HAS_UV
|
|
240
|
+
in vec2 texCoords;
|
|
241
|
+
#endif
|
|
242
|
+
#ifdef HAS_UV_1
|
|
243
|
+
in vec2 texCoords1;
|
|
244
|
+
#endif
|
|
245
|
+
#ifdef HAS_SKIN
|
|
246
|
+
in uvec4 JOINTS_0;
|
|
247
|
+
in vec4 WEIGHTS_0;
|
|
248
|
+
#endif
|
|
249
|
+
#ifdef HAS_COLORS
|
|
250
|
+
#ifdef HAS_RGBA_COLORS
|
|
251
|
+
in vec4 colors;
|
|
252
|
+
#else
|
|
253
|
+
in vec3 colors;
|
|
254
|
+
#endif
|
|
255
|
+
#endif
|
|
256
|
+
#ifdef HAS_INSTANCING
|
|
257
|
+
in vec4 instanceModelMatrixCol0;
|
|
258
|
+
in vec4 instanceModelMatrixCol1;
|
|
259
|
+
in vec4 instanceModelMatrixCol2;
|
|
260
|
+
in vec4 instanceModelMatrixCol3;
|
|
261
|
+
#endif
|
|
262
|
+
out vec4 sceneVertexColor;
|
|
263
|
+
|
|
264
|
+
void main(void) {
|
|
265
|
+
vec4 position = vec4(positions, 1.0);
|
|
266
|
+
vec4 normal = vec4(0.0, 0.0, 1.0, 0.0);
|
|
267
|
+
vec4 tangent = vec4(1.0, 0.0, 0.0, 1.0);
|
|
268
|
+
vec2 textureCoordinates = vec2(0.0);
|
|
269
|
+
vec2 secondTextureCoordinates = vec2(0.0);
|
|
270
|
+
sceneVertexColor = vec4(1.0);
|
|
271
|
+
|
|
272
|
+
#ifdef HAS_NORMALS
|
|
273
|
+
normal = vec4(normals, 0.0);
|
|
274
|
+
#endif
|
|
275
|
+
#ifdef HAS_TANGENTS
|
|
276
|
+
tangent = TANGENT;
|
|
277
|
+
#endif
|
|
278
|
+
#ifdef HAS_UV
|
|
279
|
+
textureCoordinates = texCoords;
|
|
280
|
+
#endif
|
|
281
|
+
#ifdef HAS_UV_1
|
|
282
|
+
secondTextureCoordinates = texCoords1;
|
|
283
|
+
#endif
|
|
284
|
+
#ifdef HAS_COLORS
|
|
285
|
+
#ifdef HAS_RGBA_COLORS
|
|
286
|
+
sceneVertexColor = colors;
|
|
287
|
+
#else
|
|
288
|
+
sceneVertexColor = vec4(colors, 1.0);
|
|
289
|
+
#endif
|
|
290
|
+
#endif
|
|
291
|
+
|
|
292
|
+
#ifdef HAS_SKIN
|
|
293
|
+
mat4 skinMatrix = getSkinMatrix(WEIGHTS_0, JOINTS_0);
|
|
294
|
+
position = skinMatrix * position;
|
|
295
|
+
normal = vec4(transpose(inverse(mat3(skinMatrix))) * normal.xyz, 0.0);
|
|
296
|
+
tangent = vec4((skinMatrix * vec4(tangent.xyz, 0.0)).xyz, tangent.w * sign(determinant(mat3(skinMatrix))));
|
|
297
|
+
#endif
|
|
298
|
+
|
|
299
|
+
#ifdef HAS_INSTANCING
|
|
300
|
+
mat4 instanceMatrix = mat4(
|
|
301
|
+
instanceModelMatrixCol0,
|
|
302
|
+
instanceModelMatrixCol1,
|
|
303
|
+
instanceModelMatrixCol2,
|
|
304
|
+
instanceModelMatrixCol3
|
|
305
|
+
);
|
|
306
|
+
position = instanceMatrix * position;
|
|
307
|
+
normal = vec4(normalize(transpose(inverse(mat3(instanceMatrix))) * normal.xyz), 0.0);
|
|
308
|
+
tangent = vec4(normalize(mat3(instanceMatrix) * tangent.xyz), tangent.w * sign(determinant(mat3(instanceMatrix))));
|
|
309
|
+
#endif
|
|
310
|
+
|
|
311
|
+
tangent.w *= sign(determinant(mat3(pbrProjection.modelMatrix)));
|
|
312
|
+
pbr_setPositionNormalTangentUV(
|
|
313
|
+
position,
|
|
314
|
+
normal,
|
|
315
|
+
tangent,
|
|
316
|
+
textureCoordinates,
|
|
317
|
+
secondTextureCoordinates
|
|
318
|
+
);
|
|
319
|
+
gl_Position = pbrProjection.modelViewProjectionMatrix * position;
|
|
320
|
+
#ifdef PBR_SHADOW_PASS
|
|
321
|
+
// ShadowMapRenderer light projections use [0, 1] depth on both backends.
|
|
322
|
+
gl_Position.z = gl_Position.z * 2.0 - gl_Position.w;
|
|
323
|
+
#endif
|
|
324
|
+
}
|
|
325
|
+
`
|
|
326
|
+
);
|
|
327
|
+
const PBR_FRAGMENT_SHADER = (
|
|
328
|
+
/* glsl */
|
|
329
|
+
`#version 300 es
|
|
330
|
+
in vec4 sceneVertexColor;
|
|
331
|
+
#ifndef PBR_SHADOW_PASS
|
|
332
|
+
out vec4 fragmentColor;
|
|
333
|
+
#endif
|
|
334
|
+
|
|
335
|
+
void main(void) {
|
|
336
|
+
#ifdef PBR_SHADOW_PASS
|
|
337
|
+
pbr_discardMaskedFragment(sceneVertexColor);
|
|
338
|
+
#else
|
|
339
|
+
#ifdef PBR_SURFACE_PASS
|
|
340
|
+
pbr_discardMaskedFragment(sceneVertexColor);
|
|
341
|
+
fragmentColor = pbrSurface_getColor();
|
|
342
|
+
#else
|
|
343
|
+
#ifdef DEBUG_NORMALS
|
|
344
|
+
#ifdef HAS_TANGENTS
|
|
345
|
+
fragmentColor = vec4(normalize(pbr_vTBN[2]) * 0.5 + 0.5, 1.0);
|
|
346
|
+
#else
|
|
347
|
+
#ifdef HAS_NORMALS
|
|
348
|
+
fragmentColor = vec4(normalize(pbr_vNormal) * 0.5 + 0.5, 1.0);
|
|
349
|
+
#else
|
|
350
|
+
fragmentColor = vec4(0.5, 0.5, 1.0, 1.0);
|
|
351
|
+
#endif
|
|
352
|
+
#endif
|
|
353
|
+
#else
|
|
354
|
+
#ifdef DEBUG_DEPTH
|
|
355
|
+
fragmentColor = vec4(vec3(gl_FragCoord.z), 1.0);
|
|
356
|
+
#else
|
|
357
|
+
#ifdef PBR_RECEIVE_AMBIENT_OCCLUSION
|
|
358
|
+
pbrAmbientOcclusion_setFactor(gl_FragCoord.xy);
|
|
359
|
+
#endif
|
|
360
|
+
#ifdef PBR_RECEIVE_SHADOWS
|
|
361
|
+
#ifdef HAS_NORMALS
|
|
362
|
+
#ifdef HAS_TANGENTS
|
|
363
|
+
vec3 shadowNormal = pbr_vTBN[2];
|
|
364
|
+
#else
|
|
365
|
+
vec3 shadowNormal = pbr_vNormal;
|
|
366
|
+
#endif
|
|
367
|
+
#else
|
|
368
|
+
vec3 shadowNormal = normalize(cross(dFdx(pbr_vPosition), dFdy(pbr_vPosition)));
|
|
369
|
+
#endif
|
|
370
|
+
#ifdef PBR_RECEIVE_CONTACT_SHADOWS
|
|
371
|
+
fragmentColor = pbrShadow_filterColorWithDirectionalContact(sceneVertexColor, pbr_vPosition, shadowNormal, pbrContactShadow_getFactor(gl_FragCoord.xy));
|
|
372
|
+
#else
|
|
373
|
+
fragmentColor = pbrShadow_filterColor(sceneVertexColor, pbr_vPosition, shadowNormal);
|
|
374
|
+
#endif
|
|
375
|
+
#else
|
|
376
|
+
#ifdef PBR_RECEIVE_CONTACT_SHADOWS
|
|
377
|
+
fragmentColor = pbrContactShadow_filterColor(sceneVertexColor, gl_FragCoord.xy);
|
|
378
|
+
#else
|
|
379
|
+
fragmentColor = pbr_filterColor(sceneVertexColor);
|
|
380
|
+
#endif
|
|
381
|
+
#endif
|
|
382
|
+
#endif
|
|
383
|
+
#endif
|
|
384
|
+
#endif
|
|
385
|
+
#endif
|
|
386
|
+
}
|
|
387
|
+
`
|
|
388
|
+
);
|
|
389
|
+
function createPBRModel(device, options) {
|
|
390
|
+
var _a, _b;
|
|
391
|
+
const { receiveShadows = false, receiveContactShadows = false, receiveAmbientOcclusion = false, ...modelOptions } = options;
|
|
392
|
+
const shaderModules = [
|
|
393
|
+
import_shaders.pbrScene,
|
|
394
|
+
import_shaders.pbrMaterial,
|
|
395
|
+
...receiveShadows ? [import_shaders.pbrShadow] : [],
|
|
396
|
+
...receiveContactShadows ? [import_shaders.pbrContactShadow] : [],
|
|
397
|
+
...receiveAmbientOcclusion ? [import_shaders.pbrAmbientOcclusion] : [],
|
|
398
|
+
...((_a = options.defines) == null ? void 0 : _a["PBR_SURFACE_PASS"]) ? [import_shaders.pbrSurface] : [],
|
|
399
|
+
...options.modules || []
|
|
400
|
+
];
|
|
401
|
+
const modules = shaderModules.filter((module2, moduleIndex) => shaderModules.findIndex((candidate) => candidate.name === module2.name) === moduleIndex);
|
|
402
|
+
const geometryDefines = getPBRGeometryDefines(options.geometry);
|
|
403
|
+
const hasSkin = Boolean(((_b = options.defines) == null ? void 0 : _b["HAS_SKIN"]) ?? geometryDefines["HAS_SKIN"]);
|
|
404
|
+
if (hasSkin && !modules.some((module2) => module2.name === import_shaders.skin.name)) {
|
|
405
|
+
modules.push(import_shaders.skin);
|
|
406
|
+
}
|
|
407
|
+
const model = new import_model.Model(device, {
|
|
408
|
+
source: PBR_MODEL_WGSL_SHADER,
|
|
409
|
+
vs: PBR_VERTEX_SHADER,
|
|
410
|
+
fs: PBR_FRAGMENT_SHADER,
|
|
411
|
+
...modelOptions,
|
|
412
|
+
modules,
|
|
413
|
+
defines: {
|
|
414
|
+
USE_SCENE_COLOR_MANAGEMENT: true,
|
|
415
|
+
PBR_RECEIVE_SHADOWS: receiveShadows,
|
|
416
|
+
PBR_RECEIVE_CONTACT_SHADOWS: receiveContactShadows,
|
|
417
|
+
PBR_RECEIVE_AMBIENT_OCCLUSION: receiveAmbientOcclusion,
|
|
418
|
+
...geometryDefines,
|
|
419
|
+
...getPBRTextureDefines(options.material.getResourceBindings()),
|
|
420
|
+
...options.defines
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
if (!options.shaderInputs) {
|
|
424
|
+
const identity = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
425
|
+
model.shaderInputs.setProps({
|
|
426
|
+
pbrProjection: {
|
|
427
|
+
modelMatrix: identity.slice(),
|
|
428
|
+
modelViewProjectionMatrix: identity.slice(),
|
|
429
|
+
normalMatrix: identity.slice(),
|
|
430
|
+
camera: [0, 0, 1]
|
|
431
|
+
},
|
|
432
|
+
pbrScene: { toneMapMode: 0, outputEncoding: 0 }
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
return model;
|
|
436
|
+
}
|
|
437
|
+
function createPBRShadowModel(device, options) {
|
|
438
|
+
return createPBRModel(device, {
|
|
439
|
+
colorAttachmentFormats: [],
|
|
440
|
+
depthStencilAttachmentFormat: "depth32float",
|
|
441
|
+
...options,
|
|
442
|
+
receiveShadows: false,
|
|
443
|
+
receiveContactShadows: false,
|
|
444
|
+
receiveAmbientOcclusion: false,
|
|
445
|
+
defines: { ...options.defines, PBR_SHADOW_PASS: true },
|
|
446
|
+
parameters: { depthWriteEnabled: true, depthCompare: "less-equal", ...options.parameters }
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
function createPBRSurfaceModel(device, options) {
|
|
450
|
+
return createPBRModel(device, {
|
|
451
|
+
colorAttachmentFormats: ["rgba8unorm"],
|
|
452
|
+
depthStencilAttachmentFormat: "depth32float",
|
|
453
|
+
...options,
|
|
454
|
+
receiveShadows: false,
|
|
455
|
+
receiveContactShadows: false,
|
|
456
|
+
receiveAmbientOcclusion: false,
|
|
457
|
+
defines: { ...options.defines, PBR_SHADOW_PASS: false, PBR_SURFACE_PASS: true },
|
|
458
|
+
parameters: { depthWriteEnabled: true, depthCompare: "less-equal", ...options.parameters }
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
function getPBRGeometryDefines(geometry) {
|
|
462
|
+
const attributes = geometry && "attributes" in geometry ? geometry.attributes : {};
|
|
463
|
+
const colors = attributes["COLOR_0"] || attributes["colors"];
|
|
464
|
+
return {
|
|
465
|
+
HAS_NORMALS: Boolean(attributes["NORMAL"] || attributes["normals"]),
|
|
466
|
+
HAS_TANGENTS: Boolean(attributes["TANGENT"] || attributes["tangents"]),
|
|
467
|
+
HAS_UV: Boolean(attributes["TEXCOORD_0"] || attributes["texCoords"]),
|
|
468
|
+
HAS_UV_1: Boolean(attributes["TEXCOORD_1"] || attributes["texCoords1"]),
|
|
469
|
+
HAS_SKIN: Boolean(attributes["JOINTS_0"] && attributes["WEIGHTS_0"]),
|
|
470
|
+
HAS_COLORS: Boolean(colors),
|
|
471
|
+
HAS_RGBA_COLORS: Boolean(colors && "size" in colors && colors.size === 4)
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
function getPBRTextureDefines(bindings) {
|
|
475
|
+
return {
|
|
476
|
+
HAS_BASECOLORMAP: Boolean(bindings["pbr_baseColorSampler"]),
|
|
477
|
+
HAS_NORMALMAP: Boolean(bindings["pbr_normalSampler"]),
|
|
478
|
+
HAS_LIGHTMAP: Boolean(bindings["pbr_lightmapSampler"]),
|
|
479
|
+
HAS_EMISSIVEMAP: Boolean(bindings["pbr_emissiveSampler"]),
|
|
480
|
+
HAS_METALROUGHNESSMAP: Boolean(bindings["pbr_metallicRoughnessSampler"]),
|
|
481
|
+
HAS_OCCLUSIONMAP: Boolean(bindings["pbr_occlusionSampler"]),
|
|
482
|
+
HAS_SPECULARCOLORMAP: Boolean(bindings["pbr_specularColorSampler"]),
|
|
483
|
+
HAS_SPECULARINTENSITYMAP: Boolean(bindings["pbr_specularIntensitySampler"]),
|
|
484
|
+
HAS_TRANSMISSIONMAP: Boolean(bindings["pbr_transmissionSampler"]),
|
|
485
|
+
HAS_THICKNESSMAP: Boolean(bindings["pbr_thicknessSampler"]),
|
|
486
|
+
HAS_CLEARCOATMAP: Boolean(bindings["pbr_clearcoatSampler"]),
|
|
487
|
+
HAS_CLEARCOATROUGHNESSMAP: Boolean(bindings["pbr_clearcoatRoughnessSampler"]),
|
|
488
|
+
HAS_CLEARCOATNORMALMAP: Boolean(bindings["pbr_clearcoatNormalSampler"]),
|
|
489
|
+
HAS_SHEENCOLORMAP: Boolean(bindings["pbr_sheenColorSampler"]),
|
|
490
|
+
HAS_SHEENROUGHNESSMAP: Boolean(bindings["pbr_sheenRoughnessSampler"]),
|
|
491
|
+
HAS_IRIDESCENCEMAP: Boolean(bindings["pbr_iridescenceSampler"]),
|
|
492
|
+
HAS_IRIDESCENCETHICKNESSMAP: Boolean(bindings["pbr_iridescenceThicknessSampler"]),
|
|
493
|
+
HAS_ANISOTROPYMAP: Boolean(bindings["pbr_anisotropySampler"]),
|
|
494
|
+
HAS_BUMPMAP: Boolean(bindings["pbr_bumpSampler"]),
|
|
495
|
+
HAS_DIFFUSETRANSMISSIONMAP: Boolean(bindings["pbr_diffuseTransmissionSampler"]),
|
|
496
|
+
HAS_DIFFUSETRANSMISSIONCOLORMAP: Boolean(bindings["pbr_diffuseTransmissionColorSampler"]),
|
|
497
|
+
HAS_MULTISCATTERCOLORMAP: Boolean(bindings["pbr_multiscatterColorSampler"])
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
501
|
+
0 && (module.exports = {
|
|
502
|
+
PBR_MODEL_WGSL_SHADER,
|
|
503
|
+
createPBRModel,
|
|
504
|
+
createPBRShadowModel,
|
|
505
|
+
createPBRSurfaceModel,
|
|
506
|
+
getPBRGeometryDefines,
|
|
507
|
+
getPBRModelWGSL,
|
|
508
|
+
getPBRTextureDefines
|
|
509
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Device } from '@luma.gl/core';
|
|
2
|
+
import type { Material } from "../material/material.js";
|
|
3
|
+
import { Model, type ModelProps } from "../model/model.js";
|
|
4
|
+
/** Optional WGSL extensions for adapters building specialized mesh passes. */
|
|
5
|
+
export type PBRModelShaderHooks = {
|
|
6
|
+
vertexInputs?: string;
|
|
7
|
+
fragmentInputs?: string;
|
|
8
|
+
instanceTransform?: string;
|
|
9
|
+
vertexOutput?: string;
|
|
10
|
+
fragmentDeclarations?: string;
|
|
11
|
+
fragmentReturnType?: string;
|
|
12
|
+
fragmentBody?: string;
|
|
13
|
+
};
|
|
14
|
+
/** Builds mesh entry points; default source has no scene-specific resources or identifiers. */
|
|
15
|
+
export declare function getPBRModelWGSL(hooks?: PBRModelShaderHooks): string;
|
|
16
|
+
export declare const PBR_MODEL_WGSL_SHADER: string;
|
|
17
|
+
/** Model properties accepted by the shared physically based model factory. */
|
|
18
|
+
export type CreatePBRModelOptions = ModelProps & {
|
|
19
|
+
/** Shared PBR material that owns the canonical material binding group. */
|
|
20
|
+
material: Material;
|
|
21
|
+
/** Include shadow sampling for directional, point and spot direct lights. */
|
|
22
|
+
receiveShadows?: boolean;
|
|
23
|
+
/** Include screen-space visibility for the first directional light. */
|
|
24
|
+
receiveContactShadows?: boolean;
|
|
25
|
+
/** Attenuate indirect lighting using screen-space ambient visibility. */
|
|
26
|
+
receiveAmbientOcclusion?: boolean;
|
|
27
|
+
};
|
|
28
|
+
/** Creates a standalone WebGPU/WebGL PBR model with a borrowed material. */
|
|
29
|
+
export declare function createPBRModel(device: Device, options: CreatePBRModelOptions): Model;
|
|
30
|
+
/** Creates a depth-only caster sharing PBR geometry, transforms, skinning and alpha cutouts.
|
|
31
|
+
* Supply the zero-to-one light projection returned by ShadowMapRenderer on both backends.
|
|
32
|
+
* The material is borrowed; caster and visible models may share it.
|
|
33
|
+
*/
|
|
34
|
+
export declare function createPBRShadowModel(device: Device, options: CreatePBRModelOptions): Model;
|
|
35
|
+
/** Creates a camera-space depth/normal model with the shared PBR vertex and alpha-cutout paths. */
|
|
36
|
+
export declare function createPBRSurfaceModel(device: Device, options: CreatePBRModelOptions): Model;
|
|
37
|
+
/** Returns shader features implied by canonical CPU geometry attributes. */
|
|
38
|
+
export declare function getPBRGeometryDefines(geometry: ModelProps['geometry']): Record<string, boolean>;
|
|
39
|
+
/** Returns feature-specialized shader defines for texture bindings present on one PBR material. */
|
|
40
|
+
export declare function getPBRTextureDefines(bindings: Record<string, unknown>): Record<string, boolean>;
|
|
41
|
+
//# sourceMappingURL=pbr-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pbr-model.d.ts","sourceRoot":"","sources":["../../src/lighting/pbr-model.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAC,QAAQ,EAAC,gCAA6B;AACnD,OAAO,EAAC,KAAK,EAAE,KAAK,UAAU,EAAC,0BAAuB;AAWtD,8EAA8E;AAC9E,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,+FAA+F;AAC/F,wBAAgB,eAAe,CAAC,KAAK,GAAE,mBAAwB,GAAG,MAAM,CAuMvE;AAED,eAAO,MAAM,qBAAqB,QAAoC,CAAC;AA8JvE,8EAA8E;AAC9E,MAAM,MAAM,qBAAqB,GAAG,UAAU,GAAG;IAC/C,0EAA0E;IAC1E,QAAQ,EAAE,QAAQ,CAAC;IACnB,6EAA6E;IAC7E,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,uEAAuE;IACvE,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,yEAAyE;IACzE,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC,CAAC;AAEF,4EAA4E;AAC5E,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,GAAG,KAAK,CAuDpF;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,GAAG,KAAK,CAW1F;AAED,mGAAmG;AACnG,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,GAAG,KAAK,CAW3F;AAED,4EAA4E;AAC5E,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAa/F;AAED,mGAAmG;AACnG,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAyB/F"}
|