Open aayork opened 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;
}
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.
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.
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?
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?