From 6e54f721ef87684c5a7628a00c485875d2487771 Mon Sep 17 00:00:00 2001 From: Kem Chen Date: Thu, 29 Feb 2024 18:51:45 +0800 Subject: [PATCH] Fix covariance computation (#6100) --- src/scene/gsplat/shader-generator-gsplat.js | 23 ++++++++++++--------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/scene/gsplat/shader-generator-gsplat.js b/src/scene/gsplat/shader-generator-gsplat.js index 1a35872340d..4135f9b397c 100644 --- a/src/scene/gsplat/shader-generator-gsplat.js +++ b/src/scene/gsplat/shader-generator-gsplat.js @@ -118,19 +118,22 @@ const splatCoreVS = ` void computeCov3d(in mat3 rot, in vec3 scale, out vec3 covA, out vec3 covB) { // M = S * R - vec3 M0 = scale[0] * rot[0]; - vec3 M1 = scale[1] * rot[1]; - vec3 M2 = scale[2] * rot[2]; - + mat3 M = transpose(mat3( + scale[0] * rot[0], + scale[1] * rot[1], + scale[2] * rot[2] + )); + covA = vec3( - dot(M0, M0), - dot(M0, M1), - dot(M0, M2) + dot(M[0], M[0]), + dot(M[0], M[1]), + dot(M[0], M[2]) ); + covB = vec3( - dot(M1, M1), - dot(M1, M2), - dot(M2, M2) + dot(M[1], M[1]), + dot(M[1], M[2]), + dot(M[2], M[2]) ); }