From 29a8a0c2b4de3c24a490f1d711be90744076210c Mon Sep 17 00:00:00 2001 From: Donovan Hutchence Date: Mon, 9 Dec 2024 08:55:48 +0000 Subject: [PATCH] Fixes for gsplat spherical harmonics (#7182) --- src/scene/gsplat/gsplat-compressed.js | 8 ++++---- src/scene/shader-lib/chunks/gsplat/vert/gsplat.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/scene/gsplat/gsplat-compressed.js b/src/scene/gsplat/gsplat-compressed.js index 90ac3f638e2..66d398274f9 100644 --- a/src/scene/gsplat/gsplat-compressed.js +++ b/src/scene/gsplat/gsplat-compressed.js @@ -109,10 +109,10 @@ class GSplatCompressed { const srcCoeffs = [3, 8, 15][shBands - 1]; for (let i = 0; i < numSplats; ++i) { - for (let j = 0; j < srcCoeffs; ++j) { - target0[i * 16 + j] = shData[(i * 3 + 0) * srcCoeffs + j]; - target1[i * 16 + j] = shData[(i * 3 + 1) * srcCoeffs + j]; - target2[i * 16 + j] = shData[(i * 3 + 2) * srcCoeffs + j]; + for (let j = 0; j < 15; ++j) { + target0[i * 16 + j] = j < srcCoeffs ? shData[(i * 3 + 0) * srcCoeffs + j] : 127; + target1[i * 16 + j] = j < srcCoeffs ? shData[(i * 3 + 1) * srcCoeffs + j] : 127; + target2[i * 16 + j] = j < srcCoeffs ? shData[(i * 3 + 2) * srcCoeffs + j] : 127; } } diff --git a/src/scene/shader-lib/chunks/gsplat/vert/gsplat.js b/src/scene/shader-lib/chunks/gsplat/vert/gsplat.js index ef59c49cbd8..c17ebabac92 100644 --- a/src/scene/shader-lib/chunks/gsplat/vert/gsplat.js +++ b/src/scene/shader-lib/chunks/gsplat/vert/gsplat.js @@ -32,7 +32,7 @@ void main(void) { // evaluate spherical harmonics #if SH_BANDS > 0 - clr.xyz += evalSH(state, projState)); + clr.xyz += evalSH(state, projState); #endif applyClipping(projState, clr.w);