mkkellogg / GaussianSplats3D

Three.js-based implementation of 3D Gaussian splatting
MIT License
1.09k stars 134 forks source link

Clipping Planes with Gaussian Splats #238

Open aayork opened 1 month ago

aayork commented 1 month ago

I'm trying to find a way to clip a part of my splat, but I haven't really seen anything about this online. Has anyone had any luck with clipping? Is it possible with this library?

TheExDeus commented 1 month ago

Easiest option is to do this in vertex shader, but if you don't need to change it in real-time and only do it once, then it can be done via pre-processing step where you remove splats manually. It would required regeneration of the octree in this viewer though, AFAIK. In vertex shader the gaussian splat position is define here: https://github.com/mkkellogg/GaussianSplats3D/blob/main/src/SplatMesh.js#L219 So if you pass, for example, a uniform zoffset to throw away any gaussian above a specific Z value (which means it's just a 3D plane moving upwards), then you can do:

if (splatCenter.z > zcutoff) {
  gl_Position = vec4(0.0, 0.0, 2.0, 1.0);
  return;
}
mkkellogg commented 1 month ago

I've been thinking about the best way to accomplish something like this and I think I'm going to add a feature where you can specify an arbitrary number of clipping shapes (plane, cube, sphere, etc.). I'm simultaneously developing a feature to toggle the visibility of individual splat scenes, so the same code in the shader could be used to hide/show splats for both.

Wyundi commented 2 weeks ago

I add a filter in SplatLoader to skip the point I don't want. For clip, I set a range for position of each point. And it can avoid modifying the shader.

xiasun commented 1 week ago

Is there a way to do plane clipping based on exact positions instead of centers? Just like clipping a normal mesh?Clipping of centers will only decide whether a splat is shown or not, and the rendering results of the boundary tend to be rough.

I was wondering if there's a way to achieve real clipping, to make part of a splat point visible while part of it invisible?