# Issue with Highlight Layer and Newly Added Meshes

**URL:** <https://forum.babylonjs.com/t/issue-with-highlight-layer-and-newly-added-meshes/49456>\
**Category:** Questions\
**Tags:** highlightlayer\
**Created:** [April 8, 2024, 8:51am UTC](https://forum.babylonjs.com/t/issue-with-highlight-layer-and-newly-added-meshes/49456 "2024-04-08T08:51:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paranoia](https://avatars.discourse-cdn.com/v4/letter/p/3d9bf3/32.png) [@Paranoia](https://forum.babylonjs.com/u/Paranoia)\
**Post date:** [April 8, 2024, 8:51am UTC](https://forum.babylonjs.com/t/issue-with-highlight-layer-and-newly-added-meshes/49456/1 "2024-04-08T08:51:10Z")

</div>

Hello, in the process of using `HighlightLayer` , I excluded a mesh with `addExcludedMesh` . While the glowing edges of an obscured mesh are displayed correctly, for new meshes that are highlighted and then obscured, the illumination shifts from the edges to the entire surface area of the mesh.  
I’ve managed to replicate this issue in the Playground.：

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

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [April 8, 2024, 9:43am UTC](https://forum.babylonjs.com/t/issue-with-highlight-layer-and-newly-added-meshes/49456/2 "2024-04-08T09:43:01Z")

</div>

The highlight layer relies on the stencil buffer, and the order in which the meshes are drawn matters. In your case, the ground must be rendered last. One way would be to set the `renderingGroup` property of the ground to a value greater than the one used by the other meshes (like 1, as 0 is the default), or to make sure that the material `uniqueId` property of the sphere is lower than the ground material `uniqueId` (meshes are sorted by material id before being displayed):

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

---

<div class="post-metadata">

**Author:** ![Paranoia](https://avatars.discourse-cdn.com/v4/letter/p/3d9bf3/32.png) [@Paranoia](https://forum.babylonjs.com/u/Paranoia)\
**Post date:** [April 8, 2024, 10:58am UTC](https://forum.babylonjs.com/t/issue-with-highlight-layer-and-newly-added-meshes/49456/3 "2024-04-08T10:58:08Z")

</div>

Thanks so much for the solution! Really appreciate your help.
