Skip to content

Commit

Permalink
Fix gsplat example (#6754)
Browse files Browse the repository at this point in the history
  • Loading branch information
slimbuck committed Jun 26, 2024
1 parent b4e524b commit 5d6974c
Showing 1 changed file with 35 additions and 10 deletions.
45 changes: 35 additions & 10 deletions examples/src/examples/loaders/gsplat-many.shader.vert
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 5d6974c

Please sign in to comment.