# Particle Helper and Depth Sort work around help

**URL:** https://forum.babylonjs.com/t/particle-helper-and-depth-sort-work-around-help/2015
**Category:** Questions
**Created:** [March 20, 2019, 1:42pm UTC](https://forum.babylonjs.com/t/particle-helper-and-depth-sort-work-around-help/2015 "2019-03-20T13:42:16Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![ghandijones](https://avatars.discourse-cdn.com/v4/letter/g/9fc348/32.png) [@ghandijones](https://forum.babylonjs.com/u/ghandijones)
#### Post date: [March 20, 2019, 1:42pm UTC](https://forum.babylonjs.com/t/particle-helper-and-depth-sort-work-around-help/2015/1 "2019-03-20T13:42:16Z")

</div>

From everything I have read, I understand that particles are rendered after opaque meshes. If you look at this, https://compatiblestronginitialization–ghandijones.repl.co/, and rotate the camera to where the planets are between the camera and the sun, you will see what I am dealing with. I am trying to figure out a way to hide the particle sets behind the object. Do I need to calculate the depth from camera and hide affected particles? Otherwise, I can’t quite understand how particles would ever be useful for a 3D game in Babylon (think candle inside a room and your player is outside the room).

If someone could explain what I am doing wrong, how to fix this, or a different particle system (SPS for example) that could provide a solution I am looking for, I would be grateful.  
If you need to look at the code, it is under lib/js/app.js, [Repl.it - CompatibleStrongInitialization](https://repl.it/@ghandijones/CompatibleStrongInitialization).

Thanks guys, any help or references are appreciated.

\*\* See playground for specific issue: [https://www.babylonjs-playground.com/#1ZVSBV#1](https://www.babylonjs-playground.com/#1ZVSBV#1)

---

<div class="post-metadata">

### Author: ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)
#### Post date: [March 20, 2019, 3:07pm UTC](https://forum.babylonjs.com/t/particle-helper-and-depth-sort-work-around-help/2015/2 "2019-03-20T15:07:43Z")

</div>

cc @Deltakosh our particles… and babylonjs master 🙂

---

<div class="post-metadata">

### Author: ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)
#### Post date: [March 20, 2019, 4:16pm UTC](https://forum.babylonjs.com/t/particle-helper-and-depth-sort-work-around-help/2015/3 "2019-03-20T16:16:16Z")

</div>

As you can see in this example, the particles are rendred after the opaque meshes but they will obviously honor the depth buffer:  
[https://www.babylonjs-playground.com/#WBQ8EM](https://www.babylonjs-playground.com/#WBQ8EM)

So in your case, I suspect that your planets are considered as transparent and thus they do not write into the depth buffer. So an easy fix is just to make sure they are opaque 🙂

Please repro in the Playground if that does not work

---

<div class="post-metadata">

### Author: ![ghandijones](https://avatars.discourse-cdn.com/v4/letter/g/9fc348/32.png) [@ghandijones](https://forum.babylonjs.com/u/ghandijones)
#### Post date: [March 20, 2019, 6:01pm UTC](https://forum.babylonjs.com/t/particle-helper-and-depth-sort-work-around-help/2015/4 "2019-03-20T18:01:26Z")

</div>

@Deltakosh, thanks for the initial response. I am looking into that now.

---

<div class="post-metadata">

### Author: ![ghandijones](https://avatars.discourse-cdn.com/v4/letter/g/9fc348/32.png) [@ghandijones](https://forum.babylonjs.com/u/ghandijones)
#### Post date: [March 20, 2019, 6:37pm UTC](https://forum.babylonjs.com/t/particle-helper-and-depth-sort-work-around-help/2015/5 "2019-03-20T18:37:39Z")

</div>

@Deltakosh

I updated and tested in the playground. I cannot figure out how to set the opaque nature on the “planet” to accommodate hiding the “sun” particle system. I have reproduced in the playground, as requested.

[https://www.babylonjs-playground.com/#1ZVSBV#1](https://www.babylonjs-playground.com/#1ZVSBV#1)

---

<div class="post-metadata">

### Author: ![ghandijones](https://avatars.discourse-cdn.com/v4/letter/g/9fc348/32.png) [@ghandijones](https://forum.babylonjs.com/u/ghandijones)
#### Post date: [March 20, 2019, 6:38pm UTC](https://forum.babylonjs.com/t/particle-helper-and-depth-sort-work-around-help/2015/6 "2019-03-20T18:38:26Z")

</div>

I also culled the script down to just the important parts.

---

<div class="post-metadata">

### Author: ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)
#### Post date: [March 20, 2019, 8:36pm UTC](https://forum.babylonjs.com/t/particle-helper-and-depth-sort-work-around-help/2015/7 "2019-03-20T20:36:02Z")

</div>

Ok gotcha. If you look here you will see that the sun emitter is moved to a different rendering group id:

> <https://github.com/BabylonJS/Babylon.js/blob/master/assets/particles/systems/sun.json#L12>

This is required because the sun effect is built with 3 layers.

If you want to use that specific effect you have to move your mesh to layer 3 as well:  
[https://www.babylonjs-playground.com/#1ZVSBV#4](https://www.babylonjs-playground.com/#1ZVSBV#4)

---

<div class="post-metadata">

### Author: ![ghandijones](https://avatars.discourse-cdn.com/v4/letter/g/9fc348/32.png) [@ghandijones](https://forum.babylonjs.com/u/ghandijones)
#### Post date: [March 20, 2019, 11:09pm UTC](https://forum.babylonjs.com/t/particle-helper-and-depth-sort-work-around-help/2015/8 "2019-03-20T23:09:25Z")

</div>

@Deltakosh, you are the man. Thank you. That fixed my problem.

TLDR: For anyone finding this, I simply added .renderingGroupId = 3 to my mesh object.
