Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vectorize the covariance calculation #6098

Merged
merged 2 commits into from
Feb 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 10 additions & 17 deletions src/scene/gsplat/shader-generator-gsplat.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,26 +118,19 @@ const splatCoreVS = `
void computeCov3d(in mat3 rot, in vec3 scale, out vec3 covA, out vec3 covB)
{
// M = S * R
float M0 = scale.x * rot[0][0];
float M1 = scale.x * rot[0][1];
float M2 = scale.x * rot[0][2];
float M3 = scale.y * rot[1][0];
float M4 = scale.y * rot[1][1];
float M5 = scale.y * rot[1][2];
float M6 = scale.z * rot[2][0];
float M7 = scale.z * rot[2][1];
float M8 = scale.z * rot[2][2];

vec3 M0 = scale[0] * rot[0];
vec3 M1 = scale[1] * rot[1];
vec3 M2 = scale[2] * rot[2];

covA = vec3(
M0 * M0 + M3 * M3 + M6 * M6,
M0 * M1 + M3 * M4 + M6 * M7,
M0 * M2 + M3 * M5 + M6 * M8
dot(M0, M0),
dot(M0, M1),
dot(M0, M2)
);

covB = vec3(
M1 * M1 + M4 * M4 + M7 * M7,
M1 * M2 + M4 * M5 + M7 * M8,
M2 * M2 + M5 * M5 + M8 * M8
dot(M1, M1),
dot(M1, M2),
dot(M2, M2)
);
}

Expand Down