Particles Z position

Hi! I am trying to add particles before and after gui node by changing their Z position.
But for some reason it does not change anything, particles are shown only behind the node.

There was some bug related to the particles and I have removed them from my app. Now I have added them back, they are working, but as I remember they were shown fine. Is it a bug or I am missing something in configuration?

It’s not a bug, it has to do with the render order of different materials, in your render script. If you look at builtins/default.render_script, you can see that in the update function it draws materials associated with the tile tag, then particle tag, then the gui. So z-order will only sort objects within those groups, not between them.

If you want certain particles to draw over the gui, you should:

  1. Make a local copy of the default render_script (because changes you make to builtins won’t be saved)
  2. Set the render in your project settings (bootstrap section) to use your custom render script
  3. Create a new material for particles you want to render over the gui (start by copying particlefx.material from builtins/materials)
  4. Open your version of particlefx.material, and in the tags field change “particle” to something like “particle_after” (or whatever you want, just keep it consistent with step 5)
  5. In your version of the render script, add this line to the init function:
self.particle_after_pred = render.predicate({ "particle_after" })

(the string you pass to render.predicate should match the tag you gave to your new material)

  1. In the update function of your render script, add these lines to the end:
    render.set_viewport(0, 0, render.get_window_width(), render.get_window_height())

    render.set_blend_func(render.BLEND_SRC_ALPHA, render.BLEND_ONE_MINUS_SRC_ALPHA)


  1. Finally, assign your custom particle material to any particlefx you want to draw on top of the gui.

This should solve your problem, and will hopefully give you a little bit of insight into Defold’s render pipeline.