@playcanvas/supersplat-viewer 1.17.3 → 1.18.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/public/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const TRACEID_GPU_TIMINGS = 'GpuTimings';
2
2
 
3
- const version$1 = '2.17.0';
4
- const revision = '4322c03';
3
+ const version$1 = '2.17.1';
4
+ const revision = 'b60756b';
5
5
  function extend(target, ex) {
6
6
  for(const prop in ex){
7
7
  const copy = ex[prop];
@@ -34609,6 +34609,8 @@ class FrameGraph {
34609
34609
  const renderPasses = this.renderPasses;
34610
34610
  for(let i = 0; i < renderPasses.length; i++){
34611
34611
  const renderPass = renderPasses[i];
34612
+ renderPass._skipStart = false;
34613
+ renderPass._skipEnd = false;
34612
34614
  const renderTarget = renderPass.renderTarget;
34613
34615
  if (renderTarget !== undefined) {
34614
34616
  const prevPass = renderTargetMap.get(renderTarget);
@@ -67534,11 +67536,6 @@ var composePS$1 = `
67534
67536
  void main() {
67535
67537
  #include "composeMainStartPS"
67536
67538
  vec2 uv = uv0;
67537
- #ifdef TAA
67538
- #ifdef WEBGPU
67539
- uv.y = 1.0 - uv.y;
67540
- #endif
67541
- #endif
67542
67539
  vec4 scene = texture2DLod(sceneTexture, uv, 0.0);
67543
67540
  vec3 result = scene.rgb;
67544
67541
  #ifdef CAS
@@ -67782,7 +67779,7 @@ var composeCasPS$1 = `
67782
67779
  #ifdef CAS_HDR
67783
67780
  float maxComponent(float x, float y, float z) { return max(x, max(y, z)); }
67784
67781
  vec3 toSDR(vec3 c) { return c / (1.0 + maxComponent(c.r, c.g, c.b)); }
67785
- vec3 toHDR(vec3 c) { return c / (1.0 - maxComponent(c.r, c.g, c.b)); }
67782
+ vec3 toHDR(vec3 c) { return c / max(1.0 - maxComponent(c.r, c.g, c.b), 1e-4); }
67786
67783
  #else
67787
67784
  vec3 toSDR(vec3 c) { return c; }
67788
67785
  vec3 toHDR(vec3 c) { return c; }
@@ -67797,7 +67794,7 @@ var composeCasPS$1 = `
67797
67794
  vec3 e = toSDR(texture2DLod(sceneTexture, uv + vec2(0.0, y), 0.0).rgb);
67798
67795
  float min_g = min(a.g, min(b.g, min(c.g, min(d.g, e.g))));
67799
67796
  float max_g = max(a.g, max(b.g, max(c.g, max(d.g, e.g))));
67800
- float sharpening_amount = sqrt(min(1.0 - max_g, min_g) / max_g);
67797
+ float sharpening_amount = sqrt(min(1.0 - max_g, min_g) / max(max_g, 1e-4));
67801
67798
  float w = sharpening_amount * sharpness;
67802
67799
  vec3 res = (w * (a + b + d + e) + c) / (4.0 * w + 1.0);
67803
67800
  res = max(res, 0.0);
@@ -67870,9 +67867,6 @@ var composePS = `
67870
67867
  #include "composeMainStartPS"
67871
67868
  var output: FragmentOutput;
67872
67869
  var uv = uv0;
67873
- #ifdef TAA
67874
- uv.y = 1.0 - uv.y;
67875
- #endif
67876
67870
  let scene = textureSampleLevel(sceneTexture, sceneTextureSampler, uv, 0.0);
67877
67871
  var result = scene.rgb;
67878
67872
  #ifdef CAS
@@ -68123,7 +68117,7 @@ var composeCasPS = `
68123
68117
  #ifdef CAS_HDR
68124
68118
  fn maxComponent(x: f32, y: f32, z: f32) -> f32 { return max(x, max(y, z)); }
68125
68119
  fn toSDR(c: vec3f) -> vec3f { return c / (1.0 + maxComponent(c.r, c.g, c.b)); }
68126
- fn toHDR(c: vec3f) -> vec3f { return c / (1.0 - maxComponent(c.r, c.g, c.b)); }
68120
+ fn toHDR(c: vec3f) -> vec3f { return c / max(1.0 - maxComponent(c.r, c.g, c.b), 1e-4); }
68127
68121
  #else
68128
68122
  fn toSDR(c: vec3f) -> vec3f { return c; }
68129
68123
  fn toHDR(c: vec3f) -> vec3f { return c; }
@@ -68138,8 +68132,8 @@ var composeCasPS = `
68138
68132
  let e: half3 = half3(toSDR(textureSampleLevel(sceneTexture, sceneTextureSampler, uv + vec2f(0.0, y), 0.0).rgb));
68139
68133
  let min_g = min(a.g, min(b.g, min(c.g, min(d.g, e.g))));
68140
68134
  let max_g = max(a.g, max(b.g, max(c.g, max(d.g, e.g))));
68141
- let sharpening_amount = sqrt(min(half(1.0) - max_g, min_g) / max_g);
68142
- let w = sharpening_amount * half(uniform.sharpness);
68135
+ let sharpening_amount = sqrt(min(half(1.0) - max_g, min_g) / max(max_g, half(1e-4)));
68136
+ let w = sharpening_amount * half(sharpness);
68143
68137
  var res = (w * (a + b + d + e) + c) / (half(4.0) * w + half(1.0));
68144
68138
  res = max(res, half3(0.0));
68145
68139
  return toHDR(vec3f(res));
@@ -68549,9 +68543,7 @@ var glsltaaResolvePS = `
68549
68543
  uniform vec2 textureSize;
68550
68544
  varying vec2 uv0;
68551
68545
  vec2 reproject(vec2 uv, float depth) {
68552
- #ifndef WEBGPU
68553
- depth = depth * 2.0 - 1.0;
68554
- #endif
68546
+ depth = depth * 2.0 - 1.0;
68555
68547
  vec4 ndc = vec4(uv * 2.0 - 1.0, depth, 1.0);
68556
68548
  ndc.xy -= jitters.xy;
68557
68549
  vec4 worldPosition = matrix_viewProjectionInverse * ndc;
@@ -68574,11 +68566,7 @@ var glsltaaResolvePS = `
68574
68566
  }
68575
68567
  void main()
68576
68568
  {
68577
- vec2 uv = uv0;
68578
- #ifdef WEBGPU
68579
- uv.y = 1.0 - uv.y;
68580
- #endif
68581
- vec4 srcColor = texture2D(sourceTexture, uv);
68569
+ vec4 srcColor = texture2D(sourceTexture, uv0);
68582
68570
  float linearDepth = getLinearScreenDepth(uv0);
68583
68571
  float depth = delinearizeDepth(linearDepth);
68584
68572
  vec2 historyUv = reproject(uv0, depth);
@@ -68587,7 +68575,7 @@ var glsltaaResolvePS = `
68587
68575
  #else
68588
68576
  vec4 historyColor = texture2D(historyTexture, historyUv);
68589
68577
  #endif
68590
- vec4 historyColorClamped = colorClamp(uv, historyColor);
68578
+ vec4 historyColorClamped = colorClamp(uv0, historyColor);
68591
68579
  float mixFactor = (historyUv.x < 0.0 || historyUv.x > 1.0 || historyUv.y < 0.0 || historyUv.y > 1.0) ?
68592
68580
  1.0 : 0.05;
68593
68581
  gl_FragColor = mix(historyColorClamped, srcColor, mixFactor);
@@ -68606,13 +68594,16 @@ var wgsltaaResolvePS = `
68606
68594
  uniform jitters: vec4f;
68607
68595
  uniform textureSize: vec2f;
68608
68596
  varying uv0: vec2f;
68609
- fn reproject(uv: vec2f, depth: f32) -> vec2f {
68597
+ fn reproject(uv_in: vec2f, depth: f32) -> vec2f {
68598
+ var uv = vec2f(uv_in.x, 1.0 - uv_in.y);
68610
68599
  var ndc = vec4f(uv * 2.0 - 1.0, depth, 1.0);
68611
68600
  ndc = vec4f(ndc.xy - uniform.jitters.xy, ndc.zw);
68612
68601
  var worldPosition = uniform.matrix_viewProjectionInverse * ndc;
68613
68602
  worldPosition = worldPosition / worldPosition.w;
68614
68603
  let screenPrevious = uniform.matrix_viewProjectionPrevious * worldPosition;
68615
- return (screenPrevious.xy / screenPrevious.w) * 0.5 + 0.5;
68604
+ var result = (screenPrevious.xy / screenPrevious.w) * 0.5 + 0.5;
68605
+ result.y = 1.0 - result.y;
68606
+ return result;
68616
68607
  }
68617
68608
  fn colorClamp(uv: vec2f, historyColor: vec4f) -> vec4f {
68618
68609
  var minColor = vec3f(9999.0);
@@ -68630,9 +68621,7 @@ var wgsltaaResolvePS = `
68630
68621
  @fragment
68631
68622
  fn fragmentMain(input: FragmentInput) -> FragmentOutput {
68632
68623
  var output: FragmentOutput;
68633
- var uv = input.uv0;
68634
- uv.y = 1.0 - uv.y;
68635
- let srcColor = textureSample(sourceTexture, sourceTextureSampler, uv);
68624
+ let srcColor = textureSample(sourceTexture, sourceTextureSampler, uv0);
68636
68625
  let linearDepth = getLinearScreenDepth(uv0);
68637
68626
  let depth = delinearizeDepth(linearDepth);
68638
68627
  let historyUv = reproject(uv0, depth);
@@ -68641,7 +68630,7 @@ var wgsltaaResolvePS = `
68641
68630
  #else
68642
68631
  var historyColor: vec4f = textureSample(historyTexture, historyTextureSampler, historyUv);
68643
68632
  #endif
68644
- let historyColorClamped = colorClamp(uv, historyColor);
68633
+ let historyColorClamped = colorClamp(uv0, historyColor);
68645
68634
  let mixFactor_condition = historyUv.x < 0.0 || historyUv.x > 1.0 || historyUv.y < 0.0 || historyUv.y > 1.0;
68646
68635
  let mixFactor = select(0.05, 1.0, mixFactor_condition);
68647
68636
  output.color = mix(historyColorClamped, srcColor, mixFactor);
@@ -72033,19 +72022,18 @@ const migrateV2 = (v1) => {
72033
72022
  animTracks: v1.animTracks.map((animTrackV1) => {
72034
72023
  return migrateAnimTrackV2(animTrackV1, v1.camera.fov || 60);
72035
72024
  }),
72036
- cameras: [{
72025
+ cameras: (v1.camera.position && v1.camera.target) ? [{
72037
72026
  initial: {
72038
- position: (v1.camera.position || [0, 0, 5]),
72039
- target: (v1.camera.target || [0, 0, 0]),
72027
+ position: v1.camera.position,
72028
+ target: v1.camera.target,
72040
72029
  fov: v1.camera.fov || 75
72041
72030
  }
72042
- }],
72031
+ }] : [],
72043
72032
  annotations: [],
72044
- startMode: v1.camera.startAnim === 'animTrack' ? 'animTrack' : 'default',
72045
- hasStartPose: !!(v1.camera.position && v1.camera.target)
72033
+ startMode: v1.camera.startAnim === 'animTrack' ? 'animTrack' : 'default'
72046
72034
  };
72047
72035
  };
72048
- // import a json object to conform to the latest settings schema. settings is assumed to be one of the well-formed schemas
72036
+ // migrate a JSON object to the latest settings schema (assumes valid input)
72049
72037
  const importSettings = (settings) => {
72050
72038
  let result;
72051
72039
  const version = settings.version;
@@ -73551,7 +73539,7 @@ class AnimCursor {
73551
73539
  this.cursor = mod(value, this.duration);
73552
73540
  }
73553
73541
  get value() {
73554
- return this.cursor > this.duration ? this.duration - this.cursor : this.cursor;
73542
+ return this.cursor > this.duration ? 2 * this.duration - this.cursor : this.cursor;
73555
73543
  }
73556
73544
  }
73557
73545
 
@@ -74178,9 +74166,12 @@ class CameraManager {
74178
74166
  camera = new Camera();
74179
74167
  constructor(global, bbox, collider = null) {
74180
74168
  const { config, events, settings, state } = global;
74181
- const camera0 = settings.cameras[0].initial;
74182
- const frameCamera = createFrameCamera(bbox, camera0.fov);
74183
- const resetCamera = createCamera(new Vec3(camera0.position), new Vec3(camera0.target), camera0.fov);
74169
+ const camera0 = settings.cameras[0]?.initial;
74170
+ const defaultFov = camera0?.fov ?? 75;
74171
+ const frameCamera = createFrameCamera(bbox, defaultFov);
74172
+ const resetCamera = camera0 ?
74173
+ createCamera(new Vec3(camera0.position), new Vec3(camera0.target), camera0.fov) :
74174
+ frameCamera;
74184
74175
  const getAnimTrack = (initial, isObjectExperience) => {
74185
74176
  const { animTracks } = settings;
74186
74177
  // extract the camera animation track from settings
@@ -74197,7 +74188,7 @@ class CameraManager {
74197
74188
  };
74198
74189
  // object experience starts outside the bounding box
74199
74190
  const isObjectExperience = !bbox.containsPoint(resetCamera.position);
74200
- const animTrack = getAnimTrack(settings.hasStartPose ? resetCamera : frameCamera, isObjectExperience);
74191
+ const animTrack = getAnimTrack(resetCamera, isObjectExperience);
74201
74192
  const controllers = {
74202
74193
  orbit: new OrbitController(),
74203
74194
  fly: new FlyController(),
@@ -75985,19 +75976,21 @@ class Viewer {
75985
75976
  const { graphicsDevice } = app;
75986
75977
  // enable anonymous CORS for image loading in safari
75987
75978
  app.loader.getHandler('texture').imgParser.crossOrigin = 'anonymous';
75979
+ // render skybox as plain equirect
75980
+ const glsl = ShaderChunks.get(graphicsDevice, 'glsl');
75981
+ glsl.set('skyboxPS', glsl.get('skyboxPS').replace('mapRoughnessUv(uv, mipLevel)', 'uv'));
75982
+ const wgsl = ShaderChunks.get(graphicsDevice, 'wgsl');
75983
+ wgsl.set('skyboxPS', wgsl.get('skyboxPS').replace('mapRoughnessUv(uv, uniform.mipLevel)', 'uv'));
75988
75984
  this.origChunks = {
75989
75985
  glsl: {
75990
- gsplatOutputVS: ShaderChunks.get(graphicsDevice, 'glsl').get('gsplatOutputVS')
75986
+ gsplatOutputVS: glsl.get('gsplatOutputVS'),
75987
+ skyboxPS: glsl.get('skyboxPS')
75991
75988
  },
75992
75989
  wgsl: {
75993
- gsplatOutputVS: ShaderChunks.get(graphicsDevice, 'wgsl').get('gsplatOutputVS')
75990
+ gsplatOutputVS: wgsl.get('gsplatOutputVS'),
75991
+ skyboxPS: wgsl.get('skyboxPS')
75994
75992
  }
75995
75993
  };
75996
- // render skybox as plain equirect
75997
- const glsl = ShaderChunks.get(graphicsDevice, 'glsl');
75998
- glsl.set('skyboxPS', glsl.get('skyboxPS').replace('mapRoughnessUv(uv, mipLevel)', 'uv'));
75999
- const wgsl = ShaderChunks.get(graphicsDevice, 'wgsl');
76000
- wgsl.set('skyboxPS', wgsl.get('skyboxPS').replace('mapRoughnessUv(uv, uniform.mipLevel)', 'uv'));
76001
75994
  // disable auto render, we'll render only when camera changes
76002
75995
  app.autoRender = false;
76003
75996
  // configure the camera
@@ -76246,6 +76239,10 @@ class Viewer {
76246
76239
  // force gsplat shader to write gamma-space colors
76247
76240
  ShaderChunks.get(app.graphicsDevice, 'glsl').set('gsplatOutputVS', gammaChunkGlsl);
76248
76241
  ShaderChunks.get(app.graphicsDevice, 'wgsl').set('gsplatOutputVS', gammaChunkWgsl);
76242
+ // force skybox shader to write gamma-space colors (inline pow replaces the
76243
+ // gammaCorrectOutput call which is a no-op under CameraFrame's GAMMA_NONE)
76244
+ ShaderChunks.get(app.graphicsDevice, 'glsl').set('skyboxPS', this.origChunks.glsl.skyboxPS.replace('gammaCorrectOutput(toneMap(processEnvironment(linear)))', 'pow(toneMap(processEnvironment(linear)) + 0.0000001, vec3(1.0 / 2.2))'));
76245
+ ShaderChunks.get(app.graphicsDevice, 'wgsl').set('skyboxPS', this.origChunks.wgsl.skyboxPS.replace('gammaCorrectOutput(toneMap(processEnvironment(linear)))', 'pow(toneMap(processEnvironment(linear)) + 0.0000001, vec3f(1.0 / 2.2))'));
76249
76246
  // ensure the final compose blit doesn't perform linear->gamma conversion.
76250
76247
  RenderTarget.prototype.isColorBufferSrgb = function (index) {
76251
76248
  return this === app.graphicsDevice.backBuffer ? true : origIsColorBufferSrgb.call(this, index);
@@ -76258,9 +76255,11 @@ class Viewer {
76258
76255
  this.cameraFrame.destroy();
76259
76256
  this.cameraFrame = null;
76260
76257
  }
76261
- // restore gsplat output shader chunks to engine defaults
76258
+ // restore shader chunks to engine defaults
76262
76259
  ShaderChunks.get(app.graphicsDevice, 'glsl').set('gsplatOutputVS', this.origChunks.glsl.gsplatOutputVS);
76263
76260
  ShaderChunks.get(app.graphicsDevice, 'wgsl').set('gsplatOutputVS', this.origChunks.wgsl.gsplatOutputVS);
76261
+ ShaderChunks.get(app.graphicsDevice, 'glsl').set('skyboxPS', this.origChunks.glsl.skyboxPS);
76262
+ ShaderChunks.get(app.graphicsDevice, 'wgsl').set('skyboxPS', this.origChunks.wgsl.skyboxPS);
76264
76263
  // restore original isColorBufferSrgb behavior
76265
76264
  RenderTarget.prototype.isColorBufferSrgb = origIsColorBufferSrgb;
76266
76265
  if (!app.xr.active) {
@@ -78134,7 +78133,7 @@ const initXr = (global) => {
78134
78133
  });
78135
78134
  };
78136
78135
 
78137
- var version = "1.17.3";
78136
+ var version = "1.18.0";
78138
78137
 
78139
78138
  const loadGsplat = async (app, config, progressCallback) => {
78140
78139
  const { contents, contentUrl, unified, aa } = config;