@viggle/splat-engine-three 0.3.0 → 0.4.0
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/CHANGELOG.md +9 -0
- package/README.md +15 -1
- package/dist/chunks/{chunk-2GKWT24B.js → chunk-SASRTGRD.js} +147 -7
- package/dist/chunks/chunk-SASRTGRD.js.map +7 -0
- package/dist/index.js +1 -1
- package/dist/types/character.d.ts +3 -1
- package/dist/types/splat/backend.d.ts +10 -1
- package/dist/types/splat/quality.d.ts +45 -0
- package/dist/types/splat/splat-mesh.d.ts +14 -1
- package/dist/types/splat/splat.d.ts +6 -0
- package/dist/types/splat/webgl/shaders.d.ts +1 -1
- package/dist/types/splat/webgl/splat-mesh.d.ts +1 -0
- package/dist/types/splat/webgpu/splat-mesh.d.ts +1 -0
- package/dist/webgpu.js +62 -28
- package/dist/webgpu.js.map +3 -3
- package/package.json +1 -1
- package/dist/chunks/chunk-2GKWT24B.js.map +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
Splat objects can hide one another where they overlap. The setting is off by default; with it off, every frame draws exactly as in 0.3.0.
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- **`SplatQuality.depthWriteAlpha`** and the per-object **`Splat.depthWriteAlpha`**, so splat objects hide one another where they overlap: a held weapon and the hand holding it, two fighters, a character behind a prop. Each splat object follows its colour draw with a depth-only draw of its solid parts, and the objects drawn after it depth-test against that. Off (`0`) by default. At `0.15`, a staff held in a hand scores 42-48 dB against the PlayCanvas build, up from 31-33 dB. An object that overlaps nothing draws exactly as before. An environment drawn first hides a character behind it too, which the PlayCanvas build's environment layer does not (`environment.splat.depthWriteAlpha = 0` keeps that). Costs a second draw per splat object, and `Character.addOverlaySplat` copies opt out. See the README's "Depth and draw order".
|
|
10
|
+
- `ab/check-depth-write.mjs`, and `overlap/` cases in the A/B suite (a procedural staff through the actor's hand, `ab/staff-ply.mjs`); `run-ab.mjs --depth-write <alpha>` runs the whole suite with it on.
|
|
11
|
+
|
|
3
12
|
## 0.3.0
|
|
4
13
|
|
|
5
14
|
What games remade from the PlayCanvas build need beyond 0.2.0. Every addition is new API or an opt-in; nothing an existing app calls changes behaviour.
|
package/README.md
CHANGED
|
@@ -360,7 +360,17 @@ One difference to know when mixing the two: `Character.setPosition` lowers the m
|
|
|
360
360
|
|
|
361
361
|
### Depth and draw order
|
|
362
362
|
|
|
363
|
-
Splats test against the depth buffer and do not write it. Opaque meshes therefore occlude them correctly with no extra setup, but two splat objects are layered by draw order alone, not by depth. Static meshes from `SplatPLYLoader` draw first (`renderOrder = -1`), so characters always composite on top of the scene they stand in - the same layering the PlayCanvas build uses. A character that walks behind a wall of the splat scene is still drawn over it.
|
|
363
|
+
Splats test against the depth buffer and, by default, do not write it. Opaque meshes therefore occlude them correctly with no extra setup, but two splat objects are layered by draw order alone, not by depth: each is sorted and drawn on its own, and whichever draws second paints over the other across the whole overlap. Static meshes from `SplatPLYLoader` and `Environment` draw first (`renderOrder = -1`), so characters always composite on top of the scene they stand in - the same layering the PlayCanvas build uses for its environment layer. A character that walks behind a wall of the splat scene is still drawn over it.
|
|
364
|
+
|
|
365
|
+
The PlayCanvas build sorts all the splats on one layer together, so a held weapon on the characters' layer, or two characters, interleave splat by splat there. Here `SplatQuality.depthWriteAlpha` stands in for that:
|
|
366
|
+
|
|
367
|
+
```ts
|
|
368
|
+
SplatQuality.depthWriteAlpha = 0.15; // or per object: environment.splat.depthWriteAlpha = 0.15
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
Each splat object then follows its colour draw with a depth-only draw of its solid parts (single-splat fragments at or above that alpha), and objects drawn after it depth-test against them: a weapon is hidden where it passes behind the fingers and still drawn where it passes in front. An object never tests against its own depth, so one that overlaps nothing draws exactly as before. Where the earlier object is faint the later one still paints over it, and where it is just above the alpha it hides the later one outright, so the edge of an overlap is harder than in the PlayCanvas build. Against that build, a staff held in a hand scores 31-33 dB plain and 42-48 dB with `0.15` (the A/B suite's `overlap/` cases). The alpha is taken after `setOpacity`, so a character fading out keeps hiding what is behind it until its opacity drops below the setting; opt its splats out for the fade. The vertex work, which under WebGL includes the skinning, is paid twice. `Character.addOverlaySplat` copies never write depth.
|
|
372
|
+
|
|
373
|
+
An environment draws first, so with depth writes on it also hides a character where the scene is in front of it - the prop the character stands behind, a wall it walks past. The PlayCanvas build's environment layer never does; set `environment.splat.depthWriteAlpha = 0` on a stage to keep that. A streamed LOD bundle is one splat at every level and keeps its own setting across level switches; it draws the same with depth writes on (`check-env`'s LOD cases, frame for frame). With the setting off (the default) every frame is the same as before it existed, and with it on every A/B case with one splat object is too; only the cases with a character inside the stage change.
|
|
364
374
|
|
|
365
375
|
## Performance
|
|
366
376
|
|
|
@@ -440,6 +450,8 @@ SplatQuality.pruneVoxelSize = 0.04; // metres; the cell that quota is per
|
|
|
440
450
|
SplatQuality.screenSizeCull = 0; // pixels; drop splats smaller than this. For distant crowds
|
|
441
451
|
SplatQuality.depthOcclusion = true; // scene geometry hides splats. Correctness, not performance:
|
|
442
452
|
// this renderer gets the hardware depth test for free
|
|
453
|
+
SplatQuality.depthWriteAlpha = 0; // splat objects hide one another where they overlap; see
|
|
454
|
+
// Depth and draw order. Costs a second draw per object
|
|
443
455
|
SplatQuality.passTimings = false; // then read SplatQuality.timings after each render
|
|
444
456
|
```
|
|
445
457
|
|
|
@@ -569,6 +581,7 @@ npm run ab -- --ref current # against it: poses, and the newer splat effect
|
|
|
569
581
|
node ab/check-scene.mjs # the Scene facade
|
|
570
582
|
node ab/check-fixes.mjs # one check per fix from the 0.2.0 review
|
|
571
583
|
node ab/check-gaps.mjs # time scale, update order, point-to-point joints, exported math vs PlayCanvas
|
|
584
|
+
node ab/check-depth-write.mjs # depthWriteAlpha: what hides what, overrides, overlays, teardown
|
|
572
585
|
node ab/run-relight.mjs # SplatRelight vs PlayCanvas
|
|
573
586
|
node ab/run-postfx-check.mjs # CameraFrame, PostFX, pixel-art, outline vs PlayCanvas
|
|
574
587
|
node ab/check-physics.mjs # rigid bodies, events, raycasts, ragdoll (Ammo from test-assets/ammo/)
|
|
@@ -579,6 +592,7 @@ node ab/run-vfx.mjs # VFX and presets vs PlayCanvas
|
|
|
579
592
|
`--ref` picks the PlayCanvas build: `start` (the default) is the version this port began from, which still has the legacy lights; `current` is 0.3.2, which no longer does. Against `current` - run with `legacyRootRotation` off, as a `Scene` has it - bone matrices are bit-identical in every case and frames score 49-63 dB (median 59.5), the newer effects (opacity, multiply tint, reveal, cut, colour hooks) included. Against `start`, with a `SplatEngine`'s default of pinning the root, the table above holds; see [GLB clips and the root bone](#glb-clips-and-the-root-bone).
|
|
580
593
|
|
|
581
594
|
`node ab/check-fixes.mjs` holds one check per fix from the 0.2.0 review: the root-rotation defaults, cut bounds, sprite disposal, WebGPU buffer reuse, relight ignoring `scene.environment`, LOD manifest validation, the fetch interceptor, decoding without a worker, and the shape of `dist`. `node ab/check-gaps.mjs` checks what was added for games remade from the PlayCanvas build: `timeScale` / `maxDeltaTime` / `once`, both update orders, point-to-point joints (pinned, chained, rebuilt, broken), the exported helpers, and every `Vec3` / `Quat` / `Mat4` method bit for bit against PlayCanvas 2.23.3.
|
|
595
|
+
`node ab/check-depth-write.mjs` checks `depthWriteAlpha` on both backends: which of two crossing splats hides the other with it off, on, overridden per object and with the draw order swapped, one preparation per frame, `clone`, overlay copies, teardown while on, and switching it off. The suite's `overlap/` cases hold a staff in the actor's hand from four sides: 31-33 dB against the PlayCanvas build plain, 42-48 dB at `0.15`, on either backend.
|
|
582
596
|
|
|
583
597
|
The module checks, against the PlayCanvas reference where it has a counterpart, both backends: relight 54-62 dB on the lit frames of the character and stage cases and 39-40 dB in the room (`chamber`), with PlayCanvas's own default bias reproduced at 36 dB; post-processing 34-48 dB; `.spz` / SOG scenes 41-64 dB and streamed LOD bundles 33-45 dB; VFX and the reveal 32-88 dB (WebGPU blends in linear light, which sets the low end); ragdoll final pelvis height equal to 1e-4 m.
|
|
584
598
|
|
|
@@ -5867,6 +5867,7 @@ var _screenSizeCull = 0;
|
|
|
5867
5867
|
var _minOpacity = 0.05;
|
|
5868
5868
|
var _pruneRatio = 0;
|
|
5869
5869
|
var _pruneVoxelSize = 0.04;
|
|
5870
|
+
var _depthWriteAlpha = 0;
|
|
5870
5871
|
var clamp = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
|
|
5871
5872
|
var warnedAboutCap = false;
|
|
5872
5873
|
var SplatQuality = {
|
|
@@ -6018,6 +6019,54 @@ var SplatQuality = {
|
|
|
6018
6019
|
* application wants - a character deliberately drawn over the scene.
|
|
6019
6020
|
*/
|
|
6020
6021
|
depthOcclusion: true,
|
|
6022
|
+
/**
|
|
6023
|
+
* Alpha at which a splat writes depth, so that a splat object drawn later
|
|
6024
|
+
* is hidden behind the solid parts of one drawn earlier. `0` (the default)
|
|
6025
|
+
* writes no depth: the behaviour before this setting existed.
|
|
6026
|
+
*
|
|
6027
|
+
* Every splat object is sorted and drawn on its own, so where two of them
|
|
6028
|
+
* overlap - a weapon in a hand, two fighters in a clinch, a character
|
|
6029
|
+
* behind a prop - whichever draws second paints over the other across the
|
|
6030
|
+
* whole overlap, whatever is really in front. The PlayCanvas build sorts
|
|
6031
|
+
* every splat on a layer together and does not have the problem. With this
|
|
6032
|
+
* on, each splat object follows its colour draw with a depth-only draw of
|
|
6033
|
+
* its solid parts: the fragments of single splats whose alpha (the
|
|
6034
|
+
* gaussian's falloff times the splat's opacity) reaches this value. An
|
|
6035
|
+
* object drawn after it depth-tests against that, so its parts behind the
|
|
6036
|
+
* first object's solid parts are hidden; its parts in front paint over it,
|
|
6037
|
+
* as they should. An object never tests against its own depth, so one that
|
|
6038
|
+
* overlaps nothing draws exactly as it did.
|
|
6039
|
+
*
|
|
6040
|
+
* `0.1`-`0.2` came closest to the PlayCanvas build in the A/B suite's
|
|
6041
|
+
* overlap cases (a staff through a hand). Lower, the faint edges of the
|
|
6042
|
+
* first object hide the second; higher, too little of a character is solid
|
|
6043
|
+
* enough to hide anything.
|
|
6044
|
+
*
|
|
6045
|
+
* What it costs:
|
|
6046
|
+
* - A second, depth-only draw of every splat object. Its quads are cut to
|
|
6047
|
+
* where a splat is above this alpha, so the fragments are few; the vertex
|
|
6048
|
+
* work, which under WebGL includes the skinning, is paid twice.
|
|
6049
|
+
* - Where the first object is faint but above this alpha, it hides the
|
|
6050
|
+
* second outright instead of letting it show through: a harder edge
|
|
6051
|
+
* where the two overlap.
|
|
6052
|
+
* - Where the first object is fainter than this alpha, the second still
|
|
6053
|
+
* paints over it, as before.
|
|
6054
|
+
* - The alpha is taken after {@link Splat.setOpacity}, so an object fading
|
|
6055
|
+
* out keeps hiding what is behind it at its cores until its opacity
|
|
6056
|
+
* falls below this value. Opt a fading object out with its own
|
|
6057
|
+
* {@link Splat.depthWriteAlpha} for the fade.
|
|
6058
|
+
* - Splats now hide whatever draws after them in depth: transparent meshes
|
|
6059
|
+
* and particles behind a character, and post-processing that reads the
|
|
6060
|
+
* depth buffer sees them.
|
|
6061
|
+
*
|
|
6062
|
+
* Read per frame. A splat's own {@link Splat.depthWriteAlpha} overrides it.
|
|
6063
|
+
*/
|
|
6064
|
+
get depthWriteAlpha() {
|
|
6065
|
+
return _depthWriteAlpha;
|
|
6066
|
+
},
|
|
6067
|
+
set depthWriteAlpha(value) {
|
|
6068
|
+
_depthWriteAlpha = clamp(value, 0, 1);
|
|
6069
|
+
},
|
|
6021
6070
|
/**
|
|
6022
6071
|
* Collect {@link SplatQuality.timings}. Off by default.
|
|
6023
6072
|
*
|
|
@@ -6065,10 +6114,14 @@ var SplatQuality = {
|
|
|
6065
6114
|
SplatQuality.pruneRatio = 0;
|
|
6066
6115
|
SplatQuality.pruneVoxelSize = 0.04;
|
|
6067
6116
|
SplatQuality.depthOcclusion = true;
|
|
6117
|
+
SplatQuality.depthWriteAlpha = 0;
|
|
6068
6118
|
SplatQuality.passTimings = false;
|
|
6069
6119
|
resetTimings();
|
|
6070
6120
|
}
|
|
6071
6121
|
};
|
|
6122
|
+
function effectiveDepthWriteAlpha(splatAlpha) {
|
|
6123
|
+
return splatAlpha ?? SplatQuality.depthWriteAlpha;
|
|
6124
|
+
}
|
|
6072
6125
|
function effectiveMinPixelSize(splatMinPixelSize) {
|
|
6073
6126
|
const global = SplatQuality.screenSizeCull;
|
|
6074
6127
|
return global > splatMinPixelSize ? global : splatMinPixelSize;
|
|
@@ -6348,6 +6401,7 @@ import {
|
|
|
6348
6401
|
InstancedBufferAttribute,
|
|
6349
6402
|
InstancedBufferGeometry,
|
|
6350
6403
|
LinearTransfer,
|
|
6404
|
+
NoBlending,
|
|
6351
6405
|
OneFactor,
|
|
6352
6406
|
OneMinusSrcAlphaFactor,
|
|
6353
6407
|
Quaternion as Quaternion2,
|
|
@@ -6989,6 +7043,10 @@ uniform float uMinPixelSize;
|
|
|
6989
7043
|
// expressions below reduce, bit for bit, to what they were before the cutoff
|
|
6990
7044
|
// was a setting at all. See SplatQuality.quadAlphaCutoff.
|
|
6991
7045
|
uniform float uAlphaCutoffScale;
|
|
7046
|
+
#ifdef DEPTH_ONLY
|
|
7047
|
+
// 1 / SplatQuality.depthWriteAlpha: the depth write sizes its quads to that alpha.
|
|
7048
|
+
uniform float uDepthCutoffScale;
|
|
7049
|
+
#endif
|
|
6992
7050
|
// World rotation (xyzw) and scale of the splat object.
|
|
6993
7051
|
uniform vec4 uModelRotation;
|
|
6994
7052
|
uniform vec3 uModelScale;
|
|
@@ -7216,7 +7274,11 @@ void main(void) {
|
|
|
7216
7274
|
|
|
7217
7275
|
// A splat whose peak alpha is already under the cutoff cannot put a
|
|
7218
7276
|
// fragment on screen: its own quad would be empty.
|
|
7277
|
+
#ifdef DEPTH_ONLY
|
|
7278
|
+
float alphaOverCutoff = clr.a * uDepthCutoffScale;
|
|
7279
|
+
#else
|
|
7219
7280
|
float alphaOverCutoff = clr.a * uAlphaCutoffScale;
|
|
7281
|
+
#endif
|
|
7220
7282
|
if (alphaOverCutoff <= 1.0) {
|
|
7221
7283
|
gl_Position = discardVec;
|
|
7222
7284
|
return;
|
|
@@ -7248,6 +7310,11 @@ in mediump vec4 gaussianColor;
|
|
|
7248
7310
|
|
|
7249
7311
|
layout(location = 0) out highp vec4 fragColor;
|
|
7250
7312
|
|
|
7313
|
+
#ifdef DEPTH_ONLY
|
|
7314
|
+
// SplatQuality.depthWriteAlpha: the alpha at which a fragment writes depth.
|
|
7315
|
+
uniform float uDepthAlpha;
|
|
7316
|
+
#endif
|
|
7317
|
+
|
|
7251
7318
|
const float EXP4 = exp(-4.0);
|
|
7252
7319
|
const float INV_EXP4 = 1.0 / (1.0 - EXP4);
|
|
7253
7320
|
|
|
@@ -7262,11 +7329,18 @@ void main(void) {
|
|
|
7262
7329
|
discard;
|
|
7263
7330
|
}
|
|
7264
7331
|
mediump float alpha = normExp(A) * gaussianColor.a;
|
|
7332
|
+
#ifdef DEPTH_ONLY
|
|
7333
|
+
if (alpha < uDepthAlpha) {
|
|
7334
|
+
discard;
|
|
7335
|
+
}
|
|
7336
|
+
fragColor = vec4(0.0);
|
|
7337
|
+
#else
|
|
7265
7338
|
if (alpha < 1.0 / 255.0) {
|
|
7266
7339
|
discard;
|
|
7267
7340
|
}
|
|
7268
7341
|
// Premultiplied.
|
|
7269
7342
|
fragColor = vec4(gaussianColor.rgb * alpha, alpha);
|
|
7343
|
+
#endif
|
|
7270
7344
|
}
|
|
7271
7345
|
`
|
|
7272
7346
|
);
|
|
@@ -7291,6 +7365,7 @@ var RELIGHT_UNIFORMS = [
|
|
|
7291
7365
|
var WebGLSplatImpl = class {
|
|
7292
7366
|
geometry;
|
|
7293
7367
|
material;
|
|
7368
|
+
depthMaterial;
|
|
7294
7369
|
/** The depth sort runs on the CPU, so it needs CPU-side centres. */
|
|
7295
7370
|
needsCpuCenters = true;
|
|
7296
7371
|
_host;
|
|
@@ -7375,8 +7450,25 @@ var WebGLSplatImpl = class {
|
|
|
7375
7450
|
blendSrcAlpha: OneFactor,
|
|
7376
7451
|
blendDstAlpha: OneMinusSrcAlphaFactor
|
|
7377
7452
|
});
|
|
7453
|
+
material.uniforms.uDepthCutoffScale = { value: 0 };
|
|
7454
|
+
material.uniforms.uDepthAlpha = { value: 2 };
|
|
7455
|
+
const depth = new RawShaderMaterial({
|
|
7456
|
+
name: "SplatDepthWrite",
|
|
7457
|
+
glslVersion: GLSL3,
|
|
7458
|
+
vertexShader: material.vertexShader,
|
|
7459
|
+
fragmentShader: SPLAT_FRAGMENT_GLSL,
|
|
7460
|
+
uniforms: material.uniforms,
|
|
7461
|
+
side: DoubleSide,
|
|
7462
|
+
// Drawn in the transparent list, straight after the colour draw.
|
|
7463
|
+
transparent: true,
|
|
7464
|
+
depthTest: true,
|
|
7465
|
+
depthWrite: true,
|
|
7466
|
+
colorWrite: false,
|
|
7467
|
+
blending: NoBlending
|
|
7468
|
+
});
|
|
7378
7469
|
this.geometry = geometry;
|
|
7379
7470
|
this.material = material;
|
|
7471
|
+
this.depthMaterial = depth;
|
|
7380
7472
|
this._host = host;
|
|
7381
7473
|
this._splat = splat;
|
|
7382
7474
|
this._engine = engine;
|
|
@@ -7433,6 +7525,10 @@ var WebGLSplatImpl = class {
|
|
|
7433
7525
|
this.syncRelight();
|
|
7434
7526
|
this.material.defines = defines;
|
|
7435
7527
|
this.material.needsUpdate = true;
|
|
7528
|
+
const depth = this.depthMaterial;
|
|
7529
|
+
depth.vertexShader = this.material.vertexShader;
|
|
7530
|
+
depth.defines = { ...defines, DEPTH_ONLY: "" };
|
|
7531
|
+
depth.needsUpdate = true;
|
|
7436
7532
|
}
|
|
7437
7533
|
/** Point the relight uniforms at the splat's current binding. */
|
|
7438
7534
|
syncRelight() {
|
|
@@ -7505,7 +7601,11 @@ var WebGLSplatImpl = class {
|
|
|
7505
7601
|
u.splatGroupRots.value = splat.groupRotsTexture ?? null;
|
|
7506
7602
|
if (this.material.depthTest !== SplatQuality.depthOcclusion) {
|
|
7507
7603
|
this.material.depthTest = SplatQuality.depthOcclusion;
|
|
7604
|
+
this.depthMaterial.depthTest = SplatQuality.depthOcclusion;
|
|
7508
7605
|
}
|
|
7606
|
+
const depthAlpha = effectiveDepthWriteAlpha(splat.depthWriteAlpha);
|
|
7607
|
+
u.uDepthCutoffScale.value = depthAlpha > 0 ? 1 / depthAlpha : 0;
|
|
7608
|
+
u.uDepthAlpha.value = depthAlpha > 0 ? depthAlpha : 2;
|
|
7509
7609
|
this._engine.syncLighting();
|
|
7510
7610
|
if (!SplatQuality.passTimings) {
|
|
7511
7611
|
this._sortFor(camera);
|
|
@@ -7574,6 +7674,7 @@ var WebGLSplatImpl = class {
|
|
|
7574
7674
|
this._asyncSorter?.dispose();
|
|
7575
7675
|
this.geometry.dispose();
|
|
7576
7676
|
this.material.dispose();
|
|
7677
|
+
this.depthMaterial.dispose();
|
|
7577
7678
|
}
|
|
7578
7679
|
};
|
|
7579
7680
|
|
|
@@ -7624,6 +7725,8 @@ var SplatMesh = class extends Mesh {
|
|
|
7624
7725
|
_engine;
|
|
7625
7726
|
_asyncSort;
|
|
7626
7727
|
_impl = null;
|
|
7728
|
+
/** Set by the first of this frame's two draws, which prepared it, for the second. */
|
|
7729
|
+
_prepared = false;
|
|
7627
7730
|
/**
|
|
7628
7731
|
* @param asyncSort - See {@link SplatBackend.createImpl}.
|
|
7629
7732
|
* @internal Construct a {@link Splat} instead; it creates its own mesh.
|
|
@@ -7640,6 +7743,9 @@ var SplatMesh = class extends Mesh {
|
|
|
7640
7743
|
_attach(backend) {
|
|
7641
7744
|
const impl = backend.createImpl(this, this.splat, this._engine, this._asyncSort);
|
|
7642
7745
|
this._impl = impl;
|
|
7746
|
+
const quad = impl.geometry.index.count;
|
|
7747
|
+
impl.geometry.addGroup(0, quad, 0);
|
|
7748
|
+
impl.geometry.addGroup(0, quad, 1);
|
|
7643
7749
|
this.geometry = impl.geometry;
|
|
7644
7750
|
this.material = impl.material;
|
|
7645
7751
|
this.frustumCulled = true;
|
|
@@ -7670,13 +7776,35 @@ var SplatMesh = class extends Mesh {
|
|
|
7670
7776
|
syncRelight() {
|
|
7671
7777
|
this._impl?.syncRelight();
|
|
7672
7778
|
}
|
|
7673
|
-
onBeforeRender(renderer, _scene, camera) {
|
|
7674
|
-
|
|
7779
|
+
onBeforeRender(renderer, _scene, camera, _geometry, material) {
|
|
7780
|
+
const impl = this._impl;
|
|
7781
|
+
if (!impl) {
|
|
7675
7782
|
const backend = backendFor(renderer);
|
|
7676
7783
|
if (backend) this._attach(backend);
|
|
7677
7784
|
return;
|
|
7678
7785
|
}
|
|
7679
|
-
this.
|
|
7786
|
+
if (this._prepared) {
|
|
7787
|
+
this._prepared = false;
|
|
7788
|
+
} else {
|
|
7789
|
+
impl.beforeRender(renderer, camera);
|
|
7790
|
+
this._prepared = Array.isArray(this.material);
|
|
7791
|
+
}
|
|
7792
|
+
if (material !== impl.depthMaterial) this._syncDepthWrite(impl);
|
|
7793
|
+
}
|
|
7794
|
+
/**
|
|
7795
|
+
* Draw the depth group from the next frame on when this splat writes
|
|
7796
|
+
* depth, and only the colour group when it does not. The render list for
|
|
7797
|
+
* this frame is already made.
|
|
7798
|
+
*
|
|
7799
|
+
* Both groups are transparent, so they draw in the transparent list one
|
|
7800
|
+
* after the other: three.js sorts by render order, then depth, then object,
|
|
7801
|
+
* and keeps a group's order within that. The depth this object writes is
|
|
7802
|
+
* there for the splat objects drawn after it, never for its own colour.
|
|
7803
|
+
*/
|
|
7804
|
+
_syncDepthWrite(impl) {
|
|
7805
|
+
const on = effectiveDepthWriteAlpha(this.splat.depthWriteAlpha) > 0;
|
|
7806
|
+
if (on === Array.isArray(this.material)) return;
|
|
7807
|
+
this.material = on ? [impl.material, impl.depthMaterial] : impl.material;
|
|
7680
7808
|
}
|
|
7681
7809
|
/**
|
|
7682
7810
|
* A second mesh drawing the same splat data, at the same transform. The
|
|
@@ -7803,6 +7931,12 @@ var Splat = class _Splat {
|
|
|
7803
7931
|
localBounds = new Box3();
|
|
7804
7932
|
/** Discard splats smaller than this many pixels on screen. `0` draws everything. */
|
|
7805
7933
|
minPixelSize = 0;
|
|
7934
|
+
/**
|
|
7935
|
+
* This splat's own {@link SplatQuality.depthWriteAlpha}: the alpha above which
|
|
7936
|
+
* it writes depth. `null` (the default) follows the global setting; `0`
|
|
7937
|
+
* never writes depth, whatever the global one says.
|
|
7938
|
+
*/
|
|
7939
|
+
depthWriteAlpha = null;
|
|
7806
7940
|
_activeSplatCount;
|
|
7807
7941
|
_importanceOrder = null;
|
|
7808
7942
|
/** `_importanceOrder` inverted: each splat's place in it. @internal */
|
|
@@ -7882,6 +8016,7 @@ var Splat = class _Splat {
|
|
|
7882
8016
|
copy.grade.copy(this.grade);
|
|
7883
8017
|
copy.effects.x = this.effects.x;
|
|
7884
8018
|
copy.minPixelSize = this.minPixelSize;
|
|
8019
|
+
copy.depthWriteAlpha = this.depthWriteAlpha;
|
|
7885
8020
|
copy.antiAlias = this.antiAlias;
|
|
7886
8021
|
return copy;
|
|
7887
8022
|
}
|
|
@@ -11417,7 +11552,9 @@ var Character = class _Character {
|
|
|
11417
11552
|
* animates in lockstep) but on `layerIds`. With the body occluded by real
|
|
11418
11553
|
* objects, this copy is what shows through obstacles: give it a see-through
|
|
11419
11554
|
* look with its own {@link Splat.setOpacity} or {@link Splat.setColorModifier}
|
|
11420
|
-
* (the PlayCanvas build's `applyOverlaySplatStyle` is not ported).
|
|
11555
|
+
* (the PlayCanvas build's `applyOverlaySplatStyle` is not ported). It
|
|
11556
|
+
* writes no depth under {@link SplatQuality.depthWriteAlpha}, so it never
|
|
11557
|
+
* hides what it is meant to show through.
|
|
11421
11558
|
* Synchronous: reuses the decoded data.
|
|
11422
11559
|
*/
|
|
11423
11560
|
addOverlaySplat(layerIds) {
|
|
@@ -11428,6 +11565,7 @@ var Character = class _Character {
|
|
|
11428
11565
|
sourceBoneCount: source.sourceBoneCount
|
|
11429
11566
|
});
|
|
11430
11567
|
this.armature.linkSplat(splat);
|
|
11568
|
+
splat.depthWriteAlpha = 0;
|
|
11431
11569
|
splat.setLayers(layerIds);
|
|
11432
11570
|
splat.setRenderingEnabled(this._active);
|
|
11433
11571
|
this._applyLook(splat);
|
|
@@ -12731,7 +12869,7 @@ import {
|
|
|
12731
12869
|
BufferGeometry as BufferGeometry2,
|
|
12732
12870
|
CustomBlending as CustomBlending2,
|
|
12733
12871
|
Mesh as Mesh2,
|
|
12734
|
-
NoBlending,
|
|
12872
|
+
NoBlending as NoBlending2,
|
|
12735
12873
|
NormalBlending,
|
|
12736
12874
|
OneFactor as OneFactor2,
|
|
12737
12875
|
OrthographicCamera,
|
|
@@ -12816,7 +12954,7 @@ var WebGLPostFXProgram = class {
|
|
|
12816
12954
|
depthTest: false,
|
|
12817
12955
|
depthWrite: false,
|
|
12818
12956
|
transparent: blend !== "none",
|
|
12819
|
-
blending: blend === "add" ? CustomBlending2 : blend === "alpha" ? NormalBlending :
|
|
12957
|
+
blending: blend === "add" ? CustomBlending2 : blend === "alpha" ? NormalBlending : NoBlending2,
|
|
12820
12958
|
blendEquation: AddEquation,
|
|
12821
12959
|
blendSrc: OneFactor2,
|
|
12822
12960
|
blendDst: OneFactor2,
|
|
@@ -16803,6 +16941,7 @@ var LodBundle = class {
|
|
|
16803
16941
|
splat.effects.x = previous.effects.x;
|
|
16804
16942
|
splat.minPixelSize = previous.minPixelSize;
|
|
16805
16943
|
splat.antiAlias = previous.antiAlias;
|
|
16944
|
+
splat.depthWriteAlpha = previous.depthWriteAlpha;
|
|
16806
16945
|
if (packed.numSplats === 0) {
|
|
16807
16946
|
previous.destroy();
|
|
16808
16947
|
this._splat = splat;
|
|
@@ -23048,6 +23187,7 @@ export {
|
|
|
23048
23187
|
EngineDisposedError,
|
|
23049
23188
|
packSplats,
|
|
23050
23189
|
SplatQuality,
|
|
23190
|
+
effectiveDepthWriteAlpha,
|
|
23051
23191
|
effectiveMinPixelSize,
|
|
23052
23192
|
beginFrameTimings,
|
|
23053
23193
|
pruneSplats,
|
|
@@ -23179,4 +23319,4 @@ export {
|
|
|
23179
23319
|
SplatRelight,
|
|
23180
23320
|
setPlayCanvasLightColor
|
|
23181
23321
|
};
|
|
23182
|
-
//# sourceMappingURL=chunk-
|
|
23322
|
+
//# sourceMappingURL=chunk-SASRTGRD.js.map
|