# Strange behavior of SelectiveBloomEffect when working with InstancedMesh

**URL:** <https://discourse.threejs.org/t/strange-behavior-of-selectivebloomeffect-when-working-with-instancedmesh/54792>\
**Category:** Questions\
**Tags:** postprocessing, instanced-mesh\
**Created:** [August 9, 2023, 9:32am UTC](https://discourse.threejs.org/t/strange-behavior-of-selectivebloomeffect-when-working-with-instancedmesh/54792 "2023-08-09T09:32:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![imgood](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/imgood/32/38889_2.png) [@imgood](https://discourse.threejs.org/u/imgood)\
**Post date:** [August 9, 2023, 9:32am UTC](https://discourse.threejs.org/t/strange-behavior-of-selectivebloomeffect-when-working-with-instancedmesh/54792/1 "2023-08-09T09:32:04Z")

</div>

> **[admiring-wozniak-pctkmw - CodeSandbox](https://codesandbox.io/s/admiring-wozniak-pctkmw?file=%2Fsrc%2Findex.js)**
>
> admiring-wozniak-pctkmw by godknowsiamgood using parcel-bundler, postprocessing, three

👆 Here is scene with my problem:  
Regular objects are highlighted properly, but if I use InstancedMesh and change positions for instances using BufferAttribute, the effect doesn’t apply to them.  
Note the strange artefact when the middle triangle is near to zero position. Like during one of the rendering passes, the shader positions setting is not applied.

Please, help me fix it or hint any workaround 🙏

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/0/d/0d71820f01f82ec3a5f6f0491f56efa8ceaee5f7.png)

Thank you.

---

<div class="post-metadata">

**Author:** ![prisoner849](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/prisoner849/32/535_2.png) [@prisoner849](https://discourse.threejs.org/u/prisoner849)\
**Post date:** [August 9, 2023, 10:38am UTC](https://discourse.threejs.org/t/strange-behavior-of-selectivebloomeffect-when-working-with-instancedmesh/54792/2 "2023-08-09T10:38:32Z")

</div>

Is this the result you expect?

 ![изображение](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/0/e/0eee61f1ce19c673af892a6178ffd2978930a937.png)

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [August 9, 2023, 10:47am UTC](https://discourse.threejs.org/t/strange-behavior-of-selectivebloomeffect-when-working-with-instancedmesh/54792/3 "2023-08-09T10:47:36Z")

</div>

The usage of `InstancedMesh` does not look right. Try it with:

> **[admiring-wozniak-pctkmw - CodeSandbox](https://codesandbox.io/s/flamboyant-jasper-qrtkc5?file=%2Fsrc%2Findex.js)**
>
> admiring-wozniak-pctkmw by godknowsiamgood using parcel-bundler, postprocessing, three

---

<div class="post-metadata">

**Author:** ![prisoner849](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/prisoner849/32/535_2.png) [@prisoner849](https://discourse.threejs.org/u/prisoner849)\
**Post date:** [August 9, 2023, 10:53am UTC](https://discourse.threejs.org/t/strange-behavior-of-selectivebloomeffect-when-working-with-instancedmesh/54792/4 "2023-08-09T10:53:54Z")

</div>

I kept the using of ShaderMaterial 😅 :

> **[admiring-wozniak-pctkmw - CodeSandbox](https://codesandbox.io/s/elated-bas-8vpwyx)**
>
> admiring-wozniak-pctkmw by godknowsiamgood using parcel-bundler, postprocessing, three

---

<div class="post-metadata">

**Author:** ![imgood](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/imgood/32/38889_2.png) [@imgood](https://discourse.threejs.org/u/imgood)\
**Post date:** [August 9, 2023, 10:56am UTC](https://discourse.threejs.org/t/strange-behavior-of-selectivebloomeffect-when-working-with-instancedmesh/54792/5 "2023-08-09T10:56:46Z")

</div>

Cool, both your solutions works as I expect. But why doesn’t it work in my case? My example is a part of a more complex code with a non-trivial vertex shader, which is used to draw a huge number of objects, and their position (and size) depends on other attributes. That’s why I chose the solution to compute the position in the shader.
