@playcanvas/supersplat-viewer 1.43.0 → 1.43.2
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/README.md +6 -2
- package/dist/index.js +1 -1
- package/dist/viewer.d.ts +1 -2
- package/dist/viewer.js +65 -51
- package/dist/viewer.js.map +1 -1
- package/package.json +3 -3
- package/public/index.js +94 -80
- package/public/index.js.map +1 -1
package/dist/viewer.d.ts
CHANGED
|
@@ -38,8 +38,7 @@ type ViewerAssets = {
|
|
|
38
38
|
type ViewerFlags = {
|
|
39
39
|
/**
|
|
40
40
|
* Requested renderer; the engine falls back to WebGL when WebGPU is unavailable. Default
|
|
41
|
-
* `webgpu`.
|
|
42
|
-
* whatever is requested, unless the page url has `?webgpu`. Both are temporary.
|
|
41
|
+
* `webgpu`.
|
|
43
42
|
*/
|
|
44
43
|
renderer?: 'webgl' | 'webgpu';
|
|
45
44
|
/**
|
package/dist/viewer.js
CHANGED
|
@@ -4169,6 +4169,51 @@ fn unwarpTexel(texel: vec2i) -> vec2f {
|
|
|
4169
4169
|
// visibility come from the cpu (resident-set rebuild on version change, frustum cull per frame).
|
|
4170
4170
|
/** Words per cache entry: ndc, depth, axis1, len2 | alpha | bucket, rgb, id (or the coverage draw). */
|
|
4171
4171
|
const CACHE_WORDS = 6;
|
|
4172
|
+
// The cached alpha and the splat's shape, shared by the projector and the raster. The alpha byte
|
|
4173
|
+
// is sog v3's encoding, alpha = (1.25 b / 255)^2, so it holds the alpha above 1 a sog v3 file
|
|
4174
|
+
// stores (up to 1.5625); every other source's alpha converts to it. Above 1 a splat draws as the
|
|
4175
|
+
// engine's does: a plateau at full alpha out to plateauCore of the quad's half extent, and the
|
|
4176
|
+
// falloff stretched over the rest (the engine's gsplatPlateauCore, clipCorner and splat shader).
|
|
4177
|
+
const cacheAlphaWGSL = /* wgsl */ `
|
|
4178
|
+
fn encodeCacheAlpha(alpha: f32) -> u32 {
|
|
4179
|
+
return u32(sqrt(clamp(alpha, 0.0, 1.5625)) * (255.0 / 1.25) + 0.5);
|
|
4180
|
+
}
|
|
4181
|
+
|
|
4182
|
+
fn decodeCacheAlpha(bits: u32) -> f32 {
|
|
4183
|
+
let o = f32(bits & 0xffu) * (1.25 / 255.0);
|
|
4184
|
+
return o * o;
|
|
4185
|
+
}
|
|
4186
|
+
|
|
4187
|
+
// the radius, in units of the quad's half extent, out to which alpha above 1 holds at full alpha
|
|
4188
|
+
fn plateauCore(alpha: f32) -> f32 {
|
|
4189
|
+
if (alpha <= 1.0) {
|
|
4190
|
+
return 0.0;
|
|
4191
|
+
}
|
|
4192
|
+
let t = min(alpha - 1.0, 0.5625);
|
|
4193
|
+
return sqrt(0.28986718 + 0.62504992 * t) - 0.53839315;
|
|
4194
|
+
}
|
|
4195
|
+
|
|
4196
|
+
// the splat's alpha at r^2, in units of the quad's half extent:
|
|
4197
|
+
// alpha * falloff(r^2) with falloff(x) = (exp(-4 x) - exp(-4)) / (1 - exp(-4)), or above 1 the plateau
|
|
4198
|
+
fn splatAlpha(r2: f32, alpha: f32) -> f32 {
|
|
4199
|
+
var x = r2;
|
|
4200
|
+
if (alpha > 1.0) {
|
|
4201
|
+
let core = plateauCore(alpha);
|
|
4202
|
+
let c = max(0.0, sqrt(r2) - core) / (1.0 - core);
|
|
4203
|
+
x = c * c;
|
|
4204
|
+
}
|
|
4205
|
+
let e4 = exp(-4.0);
|
|
4206
|
+
return (exp(x * -4.0) - e4) / (1.0 - e4) * min(alpha, 1.0);
|
|
4207
|
+
}
|
|
4208
|
+
|
|
4209
|
+
// the radius, in units of the quad's half extent, where splatAlpha falls to a threshold
|
|
4210
|
+
fn radiusAt(threshold: f32, alpha: f32) -> f32 {
|
|
4211
|
+
let e4 = exp(-4.0);
|
|
4212
|
+
let core = plateauCore(alpha);
|
|
4213
|
+
let r = sqrt(max(-log(threshold / min(alpha, 1.0) * (1.0 - e4) + e4) * 0.25, 0.0));
|
|
4214
|
+
return core + (1.0 - core) * r;
|
|
4215
|
+
}
|
|
4216
|
+
`;
|
|
4172
4217
|
const PROJECTOR_WORKGROUP_SIZE = 256;
|
|
4173
4218
|
/** Buckets of the counting order (shaders/order.ts); the workgroup size, so each thread owns one. */
|
|
4174
4219
|
const ORDER_BUCKETS = PROJECTOR_WORKGROUP_SIZE;
|
|
@@ -4596,6 +4641,7 @@ ${warp ? warpEye1WGSL : ''}
|
|
|
4596
4641
|
`
|
|
4597
4642
|
: ''}
|
|
4598
4643
|
${readChunk}
|
|
4644
|
+
${cacheAlphaWGSL}
|
|
4599
4645
|
${coverage !== 'pixel'
|
|
4600
4646
|
? `
|
|
4601
4647
|
// integer hash (Wellons' prospector mix), as the raster's
|
|
@@ -4609,13 +4655,6 @@ fn hashU32(x: u32) -> u32 {
|
|
|
4609
4655
|
return v;
|
|
4610
4656
|
}
|
|
4611
4657
|
|
|
4612
|
-
// the radius, in units of the quad's half extent, where alpha = opacity * falloff(r^2) falls to
|
|
4613
|
-
// a threshold, with falloff(x) = (exp(-4 x) - exp(-4)) / (1 - exp(-4))
|
|
4614
|
-
fn radiusAt(threshold: f32, opacity: f32) -> f32 {
|
|
4615
|
-
let e4 = exp(-4.0);
|
|
4616
|
-
return sqrt(max(-log(threshold / opacity * (1.0 - e4) + e4) * 0.25, 0.0));
|
|
4617
|
-
}
|
|
4618
|
-
|
|
4619
4658
|
// the 24 orders of four strata, 2 bits a set
|
|
4620
4659
|
const PERMUTATIONS = array<u32, 24>(${permutations.map((p) => `${p}u`).join(', ')});
|
|
4621
4660
|
`
|
|
@@ -4919,11 +4958,11 @@ ${coverage !== 'pixel'
|
|
|
4919
4958
|
? `
|
|
4920
4959
|
// the full quad's axes (clamped to the radius limit); the raster scales them to each polygon
|
|
4921
4960
|
result.words[2] = pack2x16float(len1 * clampScale * direction);
|
|
4922
|
-
result.words[3] = pack2x16float(vec2f(len2Full * clampScale, 0.0)) | (
|
|
4961
|
+
result.words[3] = pack2x16float(vec2f(len2Full * clampScale, 0.0)) | (encodeCacheAlpha(opacity) << 16u);
|
|
4923
4962
|
`
|
|
4924
4963
|
: `
|
|
4925
4964
|
result.words[2] = pack2x16float(axis1);
|
|
4926
|
-
result.words[3] = pack2x16float(vec2f(len2, 0.0)) | (
|
|
4965
|
+
result.words[3] = pack2x16float(vec2f(len2, 0.0)) | (encodeCacheAlpha(opacity) << 16u);
|
|
4927
4966
|
`}
|
|
4928
4967
|
// the depth bucket, log-spaced from the near plane, in the flags byte
|
|
4929
4968
|
let key = clamp((log(max(depth, 1e-6)) - uniforms.keyLogNear) * uniforms.keyInvLogRange, 0.0, 0.999) * ${ORDER_BUCKETS}.0;
|
|
@@ -6068,18 +6107,10 @@ ${varyingsWGSL}
|
|
|
6068
6107
|
// the splat's share of the coverage hash, once per vertex rather than per fragment
|
|
6069
6108
|
uniform frameSeed: u32;
|
|
6070
6109
|
${hashWGSL}
|
|
6110
|
+
${cacheAlphaWGSL}
|
|
6071
6111
|
|
|
6072
6112
|
const discardPosition = vec4f(0.0, 0.0, 2.0, 1.0);
|
|
6073
6113
|
|
|
6074
|
-
#ifdef SSE_COVERAGE_SPLAT
|
|
6075
|
-
// the radius, in units of the quad's half extent, where alpha = opacity * falloff(r^2) falls
|
|
6076
|
-
// to a threshold (the projector's radiusAt)
|
|
6077
|
-
fn radiusAt(threshold: f32, opacity: f32) -> f32 {
|
|
6078
|
-
let e4 = exp(-4.0);
|
|
6079
|
-
return sqrt(max(-log(threshold / opacity * (1.0 - e4) + e4) * 0.25, 0.0));
|
|
6080
|
-
}
|
|
6081
|
-
#endif
|
|
6082
|
-
|
|
6083
6114
|
@vertex
|
|
6084
6115
|
fn vertexMain(input: VertexInput) -> VertexOutput {
|
|
6085
6116
|
var output: VertexOutput;
|
|
@@ -6125,7 +6156,7 @@ fn vertexMain(input: VertexInput) -> VertexOutput {
|
|
|
6125
6156
|
// (shaders/projector.ts): the splat's 15-bit draw, and a nibble per draw group holding
|
|
6126
6157
|
// the stratum and sub-stratum of the jittered modes
|
|
6127
6158
|
let word5 = splatCache[base + 5u];
|
|
6128
|
-
let opacityS =
|
|
6159
|
+
let opacityS = decodeCacheAlpha(word3 >> 16u);
|
|
6129
6160
|
let drawn = f32(word5 & ${(1 << DRAW_BITS) - 1}u) * (1.0 / ${(1 << DRAW_BITS) - 1}.0);
|
|
6130
6161
|
#ifdef SSE_INTERLEAVED
|
|
6131
6162
|
let group = uniform.setIndex;
|
|
@@ -6158,9 +6189,12 @@ fn vertexMain(input: VertexInput) -> VertexOutput {
|
|
|
6158
6189
|
let corner = unit * polygonRadius;
|
|
6159
6190
|
#else
|
|
6160
6191
|
// shrink the quad to where alpha falls below the clip, as the engine's clipCorner does:
|
|
6161
|
-
// the fragment shader discards everything outside it anyway, but still pays to shade it
|
|
6162
|
-
|
|
6163
|
-
let
|
|
6192
|
+
// the fragment shader discards everything outside it anyway, but still pays to shade it.
|
|
6193
|
+
// Above 1 the plateau widens it, as there
|
|
6194
|
+
let opacity = decodeCacheAlpha(word3 >> 16u);
|
|
6195
|
+
let clip = min(1.0, sqrt(max(0.0, log(min(opacity, 1.0) / uniform.sseAlphaClip))) * 0.5);
|
|
6196
|
+
let core = plateauCore(opacity);
|
|
6197
|
+
let corner = vertex_position.xy * (core + (1.0 - core) * clip);
|
|
6164
6198
|
#endif
|
|
6165
6199
|
let pixelOffset = corner.x * axis1 + corner.y * axis2;
|
|
6166
6200
|
let w = select(depth, 1.0, ortho);
|
|
@@ -6203,13 +6237,7 @@ uniform sseAlphaClip: f32;
|
|
|
6203
6237
|
uniform jitterParams: vec4f;
|
|
6204
6238
|
#endif
|
|
6205
6239
|
|
|
6206
|
-
|
|
6207
|
-
const INV_EXP4 = 1.0 / (1.0 - EXP4);
|
|
6208
|
-
|
|
6209
|
-
// the engine's falloff: zero at the quad edge, which sits at 2 sqrt(2) sigma
|
|
6210
|
-
fn falloff(x: f32) -> f32 {
|
|
6211
|
-
return (exp(x * -4.0) - EXP4) * INV_EXP4;
|
|
6212
|
-
}
|
|
6240
|
+
${cacheAlphaWGSL}
|
|
6213
6241
|
|
|
6214
6242
|
@fragment
|
|
6215
6243
|
fn fragmentMain(input: FragmentInput) -> FragmentOutput {
|
|
@@ -6221,7 +6249,7 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
|
|
|
6221
6249
|
// stratum: interleaved gradient noise rotated by the entry's key, as the per-pixel
|
|
6222
6250
|
// raster's. The test discards the square's corners too (alpha is negative past the
|
|
6223
6251
|
// quad's edge), so the kept region is the exact ellipse with a dithered rim
|
|
6224
|
-
let alphaJ =
|
|
6252
|
+
let alphaJ = splatAlpha(dot(gaussianUV, gaussianUV), jitterVary.z);
|
|
6225
6253
|
let ignJ = fract(52.9829189 * fract(dot(pcPosition.xy, vec2f(0.06711056, 0.00583715))));
|
|
6226
6254
|
let thresholdJ = jitterVary.x + fract(ignJ + jitterVary.y) * uniform.jitterParams.z;
|
|
6227
6255
|
if (alphaJ <= max(thresholdJ, uniform.sseAlphaClip)) {
|
|
@@ -6235,8 +6263,7 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
|
|
|
6235
6263
|
if (radius > 1.0) {
|
|
6236
6264
|
discard;
|
|
6237
6265
|
}
|
|
6238
|
-
let
|
|
6239
|
-
let alpha = falloff(radius) * opacity;
|
|
6266
|
+
let alpha = splatAlpha(radius, decodeCacheAlpha(packedAlpha));
|
|
6240
6267
|
if (alpha < uniform.sseAlphaClip) {
|
|
6241
6268
|
discard;
|
|
6242
6269
|
}
|
|
@@ -6610,7 +6637,7 @@ fn srcColor() -> vec3f {
|
|
|
6610
6637
|
// 11/11/10 bits (shaders/packed-source.ts), so the projector reads one texel per active splat,
|
|
6611
6638
|
// a second per survivor and no codebook per coefficient; measured on the Pixel 7 Pro against
|
|
6612
6639
|
// reading the six textures as they are: house 11.3 to 9.3 ms, large 11.2 to 9.4. Other formats
|
|
6613
|
-
// (sog v1, ply, compressed ply) are read through the engine's format read chunks as they are.
|
|
6640
|
+
// (sog v1, sog v3, ply, compressed ply) are read through the engine's format read chunks as they are.
|
|
6614
6641
|
//
|
|
6615
6642
|
// The engine's work buffer is not read by this path, so its copy passes are switched off on
|
|
6616
6643
|
// the buffer this source sees and its textures are kept at 1x1 (shrunk if the engine sized them
|
|
@@ -6810,10 +6837,10 @@ class DirectSplatSource {
|
|
|
6810
6837
|
device.computeDispatch([compute], 'sse-splat-decode-sh');
|
|
6811
6838
|
this.decodedSH.set(resource, { texture, compute });
|
|
6812
6839
|
}
|
|
6813
|
-
// the packed layout applies to sog v2 files, the only ones the repack reads
|
|
6840
|
+
// the packed layout applies to sog v2 files, the only ones the repack reads. Sog v3 files have
|
|
6841
|
+
// the same textures, but a different rotation and opacity encoding and 24-bit sh labels
|
|
6814
6842
|
packedActive() {
|
|
6815
|
-
|
|
6816
|
-
return !!textures && textures.has('sogCodebook');
|
|
6843
|
+
return this.resource?.gsplatData?.meta?.version === 2;
|
|
6817
6844
|
}
|
|
6818
6845
|
hasSH() {
|
|
6819
6846
|
const textures = this.resource?.streams.textures;
|
|
@@ -10109,7 +10136,7 @@ const importSettings = (settings) => {
|
|
|
10109
10136
|
return result;
|
|
10110
10137
|
};
|
|
10111
10138
|
|
|
10112
|
-
var version = "1.43.
|
|
10139
|
+
var version = "1.43.2";
|
|
10113
10140
|
|
|
10114
10141
|
class Tooltip {
|
|
10115
10142
|
register;
|
|
@@ -24431,19 +24458,6 @@ const isPrefetchable = (contentUrl, contentFilename) => {
|
|
|
24431
24458
|
// gsaf is an animated splat sequence, which the viewer decodes and plays itself rather than
|
|
24432
24459
|
// through an engine parser
|
|
24433
24460
|
const isGsaf = (contentUrl, contentFilename) => contentName(contentUrl, contentFilename)?.toLowerCase().endsWith('.gsaf');
|
|
24434
|
-
// TEMPORARY, until a Quest Browser release accepts a WebGPU device for WebXR again: then delete
|
|
24435
|
-
// this and its use in resolveConfig. Quest Browser 156 refuses every WebGPU device for an
|
|
24436
|
-
// immersive session, even one from an adapter requested with xrCompatible (XRGPUBinding throws
|
|
24437
|
-
// "WebGPU device must be created by an XR compatible adapter"), so VR and AR show black. The
|
|
24438
|
-
// headsets already run the sorted renderer (quality.ts keeps the stochastic one off them), so
|
|
24439
|
-
// WebGL costs them only the gpu sort. It overrides even an explicit renderer: 'webgpu', since
|
|
24440
|
-
// hosts pass one by default (superspl.at's viewer-options.ts does). A ?webgpu in the page url
|
|
24441
|
-
// opts back in, to check a new browser release for the fix. It is read here rather than in
|
|
24442
|
-
// index.html, against the rule that only the document reads url params, because hosts parse the
|
|
24443
|
-
// url themselves (superspl.at forwards its scene page's params to the viewer's document but does
|
|
24444
|
-
// not pass this one on)
|
|
24445
|
-
const questBrowser = /OculusBrowser/.test(globalThis.navigator?.userAgent ?? '') &&
|
|
24446
|
-
!new URLSearchParams(globalThis.location?.search ?? '').has('webgpu');
|
|
24447
24461
|
const loadGsplat = async (app, config, progressCallback, cancelled) => {
|
|
24448
24462
|
const { contents, contentUrl, contentFilename } = config;
|
|
24449
24463
|
const filename = contentName(contentUrl, contentFilename);
|
|
@@ -24646,7 +24660,7 @@ const resolveConfig = (options) => ({
|
|
|
24646
24660
|
poster: options.poster ?? (options.posterUrl ? createImage(options.posterUrl) : undefined),
|
|
24647
24661
|
contents: options.contents ??
|
|
24648
24662
|
(isPrefetchable(options.contentUrl, options.contentFilename) ? fetch(options.contentUrl) : undefined),
|
|
24649
|
-
renderer:
|
|
24663
|
+
renderer: options.renderer ?? 'webgpu',
|
|
24650
24664
|
ui: options.ui ?? true,
|
|
24651
24665
|
reticle: options.reticle ?? false,
|
|
24652
24666
|
noanim: options.noanim ?? false,
|