# outlineEffect on instances of instancedMesh?

**URL:** <https://discourse.threejs.org/t/outlineeffect-on-instances-of-instancedmesh/66175>\
**Category:** Questions\
**Tags:** postprocessing, instanced-mesh\
**Created:** [May 30, 2024, 2:44am UTC](https://discourse.threejs.org/t/outlineeffect-on-instances-of-instancedmesh/66175 "2024-05-30T02:44:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![XIANGYU\_MENG](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/xiangyu_meng/32/23481_2.png) [@XIANGYU\_MENG](https://discourse.threejs.org/u/XIANGYU_MENG)\
**Post date:** [May 30, 2024, 2:44am UTC](https://discourse.threejs.org/t/outlineeffect-on-instances-of-instancedmesh/66175/1 "2024-05-30T02:44:02Z")

</div>

Hi, is anyone managed to add outlineEffect on instances of InstancedMesh?Like using [postprocessing](https://github.com/pmndrs/postprocessing) , highlight bunch of instances with outlineEffect 😼 the only approach i can imagine now is to add real meshes and apply the instanceMatrix to theme to achieve that. I’m wondering if there is a better solution,thanks.

---

<div class="post-metadata">

**Author:** ![mjurczyk](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mjurczyk/32/10995_2.png) [@mjurczyk](https://discourse.threejs.org/u/mjurczyk)\
**Post date:** [May 30, 2024, 6:36am UTC](https://discourse.threejs.org/t/outlineeffect-on-instances-of-instancedmesh/66175/2 "2024-05-30T06:36:34Z")

</div>

Instances don’t exist on the CPU - so the approach taken in the OutlineEffect won’t unfortunately work (the existing OutlineEffect implementation [relies on the CPU side](https://github.com/pmndrs/postprocessing/blob/90de77000aec1a9eecbfacecfe02593f8e1cbf6a/src/effects/OutlineEffect.js#L756) for the depth-comparison.)

The easiest solution I can imagine is having 2 `InstancedMesh`es - and just move matrices from one to another, depending on whether you’d like the instance to be highlighted or not (that way you still have only 2 draw calls instead of 1-per-mesh when using real meshes for highlighting.)

---

<div class="post-metadata">

**Author:** ![XIANGYU\_MENG](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/xiangyu_meng/32/23481_2.png) [@XIANGYU\_MENG](https://discourse.threejs.org/u/XIANGYU_MENG)\
**Post date:** [May 30, 2024, 6:56am UTC](https://discourse.threejs.org/t/outlineeffect-on-instances-of-instancedmesh/66175/3 "2024-05-30T06:56:31Z")

</div>

Thanks, that’s helpful 😃
