Clip plane with color?

Hello everyone,
is it possible to change color of clipPlane? I wanted to be orange with e.q. 80% transparency.

You would need to create a real orange plane for this, basically the clip plane is not a geometry per se but a way to cancel drawing some pixels on screen.

1 Like

You may try something like this:

It works by rendering first the full skull (no clip planes) into a depth buffer by using the scene depth renderer.

Then it is using a custom material to display the final skull. In that material, there’s a test of the current z value against the z value of the depth buffer: if different, we apply the color filter.

As there can be some precision problems when performing this testing, the difference is tested against a small value. To lower the rendering artifacts because of those precision problems, you should tweak the minZ/maxZ values of the camera so that their difference is as small as possible (as done in the PG).

I wonder if there is an easier way of achieving this effect…


I don’t think that would work, the plane would colorize pixels that should stay uncolorized.

another way would be through a custom node material but yup it depends on the final goal :slight_smile:

Hum, I don’t see how it would work. Want to explain a bit? I could have a try, removing the depth render pass as I do in my PG would help performance and maybe also would get rid of the precision problems.

Thank you for your answers but I meant something like this. So the user could se clipplane as the real plane.

Although your playground @Evgeni_Popov is very interesting!

So yup just go with an orange transparent plane in your scene that would be perfect


doc: Use clip planes - Babylon.js Documentation


That’s it! Great! :smiley: