# Using Clipping Planes

> Learn all about clipping planes in Babylon.js.

Source: https://doc.babylonjs.com/features/featuresDeepDive/scene/clipPlanes

## How to use clip planes

You can clip the rendering of a scene by using one of the supported clip planes:

- `scene.clipPlane`
- `scene.clipPlane2`
- `scene.clipPlane3`
- `scene.clipPlane4`
- `scene.clipPlane5`
- `scene.clipPlane6`

Each clip plane is a BABYLON.Plane that you can define like this:

```
scene.clipPlane4 = new BABYLON.Plane(0, 1, 0, 0);
```

The first three parameters of the Plane constructor define the normal of the plane, and the last one defines the distance from (0,0,0).

You can find an interactive demo about clip planes here: [Playground: Clipping Planes Example 1](https://playground.babylonjs.com/#Y6W087) - Simple example showing how to use clipping planes.

A maximum of 6 different clip planes can be used simultaneously for a specific rendering.

If you want to apply per mesh clip planes, you can rely on the following observables:

- `mesh.onBeforeRenderObservable`
- `mesh.onAfterRenderObservable`

Example:

```
sphere.onBeforeRenderObservable.add(function() {
    scene.clipPlane = new BABYLON.Plane(1, 0, 0, 0);
});

sphere.onAfterRenderObservable.add(function() {
    scene.clipPlane = null;
});    
```

Demo: [Playground: Clipping Planes Example 2](https://playground.babylonjs.com/#EHLHNX) - Using clipping planes per mesh (scene level).

Since version 5.33.0, the best way to use clip planes in this case is through the properties `material.clipPlane` / `clipPlane2` / ... / `clipPlane6`. This way, you don't need to add observers to `onBeforeRenderObservable` / `onAfterRenderObservable`.

Demo: [Playground: Clipping Planes Example 3](https://playground.babylonjs.com/#EHLHNX#104) - Using clipping planes per mesh (material level).
