Custom/extended splat encoding ranges, Premultiplied alpha for hyper-saturated colors #134
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added the
SplatEncodingconcept (defined inPackedSplats.ts) that stores user-configurable ranges for RGB values (rgbMin/rgbMax), scale X/Y/Z (lnScaleMin/Max), as well as sh1Min/Max, sh2, sh3.The default values are always rgbMin/Max=(0,1), sh?Min/Max=(-1,1), lnScaleMin/Max=(-12,9), and should be fully backward-compatible with the current Spark behavior. You can adjust these settings on both
SparkRenderer(which changes the allowed encoding ranges in theSplatAccumulatorthat aggregates all scene splats), and onPackedSplats(within aSplatMesh), which indicates the encoding used for the stored splats.It's advisable to use the same ranges for both SparkRenderer and your SplatMeshes because otherwise you may incur double-rounding error.
This PR also adds a (default on)
SparkRenderer.premultipliedAlphamode, which adjusts the blend mode allowing us to blend hyper-saturated colors (when RGB > A). Without this setting the encoding ranges have no effect because RGB values are always clamped to 1.Examples/editor has been updated with new settings under the "Debug" menu where you can change the values. Changing SplatMesh encoding requires loading a new file for the new ranges to take effect.
I believe these new settings allow the user to fix the contrast issue in #81 , see the video below:
Screen.Recording.2025-07-22.at.8.49.03.AM.mov
There's a substantial amount of piping needed to send all the encodings where it needs to go (including Rust), I hope I've covered everything!
In the future when we add an "ExtendedSplats" sort of concept, we can reuse this infra hopefully to allow configurable scaling there as well.