From 5d6974ca1c76230683817484bfe1b222516e0bb5 Mon Sep 17 00:00:00 2001 From: Donovan Hutchence Date: Wed, 26 Jun 2024 18:09:06 +0100 Subject: [PATCH] Fix gsplat example (#6754) --- .../examples/loaders/gsplat-many.shader.vert | 45 ++++++++++++++----- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/examples/src/examples/loaders/gsplat-many.shader.vert b/examples/src/examples/loaders/gsplat-many.shader.vert index 655d987e123..7c9c9806dcc 100644 --- a/examples/src/examples/loaders/gsplat-many.shader.vert +++ b/examples/src/examples/loaders/gsplat-many.shader.vert @@ -1,19 +1,44 @@ uniform float uTime; varying float height; +void animate() { + // modify center + float heightIntensity = center.y * 0.2; + center.x += sin(uTime * 5.0 + center.y) * 0.3 * heightIntensity; + + // output y-coordinate + height = center.y; +} + +vec4 discardVec = vec4(0.0, 0.0, 2.0, 1.0); + void main(void) { - // evaluate center of the splat in object space - vec3 centerLocal = evalCenter(); + // calculate splat uv + if (!calcSplatUV()) { + gl_Position = discardVec; + return; + } - // modify it - float heightIntensity = centerLocal.y * 0.2; - centerLocal.x += sin(uTime * 5.0 + centerLocal.y) * 0.3 * heightIntensity; + // read data + readData(); - // output y-coordinate - height = centerLocal.y; + // animate + animate(); + + vec4 pos; + if (!evalSplat(pos)) { + gl_Position = discardVec; + return; + } + + gl_Position = pos; + + texCoord = vertex_position.xy; + color = getColor(); + + #ifndef DITHER_NONE + id = float(splatId); + #endif - // evaluate the rest of the splat using world space center - vec4 centerWorld = matrix_model * vec4(centerLocal, 1.0); - gl_Position = evalSplat(centerWorld); }