guiNode and depth tests

I have been trying to render a Mesh geometry in guiNode that has tris with some variance in the Z axis, however when rendered, the tris in the mesh are just drawn over the top of each other with no respect to Z. I’m guessing this must be because there is no depth buffer/test in guiNode? So my question is; is there any way to enable depth tests in guiNode?

The Gui Bucket scales Z to 0 and only uses it for sorting.

The irony is that since guiNode is in its own viewport, this special bucket setup is no longer necessary and I’ve kind of petitioned to remove the Gui Bucket when we have time to properly validate it.

So what I’m about to tell you is experimental… I’ve not tried it but it should work in theory.

Try calling:
guiNode.setQueueBucket( RenderQueue.Bucket.Transparent );

In theory, that gets the same sorting behavior you have now at the object level but gives you a proper orthogonal rendering without the 0 z scaling.

As long as none of your other stuff is specifically set to Bucket.Gui then that should work. I’m curious to know if it does… and I wish I’d thought of it before because I hacked the renderer to get similar behavior.

1 Like

I just tried this on my test case but it resulted in nothing being drawn.

I’ve included my test code below. It creates a mesh with 2 different colored quads (red/green), with a Z of 0.5 and 0 respectively. It also creates a second copy of this mesh with different colors (blue/white) and moves it -0.1 Z. So the order should ideally be white, green, blue, red.

import com.jme3.material.Material;
import com.jme3.material.RenderState;
import com.jme3.math.ColorRGBA;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Geometry;
import com.jme3.scene.Mesh;
import com.jme3.scene.VertexBuffer;
import com.jme3.system.AppSettings;
import com.jme3.texture.FrameBuffer;
import com.jme3.texture.Image;


  • GUI Z order test.

public class GUIOrder extends SimpleApplication {

public Geometry createGeom(ColorRGBA color1, ColorRGBA color2) {

// Create new mesh for my geometry
Mesh my_mesh = new Mesh();
Geometry my_geo = new Geometry("My Geometry", my_mesh);
// Material stuff,
Material mat = new Material(assetManager,

// Disable culling,
RenderState render_state = mat.getAdditionalRenderState();

// Define the quads in the mesh
float[] posits = new float[] {
           500, 300, 0.5f,  // Box with 0.5 depth
           700, 300, 0.5f,
           700, 100, 0.5f,
           500, 100, 0.5f,

           500 + 10, 300 - 10, 0,  // Box with 0 depth
           700 + 10, 300 - 10, 0,
           700 + 10, 100 - 10, 0,
           500 + 10, 100 - 10, 0,

float[] colors = new float[] {
           color1.r, color1.g, color1.b, color1.a,
           color1.r, color1.g, color1.b, color1.a,
           color1.r, color1.g, color1.b, color1.a,
           color1.r, color1.g, color1.b, color1.a,

           color2.r, color2.g, color2.b, color2.a,
           color2.r, color2.g, color2.b, color2.a,
           color2.r, color2.g, color2.b, color2.a,
           color2.r, color2.g, color2.b, color2.a,

short[] indices = new short[] {
           0, 1, 2, 0, 2, 3,  // box1
           4, 5, 6, 4, 6, 7,  // box2

Mesh mesh = my_geo.getMesh();
mesh.setBuffer(VertexBuffer.Type.Position, 3, posits);
mesh.setBuffer(VertexBuffer.Type.Color, 4, colors);
mesh.setBuffer(VertexBuffer.Type.Index, 1, indices);


return my_geo;


public void simpleInitApp() {

Geometry geo1 = createGeom(ColorRGBA.Red, ColorRGBA.Green);
Geometry geo2 = createGeom(ColorRGBA.Blue, ColorRGBA.White);

geo2.move(150, 20, -0.1f);

// guiNode.setQueueBucket( RenderQueue.Bucket.Transparent );

// Attach it,

// disable the fly cam

// flyCam.setEnabled(false);


public static void main(String[] args){

final AppSettings settings = new AppSettings(true);

GUIOrder app = new GUIOrder();




If there’s no solution then I can probably live with it. It’s just something I wouldn’t expect to work this way.

Since the Gui bucket overrides camera settings it’s possible that the camera associated with the gui viewport has never been setup properly, ie: relying on the gui bucket related renderer hacks.

You could try playing with guiViewport’s Camera but I haven’t really played with ortho cameras too much. I’d have to look a lot deeper to offer any advice.