What would be the best way to inject shader code into the GaussianSplattingMaterial?

I am looking to extend the GaussianSplattingMaterial with some custom uniforms and shader code. I tried to extend the material and then attach it to the mesh but it does not like that even if I make no changes to the class. There is a forceful way this could be done, but Id prefer something less invasive.

Any ideas?

Alternatively what would be a good way to clip points outside of a specific bounding box?

cc @Cedric

I see “AddClipPlaneUniforms” when building the material, so maybe that can be leveraged?

I was able to figure out a work around. It took a second because it seems as though GaussianSplatMesh.onBefore and onAfterRender observables are not triggering.

https://playground.babylonjs.com/#NCUKUJ

Good catch! Please open a PR, I’ll be happy to review it.

Shader injection should not be too difficult once you know where to inject. It’s a matter of adding preprocessors and setting them in the materials. But nothing is exposed yet for that.