Clipping planes on ShaderMaterial

How to implement clipping on ShaderMaterial?
http://fiddle.jshell.net/sogrey/5wL20k3m/32/show/

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.

https://jsfiddle.net/5wL20k3m/

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.

tks,
I found this question:

and it’s a demo:

https://jsfiddle.net/sogrey/q8bt026y/embedded/