Is it possible to apply clipping solids to lineMaterial (mesh instanced lines)?

How to apply the clipping solids to lineMaterial shader? I was able to apply to Shader Material for points the solution shown in this post and play around with the Distance Functions from here but I was not able to make the similar approach working with the lineMaterial Shader.

Any help would be gold for me! Thanks in advance

Which line material? LineBasicMaterial or LineMaterial? The latter is for Fat Lines.

@prisoner849 I’m asking for LineMaterial for fat lines.

Could you provide a minimal live code example with the setup you used for your experiments with clipping of fat lines?

The best I could do, but with the regular lines (LineBasicMaterial)

Yeah, the idea of using SDF functions for clipping points is just pure gold, I’ve been using it for a couple of projects and can’t help enough @prisoner849 for coming up with the idea and implementation, you are a genius!

Regarding fat lines, it looks like a candidate for trying injecting code on before compile (not sure really, having a working code example would make it easy for exploring possibilities)

I actually achieved the desired result (needed vertical cylinder clipping) using an array of clipping planes “covering” the walls of cylinder with the renderer.localClipping enabled. At first I’ve tried the direct modification of fragment shader of LineMaterial, adding the SDF (as @prisoner849 did in his example with points), but couldn’t find a place which actually stores the vertices positions, which can be fed into SDF. Of course using SDF functions would be desired as it is more robust - one can simply use SDF functions from the Shader Toy example to get particular volumes. Thanks for help, I’m closing the question as I found “hacky” workaround suitable for me.

@Maciej Could you show the result? I’m really curious of the visual.

@prisoner849 Will post the visuals, when the feature will be fully completed :slight_smile: