-
Notifications
You must be signed in to change notification settings - Fork 1.7k
GSplat Extra Streams and Work Buffer Customization #8383
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
Conversation
There was a problem hiding this 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 adds support for custom texture streams on gsplat resources and per-instance shader customization in unified rendering mode. It enables users to store custom per-splat or per-instance data and modify splats during work buffer rendering via custom shader code.
Changes:
- Added
GSplatFormat.addExtraStreams()API to define custom texture streams (resource-level or instance-level) - Added
GSplatComponent.setWorkBufferModifier()to inject custom shader code for modifying splats during work buffer rendering - Added work buffer update control via new constants (
WORKBUFFER_UPDATE_AUTO,WORKBUFFER_UPDATE_ONCE,WORKBUFFER_UPDATE_ALWAYS)
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/scene/shader-lib/wgsl/chunks/gsplat/frag/gsplatCopyToWorkbuffer.js | Integrates custom modifier functions into work buffer rendering (WGSL) |
| src/scene/shader-lib/glsl/chunks/gsplat/frag/gsplatCopyToWorkbuffer.js | Integrates custom modifier functions into work buffer rendering (GLSL) |
| src/scene/gsplat/gsplat-streams.js | Adds instance-level texture management and dynamic stream synchronization |
| src/scene/gsplat/gsplat-format.js | Implements extra streams API with version tracking and shader code generation |
| src/scene/gsplat/gsplat-container.js | Changes constructor to use maxNumSplats and adds dynamic numSplats setter |
| src/scene/gsplat/gsplat-resource-base.js | Updates material configuration to support custom modifiers and format declarations |
| src/scene/gsplat/gsplat-resource.js | Changes format property from public to protected |
| src/scene/gsplat/gsplat-compressed-resource.js | Changes format property from public to protected |
| src/scene/gsplat/gsplat-sog-resource.js | Changes format property from public to protected |
| src/scene/gsplat-unified/gsplat-placement.js | Adds work buffer modifier support, instance texture management, and update mode control |
| src/scene/gsplat-unified/gsplat-info.js | Captures format state and instance streams for rendering |
| src/scene/gsplat-unified/gsplat-manager.js | Integrates state tracking and instance stream initialization |
| src/scene/gsplat-unified/gsplat-work-buffer-render-pass.js | Binds instance textures and passes modifier to render info |
| src/scene/gsplat-unified/gsplat-placement-state-tracker.js | New file tracking placement state changes for work buffer invalidation |
| src/scene/gsplat/gsplat-instance.js | Updates material configuration call signature |
| src/scene/constants.js | Defines new work buffer update mode constants |
| src/framework/components/gsplat/component.js | Exposes public API for work buffer modifiers and instance textures |
| examples/src/examples/gaussian-splatting/procedural-instanced.example.mjs | Demonstrates dynamic numSplats modification |
Comments suppressed due to low confidence (1)
src/framework/components/gsplat/component.js:1
- The example incorrectly assigns to
extraStreamsproperty directly, but the actual API isaddExtraStreams()method. This should be:resource.format.addExtraStreams([...]). The property is read-only according to the implementation.
import { hashCode } from '../../../core/hash.js';
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Treetosayoot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Born to be free
GSplat Extra Streams and Work Buffer Customization
Overview
Adds support for custom texture streams on gsplat resources and per-instance shader customization in unified rendering mode.
Features
Extra Streams Support
GSplatFormat.addExtraStreams(streams)- Add custom texture streams to a gsplat formatinstance: false(default) - texture shared across all instances of the resourceinstance: true- texture created per gsplat component instanceGSplatComponent.getInstanceTexture(name)- Access instance-level textures for writing custom dataWork Buffer Customization
GSplatComponent.setWorkBufferModifier({ glsl, wgsl })- Inject custom shader code to modify splats during work buffer renderingmodifySplatCenter(center),modifySplatRotationScale(originalCenter, center, rotation, scale), andmodifySplatColor(center, color)functionsloadStreamName()functionsWork Buffer Update Control
New constants for controlling work buffer update frequency:
WORKBUFFER_UPDATE_AUTO- Update only when needed (default)WORKBUFFER_UPDATE_ONCE- Update next frame, then revert to AUTOWORKBUFFER_UPDATE_ALWAYS- Update every frame (for time-based effects)Set via
gsplatComponent.workBufferUpdate = pc.WORKBUFFER_UPDATE_ALWAYSNew Public API
Constants
WORKBUFFER_UPDATE_AUTOWORKBUFFER_UPDATE_ONCEWORKBUFFER_UPDATE_ALWAYSGSplatFormat
addExtraStreams(streams)Adds additional texture streams for custom gsplat data.
Parameters:
streams-Array<GSplatStreamDescriptor>- Array of stream descriptorsGSplatStreamDescriptor:
namestringloadName()function)formatnumberPIXELFORMAT_RGBA8,PIXELFORMAT_RGBA32F)instancebooleanfalseextraStreams(getter)Returns the array of extra streams. Read-only, do not modify directly.
GSplatComponent
getInstanceTexture(name)Returns the instance-level texture for the given stream name.
Parameters:
name-string- The stream nameReturns:
Texture | undefinedsetWorkBufferModifier(value)Sets custom shader code for modifying splats when written to the work buffer.
Parameters:
value-{ glsl?: string, wgsl?: string } | null- Shader code object or null to clearworkBufferUpdateControls how often the work buffer is updated for this component.
Type:
number(useWORKBUFFER_UPDATE_*constants)Default:
WORKBUFFER_UPDATE_AUTOGSplatContainer
Constructor Change
The constructor now takes
maxSplatsinstead ofnumSplats:maxSplats(getter)Returns the maximum number of splats the container can hold (set at construction).
Type:
number(read-only)numSplats(getter/setter)Controls the number of splats to render. Must be between 0 and
maxSplats.Type:
numberDefault:
maxSplatsNote: Changing this value triggers internal buffer reallocation in unified rendering mode. Avoid calling this every frame. For per-frame visibility control, consider using the format's read shader code that returns
splatScale = vec3(0.0)for splats you want to hide.Usage Examples
Adding Custom Color Per Instance