I create a particle (white square texture) that should be nearer to the camera than a plain mesh (Sprite - ./assets/background.png node), but the particle renders behind the mesh.
Some idea why is this happening?
Camera position: -380, 0, 0.001
Camera target: 1, 0, 0
Particle position: 0, 0, -10
Mesh position: 1000, 0, 90
Your meshes (materials) are transparent, and transparent objects are rendered last, after the particle systems.
I think you set needAlphaBlending:true to the shader materials? As your meshes don’t seem to be transparent, you should remove this setting. If the materials must be transparent, you can set the renderingGroupId property of the particle system to 1, so that it is drawn after the transparent meshes.
Particles are not sorted, it would take too much time, and a particle system is rendered as a single draw call, for performance reason too. So, it’s not possible to interleave the rendering of meshes/sprites with the rendering of the particles of a particle system. You can only decide to render sprites/meshes before/after the particle systems by using the renderingGroupId property of meshes/spritees/particle systems.
Transparent objects (meshes, sprites, particles) do not write in the depth buffer, so they do not occlude themselves and they are all blended up. Drawing them in the wrong depth order is often not very visible, but of course it depends on your scene. Unfortunately, this is something we can’t do much about; it’s a well-known problem with transparent objects.