@luma.gl/gltf 9.0.0-alpha.48 → 9.0.0-alpha.51
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/dist.dev.js +191 -120
- package/dist.min.js +134 -131
- package/package.json +6 -6
package/dist/dist.dev.js
CHANGED
|
@@ -1272,7 +1272,7 @@ var __exports__ = (() => {
|
|
|
1272
1272
|
throw new Error(`Accessing '${canvasId}' before page was loaded`);
|
|
1273
1273
|
}
|
|
1274
1274
|
if (!(canvas instanceof HTMLCanvasElement)) {
|
|
1275
|
-
throw new Error(
|
|
1275
|
+
throw new Error("Object is not a canvas element");
|
|
1276
1276
|
}
|
|
1277
1277
|
return canvas;
|
|
1278
1278
|
}
|
|
@@ -1356,26 +1356,172 @@ var __exports__ = (() => {
|
|
|
1356
1356
|
__publicField(Texture, "STORAGE_BINDING", 8);
|
|
1357
1357
|
__publicField(Texture, "RENDER_ATTACHMENT", 16);
|
|
1358
1358
|
|
|
1359
|
+
// ../core/src/lib/compiler-log/format-compiler-log.ts
|
|
1360
|
+
function formatCompilerLog(shaderLog, source, options) {
|
|
1361
|
+
let formattedLog = "";
|
|
1362
|
+
const lines = source.split(/\r?\n/);
|
|
1363
|
+
const log3 = shaderLog.slice().sort((a, b) => a.lineNum - b.lineNum);
|
|
1364
|
+
switch (options?.showSourceCode || "no") {
|
|
1365
|
+
case "all":
|
|
1366
|
+
let currentMessage = 0;
|
|
1367
|
+
for (let lineNum = 1; lineNum <= lines.length; lineNum++) {
|
|
1368
|
+
formattedLog += getNumberedLine(lines[lineNum - 1], lineNum, options);
|
|
1369
|
+
while (log3.length > currentMessage && log3[currentMessage].lineNum === lineNum) {
|
|
1370
|
+
const message2 = log3[currentMessage++];
|
|
1371
|
+
formattedLog += formatCompilerMessage(message2, lines, message2.lineNum, {
|
|
1372
|
+
...options,
|
|
1373
|
+
inlineSource: false
|
|
1374
|
+
});
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
return formattedLog;
|
|
1378
|
+
case "issues":
|
|
1379
|
+
case "no":
|
|
1380
|
+
for (const message2 of shaderLog) {
|
|
1381
|
+
formattedLog += formatCompilerMessage(message2, lines, message2.lineNum, {
|
|
1382
|
+
inlineSource: options?.showSourceCode !== "no"
|
|
1383
|
+
});
|
|
1384
|
+
}
|
|
1385
|
+
return formattedLog;
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
function formatCompilerMessage(message2, lines, lineNum, options) {
|
|
1389
|
+
if (options?.inlineSource) {
|
|
1390
|
+
const numberedLines = getNumberedLines(lines, lineNum);
|
|
1391
|
+
const positionIndicator = message2.linePos > 0 ? `${" ".repeat(message2.linePos + 5)}^^^
|
|
1392
|
+
` : "";
|
|
1393
|
+
return `
|
|
1394
|
+
${numberedLines}${positionIndicator}${message2.type.toUpperCase()}: ${message2.message}
|
|
1395
|
+
|
|
1396
|
+
`;
|
|
1397
|
+
}
|
|
1398
|
+
return options?.html ? `<div class='luma-compiler-log-error' style="color:red;"><b> ${message2.type.toUpperCase()}: ${message2.message}</b></div>` : `${message2.type.toUpperCase()}: ${message2.message}`;
|
|
1399
|
+
}
|
|
1400
|
+
function getNumberedLines(lines, lineNum, options) {
|
|
1401
|
+
let numberedLines = "";
|
|
1402
|
+
for (let lineIndex = lineNum - 2; lineIndex <= lineNum; lineIndex++) {
|
|
1403
|
+
const sourceLine = lines[lineIndex - 1];
|
|
1404
|
+
if (sourceLine !== void 0) {
|
|
1405
|
+
numberedLines += getNumberedLine(sourceLine, lineNum, options);
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
return numberedLines;
|
|
1409
|
+
}
|
|
1410
|
+
function getNumberedLine(line, lineNum, options) {
|
|
1411
|
+
return `${padLeft(String(lineNum), 4)}: ${line}${options?.html ? "<br/>" : "\n"}`;
|
|
1412
|
+
}
|
|
1413
|
+
function padLeft(string, paddedLength) {
|
|
1414
|
+
let result = "";
|
|
1415
|
+
for (let i = string.length; i < paddedLength; ++i) {
|
|
1416
|
+
result += " ";
|
|
1417
|
+
}
|
|
1418
|
+
return result + string;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
// ../core/src/lib/compiler-log/get-shader-info.ts
|
|
1422
|
+
function getShaderInfo(source, defaultName) {
|
|
1423
|
+
return {
|
|
1424
|
+
name: getShaderName(source, defaultName),
|
|
1425
|
+
language: "glsl",
|
|
1426
|
+
version: getShaderVersion(source)
|
|
1427
|
+
};
|
|
1428
|
+
}
|
|
1429
|
+
function getShaderName(shader, defaultName = "unnamed") {
|
|
1430
|
+
const SHADER_NAME_REGEXP = /#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/;
|
|
1431
|
+
const match = SHADER_NAME_REGEXP.exec(shader);
|
|
1432
|
+
return match ? match[1] : defaultName;
|
|
1433
|
+
}
|
|
1434
|
+
function getShaderVersion(source) {
|
|
1435
|
+
let version = 100;
|
|
1436
|
+
const words = source.match(/[^\s]+/g);
|
|
1437
|
+
if (words && words.length >= 2 && words[0] === "#version") {
|
|
1438
|
+
const v = parseInt(words[1], 10);
|
|
1439
|
+
if (Number.isFinite(v)) {
|
|
1440
|
+
version = v;
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
return version;
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1359
1446
|
// ../core/src/adapter/resources/shader.ts
|
|
1360
1447
|
var _Shader = class extends Resource {
|
|
1361
1448
|
get [Symbol.toStringTag]() {
|
|
1362
1449
|
return "Shader";
|
|
1363
1450
|
}
|
|
1451
|
+
compilationStatus = "pending";
|
|
1364
1452
|
constructor(device, props) {
|
|
1365
|
-
super(device,
|
|
1453
|
+
super(device, {
|
|
1454
|
+
id: getShaderIdFromProps(props),
|
|
1455
|
+
...props
|
|
1456
|
+
}, _Shader.defaultProps);
|
|
1366
1457
|
this.stage = this.props.stage;
|
|
1367
1458
|
this.source = this.props.source;
|
|
1368
1459
|
}
|
|
1460
|
+
getCompilationInfoSync() {
|
|
1461
|
+
return null;
|
|
1462
|
+
}
|
|
1463
|
+
async debugShader() {
|
|
1464
|
+
switch (this.props.debug) {
|
|
1465
|
+
case "never":
|
|
1466
|
+
return;
|
|
1467
|
+
case "errors":
|
|
1468
|
+
if (this.compilationStatus === "success") {
|
|
1469
|
+
return;
|
|
1470
|
+
}
|
|
1471
|
+
break;
|
|
1472
|
+
case "warnings":
|
|
1473
|
+
case "always":
|
|
1474
|
+
break;
|
|
1475
|
+
}
|
|
1476
|
+
const messages = await this.getCompilationInfo();
|
|
1477
|
+
if (this.props.debug === "warnings" && messages?.length === 0) {
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
this._displayShaderLog(messages);
|
|
1481
|
+
}
|
|
1482
|
+
_displayShaderLog(messages) {
|
|
1483
|
+
if (typeof document === "undefined" || !document?.createElement) {
|
|
1484
|
+
return;
|
|
1485
|
+
}
|
|
1486
|
+
const shaderName = getShaderInfo(this.source).name;
|
|
1487
|
+
const shaderTitle = `${this.stage} ${shaderName}`;
|
|
1488
|
+
const htmlLog = formatCompilerLog(messages, this.source, {
|
|
1489
|
+
showSourceCode: "all",
|
|
1490
|
+
html: true
|
|
1491
|
+
});
|
|
1492
|
+
const button = document.createElement("Button");
|
|
1493
|
+
button.innerHTML = `
|
|
1494
|
+
<h1>Shader Compilation Error in ${shaderTitle}</h1><br /><br />
|
|
1495
|
+
<code style="user-select:text;"><pre>
|
|
1496
|
+
${htmlLog}
|
|
1497
|
+
</pre></code>`;
|
|
1498
|
+
button.style.top = "10px";
|
|
1499
|
+
button.style.left = "10px";
|
|
1500
|
+
button.style.position = "absolute";
|
|
1501
|
+
button.style.zIndex = "9999";
|
|
1502
|
+
button.style.width = "100%";
|
|
1503
|
+
button.style.textAlign = "left";
|
|
1504
|
+
document.body.appendChild(button);
|
|
1505
|
+
document.getElementsByClassName("luma-compiler-log-error")[0]?.scrollIntoView();
|
|
1506
|
+
button.onclick = () => {
|
|
1507
|
+
const dataURI = `data:text/plain,${encodeURIComponent(this.source)}`;
|
|
1508
|
+
navigator.clipboard.writeText(dataURI);
|
|
1509
|
+
};
|
|
1510
|
+
}
|
|
1369
1511
|
};
|
|
1370
1512
|
var Shader = _Shader;
|
|
1371
1513
|
__publicField(Shader, "defaultProps", {
|
|
1372
1514
|
...Resource.defaultProps,
|
|
1515
|
+
language: "auto",
|
|
1373
1516
|
stage: "vertex",
|
|
1374
1517
|
source: "",
|
|
1375
1518
|
sourceMap: null,
|
|
1376
|
-
|
|
1377
|
-
|
|
1519
|
+
entryPoint: "main",
|
|
1520
|
+
debug: "errors"
|
|
1378
1521
|
});
|
|
1522
|
+
function getShaderIdFromProps(props) {
|
|
1523
|
+
return getShaderInfo(props.source).name || props.id || uid(`unnamed ${props.stage}-shader`);
|
|
1524
|
+
}
|
|
1379
1525
|
|
|
1380
1526
|
// ../core/src/adapter/resources/sampler.ts
|
|
1381
1527
|
var _Sampler = class extends Resource {
|
|
@@ -2266,7 +2412,7 @@ var __exports__ = (() => {
|
|
|
2266
2412
|
const decodedType = decodeVertexType(dataType);
|
|
2267
2413
|
return {
|
|
2268
2414
|
format: format2,
|
|
2269
|
-
components:
|
|
2415
|
+
components: format2.length,
|
|
2270
2416
|
srgb: srgb === "-srgb",
|
|
2271
2417
|
unsized: suffix === "-unsized",
|
|
2272
2418
|
webgl: suffix === "-webgl",
|
|
@@ -2348,7 +2494,7 @@ var __exports__ = (() => {
|
|
|
2348
2494
|
}
|
|
2349
2495
|
return {
|
|
2350
2496
|
format: data.format || "",
|
|
2351
|
-
components: data.components || 1,
|
|
2497
|
+
components: data.components || data.format?.length || 1,
|
|
2352
2498
|
byteLength: data.bpp || 1,
|
|
2353
2499
|
srgb: false,
|
|
2354
2500
|
unsized: false
|
|
@@ -2408,46 +2554,6 @@ var __exports__ = (() => {
|
|
|
2408
2554
|
return `${dataType}x${components}`;
|
|
2409
2555
|
}
|
|
2410
2556
|
|
|
2411
|
-
// ../core/src/lib/compiler-log/format-compiler-log.ts
|
|
2412
|
-
function formatCompilerLog(shaderLog, source, options) {
|
|
2413
|
-
const lines = source.split(/\r?\n/);
|
|
2414
|
-
let formattedLog = "";
|
|
2415
|
-
for (const message2 of shaderLog) {
|
|
2416
|
-
formattedLog += formatCompilerMessage(message2, lines, message2.lineNum, options);
|
|
2417
|
-
}
|
|
2418
|
-
return formattedLog;
|
|
2419
|
-
}
|
|
2420
|
-
function formatCompilerMessage(message2, lines, lineNum, options) {
|
|
2421
|
-
if (options?.showSourceCode) {
|
|
2422
|
-
const positionIndicator = message2.linePos > 0 ? `${" ".repeat(message2.linePos + 5)}^^^
|
|
2423
|
-
` : "";
|
|
2424
|
-
const numberedLines = getNumberedLines(lines, lineNum);
|
|
2425
|
-
return `${numberedLines}${positionIndicator}${message2.type.toUpperCase()}: ${message2.message}
|
|
2426
|
-
|
|
2427
|
-
`;
|
|
2428
|
-
}
|
|
2429
|
-
return `${message2.type.toUpperCase()}: ${message2.message}
|
|
2430
|
-
`;
|
|
2431
|
-
}
|
|
2432
|
-
function getNumberedLines(lines, lineNum) {
|
|
2433
|
-
let numberedLines = "";
|
|
2434
|
-
for (let line = lineNum - 2; line <= lineNum; line++) {
|
|
2435
|
-
const sourceLine = lines[line];
|
|
2436
|
-
if (sourceLine !== void 0) {
|
|
2437
|
-
numberedLines += `${padLeft(String(line), 4)}: ${sourceLine}
|
|
2438
|
-
`;
|
|
2439
|
-
}
|
|
2440
|
-
}
|
|
2441
|
-
return numberedLines;
|
|
2442
|
-
}
|
|
2443
|
-
function padLeft(string, paddedLength) {
|
|
2444
|
-
let result = "";
|
|
2445
|
-
for (let i = string.length; i < paddedLength; ++i) {
|
|
2446
|
-
result += " ";
|
|
2447
|
-
}
|
|
2448
|
-
return result + string;
|
|
2449
|
-
}
|
|
2450
|
-
|
|
2451
2557
|
// ../core/src/lib/utils/cast.ts
|
|
2452
2558
|
function cast(value) {
|
|
2453
2559
|
return value;
|
|
@@ -2965,7 +3071,7 @@ var __exports__ = (() => {
|
|
|
2965
3071
|
if (module instanceof ShaderModuleInstance) {
|
|
2966
3072
|
return module;
|
|
2967
3073
|
}
|
|
2968
|
-
assert3(typeof module !== "string", `Shader module use by name is deprecated. Import shader module '${module}' and use it directly.`);
|
|
3074
|
+
assert3(typeof module !== "string", `Shader module use by name is deprecated. Import shader module '${JSON.stringify(module)}' and use it directly.`);
|
|
2969
3075
|
if (!module.name) {
|
|
2970
3076
|
console.warn("shader module has no name");
|
|
2971
3077
|
module.name = `shader-module-${index++}`;
|
|
@@ -3337,19 +3443,19 @@ ${moduleSource}
|
|
|
3337
3443
|
}
|
|
3338
3444
|
|
|
3339
3445
|
// ../shadertools/src/lib/glsl-utils/get-shader-info.ts
|
|
3340
|
-
function
|
|
3446
|
+
function getShaderInfo2(source, defaultName) {
|
|
3341
3447
|
return {
|
|
3342
|
-
name:
|
|
3448
|
+
name: getShaderName2(source, defaultName),
|
|
3343
3449
|
language: "glsl",
|
|
3344
|
-
version:
|
|
3450
|
+
version: getShaderVersion2(source)
|
|
3345
3451
|
};
|
|
3346
3452
|
}
|
|
3347
|
-
function
|
|
3453
|
+
function getShaderName2(shader, defaultName = "unnamed") {
|
|
3348
3454
|
const SHADER_NAME_REGEXP = /#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/;
|
|
3349
3455
|
const match = SHADER_NAME_REGEXP.exec(shader);
|
|
3350
3456
|
return match ? match[1] : defaultName;
|
|
3351
3457
|
}
|
|
3352
|
-
function
|
|
3458
|
+
function getShaderVersion2(source) {
|
|
3353
3459
|
let version = 100;
|
|
3354
3460
|
const words = source.match(/[^\s]+/g);
|
|
3355
3461
|
if (words && words.length >= 2 && words[0] === "#version") {
|
|
@@ -3498,7 +3604,7 @@ precision highp float;
|
|
|
3498
3604
|
log: log3
|
|
3499
3605
|
} = options;
|
|
3500
3606
|
assert3(typeof source === "string", "shader source must be a string");
|
|
3501
|
-
const sourceVersion = language === "glsl" ?
|
|
3607
|
+
const sourceVersion = language === "glsl" ? getShaderInfo2(source).version : -1;
|
|
3502
3608
|
const targetVersion = platformInfo.shaderLanguageVersion;
|
|
3503
3609
|
const sourceVersionDirective = sourceVersion === 100 ? "#version 100" : "#version 300 es";
|
|
3504
3610
|
const sourceLines = source.split("\n");
|
|
@@ -6410,14 +6516,14 @@ uniform mat4 u_MVPMatrix;
|
|
|
6410
6516
|
uniform mat4 u_ModelMatrix;
|
|
6411
6517
|
uniform mat4 u_NormalMatrix;
|
|
6412
6518
|
|
|
6413
|
-
|
|
6414
|
-
|
|
6519
|
+
out vec3 pbr_vPosition;
|
|
6520
|
+
out vec2 pbr_vUV;
|
|
6415
6521
|
|
|
6416
6522
|
#ifdef HAS_NORMALS
|
|
6417
6523
|
# ifdef HAS_TANGENTS
|
|
6418
|
-
|
|
6524
|
+
out mat3 pbr_vTBN;
|
|
6419
6525
|
# else
|
|
6420
|
-
|
|
6526
|
+
out vec3 pbr_vNormal;
|
|
6421
6527
|
# endif
|
|
6422
6528
|
#endif
|
|
6423
6529
|
|
|
@@ -6509,15 +6615,15 @@ uniform vec4 u_ScaleDiffBaseMR;
|
|
|
6509
6615
|
uniform vec4 u_ScaleFGDSpec;
|
|
6510
6616
|
#endif
|
|
6511
6617
|
|
|
6512
|
-
|
|
6618
|
+
in vec3 pbr_vPosition;
|
|
6513
6619
|
|
|
6514
|
-
|
|
6620
|
+
in vec2 pbr_vUV;
|
|
6515
6621
|
|
|
6516
6622
|
#ifdef HAS_NORMALS
|
|
6517
6623
|
#ifdef HAS_TANGENTS
|
|
6518
|
-
|
|
6624
|
+
in mat3 pbr_vTBN;
|
|
6519
6625
|
#else
|
|
6520
|
-
|
|
6626
|
+
in vec3 pbr_vNormal;
|
|
6521
6627
|
#endif
|
|
6522
6628
|
#endif
|
|
6523
6629
|
|
|
@@ -6586,7 +6692,7 @@ vec3 getNormal()
|
|
|
6586
6692
|
#endif
|
|
6587
6693
|
|
|
6588
6694
|
#ifdef HAS_NORMALMAP
|
|
6589
|
-
vec3 n =
|
|
6695
|
+
vec3 n = texture(u_NormalSampler, pbr_vUV).rgb;
|
|
6590
6696
|
n = normalize(tbn * ((2.0 * n - 1.0) * vec3(u_NormalScale, u_NormalScale, 1.0)));
|
|
6591
6697
|
#else
|
|
6592
6698
|
// The tbn matrix is linearly interpolated, so we need to re-normalize
|
|
@@ -6605,7 +6711,7 @@ vec3 getIBLContribution(PBRInfo pbrInputs, vec3 n, vec3 reflection)
|
|
|
6605
6711
|
float mipCount = 9.0; // resolution of 512x512
|
|
6606
6712
|
float lod = (pbrInputs.perceptualRoughness * mipCount);
|
|
6607
6713
|
// retrieve a scale and bias to F0. See [1], Figure 3
|
|
6608
|
-
vec3 brdf = SRGBtoLINEAR(
|
|
6714
|
+
vec3 brdf = SRGBtoLINEAR(texture(u_brdfLUT,
|
|
6609
6715
|
vec2(pbrInputs.NdotV, 1.0 - pbrInputs.perceptualRoughness))).rgb;
|
|
6610
6716
|
vec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb;
|
|
6611
6717
|
|
|
@@ -6712,7 +6818,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
6712
6818
|
{
|
|
6713
6819
|
// The albedo may be defined from a base texture or a flat color
|
|
6714
6820
|
#ifdef HAS_BASECOLORMAP
|
|
6715
|
-
vec4 baseColor = SRGBtoLINEAR(
|
|
6821
|
+
vec4 baseColor = SRGBtoLINEAR(texture(u_BaseColorSampler, pbr_vUV)) * u_BaseColorFactor;
|
|
6716
6822
|
#else
|
|
6717
6823
|
vec4 baseColor = u_BaseColorFactor;
|
|
6718
6824
|
#endif
|
|
@@ -6737,7 +6843,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
6737
6843
|
#ifdef HAS_METALROUGHNESSMAP
|
|
6738
6844
|
// Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel.
|
|
6739
6845
|
// This layout intentionally reserves the 'r' channel for (optional) occlusion map data
|
|
6740
|
-
vec4 mrSample =
|
|
6846
|
+
vec4 mrSample = texture(u_MetallicRoughnessSampler, pbr_vUV);
|
|
6741
6847
|
perceptualRoughness = mrSample.g * perceptualRoughness;
|
|
6742
6848
|
metallic = mrSample.b * metallic;
|
|
6743
6849
|
#endif
|
|
@@ -6816,12 +6922,12 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
6816
6922
|
|
|
6817
6923
|
// Apply optional PBR terms for additional (optional) shading
|
|
6818
6924
|
#ifdef HAS_OCCLUSIONMAP
|
|
6819
|
-
float ao =
|
|
6925
|
+
float ao = texture(u_OcclusionSampler, pbr_vUV).r;
|
|
6820
6926
|
color = mix(color, color * ao, u_OcclusionStrength);
|
|
6821
6927
|
#endif
|
|
6822
6928
|
|
|
6823
6929
|
#ifdef HAS_EMISSIVEMAP
|
|
6824
|
-
vec3 emissive = SRGBtoLINEAR(
|
|
6930
|
+
vec3 emissive = SRGBtoLINEAR(texture(u_EmissiveSampler, pbr_vUV)).rgb * u_EmissiveFactor;
|
|
6825
6931
|
color += emissive;
|
|
6826
6932
|
#endif
|
|
6827
6933
|
|
|
@@ -6868,7 +6974,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
6868
6974
|
this.moduleBindings = {};
|
|
6869
6975
|
for (const [name2, module] of Object.entries(modules)) {
|
|
6870
6976
|
const moduleName = name2;
|
|
6871
|
-
this.moduleUniforms[moduleName] = module.
|
|
6977
|
+
this.moduleUniforms[moduleName] = module.defaultUniforms || {};
|
|
6872
6978
|
this.moduleBindings[moduleName] = {};
|
|
6873
6979
|
}
|
|
6874
6980
|
}
|
|
@@ -6879,10 +6985,12 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
6879
6985
|
const moduleName = name2;
|
|
6880
6986
|
const moduleProps = props[moduleName];
|
|
6881
6987
|
const module = this.modules[moduleName];
|
|
6882
|
-
const
|
|
6883
|
-
|
|
6884
|
-
this.moduleUniforms[moduleName] =
|
|
6885
|
-
|
|
6988
|
+
const oldUniforms = this.moduleUniforms[moduleName];
|
|
6989
|
+
const uniforms = module.getUniforms?.(moduleProps, this.moduleUniforms[moduleName]) || moduleProps;
|
|
6990
|
+
this.moduleUniforms[moduleName] = {
|
|
6991
|
+
...oldUniforms,
|
|
6992
|
+
...uniforms
|
|
6993
|
+
};
|
|
6886
6994
|
}
|
|
6887
6995
|
}
|
|
6888
6996
|
getModules() {
|
|
@@ -12553,31 +12661,6 @@ void main(void) {}`;
|
|
|
12553
12661
|
}
|
|
12554
12662
|
}
|
|
12555
12663
|
|
|
12556
|
-
// ../webgl/src/adapter/helpers/get-shader-info.ts
|
|
12557
|
-
function getShaderInfo2(source, defaultName) {
|
|
12558
|
-
return {
|
|
12559
|
-
name: getShaderName2(source, defaultName),
|
|
12560
|
-
language: "glsl",
|
|
12561
|
-
version: getShaderVersion2(source)
|
|
12562
|
-
};
|
|
12563
|
-
}
|
|
12564
|
-
function getShaderName2(shader, defaultName = "unnamed") {
|
|
12565
|
-
const SHADER_NAME_REGEXP = /#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/;
|
|
12566
|
-
const match = SHADER_NAME_REGEXP.exec(shader);
|
|
12567
|
-
return match ? match[1] : defaultName;
|
|
12568
|
-
}
|
|
12569
|
-
function getShaderVersion2(source) {
|
|
12570
|
-
let version = 100;
|
|
12571
|
-
const words = source.match(/[^\s]+/g);
|
|
12572
|
-
if (words && words.length >= 2 && words[0] === "#version") {
|
|
12573
|
-
const v = parseInt(words[1], 10);
|
|
12574
|
-
if (Number.isFinite(v)) {
|
|
12575
|
-
version = v;
|
|
12576
|
-
}
|
|
12577
|
-
}
|
|
12578
|
-
return version;
|
|
12579
|
-
}
|
|
12580
|
-
|
|
12581
12664
|
// ../webgl/src/adapter/helpers/parse-shader-compiler-log.ts
|
|
12582
12665
|
function parseShaderCompilerLog(errLog) {
|
|
12583
12666
|
const lines = errLog.split(/\r?\n/);
|
|
@@ -12624,10 +12707,7 @@ void main(void) {}`;
|
|
|
12624
12707
|
// ../webgl/src/adapter/resources/webgl-shader.ts
|
|
12625
12708
|
var WEBGLShader = class extends Shader {
|
|
12626
12709
|
constructor(device, props) {
|
|
12627
|
-
super(device,
|
|
12628
|
-
id: getShaderIdFromProps(props),
|
|
12629
|
-
...props
|
|
12630
|
-
});
|
|
12710
|
+
super(device, props);
|
|
12631
12711
|
this.device = device;
|
|
12632
12712
|
switch (this.props.stage) {
|
|
12633
12713
|
case "vertex":
|
|
@@ -12648,9 +12728,12 @@ void main(void) {}`;
|
|
|
12648
12728
|
this.destroyed = true;
|
|
12649
12729
|
}
|
|
12650
12730
|
}
|
|
12651
|
-
async
|
|
12731
|
+
async getCompilationInfo() {
|
|
12732
|
+
return this.getCompilationInfoSync();
|
|
12733
|
+
}
|
|
12734
|
+
getCompilationInfoSync() {
|
|
12652
12735
|
const log3 = this.device.gl.getShaderInfoLog(this.handle);
|
|
12653
|
-
return
|
|
12736
|
+
return parseShaderCompilerLog(log3);
|
|
12654
12737
|
}
|
|
12655
12738
|
_compile(source) {
|
|
12656
12739
|
const addGLSLVersion = (source2) => source2.startsWith("#version ") ? source2 : `#version 100
|
|
@@ -12661,25 +12744,13 @@ ${source2}`;
|
|
|
12661
12744
|
} = this.device;
|
|
12662
12745
|
gl.shaderSource(this.handle, source);
|
|
12663
12746
|
gl.compileShader(this.handle);
|
|
12664
|
-
|
|
12665
|
-
|
|
12666
|
-
|
|
12667
|
-
|
|
12668
|
-
const messages = parsedLog.filter((message2) => message2.type === "error");
|
|
12669
|
-
const formattedLog = formatCompilerLog(messages, source, {
|
|
12670
|
-
showSourceCode: true
|
|
12671
|
-
});
|
|
12672
|
-
const shaderName = getShaderInfo2(source).name;
|
|
12673
|
-
const shaderDescription = `${this.stage} shader ${shaderName}`;
|
|
12674
|
-
log.error(`GLSL compilation errors in ${shaderDescription}
|
|
12675
|
-
${formattedLog}`)();
|
|
12676
|
-
throw new Error(`GLSL compilation errors in ${shaderName}`);
|
|
12747
|
+
this.compilationStatus = gl.getShaderParameter(this.handle, GLEnum2.COMPILE_STATUS) ? "success" : "error";
|
|
12748
|
+
this.debugShader();
|
|
12749
|
+
if (this.compilationStatus === "error") {
|
|
12750
|
+
throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);
|
|
12677
12751
|
}
|
|
12678
12752
|
}
|
|
12679
12753
|
};
|
|
12680
|
-
function getShaderIdFromProps(props) {
|
|
12681
|
-
return getShaderInfo2(props.source).name || props.id || uid(`unnamed ${props.stage}-shader`);
|
|
12682
|
-
}
|
|
12683
12754
|
|
|
12684
12755
|
// ../webgl/src/adapter/resources/webgl-render-pass.ts
|
|
12685
12756
|
var GL_DEPTH_BUFFER_BIT = 256;
|
|
@@ -13425,7 +13496,7 @@ ${formattedLog}`)();
|
|
|
13425
13496
|
bindings
|
|
13426
13497
|
} = splitUniformsAndBindings(uniforms);
|
|
13427
13498
|
Object.keys(bindings).forEach((name2) => {
|
|
13428
|
-
log.warn(`Unsupported value "${bindings[name2]}" used in setUniforms() for key ${name2}. Use setBindings() instead?`)();
|
|
13499
|
+
log.warn(`Unsupported value "${JSON.stringify(bindings[name2])}" used in setUniforms() for key ${name2}. Use setBindings() instead?`)();
|
|
13429
13500
|
});
|
|
13430
13501
|
Object.assign(this.uniforms, uniforms);
|
|
13431
13502
|
}
|