# Edge Detection

> Check out the edge detection post process in your Babylon.js scenes.

Source: https://doc.babylonjs.com/toolsAndResources/assetLibraries/postProcessLibrary/edgeDetectionPP

## Using the Edge Detection post-process

With this Edge Detection post-process, you can create full-scene outlines in a style suited for comics or games, which cannot be achieved with renderOutline, edgeRendering, or HighlightLayer.

If you’re aiming for that look, this tutorial is for you.

![Screenshot](https://doc.babylonjs.com/img/resources/edgeDetectionPP/EDPP.webp)

## How to use?

To use it, attach the post-process to your main camera to enable the effect.

```javascript
// Creates the post process
var edgeDetectionPostProcess = new BABYLON.EdgeDetectionPostProcess("EdgeDetection", camera);
```
- [Playground: Edge Detection Post Process Demo](https://playground.babylonjs.com/#HBSUDW)

## Going further

You can adjust the thickness of the outlines like so:

```javascript
// Creates the post process with custom width, intensity, color
edgeDetectionPostProcess.edgeWidth = 1; // default is 1.0 
edgeDetectionPostProcess.edgeIntensity = 1;
edgeDetectionPostProcess.edgeColor = BABYLON.Color3.Red();
```

- [Playground: Edge Detection Post Process Render Mode Demo](https://playground.babylonjs.com/#HBSUDW#1)

Additionally, you can change the render mode:

```javascript
// General :0, Normal: 1, Depth: 2, Only Outline: 3 
edgeDetectionPostProcess.renderMode = 3; // default is 1 
```

Here is a full demo where you can control all the properties of the EdgeDetection PostProcess.
Furthermore, you can also check the cel materials with outlines.

![Screenshot](https://doc.babylonjs.com/img/resources/edgeDetectionPP/EDPP2.webp)

- [Playground: Edge Detection Post Process Full Demo](https://playground.babylonjs.com/#T6IKWW) - Edge Detection Post Process Full Demo

The available parameters are:

- edgeWidth: Controls the thickness of the edge lines. Higher values create thicker outlines. Default is 1.0.
- edgeIntensity: Adjusts the intensity or brightness of the outline effect. Higher values make edges appear more prominent. Default is 1.0.
- edgeColor: Defines the color of the outline using BABYLON.Color3 format, allowing for customization of edge hue. Default is BABYLON.Color3.Black().
- renderMode: Sets the rendering mode for the post-process effect:
    0: General (combined view with edge effect and scene),
    1: Normal (shows the scene with edge overlay),
    2: Depth (emphasizes depth for 3D effect),
    3: Only Outline (displays only the edges, hiding other details).

For optimal results, adjust edgeWidth and edgeIntensity in combination. 
Modifying only one may make it difficult to achieve the desired effect, as these parameters work best when balanced to create clear and precise outlines.
