# How to exclude ground when post-processing is turned on

**URL:** <https://forum.babylonjs.com/t/how-to-exclude-ground-when-post-processing-is-turned-on/51885>\
**Category:** Questions\
**Created:** [July 8, 2024, 1:55am UTC](https://forum.babylonjs.com/t/how-to-exclude-ground-when-post-processing-is-turned-on/51885 "2024-07-08T01:55:24Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![lxq100](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/lxq100/32/43689_2.png) [@lxq100](https://forum.babylonjs.com/u/lxq100)\
**Post date:** [July 8, 2024, 1:55am UTC](https://forum.babylonjs.com/t/how-to-exclude-ground-when-post-processing-is-turned-on/51885/1 "2024-07-08T01:55:24Z")

</div>

When the node material is set to Ground, adding a post-processing Ground material will enhance the visual effect.  
How to exclude ground when post-processing is turned on  
before add post-process:

> **[Babylon.js Playground](https://playground.babylonjs.com/#BG423R)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

after add post-process:

> **[Babylon.js Playground](https://playground.babylonjs.com/#GDOEO2)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [July 8, 2024, 2:26am UTC](https://forum.babylonjs.com/t/how-to-exclude-ground-when-post-processing-is-turned-on/51885/2 "2024-07-08T02:26:11Z")

</div>

Do something like

```auto
    const camera2 = camera.clone("camera2")
    scene.activeCameras = [camera, camera2];
    camera2.layerMask = 0x10000000;
    ground.layerMask = 0x10000000;

```

Since you can choose not to attach the postprocess to the second camera you are good to go…

---

<div class="post-metadata">

**Author:** ![lxq100](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/lxq100/32/43689_2.png) [@lxq100](https://forum.babylonjs.com/u/lxq100)\
**Post date:** [July 8, 2024, 5:10am UTC](https://forum.babylonjs.com/t/how-to-exclude-ground-when-post-processing-is-turned-on/51885/3 "2024-07-08T05:10:32Z")

</div>

add codes at line 8240-8245 not see ground.

```auto
    //add new camera only see ground.
    const camera2 = camera.clone("camera2")
    camera2.id = "camera2";
    scene.activeCameras = [camera2, camera];
    camera2.layerMask = 0x10000000;
    ground.layerMask = 0x10000000;

```

PG:

> **[Babylon.js Playground](https://playground.babylonjs.com/#GDOEO2%231)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [July 8, 2024, 5:38am UTC](https://forum.babylonjs.com/t/how-to-exclude-ground-when-post-processing-is-turned-on/51885/4 "2024-07-08T05:38:18Z")

</div>

> [@lxq100](#):
>
> ` scene.activeCameras = [camera2, camera];`

Sorry, swap the cameras here:

`scene.activeCameras = [camera, camera2];`

---

<div class="post-metadata">

**Author:** ![lxq100](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/lxq100/32/43689_2.png) [@lxq100](https://forum.babylonjs.com/u/lxq100)\
**Post date:** [July 8, 2024, 9:55am UTC](https://forum.babylonjs.com/t/how-to-exclude-ground-when-post-processing-is-turned-on/51885/5 "2024-07-08T09:55:29Z")

</div>

if code

```auto
scene.activeCameras = [camera, camera2];

```

so  
scene.activeCameras[1] == scene.activeCamera  
but I want scene.activeCamera to be camera and not camera2.  
How do I get over this?

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [July 8, 2024, 10:43am UTC](https://forum.babylonjs.com/t/how-to-exclude-ground-when-post-processing-is-turned-on/51885/6 "2024-07-08T10:43:02Z")

</div>

> [@lxq100](#):
>
> but I want scene.activeCamera to be camera and not cameras.

Is there any particular reason for this?

Technically it shouldn’t be a problem having two cameras on the scene. This is common when using `layerMask`s.

---

<div class="post-metadata">

**Author:** ![lxq100](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/lxq100/32/43689_2.png) [@lxq100](https://forum.babylonjs.com/u/lxq100)\
**Post date:** [July 9, 2024, 6:07am UTC](https://forum.babylonjs.com/t/how-to-exclude-ground-when-post-processing-is-turned-on/51885/7 "2024-07-09T06:07:51Z")

</div>

the layerMask of camera lower the layerMask of camera2  
so sphere layer on the back of the sphere on the ground.

However I am trying to make a scene where the ball is the main scene and the ground is the secondary, scene.activeCamera(the main camera) is camera not camera2

How to overcome this difficulty

PG:

> **[Babylon.js Playground](https://playground.babylonjs.com/#GDOEO2%232)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [July 9, 2024, 6:21am UTC](https://forum.babylonjs.com/t/how-to-exclude-ground-when-post-processing-is-turned-on/51885/8 "2024-07-09T06:21:57Z")

</div>

You mean render the ball in front of the ground? Or what? Sorry 🙂

---

<div class="post-metadata">

**Author:** ![lxq100](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/lxq100/32/43689_2.png) [@lxq100](https://forum.babylonjs.com/u/lxq100)\
**Post date:** [July 9, 2024, 6:25am UTC](https://forum.babylonjs.com/t/how-to-exclude-ground-when-post-processing-is-turned-on/51885/9 "2024-07-09T06:25:58Z")

</div>

You mean render the ball in front of the ground?  
Yes!

Render the sphere to the ground before while post-processing the renderList to exclude the ground

PG: How to exclude ground from post-processing renderList

> **[Babylon.js Playground](https://playground.babylonjs.com/#GDOEO2%233)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [July 9, 2024, 6:43am UTC](https://forum.babylonjs.com/t/how-to-exclude-ground-when-post-processing-is-turned-on/51885/10 "2024-07-09T06:43:32Z")

</div>

> [@lxq100](#):
>
> Render the sphere to the ground before while post-processing the renderList to exclude the ground

Bro, like for real. I can’t get any meaningful from this sentence.

> [@lxq100](#):
>
> PG: How to exclude ground from post-processing renderList
> 
> [Babylon.js Playground](https://playground.babylonjs.com/#GDOEO2%233)

That’s what we are doing here the whole time. You have two cameras and postprocess only the one. That one will render the meshes wich you want to include in the postprocess so they will have the same `layermask` as the camera rendering them.

Set the other camera’s and meshes (wich woll not be processed) `layermask` to a different value as the first camera’s value is. But for the excluded meshes and other camera the value is same.

Like shown here:

> **[Babylon.js Playground](https://playground.babylonjs.com/#EF5PVK)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

---

<div class="post-metadata">

**Author:** ![lxq100](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/lxq100/32/43689_2.png) [@lxq100](https://forum.babylonjs.com/u/lxq100)\
**Post date:** [July 9, 2024, 7:08am UTC](https://forum.babylonjs.com/t/how-to-exclude-ground-when-post-processing-is-turned-on/51885/12 "2024-07-09T07:08:05Z")

</div>

Thank you, you understand my understanding and I feel close to success

But there’s an error.  
post process should only work camera2，I can’t see ground

PG:

> **[Babylon.js Playground](https://playground.babylonjs.com/#EF5PVK%231)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [July 9, 2024, 10:46am UTC](https://forum.babylonjs.com/t/how-to-exclude-ground-when-post-processing-is-turned-on/51885/13 "2024-07-09T10:46:22Z")

</div>

> **[Babylon.js Playground](https://playground.babylonjs.com/#EF5PVK%232)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

camera is displaying the ground  
camera2 is displaying the sphere  
camera renders first, camera2 second (activeCameras array order)  
blur postprocess on camera only
