Skip to content

Commit

Permalink
Small gsplat shader update (#7186)
Browse files Browse the repository at this point in the history
  • Loading branch information
slimbuck committed Dec 9, 2024
1 parent e82a760 commit ad52035
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions examples/src/examples/loaders/gsplat-many.shader.vert
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@ void main(void)
// handle transforms
mat4 model_view = matrix_view * matrix_model;
vec4 splat_cam = model_view * vec4(center, 1.0);
vec4 splat_proj = matrix_projection * splat_cam;

// cull behind camera
if (splat_proj.z < -splat_proj.w) {
if (splat_cam.z > 0.0) {
gl_Position = discardVec;
return;
}

vec4 splat_proj = matrix_projection * splat_cam;

// ensure gaussians are not clipped by camera near and far
splat_proj.z = clamp(splat_proj.z, -abs(splat_proj.w), abs(splat_proj.w));

// get covariance
vec3 covA, covB;
getCovariance(covA, covB);
Expand Down
8 changes: 6 additions & 2 deletions src/scene/gsplat/gsplat-material.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,18 @@ const splatMainVS = /* glsl */ `
// handle transforms
mat4 model_view = matrix_view * matrix_model;
vec4 splat_cam = model_view * vec4(center, 1.0);
vec4 splat_proj = matrix_projection * splat_cam;
// cull behind camera
if (splat_proj.z < -splat_proj.w) {
if (splat_cam.z > 0.0) {
gl_Position = discardVec;
return;
}
vec4 splat_proj = matrix_projection * splat_cam;
// ensure gaussians are not clipped by camera near and far
splat_proj.z = clamp(splat_proj.z, -abs(splat_proj.w), abs(splat_proj.w));
// get covariance
vec3 covA, covB;
getCovariance(covA, covB);
Expand Down

0 comments on commit ad52035

Please sign in to comment.