Skip to content

Commit

Permalink
Stop clipping splats to front and back camera planes (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
slimbuck authored Oct 23, 2024
1 parent 3b65c99 commit bc2755a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/shaders/splat-shader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ void main(void)
// handle transforms
mat4 model_view = matrix_view * 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;
}
Expand All @@ -83,8 +82,12 @@ void main(void)
return;
}
vec4 splat_proj = matrix_projection * splat_cam;
gl_Position = splat_proj + vec4((vertex_position.x * v1v2.xy + vertex_position.y * v1v2.zw) / viewport * splat_proj.w, 0, 0);
// ensure splats aren't clipped by front and back clipping planes
gl_Position.z = clamp(gl_Position.z, -abs(gl_Position.w), abs(gl_Position.w));
texCoord = vertex_position.xy * 0.5;
#ifdef FORWARD_PASS
Expand Down

0 comments on commit bc2755a

Please sign in to comment.