Skip to content

Sogs updates #7662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 12, 2025
Merged

Sogs updates #7662

merged 9 commits into from
May 12, 2025

Conversation

slimbuck
Copy link
Member

Fixes #7537

This PR updates SOGS runtime as follows:

  • combine labels_u and labels_l data into single RG texture
  • combine gaussian sh0 (color) and opacity into single texture
  • implement more accurate quaternion storage in (2, 8, 8, 8) bits
  • reorder data on GPU at load-time to improve runtime memory cache coherency

SOGS Data Comparison

Examples of SOGS compression. All scenes contain 3 bands of spherical harmonics.

Scene Gaussians PLY Compressed PLY SOGS
model-viewer 4.3M 1GB 263MB 56MB
model-viewer (1) 60K 14.6MB 3.6MB 1.2MB
model-viewer (2) 720K 174MB 43MB 11MB

Notes

  • rendering performance is still slower than compressed.ply (on my windows RTX3070 ti machine), but faster than uncompressed ply. haven't investigated why
  • load time reordering isn't fast due to the cpu sort. 4M particles takes around 600ms (on laptop). we could perform this sort ahead of time and store the order in another texture, but for now we choose the load-time approach.
  • the tooling for generating SOGS scenes is based on a fork of https://github.com/vincentwoo/sogs. we will make this public soon or merge our changes into the mainline, depending on @vincentwoo 's preference.
  • creating SOGS scenes requires (currently) a CUDA-enabled python install. we hope to create a browser-based solution.

@slimbuck slimbuck requested review from a team and Copilot May 12, 2025 11:30
@slimbuck slimbuck self-assigned this May 12, 2025
@slimbuck slimbuck added area: graphics Graphics related issue enhancement labels May 12, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the SOGS runtime to combine texture resources, improve quaternion storage precision, and reorder GPU data for better memory cache coherency.

  • Combine separate label textures into a unified texture and merge Gaussian color and opacity data.
  • Update quaternion unpacking and storage using a (2, 8, 8, 8) bit scheme.
  • Introduce a GPU-based reordering step that computes Morton order indices to improve runtime memory performance.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/scene/shader-lib/chunks/gsplat/vert/gsplatSogsSH.js Combined label uniforms into a single texture uniform.
src/scene/shader-lib/chunks/gsplat/vert/gsplatSogsData.js Updated quaternion reading logic using a mode-based selection.
src/scene/shader-lib/chunks/gsplat/vert/gsplatSogsColor.js Merged sh0 and opacity data into one texture and adjusted processing.
src/scene/shader-lib/chunks/gsplat/vert/gsplatData.js Modified quaternion unpacking calls to support new bit storage order.
src/scene/shader-lib/chunks/gsplat/vert/gsplatCompressedData.js Removed obsolete quaternion conversion function.
src/scene/shader-lib/chunks/gsplat/vert/gsplatCommon.js Updated documentation and fixed minor comment typos.
src/scene/gsplat/gsplat-sogs.js Removed redundant texture parameters and updated parameter passing.
src/scene/gsplat/gsplat-sogs-data.js Added new GPU reordering logic based on Morton order for improved cache coherency.
src/scene/gsplat/gsplat-data.js Clamped coordinate values to a maximum of 1023 to prevent potential overflows.
src/framework/parsers/sogs.js Updated texture async reads and adjusted texture assignments for the new data layout.

targetTexture.name = `sogs-${member}`;
targetTexture._levels = sourceTexture._levels;
this[member] = targetTexture;

Copy link
Preview

Copilot AI May 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding an inline comment to explain the texture swap logic in this loop, clarifying how the chain of render targets is being updated for maintainability.

Suggested change
// Swap targetTexture and sourceTexture to prepare for the next iteration.

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@mvaligursky mvaligursky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WGSL chunks need to be updated as well, otherwise this won't work on WebGPU

@mvaligursky
Copy link
Contributor

Also, it'd be great to have an engine example using this, so that we can test both platforms easily.

@slimbuck
Copy link
Member Author

slimbuck commented May 12, 2025

There is some remaining follow up work:

  • implement wgsl chunks
  • get device recovery working
  • add SOGS loader to engine examples

@slimbuck slimbuck merged commit c1e865f into playcanvas:main May 12, 2025
7 checks passed
@slimbuck slimbuck deleted the sogs-dev branch May 12, 2025 15:30
@Maksims
Copy link
Collaborator

Maksims commented May 12, 2025

If the rendering is done by reading from textures, then there might be a significant performance reduction when accessing texture texels at random positions. As it does not allow GPU to cache chunks of it, so the reads from it will require a slow memory trips.
This is especially strong on mobile.

@slimbuck
Copy link
Member Author

@Maksims , yep, that's what this PR is addressing :)

slimbuck added a commit that referenced this pull request May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sogs followup work
4 participants