Expand internal splat scale encoding to e^[-12,9]. Lower zero cut-off to e^-30. Fix background color selection in editor. (#110)

This commit is contained in:
Andreas Sundquist
2025-07-11 10:48:10 -07:00
committed by GitHub
parent c8394665ec
commit dc07e02a33
10 changed files with 33 additions and 28 deletions
+13 -12
View File
@@ -6,6 +6,7 @@ import * as THREE from "three";
import {
LN_RESCALE,
LN_SCALE_MIN,
SCALE_ZERO,
SPLAT_TEX_HEIGHT,
SPLAT_TEX_MIN_HEIGHT,
SPLAT_TEX_WIDTH,
@@ -370,32 +371,32 @@ export function setPackedSplat(
// Allow scales below LN_SCALE_MIN to be encoded as 0, which signifies a 2DGS
const uScaleX =
scaleX === 0.0
scaleX < SCALE_ZERO
? 0
: Math.min(
255,
Math.max(
0,
1,
Math.round((Math.log(scaleX) - LN_SCALE_MIN) / LN_RESCALE) + 1,
),
);
const uScaleY =
scaleY === 0.0
scaleY < SCALE_ZERO
? 0
: Math.min(
255,
Math.max(
0,
1,
Math.round((Math.log(scaleY) - LN_SCALE_MIN) / LN_RESCALE) + 1,
),
);
const uScaleZ =
scaleZ === 0.0
scaleZ < SCALE_ZERO
? 0
: Math.min(
255,
Math.max(
0,
1,
Math.round((Math.log(scaleZ) - LN_SCALE_MIN) / LN_RESCALE) + 1,
),
);
@@ -441,32 +442,32 @@ export function setPackedSplatScales(
) {
// Allow scales below LN_SCALE_MIN to be encoded as 0, which signifies a 2DGS
const uScaleX =
scaleX === 0.0
scaleX < SCALE_ZERO
? 0
: Math.min(
255,
Math.max(
0,
1,
Math.round((Math.log(scaleX) - LN_SCALE_MIN) / LN_RESCALE) + 1,
),
);
const uScaleY =
scaleY === 0.0
scaleY < SCALE_ZERO
? 0
: Math.min(
255,
Math.max(
0,
1,
Math.round((Math.log(scaleY) - LN_SCALE_MIN) / LN_RESCALE) + 1,
),
);
const uScaleZ =
scaleZ === 0.0
scaleZ < SCALE_ZERO
? 0
: Math.min(
255,
Math.max(
0,
1,
Math.round((Math.log(scaleZ) - LN_SCALE_MIN) / LN_RESCALE) + 1,
),
);