# renderOutline and renderOverlay on instancied meshes

**URL:** <https://forum.babylonjs.com/t/renderoutline-and-renderoverlay-on-instancied-meshes/42780>\
**Category:** Feature requests\
**Created:** [July 28, 2023, 3:30pm UTC](https://forum.babylonjs.com/t/renderoutline-and-renderoverlay-on-instancied-meshes/42780 "2023-07-28T15:30:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![VerandaLouis](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/verandalouis/32/19395_2.png) [@VerandaLouis](https://forum.babylonjs.com/u/VerandaLouis)\
**Post date:** [July 28, 2023, 3:30pm UTC](https://forum.babylonjs.com/t/renderoutline-and-renderoverlay-on-instancied-meshes/42780/1 "2023-07-28T15:30:29Z")

</div>

If it’s possible make the renderOutilne and renderOverlay available on instancied meshes.

Should I create an issue on github ?

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [July 29, 2023, 8:30am UTC](https://forum.babylonjs.com/t/renderoutline-and-renderoverlay-on-instancied-meshes/42780/2 "2023-07-29T08:30:31Z")

</div>

Hmm, weirdo. It’s in the API for instancedMesh but it doesn’t seem to work the way I expected and I cannot find any working examples. May be it needs a custom buffer? I’m eager to hear the answer from an expert cc @Evgeni_Popov

> **[Babylon.js Playground](https://playground.babylonjs.com/#10WJ5S%2330)**
>
> 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:** [July 29, 2023, 10:06am UTC](https://forum.babylonjs.com/t/renderoutline-and-renderoverlay-on-instancied-meshes/42780/3 "2023-07-29T10:06:22Z")

</div>

A mesh and its instances are rendered in a single draw call, so you can’t have a different setting for the mesh and each of the instances: it’s the mesh setting that’s used to render the outline/overlay for all instances + mesh.

If you have only a few meshes to outline/overlay, the workaround would be to clone these meshes and to apply outline/overlay on these meshes instead.

---

<div class="post-metadata">

**Author:** ![oriongu](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/oriongu/32/40402_2.png) [@oriongu](https://forum.babylonjs.com/u/oriongu)\
**Post date:** [September 1, 2023, 5:04am UTC](https://forum.babylonjs.com/t/renderoutline-and-renderoverlay-on-instancied-meshes/42780/4 "2023-09-01T05:04:03Z")

</div>

EDIT: actually found this post that explains more in detail and has a solution: [Issue with highlighting instances - #5 by Calsa](https://forum.babylonjs.com/t/issue-with-highlighting-instances/10188/5)

* * *

I’m trying to use instancing on my project for all the loot on the ground and it works amazing even with 5000 items on the ground.

I’ve realized now that I can no longer use the overlayColor and renderOverlay to highlight items when I hover over them with the mouse.

As I’m not quite sure I understand what you were saying in previous post (…the workaround would be to clone these meshes and to apply outline/overlay on these meshes instead…), do you have any advice @Evgeni_Popov ?

 ![screenshot_23-9-1_14-58](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/6/a/6a50d5478ce0aeaf3ed01895800e77cbd459f6b9.jpeg)

---

<div class="post-metadata">

**Author:** ![xiehangyun](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/xiehangyun/32/30777_2.png) [@xiehangyun](https://forum.babylonjs.com/u/xiehangyun)\
**Post date:** [September 1, 2023, 9:48am UTC](https://forum.babylonjs.com/t/renderoutline-and-renderoverlay-on-instancied-meshes/42780/5 "2023-09-01T09:48:51Z")

</div>

Prepare two different source objects. One of them is used as a highlighter. Use it to create a new instance object and replace the object that needs to be highlighted when it needs to be highlighted.

---

<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:** [September 1, 2023, 10:30am UTC](https://forum.babylonjs.com/t/renderoutline-and-renderoverlay-on-instancied-meshes/42780/6 "2023-09-01T10:30:41Z")

</div>

You should clone the object that needs to be highlighted (either ahead of time as a preprocess or at the time you need to highlight), apply the highlight to this object (which is not an instance, it’s a regular mesh!) and hide the original instance.

---

<div class="post-metadata">

**Author:** ![oriongu](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/oriongu/32/40402_2.png) [@oriongu](https://forum.babylonjs.com/u/oriongu)\
**Post date:** [September 1, 2023, 11:26am UTC](https://forum.babylonjs.com/t/renderoutline-and-renderoverlay-on-instancied-meshes/42780/7 "2023-09-01T11:26:35Z")

</div>

Make sense, thanks @xiehangyun and @Evgeni_Popov
