Clipping planes on ShaderMaterial

How to implement clipping on ShaderMaterial?

First advice is to include the clipping ShaderChunks, as is done in the built-in shaders in ShaderLib. Both are found under src/renderers/shaders.

In the example, the plane is clipped, but the box is not. The material of the box is ShaderMaterial.

1 Like

Is that all?

Yes. You have to #include them in the same/similar places that they are included in e.g. MeshBasicMaterial, whose shaders you will find in the ShaderLib folder (three.js\src\renderers\shaders\ShaderLib). They are named meshbasic_vert.glsl.js and meshbasic_frag.glsl.js.

I found this question:

and it’s a demo: