Skip to content

Conversation

@asundqui
Copy link
Contributor

Added the SplatEncoding concept (defined in PackedSplats.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 the SplatAccumulator that aggregates all scene splats), and on PackedSplats (within a SplatMesh), 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.premultipliedAlpha mode, 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.

asundqui added 2 commits July 21, 2025 22:35
…ed to documentation. Added to examples/editor under Debug folder, moved sort32 there.
…gbMin/Max, lnScaleMinMax), SplatMesh (additionally sh1Min/Max, sh2, sh3). Updated examples/editor to control settings via gui. Updated all related code to pipe along settings where needed.

Added SparkRenderer.premultipliedAlpha to control blend mode and enable hyper-saturated color contributions by default.
@61cygni
Copy link
Contributor

61cygni commented Jul 23, 2025

Looks great. I cloned and run through all the examples and spot checks seem OK. Thank you!

@61cygni 61cygni merged commit f60c2b0 into sparkjsdev:main Jul 23, 2025
2 checks passed
kali-shade pushed a commit to kali-shade/spark-kali that referenced this pull request Sep 16, 2025
…saturated colors (sparkjsdev#134)

* Externalized SparkRenderer.maxPixelRadius and .minAlpha settings. Added to documentation. Added to examples/editor under Debug folder, moved sort32 there.

* Added SplatEncoding concept, applied individually to SparkRenderer (rgbMin/Max, lnScaleMinMax), SplatMesh (additionally sh1Min/Max, sh2, sh3). Updated examples/editor to control settings via gui. Updated all related code to pipe along settings where needed.
Added SparkRenderer.premultipliedAlpha to control blend mode and enable hyper-saturated color contributions by default.

* Fix SplatLoader not passing along encoding. Complete renaming to splat encoding.
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