From 7f0dc9f26a1243210e938fa720d8d93db9007fad Mon Sep 17 00:00:00 2001 From: Kem Chen Date: Fri, 8 Mar 2024 00:57:16 +0800 Subject: [PATCH] Tiny shader improvements (#6106) --- src/scene/gsplat/shader-generator-gsplat.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/scene/gsplat/shader-generator-gsplat.js b/src/scene/gsplat/shader-generator-gsplat.js index c63e03ec6eb..0a9393daa89 100644 --- a/src/scene/gsplat/shader-generator-gsplat.js +++ b/src/scene/gsplat/shader-generator-gsplat.js @@ -134,9 +134,11 @@ const splatCoreVS = ` float focal = viewport.x * matrix_projection[0][0]; + float J1 = focal / splat_cam.z; + vec2 J2 = -J1 / splat_cam.z * splat_cam.xy; mat3 J = mat3( - focal / splat_cam.z, 0., -(focal * splat_cam.x) / (splat_cam.z * splat_cam.z), - 0., focal / splat_cam.z, -(focal * splat_cam.y) / (splat_cam.z * splat_cam.z), + J1, 0., J2.x, + 0., J1, J2.y, 0., 0., 0. ); @@ -166,9 +168,8 @@ const splatCoreVS = ` texCoord = vertex_position.xy * 2.0; - return splat_proj + - vec4((vertex_position.x * v1 + vertex_position.y * v2) / viewport * 2.0, - 0.0, 0.0) * splat_proj.w; + splat_proj.xy += (texCoord.x * v1 + texCoord.y * v2) / viewport * splat_proj.w; + return splat_proj; id = float(vertex_id); }