lythreeframe 1.2.22 → 1.2.24
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/bundle.cjs.js +222 -330
- package/dist/bundle.esm.js +225 -333
- package/dist/index.d.ts +5 -3
- package/dist/lythreeframe/Frame/Viewport.d.ts +2 -22
- package/dist/lythreeframe/PostProcess/Param/AAParam.d.ts +4 -3
- package/dist/lythreeframe/PostProcess/Param/Bloom.d.ts +3 -2
- package/dist/lythreeframe/PostProcess/Param/DOF.d.ts +3 -2
- package/dist/lythreeframe/PostProcess/Param/GTAO.d.ts +10 -3
- package/dist/lythreeframe/PostProcess/Param/Outline.d.ts +3 -2
- package/dist/lythreeframe/PostProcess/Param/SSR.d.ts +3 -2
- package/dist/lythreeframe/PostProcess/PostProcessParam.d.ts +12 -12
- package/dist/lythreeframe/PostProcess/WebGPUPostProcessFactory.d.ts +10 -17
- package/package.json +3 -3
- package/dist/lythreeframe/PostProcess/Param/Denoise.d.ts +0 -7
package/dist/bundle.cjs.js
CHANGED
|
@@ -3,15 +3,12 @@
|
|
|
3
3
|
var webgpu = require('three/webgpu');
|
|
4
4
|
var Addons_js = require('three/examples/jsm/Addons.js');
|
|
5
5
|
var tsl = require('three/tsl');
|
|
6
|
+
var DepthOfFieldNode_js = require('three/addons/tsl/display/DepthOfFieldNode.js');
|
|
6
7
|
var BloomNode_js = require('three/examples/jsm/tsl/display/BloomNode.js');
|
|
7
8
|
var DenoiseNode_js = require('three/examples/jsm/tsl/display/DenoiseNode.js');
|
|
8
|
-
var
|
|
9
|
+
var FXAANode_js = require('three/examples/jsm/tsl/display/FXAANode.js');
|
|
9
10
|
var GTAONode_js = require('three/examples/jsm/tsl/display/GTAONode.js');
|
|
10
|
-
var SSRNode_js = require('three/examples/jsm/tsl/display/SSRNode.js');
|
|
11
|
-
var LensflareNode_js = require('three/examples/jsm/tsl/display/LensflareNode.js');
|
|
12
11
|
var OutlineNode_js = require('three/examples/jsm/tsl/display/OutlineNode.js');
|
|
13
|
-
var MotionBlur_js = require('three/examples/jsm/tsl/display/MotionBlur.js');
|
|
14
|
-
var FXAANode_js = require('three/examples/jsm/tsl/display/FXAANode.js');
|
|
15
12
|
var SMAANode_js = require('three/examples/jsm/tsl/display/SMAANode.js');
|
|
16
13
|
var gsap = require('gsap');
|
|
17
14
|
var three = require('three');
|
|
@@ -1263,68 +1260,18 @@ class Delegate {
|
|
|
1263
1260
|
}
|
|
1264
1261
|
}
|
|
1265
1262
|
|
|
1266
|
-
const DefaultSSRParam = {
|
|
1267
|
-
isEnabled: false,
|
|
1268
|
-
maxDistance: 0.5,
|
|
1269
|
-
opacity: 1,
|
|
1270
|
-
thickness: 0.015,
|
|
1271
|
-
};
|
|
1272
|
-
|
|
1273
|
-
const DefaultDenoiseParam = {
|
|
1274
|
-
denoiseRadius: 5,
|
|
1275
|
-
lumaPhi: 5,
|
|
1276
|
-
depthPhi: 5,
|
|
1277
|
-
normalPhi: 5
|
|
1278
|
-
};
|
|
1279
|
-
|
|
1280
|
-
const DefaultGTAOParam = {
|
|
1281
|
-
isEnabled: false,
|
|
1282
|
-
distanceExponent: 1,
|
|
1283
|
-
distanceFallOff: 1,
|
|
1284
|
-
radius: 0.25,
|
|
1285
|
-
scale: 1,
|
|
1286
|
-
thickness: 1,
|
|
1287
|
-
denoised: true,
|
|
1288
|
-
denoiseParam: DefaultDenoiseParam,
|
|
1289
|
-
};
|
|
1290
|
-
|
|
1291
|
-
const DefaultBloomParam = {
|
|
1292
|
-
isEnabled: false,
|
|
1293
|
-
threshold: 0,
|
|
1294
|
-
strength: 1,
|
|
1295
|
-
radius: 0,
|
|
1296
|
-
};
|
|
1297
|
-
|
|
1298
|
-
const DefaultDOFParam = {
|
|
1299
|
-
isEnabled: false,
|
|
1300
|
-
focus: 500.0,
|
|
1301
|
-
aperture: 5,
|
|
1302
|
-
maxblur: 0.01
|
|
1303
|
-
};
|
|
1304
|
-
|
|
1305
|
-
const DefaultOutlineParams = {
|
|
1306
|
-
isEnabled: false,
|
|
1307
|
-
edgeStrength: 3.0,
|
|
1308
|
-
edgeGlow: 1.0,
|
|
1309
|
-
edgeThickness: 1.0,
|
|
1310
|
-
pulsePeriod: 0.0,
|
|
1311
|
-
visibleEdgeColor: 0xffffff,
|
|
1312
|
-
hiddenEdgeColor: 0xffffff,
|
|
1313
|
-
};
|
|
1314
|
-
|
|
1315
|
-
const DefaultAAParams = {
|
|
1316
|
-
isEnabled: false,
|
|
1317
|
-
type: "fxaa",
|
|
1318
|
-
};
|
|
1319
|
-
|
|
1320
1263
|
const DefaultPostProcessParam = {
|
|
1321
|
-
|
|
1322
|
-
dof: Object.assign({}, DefaultDOFParam),
|
|
1323
|
-
ssr: Object.assign({}, DefaultSSRParam),
|
|
1324
|
-
gtao: Object.assign({}, DefaultGTAOParam),
|
|
1325
|
-
outline: Object.assign({}, DefaultOutlineParams),
|
|
1326
|
-
aa: Object.assign({}, DefaultAAParams)
|
|
1264
|
+
steps: []
|
|
1327
1265
|
};
|
|
1266
|
+
exports.PostProcessStepType = void 0;
|
|
1267
|
+
(function (PostProcessStepType) {
|
|
1268
|
+
PostProcessStepType[PostProcessStepType["Bloom"] = 0] = "Bloom";
|
|
1269
|
+
PostProcessStepType[PostProcessStepType["DepthOfField"] = 1] = "DepthOfField";
|
|
1270
|
+
PostProcessStepType[PostProcessStepType["ScreenSpaceReflection"] = 2] = "ScreenSpaceReflection";
|
|
1271
|
+
PostProcessStepType[PostProcessStepType["GroundTruthAmbientOcclusion"] = 3] = "GroundTruthAmbientOcclusion";
|
|
1272
|
+
PostProcessStepType[PostProcessStepType["Outline"] = 4] = "Outline";
|
|
1273
|
+
PostProcessStepType[PostProcessStepType["Antialiasing"] = 5] = "Antialiasing";
|
|
1274
|
+
})(exports.PostProcessStepType || (exports.PostProcessStepType = {}));
|
|
1328
1275
|
|
|
1329
1276
|
class World {
|
|
1330
1277
|
get scene() {
|
|
@@ -1394,7 +1341,10 @@ class World {
|
|
|
1394
1341
|
class WebGPUPostProcessFactory {
|
|
1395
1342
|
// scene pass
|
|
1396
1343
|
static constructScenePass(scene, camera) {
|
|
1397
|
-
const scenePass = tsl.pass(scene, camera);
|
|
1344
|
+
const scenePass = tsl.pass(scene, camera, { minFilter: webgpu.NearestFilter, magFilter: webgpu.NearestFilter });
|
|
1345
|
+
// scenePass.setMRT(mrt({
|
|
1346
|
+
// output: output,
|
|
1347
|
+
// }));
|
|
1398
1348
|
scenePass.setMRT(tsl.mrt({
|
|
1399
1349
|
output: tsl.output,
|
|
1400
1350
|
}));
|
|
@@ -1404,12 +1354,12 @@ class WebGPUPostProcessFactory {
|
|
|
1404
1354
|
let oldMRT = scenePass.getMRT();
|
|
1405
1355
|
let newMRT = tsl.mrt(outputNodes);
|
|
1406
1356
|
if (oldMRT) {
|
|
1407
|
-
|
|
1357
|
+
let merge = oldMRT.merge(newMRT);
|
|
1358
|
+
scenePass.setMRT(merge);
|
|
1408
1359
|
}
|
|
1409
1360
|
else {
|
|
1410
1361
|
scenePass.setMRT(newMRT);
|
|
1411
1362
|
}
|
|
1412
|
-
console.log(scenePass.getMRT(), "MRTTTTTTT");
|
|
1413
1363
|
}
|
|
1414
1364
|
// bloom pass
|
|
1415
1365
|
static constructBloomPass(scenePass, params) {
|
|
@@ -1427,34 +1377,37 @@ class WebGPUPostProcessFactory {
|
|
|
1427
1377
|
static constructDOFPass(scenePass, params) {
|
|
1428
1378
|
const scenePassColor = scenePass.getTextureNode('output');
|
|
1429
1379
|
const scenePassViewZ = scenePass.getViewZNode();
|
|
1430
|
-
return DepthOfFieldNode_js.dof(scenePassColor, scenePassViewZ, tsl.uniform(params.focus), tsl.uniform(params.aperture)
|
|
1380
|
+
return DepthOfFieldNode_js.dof(scenePassColor, scenePassViewZ, tsl.uniform(params.focus), tsl.uniform(params.aperture), tsl.uniform(params.maxblur));
|
|
1431
1381
|
}
|
|
1432
1382
|
static updateDOFPass(dofPass, params) {
|
|
1433
1383
|
dofPass.focus.value = params.focus;
|
|
1434
|
-
dofPass.aperture.value = params.aperture
|
|
1384
|
+
dofPass.aperture.value = params.aperture;
|
|
1435
1385
|
dofPass.maxblur.value = params.maxblur;
|
|
1436
1386
|
}
|
|
1437
1387
|
// motion blur
|
|
1438
|
-
static constructMotionBlurPass(lastNode, scenePass
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1388
|
+
// static constructMotionBlurPass(lastNode:NodeRepresentation, scenePass: ShaderNodeObject<PassNode>, param:MotionBlurParam): ShaderNodeObject<Node>
|
|
1389
|
+
// {
|
|
1390
|
+
// WebGPUPostProcessFactory.updateScenePass(scenePass, {velocity})
|
|
1391
|
+
// const scenePassVelocity = scenePass.getTextureNode( 'velocity' ).mul( param.blurAmount );
|
|
1392
|
+
// const scenePassColor = scenePass.getTextureNode('output');
|
|
1393
|
+
// const motionBlurPass = motionBlur( scenePassColor, scenePassVelocity );
|
|
1394
|
+
// return motionBlurPass
|
|
1395
|
+
// }
|
|
1445
1396
|
// ssr
|
|
1446
1397
|
static constructSSRPass(scenePass, param) {
|
|
1447
1398
|
WebGPUPostProcessFactory.updateScenePass(scenePass, {
|
|
1399
|
+
output: tsl.output,
|
|
1448
1400
|
normal: tsl.transformedNormalView,
|
|
1449
|
-
metalness: tsl.metalness
|
|
1401
|
+
metalness: tsl.metalness
|
|
1450
1402
|
});
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
const
|
|
1456
|
-
ssrPass
|
|
1457
|
-
|
|
1403
|
+
let ssrPass = null;
|
|
1404
|
+
scenePass.getTextureNode('output');
|
|
1405
|
+
scenePass.getTextureNode('depth');
|
|
1406
|
+
scenePass.getTextureNode('normal');
|
|
1407
|
+
//const scenePassMetalness = scenePass.getTextureNode('metalness');
|
|
1408
|
+
// const ssrPass = ssr(scenePassColor, scenePassDepth, scenePassNormal, scenePassMetalness, scenePass.camera)
|
|
1409
|
+
// ssrPass.resolutionScale = 1.0;
|
|
1410
|
+
//WebGPUPostProcessFactory.updateSSRPass(ssrPass, param);
|
|
1458
1411
|
return ssrPass;
|
|
1459
1412
|
}
|
|
1460
1413
|
static updateSSRPass(ssrPass, params) {
|
|
@@ -1503,19 +1456,21 @@ class WebGPUPostProcessFactory {
|
|
|
1503
1456
|
static updateGTAODenoisePass(denoisePass, params) {
|
|
1504
1457
|
WebGPUPostProcessFactory.updateDenoisePass(denoisePass, params.denoiseParam);
|
|
1505
1458
|
}
|
|
1506
|
-
static constructLensFlarePass(inputNode, params)
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1459
|
+
// static constructLensFlarePass(inputNode: NodeRepresentation, params: LensFlareParam): ShaderNodeObject<LensflareNode>
|
|
1460
|
+
// {
|
|
1461
|
+
// const lensflarePass = lensflare(inputNode, {
|
|
1462
|
+
// threshold : uniform(params.threshold),
|
|
1463
|
+
// ghostAttenuationFactor: uniform(params.ghostAttenuationFactor),
|
|
1464
|
+
// ghostSpacing : uniform(params.ghostSpacing),
|
|
1465
|
+
// });
|
|
1466
|
+
// return lensflarePass;
|
|
1467
|
+
// }
|
|
1468
|
+
// static updateLensFlarPass(lensflarePass: ShaderNodeObject<LensflareNode>, params: LensFlareParam)
|
|
1469
|
+
// {
|
|
1470
|
+
// lensflarePass.thresholdNode.value = params.threshold
|
|
1471
|
+
// lensflarePass.ghostSpacingNode.value = params.ghostSpacing
|
|
1472
|
+
// lensflarePass.ghostAttenuationFactorNode.value = params.ghostAttenuationFactor
|
|
1473
|
+
// }
|
|
1519
1474
|
static constructOutlinePass(scene, camera, outlineObjects, param) {
|
|
1520
1475
|
const outlinePass = OutlineNode_js.outline(scene, camera, {
|
|
1521
1476
|
selectedObjects: outlineObjects,
|
|
@@ -1563,17 +1518,6 @@ class Viewport {
|
|
|
1563
1518
|
this._canvas = null;
|
|
1564
1519
|
this.isRenderStateDirty = true;
|
|
1565
1520
|
this.postProcessing = null;
|
|
1566
|
-
this.scenePass = null;
|
|
1567
|
-
this.bloomPass = null;
|
|
1568
|
-
this.dofPass = null;
|
|
1569
|
-
this.GTAOPass = null;
|
|
1570
|
-
this.denoiseGTAOPass = null;
|
|
1571
|
-
this.ssrPass = null;
|
|
1572
|
-
this.outlinePass = null;
|
|
1573
|
-
this.fxaaPass = null;
|
|
1574
|
-
this.smaaPass = null;
|
|
1575
|
-
// private motionBlurPass: ShaderNodeObject<Node> | null = null;
|
|
1576
|
-
// private denoiseOutlinePass: ShaderNodeObject<DenoiseNode> | null = null;
|
|
1577
1521
|
this.outlineObjects = [];
|
|
1578
1522
|
this.postProcessParam = Object.assign({}, postProcessParam);
|
|
1579
1523
|
this._app = app;
|
|
@@ -1635,221 +1579,144 @@ class Viewport {
|
|
|
1635
1579
|
this.setupPostProcess();
|
|
1636
1580
|
}
|
|
1637
1581
|
setupPostProcess() {
|
|
1638
|
-
|
|
1639
|
-
const isBloomEnabled = this.postProcessParam.bloom.isEnabled;
|
|
1640
|
-
const isDOFEnabled = this.postProcessParam.dof.isEnabled;
|
|
1641
|
-
const isSSREnabled = this.postProcessParam.ssr.isEnabled;
|
|
1642
|
-
const isGTAOEnabled = this.postProcessParam.gtao.isEnabled;
|
|
1643
|
-
const isOutlineEnabled = this.postProcessParam.outline.isEnabled;
|
|
1644
|
-
const isAAEnabled = this.postProcessParam.aa.isEnabled;
|
|
1645
|
-
if (!(isBloomEnabled) && !(isDOFEnabled) && !(isSSREnabled) && !(isGTAOEnabled) && !(isOutlineEnabled) && !(isAAEnabled)) {
|
|
1582
|
+
if (this.postProcessParam.steps.length === 0) {
|
|
1646
1583
|
this.destroyPostProcess();
|
|
1647
|
-
|
|
1584
|
+
this.markRenderStateDirty();
|
|
1648
1585
|
return;
|
|
1649
1586
|
}
|
|
1650
1587
|
if (!this.postProcessing) {
|
|
1651
1588
|
this.postProcessing = new webgpu.PostProcessing(this.renderer);
|
|
1652
1589
|
}
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
finalNode = this.denoiseGTAOPass.mul(finalNode);
|
|
1731
|
-
}
|
|
1732
|
-
else {
|
|
1733
|
-
finalNode = this.GTAOPass.getTextureNode().mul(finalNode);
|
|
1734
|
-
if (this.denoiseGTAOPass) {
|
|
1735
|
-
this.denoiseGTAOPass.dispose();
|
|
1736
|
-
this.denoiseGTAOPass = null;
|
|
1737
|
-
console.log("[PostProcess] GTAODenoisePass 已销毁");
|
|
1738
|
-
}
|
|
1739
|
-
}
|
|
1740
|
-
}
|
|
1741
|
-
else {
|
|
1742
|
-
if (this.GTAOPass) {
|
|
1743
|
-
this.GTAOPass.dispose();
|
|
1744
|
-
this.GTAOPass = null;
|
|
1745
|
-
console.log("[PostProcess] GTAOPass 已销毁");
|
|
1746
|
-
}
|
|
1747
|
-
if (this.denoiseGTAOPass) {
|
|
1748
|
-
this.denoiseGTAOPass.dispose();
|
|
1749
|
-
this.denoiseGTAOPass = null;
|
|
1750
|
-
console.log("[PostProcess] GTAODenoisePass 已销毁");
|
|
1751
|
-
}
|
|
1752
|
-
}
|
|
1753
|
-
// outline
|
|
1754
|
-
if (isOutlineEnabled) {
|
|
1755
|
-
console.log("[PostProcess] Outline 启用,参数:", this.postProcessParam.outline);
|
|
1756
|
-
if (!this.outlinePass) {
|
|
1757
|
-
this.outlinePass = WebGPUPostProcessFactory.constructOutlinePass(this.app.world.scene, this.scenePass.camera, this.outlineObjects, this.postProcessParam.outline);
|
|
1758
|
-
console.log("[PostProcess] OutlinePass 构建完成");
|
|
1759
|
-
}
|
|
1760
|
-
else {
|
|
1761
|
-
WebGPUPostProcessFactory.updateOutlinePass(this.outlinePass, this.outlineObjects, this.postProcessParam.outline);
|
|
1762
|
-
console.log("[PostProcess] OutlinePass 更新完成");
|
|
1763
|
-
}
|
|
1764
|
-
// ... existing code ...
|
|
1765
|
-
}
|
|
1766
|
-
else {
|
|
1767
|
-
if (this.outlinePass) {
|
|
1768
|
-
this.outlinePass.dispose();
|
|
1769
|
-
this.outlinePass = null;
|
|
1770
|
-
console.log("[PostProcess] OutlinePass 已销毁");
|
|
1771
|
-
}
|
|
1772
|
-
}
|
|
1773
|
-
if (isAAEnabled) {
|
|
1774
|
-
console.log("[PostProcess] AA 启用,类型:", this.postProcessParam.aa.type);
|
|
1775
|
-
if (this.postProcessParam.aa.type === "fxaa") {
|
|
1776
|
-
this.fxaaPass = WebGPUPostProcessFactory.constructFXAAPass(finalNode);
|
|
1777
|
-
finalNode = this.fxaaPass;
|
|
1778
|
-
console.log("[PostProcess] FXAAPass 构建完成");
|
|
1779
|
-
}
|
|
1780
|
-
if (this.postProcessParam.aa.type === "smaa") {
|
|
1781
|
-
this.smaaPass = WebGPUPostProcessFactory.constructSMAAPass(finalNode);
|
|
1782
|
-
finalNode = this.smaaPass;
|
|
1783
|
-
console.log("[PostProcess] SMAAPass 构建完成");
|
|
1784
|
-
}
|
|
1785
|
-
}
|
|
1786
|
-
else {
|
|
1787
|
-
if (this.fxaaPass) {
|
|
1788
|
-
this.fxaaPass.dispose();
|
|
1789
|
-
this.fxaaPass = null;
|
|
1790
|
-
console.log("[PostProcess] FXAAPass 已销毁");
|
|
1791
|
-
}
|
|
1792
|
-
if (this.smaaPass) {
|
|
1793
|
-
this.smaaPass.dispose();
|
|
1794
|
-
this.smaaPass = null;
|
|
1795
|
-
console.log("[PostProcess] SMAAPass 已销毁");
|
|
1590
|
+
const scenePass = WebGPUPostProcessFactory.constructScenePass(this.app.world.scene, this.app.camera);
|
|
1591
|
+
let finalNode = scenePass.getTextureNode('output');
|
|
1592
|
+
this.postProcessParam.steps.forEach((step) => {
|
|
1593
|
+
switch (step.type) {
|
|
1594
|
+
case exports.PostProcessStepType.Bloom:
|
|
1595
|
+
{
|
|
1596
|
+
const bloomPass = WebGPUPostProcessFactory.constructBloomPass(scenePass, step);
|
|
1597
|
+
console.log("[PostProcess] BloomPass 构建完成");
|
|
1598
|
+
finalNode = finalNode.add(bloomPass);
|
|
1599
|
+
break;
|
|
1600
|
+
}
|
|
1601
|
+
case exports.PostProcessStepType.DepthOfField:
|
|
1602
|
+
{
|
|
1603
|
+
const dofPass = WebGPUPostProcessFactory.constructDOFPass(scenePass, step);
|
|
1604
|
+
console.log("[PostProcess] DOFPass 构建完成");
|
|
1605
|
+
finalNode = finalNode.add(dofPass);
|
|
1606
|
+
break;
|
|
1607
|
+
}
|
|
1608
|
+
case exports.PostProcessStepType.ScreenSpaceReflection:
|
|
1609
|
+
{
|
|
1610
|
+
console.warn("[PostProcess] SSR 目前存在技术问题,暂不支持。");
|
|
1611
|
+
// const ssrPass = WebGPUPostProcessFactory.constructSSRPass(scenePass, step as SSRParam);
|
|
1612
|
+
// console.log("[PostProcess] SSRPass 构建完成");
|
|
1613
|
+
//finalNode = blendColor(finalNode, ssrPass);
|
|
1614
|
+
break;
|
|
1615
|
+
}
|
|
1616
|
+
case exports.PostProcessStepType.GroundTruthAmbientOcclusion:
|
|
1617
|
+
{
|
|
1618
|
+
console.warn("[PostProcess] AO 目前存在技术问题,暂不支持。");
|
|
1619
|
+
// const stepParam = step as GTAOParam
|
|
1620
|
+
// const GTAOPass = WebGPUPostProcessFactory.constructGTAOPass(scenePass, stepParam);
|
|
1621
|
+
// console.log("[PostProcess] GTAOPass 构建完成");
|
|
1622
|
+
// if (stepParam.denoised)
|
|
1623
|
+
// {
|
|
1624
|
+
// const denoiseGTAOPass = WebGPUPostProcessFactory.constructGTAODenoisePass(scenePass, GTAOPass, stepParam);
|
|
1625
|
+
// console.log("[PostProcess] GTAODenoisePass 构建完成");
|
|
1626
|
+
// finalNode = denoiseGTAOPass.mul(finalNode);
|
|
1627
|
+
// }
|
|
1628
|
+
// else
|
|
1629
|
+
// {
|
|
1630
|
+
// finalNode = GTAOPass.getTextureNode().mul(finalNode);
|
|
1631
|
+
// }
|
|
1632
|
+
break;
|
|
1633
|
+
}
|
|
1634
|
+
case exports.PostProcessStepType.Outline:
|
|
1635
|
+
{
|
|
1636
|
+
const outlineParam = step;
|
|
1637
|
+
const outlinePass = WebGPUPostProcessFactory.constructOutlinePass(this.app.world.scene, scenePass.camera, this.outlineObjects, outlineParam);
|
|
1638
|
+
const { visibleEdge, hiddenEdge } = outlinePass;
|
|
1639
|
+
const pulsePeriod = tsl.uniform(outlineParam.pulsePeriod);
|
|
1640
|
+
const period = tsl.time.div(pulsePeriod).mul(2);
|
|
1641
|
+
const osc = tsl.oscSine(period).mul(.5).add(.5);
|
|
1642
|
+
const outlineColor = visibleEdge.mul(tsl.uniform(new webgpu.Color(outlineParam.visibleEdgeColor))).add(hiddenEdge.mul(tsl.uniform(new webgpu.Color(outlineParam.hiddenEdgeColor)))).mul(outlineParam.edgeStrength);
|
|
1643
|
+
const outlinePulse = pulsePeriod.greaterThan(0).select(outlineColor.mul(osc), outlineColor);
|
|
1644
|
+
// if(!this.denoiseOutlinePass)
|
|
1645
|
+
// {
|
|
1646
|
+
// this.denoiseOutlinePass = WebGPUPostProcessFactory.constructDenoisePass(this.scenePass, outlinePulse, DefaultDenoiseParam);
|
|
1647
|
+
// }
|
|
1648
|
+
// outlinePulse = this.denoiseOutlinePass.mul(outlinePulse)
|
|
1649
|
+
// finalNode = this.denoiseOutlinePass.mul(outlinePulse).add(finalNode);
|
|
1650
|
+
finalNode = outlinePulse.add(finalNode);
|
|
1651
|
+
console.log("[PostProcess] OutlinePass 构建完成");
|
|
1652
|
+
break;
|
|
1653
|
+
}
|
|
1654
|
+
case exports.PostProcessStepType.Antialiasing:
|
|
1655
|
+
{
|
|
1656
|
+
const aaParam = step;
|
|
1657
|
+
if (aaParam.method === "fxaa") {
|
|
1658
|
+
finalNode = WebGPUPostProcessFactory.constructFXAAPass(finalNode);
|
|
1659
|
+
console.log("[PostProcess] FXAAPass 构建完成");
|
|
1660
|
+
}
|
|
1661
|
+
if (aaParam.method === "smaa") {
|
|
1662
|
+
finalNode = WebGPUPostProcessFactory.constructSMAAPass(finalNode);
|
|
1663
|
+
console.log("[PostProcess] SMAAPass 构建完成");
|
|
1664
|
+
}
|
|
1665
|
+
break;
|
|
1666
|
+
}
|
|
1796
1667
|
}
|
|
1797
|
-
}
|
|
1668
|
+
});
|
|
1798
1669
|
this.postProcessing.outputNode = finalNode;
|
|
1670
|
+
this.postProcessing.needsUpdate = true;
|
|
1671
|
+
console.log("[PostProcess] setup complete", this.postProcessParam.steps);
|
|
1799
1672
|
this.markRenderStateDirty();
|
|
1800
1673
|
}
|
|
1801
|
-
|
|
1802
|
-
this.postProcessParam.
|
|
1803
|
-
this.setupPostProcess();
|
|
1804
|
-
}
|
|
1805
|
-
updateGTAOParam(params) {
|
|
1806
|
-
this.postProcessParam.gtao = Object.assign({}, params);
|
|
1807
|
-
this.setupPostProcess();
|
|
1808
|
-
}
|
|
1809
|
-
updateDOFParam(params) {
|
|
1810
|
-
this.postProcessParam.dof = Object.assign({}, params);
|
|
1811
|
-
this.setupPostProcess();
|
|
1812
|
-
}
|
|
1813
|
-
updateSSRParam(params) {
|
|
1814
|
-
this.postProcessParam.ssr = Object.assign({}, params);
|
|
1815
|
-
this.setupPostProcess();
|
|
1816
|
-
}
|
|
1817
|
-
updateOutlineParam(params) {
|
|
1818
|
-
this.postProcessParam.outline = Object.assign({}, params);
|
|
1819
|
-
this.setupPostProcess();
|
|
1820
|
-
}
|
|
1821
|
-
updateAAParam(params) {
|
|
1822
|
-
this.postProcessParam.aa = Object.assign({}, params);
|
|
1674
|
+
updatePostProcess(steps) {
|
|
1675
|
+
this.postProcessParam.steps = steps;
|
|
1823
1676
|
this.setupPostProcess();
|
|
1824
1677
|
}
|
|
1678
|
+
// updateBloomPass(params: BloomParam)
|
|
1679
|
+
// {
|
|
1680
|
+
// this.postProcessParam.bloom = { ...params };
|
|
1681
|
+
// this.setupPostProcess();
|
|
1682
|
+
// }
|
|
1683
|
+
// updateGTAOParam(params: GTAOParam)
|
|
1684
|
+
// {
|
|
1685
|
+
// this.postProcessParam.gtao = { ...params };
|
|
1686
|
+
// this.setupPostProcess();
|
|
1687
|
+
// }
|
|
1688
|
+
// updateDOFParam(params: DOFParam)
|
|
1689
|
+
// {
|
|
1690
|
+
// this.postProcessParam.dof = { ...params };
|
|
1691
|
+
// this.setupPostProcess();
|
|
1692
|
+
// }
|
|
1693
|
+
// updateSSRParam(params: SSRParam)
|
|
1694
|
+
// {
|
|
1695
|
+
// this.postProcessParam.ssr = { ...params };
|
|
1696
|
+
// this.setupPostProcess();
|
|
1697
|
+
// }
|
|
1698
|
+
// updateOutlineParam(params: OutlineParams)
|
|
1699
|
+
// {
|
|
1700
|
+
// this.postProcessParam.outline = { ...params }
|
|
1701
|
+
// this.setupPostProcess();
|
|
1702
|
+
// }
|
|
1703
|
+
// updateAAParam(params: AAParams)
|
|
1704
|
+
// {
|
|
1705
|
+
// this.postProcessParam.aa = { ...params };
|
|
1706
|
+
// this.setupPostProcess();
|
|
1707
|
+
// }
|
|
1825
1708
|
addOutlineObject(obj) {
|
|
1826
1709
|
if (!this.outlineObjects.includes(obj)) {
|
|
1827
1710
|
this.outlineObjects.push(obj);
|
|
1828
1711
|
}
|
|
1829
|
-
|
|
1830
|
-
this.postProcessParam.outline = DefaultOutlineParams;
|
|
1831
|
-
this.setupPostProcess();
|
|
1832
|
-
}
|
|
1833
|
-
else {
|
|
1834
|
-
this.markRenderStateDirty();
|
|
1835
|
-
}
|
|
1712
|
+
this.markRenderStateDirty();
|
|
1836
1713
|
}
|
|
1837
1714
|
setOutlineObjects(objects) {
|
|
1838
1715
|
this.outlineObjects.length = 0;
|
|
1839
1716
|
this.outlineObjects.push(...objects);
|
|
1840
|
-
|
|
1841
|
-
this.postProcessParam.outline = DefaultOutlineParams;
|
|
1842
|
-
this.setupPostProcess();
|
|
1843
|
-
}
|
|
1844
|
-
else {
|
|
1845
|
-
this.markRenderStateDirty();
|
|
1846
|
-
}
|
|
1717
|
+
this.markRenderStateDirty();
|
|
1847
1718
|
}
|
|
1848
1719
|
removeOutlineObject(obj) {
|
|
1849
|
-
if (!this.postProcessParam.outline) {
|
|
1850
|
-
this.outlineObjects = [];
|
|
1851
|
-
return;
|
|
1852
|
-
}
|
|
1853
1720
|
const index = this.outlineObjects.indexOf(obj);
|
|
1854
1721
|
if (index > -1) {
|
|
1855
1722
|
this.outlineObjects.splice(index, 1);
|
|
@@ -1857,35 +1724,7 @@ class Viewport {
|
|
|
1857
1724
|
this.markRenderStateDirty();
|
|
1858
1725
|
}
|
|
1859
1726
|
destroyPostProcess() {
|
|
1860
|
-
if (this.bloomPass) {
|
|
1861
|
-
this.bloomPass.dispose();
|
|
1862
|
-
this.bloomPass = null;
|
|
1863
|
-
}
|
|
1864
|
-
if (this.dofPass) {
|
|
1865
|
-
this.dofPass.dispose();
|
|
1866
|
-
this.dofPass = null;
|
|
1867
|
-
}
|
|
1868
|
-
if (this.GTAOPass) {
|
|
1869
|
-
this.GTAOPass.dispose();
|
|
1870
|
-
this.GTAOPass = null;
|
|
1871
|
-
}
|
|
1872
|
-
if (this.denoiseGTAOPass) {
|
|
1873
|
-
this.denoiseGTAOPass.dispose();
|
|
1874
|
-
this.denoiseGTAOPass = null;
|
|
1875
|
-
}
|
|
1876
|
-
if (this.ssrPass) {
|
|
1877
|
-
this.ssrPass.dispose();
|
|
1878
|
-
this.ssrPass = null;
|
|
1879
|
-
}
|
|
1880
|
-
if (this.outlinePass) {
|
|
1881
|
-
this.outlinePass.dispose();
|
|
1882
|
-
this.outlinePass = null;
|
|
1883
|
-
}
|
|
1884
1727
|
this.outlineObjects = [];
|
|
1885
|
-
if (this.scenePass) {
|
|
1886
|
-
this.scenePass.dispose();
|
|
1887
|
-
this.scenePass = null;
|
|
1888
|
-
}
|
|
1889
1728
|
if (this.postProcessing) {
|
|
1890
1729
|
this.postProcessing.dispose();
|
|
1891
1730
|
this.postProcessing = null;
|
|
@@ -3226,6 +3065,59 @@ class LabelComponent extends SceneComponent {
|
|
|
3226
3065
|
// labelStyle.style.fontSize = "10px";
|
|
3227
3066
|
// labelStyle.style.pointerEvents = 'auto';
|
|
3228
3067
|
|
|
3068
|
+
const DefaultBloomParam = {
|
|
3069
|
+
type: exports.PostProcessStepType.Bloom,
|
|
3070
|
+
threshold: 0,
|
|
3071
|
+
strength: 1,
|
|
3072
|
+
radius: 0,
|
|
3073
|
+
};
|
|
3074
|
+
|
|
3075
|
+
const DefaultDenoiseParam = {
|
|
3076
|
+
denoiseRadius: 5,
|
|
3077
|
+
lumaPhi: 5,
|
|
3078
|
+
depthPhi: 5,
|
|
3079
|
+
normalPhi: 5
|
|
3080
|
+
};
|
|
3081
|
+
const DefaultGTAOParam = {
|
|
3082
|
+
type: exports.PostProcessStepType.GroundTruthAmbientOcclusion,
|
|
3083
|
+
distanceExponent: 1,
|
|
3084
|
+
distanceFallOff: 1,
|
|
3085
|
+
radius: 0.25,
|
|
3086
|
+
scale: 1,
|
|
3087
|
+
thickness: 1,
|
|
3088
|
+
denoised: true,
|
|
3089
|
+
denoiseParam: DefaultDenoiseParam,
|
|
3090
|
+
};
|
|
3091
|
+
|
|
3092
|
+
const DefaultDOFParam = {
|
|
3093
|
+
type: exports.PostProcessStepType.DepthOfField,
|
|
3094
|
+
focus: 500.0,
|
|
3095
|
+
aperture: 5,
|
|
3096
|
+
maxblur: 0.01
|
|
3097
|
+
};
|
|
3098
|
+
|
|
3099
|
+
const DefaultOutlineParams = {
|
|
3100
|
+
type: exports.PostProcessStepType.Outline,
|
|
3101
|
+
edgeStrength: 3.0,
|
|
3102
|
+
edgeGlow: 1.0,
|
|
3103
|
+
edgeThickness: 1.0,
|
|
3104
|
+
pulsePeriod: 0.0,
|
|
3105
|
+
visibleEdgeColor: 0xffffff,
|
|
3106
|
+
hiddenEdgeColor: 0xffffff,
|
|
3107
|
+
};
|
|
3108
|
+
|
|
3109
|
+
const DefaultSSRParam = {
|
|
3110
|
+
type: exports.PostProcessStepType.ScreenSpaceReflection,
|
|
3111
|
+
maxDistance: 0.5,
|
|
3112
|
+
opacity: 1,
|
|
3113
|
+
thickness: 0.015,
|
|
3114
|
+
};
|
|
3115
|
+
|
|
3116
|
+
const DefaultAAParams = {
|
|
3117
|
+
type: exports.PostProcessStepType.Antialiasing,
|
|
3118
|
+
method: "fxaa"
|
|
3119
|
+
};
|
|
3120
|
+
|
|
3229
3121
|
class FirstPerson extends Pawn {
|
|
3230
3122
|
constructor(controller) {
|
|
3231
3123
|
super(controller);
|