Skip to content

Source geometry from work buffer for SOG spherical harmonics updates#8902

Merged
mvaligursky merged 3 commits into
mainfrom
mv-gsplat-sh-workbuffer-geometry
Jun 15, 2026
Merged

Source geometry from work buffer for SOG spherical harmonics updates#8902
mvaligursky merged 3 commits into
mainfrom
mv-gsplat-sh-workbuffer-geometry

Conversation

@mvaligursky

Copy link
Copy Markdown
Contributor

Color-only (spherical harmonics) work buffer updates for SOG resources now reconstruct geometry from the work buffer's stored world-space transform data instead of re-reading and dequantizing the source SOG textures. This skips the means/quats/scales source fetches (and V2 codebook lookups) on the SH-refresh pass, which fires whenever the camera translates.

Changes:

  • Add gsplatWorkBufferGeometry shader chunk (GLSL + WGSL) that decodes the stored center/rotation/scale for both compact and packed work buffer encodings, then converts them back to local space so user modifier code keeps working unchanged.
  • Add a work-buffer-geometry path to the gsplatCopyToWorkbuffer shaders and unify the shared color/SH tail across both the full-render and SH-only paths.
  • Add a dataFormat layout tag to GSplatFormat (set by GSplatParams) so the decode variant is selected from the format's identity rather than by inspecting stream pixel formats.
  • Opt-in per resource via GSplatResourceBase#supportsWorkBufferGeometry, enabled for SOG only; all other formats keep the existing source-read path.

Performance:

  • For SOG SH refreshes, replaces 4 source texture fetches + dequantization per fragment (plus V2 codebook lookups) and a per-fragment mat4×mat4 with a single work-buffer fetch and a quaternion rotate. Net ALU reduction with fewer texture fetches on that pass; largest at SH band 3 and when a work buffer modifier is present. No effect on non-SOG formats or on the full-render path.

Behavior notes:

  • SH colors for SOG are no longer bit-identical (the view direction is computed in world space via the inverse model rotation rather than from the model-view matrix); differences are visually negligible.
  • Inside setWorkBufferModifier code on the SH path, getCenter/getRotation/getScale now return post-modifier values reconstructed from the work buffer, so rotation/scale carry the work buffer format's quantization.

Color-only (spherical harmonics) work buffer updates for SOG resources
now reconstruct geometry from the work buffer's stored world-space
transform data instead of re-reading and dequantizing the source SOG
textures (means_l/means_u/quats/scales).

- Add gsplatWorkBufferGeometry chunk (GLSL + WGSL) that decodes the
  stored center/rotation/scale (both compact and packed work buffer
  encodings) and converts them back to local space, preserving the
  getCenter/getRotation/getScale API used by setWorkBufferModifier code.
- Add a work-buffer-geometry path to gsplatCopyToWorkbuffer and unify
  the shared color/SH tail across both paths.
- Add a dataFormat layout tag to GSplatFormat (set by GSplatParams) so
  the decode variant is selected from the format identity rather than by
  inspecting stream pixel formats.
- Gate behind GSplatResourceBase#supportsWorkBufferGeometry (SOG only).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 optimizes SOG (splat-over-geometry) spherical harmonics (SH) refreshes by reconstructing geometry (center/rotation/scale) from the already-populated work buffer transform streams, avoiding repeated source texture reads + dequantization during color-only updates.

Changes:

  • Adds a new gsplatWorkBufferGeometry shader chunk (GLSL + WGSL) to decode work-buffer transform data and expose getCenter/getRotation/getScale for modifier code.
  • Updates the gsplatCopyToWorkbuffer shaders to optionally source geometry from the work buffer on the color-only (SH) update path and unify SH evaluation tail logic.
  • Introduces GSplatFormat.dataFormat (set by GSplatParams) and a per-resource opt-in (supportsWorkBufferGeometry) enabled for SOG resources.

Reviewed changes

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

Show a summary per file
File Description
src/scene/shader-lib/wgsl/collections/gsplat-chunks-wgsl.js Registers the new WGSL work-buffer geometry chunk for inclusion.
src/scene/shader-lib/wgsl/chunks/gsplat/vert/formats/sog.js Compiles out SOG geometry getters when sourcing geometry from the work buffer.
src/scene/shader-lib/wgsl/chunks/gsplat/frag/gsplatWorkBufferGeometry.js Adds WGSL work-buffer geometry decode + getter implementations.
src/scene/shader-lib/wgsl/chunks/gsplat/frag/gsplatCopyToWorkbuffer.js Adds work-buffer-geometry path for color-only updates and unifies SH direction handling.
src/scene/shader-lib/glsl/collections/gsplat-chunks-glsl.js Registers the new GLSL work-buffer geometry chunk for inclusion.
src/scene/shader-lib/glsl/chunks/gsplat/vert/formats/sog.js Compiles out SOG geometry getters under work-buffer geometry mode.
src/scene/shader-lib/glsl/chunks/gsplat/frag/gsplatWorkBufferGeometry.js Adds GLSL work-buffer geometry decode + getter implementations.
src/scene/shader-lib/glsl/chunks/gsplat/frag/gsplatCopyToWorkbuffer.js Adds work-buffer-geometry path for color-only updates and unifies SH direction handling.
src/scene/gsplat/gsplat-sog-resource.js Opts SOG resources into work-buffer geometry sourcing (supportsWorkBufferGeometry).
src/scene/gsplat/gsplat-resource-base.js Enables GSPLAT_WORKBUFFER_GEOMETRY(+COMPACT) defines for color-only passes when supported.
src/scene/gsplat/gsplat-format.js Adds dataFormat tag to identify work buffer layout without stream-format inspection.
src/scene/gsplat-unified/gsplat-work-buffer-render-pass.js Binds work-buffer transform textures / camera position and sets matrix_model_inverse for the new decode path.
src/scene/gsplat-unified/gsplat-params.js Sets format.dataFormat when creating work-buffer formats.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/scene/gsplat-unified/gsplat-work-buffer-render-pass.js Outdated
Comment thread src/scene/gsplat-unified/gsplat-work-buffer-render-pass.js Outdated
The work-buffer-sourced geometry uniforms (transform textures, camera
position, inverse model matrix) are only consumed by shaders compiled
with GSPLAT_WORKBUFFER_GEOMETRY, which exist only for resources where
supportsWorkBufferGeometry is true. Gate their setup on that condition
so color-only (SH) updates of other formats skip the redundant scope
resolves and, notably, the per-splat Mat4 inversion.

Addresses review feedback on #8902.
@mvaligursky mvaligursky merged commit 44cfb26 into main Jun 15, 2026
9 checks passed
@mvaligursky mvaligursky deleted the mv-gsplat-sh-workbuffer-geometry branch June 15, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants