@playcanvas/supersplat-viewer 1.43.0 → 1.43.1
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 +2 -2
- package/dist/index.js +1 -1
- package/dist/viewer.d.ts +1 -2
- package/dist/viewer.js +65 -50
- package/dist/viewer.js.map +1 -1
- package/package.json +1 -1
- package/public/index.js +65 -50
- package/public/index.js.map +1 -1
package/package.json
CHANGED
package/public/index.js
CHANGED
|
@@ -93300,6 +93300,51 @@ fn unwarpTexel(texel: vec2i) -> vec2f {
|
|
|
93300
93300
|
// visibility come from the cpu (resident-set rebuild on version change, frustum cull per frame).
|
|
93301
93301
|
/** Words per cache entry: ndc, depth, axis1, len2 | alpha | bucket, rgb, id (or the coverage draw). */
|
|
93302
93302
|
const CACHE_WORDS = 6;
|
|
93303
|
+
// The cached alpha and the splat's shape, shared by the projector and the raster. The alpha byte
|
|
93304
|
+
// is sog v3's encoding, alpha = (1.25 b / 255)^2, so it holds the alpha above 1 a sog v3 file
|
|
93305
|
+
// stores (up to 1.5625); every other source's alpha converts to it. Above 1 a splat draws as the
|
|
93306
|
+
// engine's does: a plateau at full alpha out to plateauCore of the quad's half extent, and the
|
|
93307
|
+
// falloff stretched over the rest (the engine's gsplatPlateauCore, clipCorner and splat shader).
|
|
93308
|
+
const cacheAlphaWGSL = /* wgsl */ `
|
|
93309
|
+
fn encodeCacheAlpha(alpha: f32) -> u32 {
|
|
93310
|
+
return u32(sqrt(clamp(alpha, 0.0, 1.5625)) * (255.0 / 1.25) + 0.5);
|
|
93311
|
+
}
|
|
93312
|
+
|
|
93313
|
+
fn decodeCacheAlpha(bits: u32) -> f32 {
|
|
93314
|
+
let o = f32(bits & 0xffu) * (1.25 / 255.0);
|
|
93315
|
+
return o * o;
|
|
93316
|
+
}
|
|
93317
|
+
|
|
93318
|
+
// the radius, in units of the quad's half extent, out to which alpha above 1 holds at full alpha
|
|
93319
|
+
fn plateauCore(alpha: f32) -> f32 {
|
|
93320
|
+
if (alpha <= 1.0) {
|
|
93321
|
+
return 0.0;
|
|
93322
|
+
}
|
|
93323
|
+
let t = min(alpha - 1.0, 0.5625);
|
|
93324
|
+
return sqrt(0.28986718 + 0.62504992 * t) - 0.53839315;
|
|
93325
|
+
}
|
|
93326
|
+
|
|
93327
|
+
// the splat's alpha at r^2, in units of the quad's half extent:
|
|
93328
|
+
// alpha * falloff(r^2) with falloff(x) = (exp(-4 x) - exp(-4)) / (1 - exp(-4)), or above 1 the plateau
|
|
93329
|
+
fn splatAlpha(r2: f32, alpha: f32) -> f32 {
|
|
93330
|
+
var x = r2;
|
|
93331
|
+
if (alpha > 1.0) {
|
|
93332
|
+
let core = plateauCore(alpha);
|
|
93333
|
+
let c = max(0.0, sqrt(r2) - core) / (1.0 - core);
|
|
93334
|
+
x = c * c;
|
|
93335
|
+
}
|
|
93336
|
+
let e4 = exp(-4.0);
|
|
93337
|
+
return (exp(x * -4.0) - e4) / (1.0 - e4) * min(alpha, 1.0);
|
|
93338
|
+
}
|
|
93339
|
+
|
|
93340
|
+
// the radius, in units of the quad's half extent, where splatAlpha falls to a threshold
|
|
93341
|
+
fn radiusAt(threshold: f32, alpha: f32) -> f32 {
|
|
93342
|
+
let e4 = exp(-4.0);
|
|
93343
|
+
let core = plateauCore(alpha);
|
|
93344
|
+
let r = sqrt(max(-log(threshold / min(alpha, 1.0) * (1.0 - e4) + e4) * 0.25, 0.0));
|
|
93345
|
+
return core + (1.0 - core) * r;
|
|
93346
|
+
}
|
|
93347
|
+
`;
|
|
93303
93348
|
const PROJECTOR_WORKGROUP_SIZE = 256;
|
|
93304
93349
|
/** Buckets of the counting order (shaders/order.ts); the workgroup size, so each thread owns one. */
|
|
93305
93350
|
const ORDER_BUCKETS = PROJECTOR_WORKGROUP_SIZE;
|
|
@@ -93727,6 +93772,7 @@ ${warp ? warpEye1WGSL : ''}
|
|
|
93727
93772
|
`
|
|
93728
93773
|
: ''}
|
|
93729
93774
|
${readChunk}
|
|
93775
|
+
${cacheAlphaWGSL}
|
|
93730
93776
|
${coverage !== 'pixel'
|
|
93731
93777
|
? `
|
|
93732
93778
|
// integer hash (Wellons' prospector mix), as the raster's
|
|
@@ -93740,13 +93786,6 @@ fn hashU32(x: u32) -> u32 {
|
|
|
93740
93786
|
return v;
|
|
93741
93787
|
}
|
|
93742
93788
|
|
|
93743
|
-
// the radius, in units of the quad's half extent, where alpha = opacity * falloff(r^2) falls to
|
|
93744
|
-
// a threshold, with falloff(x) = (exp(-4 x) - exp(-4)) / (1 - exp(-4))
|
|
93745
|
-
fn radiusAt(threshold: f32, opacity: f32) -> f32 {
|
|
93746
|
-
let e4 = exp(-4.0);
|
|
93747
|
-
return sqrt(max(-log(threshold / opacity * (1.0 - e4) + e4) * 0.25, 0.0));
|
|
93748
|
-
}
|
|
93749
|
-
|
|
93750
93789
|
// the 24 orders of four strata, 2 bits a set
|
|
93751
93790
|
const PERMUTATIONS = array<u32, 24>(${permutations.map((p) => `${p}u`).join(', ')});
|
|
93752
93791
|
`
|
|
@@ -94050,11 +94089,11 @@ ${coverage !== 'pixel'
|
|
|
94050
94089
|
? `
|
|
94051
94090
|
// the full quad's axes (clamped to the radius limit); the raster scales them to each polygon
|
|
94052
94091
|
result.words[2] = pack2x16float(len1 * clampScale * direction);
|
|
94053
|
-
result.words[3] = pack2x16float(vec2f(len2Full * clampScale, 0.0)) | (
|
|
94092
|
+
result.words[3] = pack2x16float(vec2f(len2Full * clampScale, 0.0)) | (encodeCacheAlpha(opacity) << 16u);
|
|
94054
94093
|
`
|
|
94055
94094
|
: `
|
|
94056
94095
|
result.words[2] = pack2x16float(axis1);
|
|
94057
|
-
result.words[3] = pack2x16float(vec2f(len2, 0.0)) | (
|
|
94096
|
+
result.words[3] = pack2x16float(vec2f(len2, 0.0)) | (encodeCacheAlpha(opacity) << 16u);
|
|
94058
94097
|
`}
|
|
94059
94098
|
// the depth bucket, log-spaced from the near plane, in the flags byte
|
|
94060
94099
|
let key = clamp((log(max(depth, 1e-6)) - uniforms.keyLogNear) * uniforms.keyInvLogRange, 0.0, 0.999) * ${ORDER_BUCKETS}.0;
|
|
@@ -95199,18 +95238,10 @@ ${varyingsWGSL}
|
|
|
95199
95238
|
// the splat's share of the coverage hash, once per vertex rather than per fragment
|
|
95200
95239
|
uniform frameSeed: u32;
|
|
95201
95240
|
${hashWGSL}
|
|
95241
|
+
${cacheAlphaWGSL}
|
|
95202
95242
|
|
|
95203
95243
|
const discardPosition = vec4f(0.0, 0.0, 2.0, 1.0);
|
|
95204
95244
|
|
|
95205
|
-
#ifdef SSE_COVERAGE_SPLAT
|
|
95206
|
-
// the radius, in units of the quad's half extent, where alpha = opacity * falloff(r^2) falls
|
|
95207
|
-
// to a threshold (the projector's radiusAt)
|
|
95208
|
-
fn radiusAt(threshold: f32, opacity: f32) -> f32 {
|
|
95209
|
-
let e4 = exp(-4.0);
|
|
95210
|
-
return sqrt(max(-log(threshold / opacity * (1.0 - e4) + e4) * 0.25, 0.0));
|
|
95211
|
-
}
|
|
95212
|
-
#endif
|
|
95213
|
-
|
|
95214
95245
|
@vertex
|
|
95215
95246
|
fn vertexMain(input: VertexInput) -> VertexOutput {
|
|
95216
95247
|
var output: VertexOutput;
|
|
@@ -95256,7 +95287,7 @@ fn vertexMain(input: VertexInput) -> VertexOutput {
|
|
|
95256
95287
|
// (shaders/projector.ts): the splat's 15-bit draw, and a nibble per draw group holding
|
|
95257
95288
|
// the stratum and sub-stratum of the jittered modes
|
|
95258
95289
|
let word5 = splatCache[base + 5u];
|
|
95259
|
-
let opacityS =
|
|
95290
|
+
let opacityS = decodeCacheAlpha(word3 >> 16u);
|
|
95260
95291
|
let drawn = f32(word5 & ${(1 << DRAW_BITS) - 1}u) * (1.0 / ${(1 << DRAW_BITS) - 1}.0);
|
|
95261
95292
|
#ifdef SSE_INTERLEAVED
|
|
95262
95293
|
let group = uniform.setIndex;
|
|
@@ -95289,9 +95320,12 @@ fn vertexMain(input: VertexInput) -> VertexOutput {
|
|
|
95289
95320
|
let corner = unit * polygonRadius;
|
|
95290
95321
|
#else
|
|
95291
95322
|
// shrink the quad to where alpha falls below the clip, as the engine's clipCorner does:
|
|
95292
|
-
// the fragment shader discards everything outside it anyway, but still pays to shade it
|
|
95293
|
-
|
|
95294
|
-
let
|
|
95323
|
+
// the fragment shader discards everything outside it anyway, but still pays to shade it.
|
|
95324
|
+
// Above 1 the plateau widens it, as there
|
|
95325
|
+
let opacity = decodeCacheAlpha(word3 >> 16u);
|
|
95326
|
+
let clip = min(1.0, sqrt(max(0.0, log(min(opacity, 1.0) / uniform.sseAlphaClip))) * 0.5);
|
|
95327
|
+
let core = plateauCore(opacity);
|
|
95328
|
+
let corner = vertex_position.xy * (core + (1.0 - core) * clip);
|
|
95295
95329
|
#endif
|
|
95296
95330
|
let pixelOffset = corner.x * axis1 + corner.y * axis2;
|
|
95297
95331
|
let w = select(depth, 1.0, ortho);
|
|
@@ -95334,13 +95368,7 @@ uniform sseAlphaClip: f32;
|
|
|
95334
95368
|
uniform jitterParams: vec4f;
|
|
95335
95369
|
#endif
|
|
95336
95370
|
|
|
95337
|
-
|
|
95338
|
-
const INV_EXP4 = 1.0 / (1.0 - EXP4);
|
|
95339
|
-
|
|
95340
|
-
// the engine's falloff: zero at the quad edge, which sits at 2 sqrt(2) sigma
|
|
95341
|
-
fn falloff(x: f32) -> f32 {
|
|
95342
|
-
return (exp(x * -4.0) - EXP4) * INV_EXP4;
|
|
95343
|
-
}
|
|
95371
|
+
${cacheAlphaWGSL}
|
|
95344
95372
|
|
|
95345
95373
|
@fragment
|
|
95346
95374
|
fn fragmentMain(input: FragmentInput) -> FragmentOutput {
|
|
@@ -95352,7 +95380,7 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
|
|
|
95352
95380
|
// stratum: interleaved gradient noise rotated by the entry's key, as the per-pixel
|
|
95353
95381
|
// raster's. The test discards the square's corners too (alpha is negative past the
|
|
95354
95382
|
// quad's edge), so the kept region is the exact ellipse with a dithered rim
|
|
95355
|
-
let alphaJ =
|
|
95383
|
+
let alphaJ = splatAlpha(dot(gaussianUV, gaussianUV), jitterVary.z);
|
|
95356
95384
|
let ignJ = fract(52.9829189 * fract(dot(pcPosition.xy, vec2f(0.06711056, 0.00583715))));
|
|
95357
95385
|
let thresholdJ = jitterVary.x + fract(ignJ + jitterVary.y) * uniform.jitterParams.z;
|
|
95358
95386
|
if (alphaJ <= max(thresholdJ, uniform.sseAlphaClip)) {
|
|
@@ -95366,8 +95394,7 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
|
|
|
95366
95394
|
if (radius > 1.0) {
|
|
95367
95395
|
discard;
|
|
95368
95396
|
}
|
|
95369
|
-
let
|
|
95370
|
-
let alpha = falloff(radius) * opacity;
|
|
95397
|
+
let alpha = splatAlpha(radius, decodeCacheAlpha(packedAlpha));
|
|
95371
95398
|
if (alpha < uniform.sseAlphaClip) {
|
|
95372
95399
|
discard;
|
|
95373
95400
|
}
|
|
@@ -95741,7 +95768,7 @@ fn srcColor() -> vec3f {
|
|
|
95741
95768
|
// 11/11/10 bits (shaders/packed-source.ts), so the projector reads one texel per active splat,
|
|
95742
95769
|
// a second per survivor and no codebook per coefficient; measured on the Pixel 7 Pro against
|
|
95743
95770
|
// reading the six textures as they are: house 11.3 to 9.3 ms, large 11.2 to 9.4. Other formats
|
|
95744
|
-
// (sog v1, ply, compressed ply) are read through the engine's format read chunks as they are.
|
|
95771
|
+
// (sog v1, sog v3, ply, compressed ply) are read through the engine's format read chunks as they are.
|
|
95745
95772
|
//
|
|
95746
95773
|
// The engine's work buffer is not read by this path, so its copy passes are switched off on
|
|
95747
95774
|
// the buffer this source sees and its textures are kept at 1x1 (shrunk if the engine sized them
|
|
@@ -95941,10 +95968,11 @@ class DirectSplatSource {
|
|
|
95941
95968
|
device.computeDispatch([compute], 'sse-splat-decode-sh');
|
|
95942
95969
|
this.decodedSH.set(resource, { texture, compute });
|
|
95943
95970
|
}
|
|
95944
|
-
// the packed layout applies to sog v2 files, the only ones the repack reads
|
|
95971
|
+
// the packed layout applies to sog v2 files, the only ones the repack reads. The engine gives
|
|
95972
|
+
// sog v3 files a codebook too, but no quats texture: their rotation is in the alpha channels
|
|
95945
95973
|
packedActive() {
|
|
95946
95974
|
const textures = this.resource?.streams.textures;
|
|
95947
|
-
return !!textures && textures.has('sogCodebook');
|
|
95975
|
+
return !!textures && textures.has('sogCodebook') && textures.has('quats');
|
|
95948
95976
|
}
|
|
95949
95977
|
hasSH() {
|
|
95950
95978
|
const textures = this.resource?.streams.textures;
|
|
@@ -99240,7 +99268,7 @@ const importSettings = (settings) => {
|
|
|
99240
99268
|
return result;
|
|
99241
99269
|
};
|
|
99242
99270
|
|
|
99243
|
-
var version = "1.43.
|
|
99271
|
+
var version = "1.43.1";
|
|
99244
99272
|
|
|
99245
99273
|
class Tooltip {
|
|
99246
99274
|
register;
|
|
@@ -115107,19 +115135,6 @@ const isPrefetchable = (contentUrl, contentFilename) => {
|
|
|
115107
115135
|
// gsaf is an animated splat sequence, which the viewer decodes and plays itself rather than
|
|
115108
115136
|
// through an engine parser
|
|
115109
115137
|
const isGsaf = (contentUrl, contentFilename) => contentName(contentUrl, contentFilename)?.toLowerCase().endsWith('.gsaf');
|
|
115110
|
-
// TEMPORARY, until a Quest Browser release accepts a WebGPU device for WebXR again: then delete
|
|
115111
|
-
// this and its use in resolveConfig. Quest Browser 156 refuses every WebGPU device for an
|
|
115112
|
-
// immersive session, even one from an adapter requested with xrCompatible (XRGPUBinding throws
|
|
115113
|
-
// "WebGPU device must be created by an XR compatible adapter"), so VR and AR show black. The
|
|
115114
|
-
// headsets already run the sorted renderer (quality.ts keeps the stochastic one off them), so
|
|
115115
|
-
// WebGL costs them only the gpu sort. It overrides even an explicit renderer: 'webgpu', since
|
|
115116
|
-
// hosts pass one by default (superspl.at's viewer-options.ts does). A ?webgpu in the page url
|
|
115117
|
-
// opts back in, to check a new browser release for the fix. It is read here rather than in
|
|
115118
|
-
// index.html, against the rule that only the document reads url params, because hosts parse the
|
|
115119
|
-
// url themselves (superspl.at forwards its scene page's params to the viewer's document but does
|
|
115120
|
-
// not pass this one on)
|
|
115121
|
-
const questBrowser = /OculusBrowser/.test(globalThis.navigator?.userAgent ?? '') &&
|
|
115122
|
-
!new URLSearchParams(globalThis.location?.search ?? '').has('webgpu');
|
|
115123
115138
|
const loadGsplat = async (app, config, progressCallback, cancelled) => {
|
|
115124
115139
|
const { contents, contentUrl, contentFilename } = config;
|
|
115125
115140
|
const filename = contentName(contentUrl, contentFilename);
|
|
@@ -115322,7 +115337,7 @@ const resolveConfig = (options) => ({
|
|
|
115322
115337
|
poster: options.poster ?? (options.posterUrl ? createImage(options.posterUrl) : undefined),
|
|
115323
115338
|
contents: options.contents ??
|
|
115324
115339
|
(isPrefetchable(options.contentUrl, options.contentFilename) ? fetch(options.contentUrl) : undefined),
|
|
115325
|
-
renderer:
|
|
115340
|
+
renderer: options.renderer ?? 'webgpu',
|
|
115326
115341
|
ui: options.ui ?? true,
|
|
115327
115342
|
reticle: options.reticle ?? false,
|
|
115328
115343
|
noanim: options.noanim ?? false,
|