From bc2755ace841cdc5dee12bb55ac0bbc5dfc0b25e Mon Sep 17 00:00:00 2001 From: Donovan Hutchence Date: Wed, 23 Oct 2024 14:02:06 +0100 Subject: [PATCH] Stop clipping splats to front and back camera planes (#229) --- src/shaders/splat-shader.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/shaders/splat-shader.ts b/src/shaders/splat-shader.ts index 3a9ca1c..67f2099 100644 --- a/src/shaders/splat-shader.ts +++ b/src/shaders/splat-shader.ts @@ -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; } @@ -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