From c6a5a778c99d24b3a147cb88d4343f1f8fd088d2 Mon Sep 17 00:00:00 2001 From: Noeri Huisman <8823461+mrxz@users.noreply.github.com> Date: Tue, 29 Jul 2025 09:50:09 +0200 Subject: [PATCH] Add support for orthographic rendering --- src/shaders/splatVertex.glsl | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/shaders/splatVertex.glsl b/src/shaders/splatVertex.glsl index 0162293..c246064 100644 --- a/src/shaders/splatVertex.glsl +++ b/src/shaders/splatVertex.glsl @@ -131,14 +131,24 @@ void main() { // Compute the Jacobian of the splat's projection at its center vec2 scaledRenderSize = renderSize * focalAdjustment; vec2 focal = 0.5 * scaledRenderSize * vec2(projectionMatrix[0][0], projectionMatrix[1][1]); - float invZ = 1.0 / viewCenter.z; - vec2 J1 = focal * invZ; - vec2 J2 = -(J1 * viewCenter.xy) * invZ; - mat3 J = mat3( - J1.x, 0.0, J2.x, - 0.0, J1.y, J2.y, - 0.0, 0.0, 0.0 - ); + + mat3 J; + if(isOrthographic) { + J = mat3( + focal.x, 0.0, 0.0, + 0.0, focal.y, 0.0, + 0.0, 0.0, 0.0 + ); + } else { + float invZ = 1.0 / viewCenter.z; + vec2 J1 = focal * invZ; + vec2 J2 = -(J1 * viewCenter.xy) * invZ; + J = mat3( + J1.x, 0.0, J2.x, + 0.0, J1.y, J2.y, + 0.0, 0.0, 0.0 + ); + } // Compute the 2D covariance by projecting the 3D covariance // and picking out the XY plane components.