Ignored Z for batched quads?

I have a batched Geometry made of quads, which go into the gui node. I’ve put a Z values for these quads but it looks like it’s ignored.

By “ignored” I mean that regardless of what I write as a Z value, these batched quads are drawn as if they had Z=0…

If you mean the quads don’t change their size, it’s because the gui viewport’s cam uses orthogonal projection.

Nope, I mean Z in the sense that, when overlapping, a quad is drawn on top of another one. Changing the Z value so that drawing order is changed has no effect.

Are you batching them yourself and ensuring that they are added to the batch in order?

For some reason, z scale is flattened to 0 in the Gui Bucket but things will still be rendered in the order they are in the batch.

If you are using one of JME’s built in batching classes then you probably don’t want to do that… I’m pretty sure they don’t sort on Z since they wouldn’t know which way to sort things.

I do this:

  1. make a batched Node by myself
  2. add quad 1 with Z=0 and a quad 2 with Z=1.
  3. they render as I expect, good
  4. set quad 1 with Z=1 and quad 2 with Z=0.
  5. they render the same as before, bad :frowning:

So this is it? I just can’t do the above?

However, if I have different Node on the Gui bucket and change the Z, the value is managed correctly. The misbehavior is only with batched quads

Yes, batching quads do not automatically get rebatched just because you changed their Z.

I feel like maybe you don’t understand where z sorting is done or how batching works… probably the former. JME sorts buckets by geometry. It can’t do otherwise. A batch is just a geometry.

Edit: actually, I made an assumption that you were batching yourself… because you didn’t say specifically that you were using JME’s classes. JME cannot auto sort because it doesn’t know what bucket, what sort order, what sort algorithm, etc. to use at that level. Your app knows.

Edit 2: yes, you are batching yourself… reread your post. So where do you expect the magic buffer reordering to happen?

I’m going to assume that the above question is rhetorical and is an euphemisms for saying “you don’t have a clue on how rendering is done in jme” so I guess you aren’t expecting an answer.

So I take that, on the GUI bucket and within the same Geometry, the quads are drawn on their buffer order, completely ignoring their Z value. This is by design and will never change.

A further clarification:

If, on the GUI bucket, I have batched node 1 and batched node 2, does Z values of their quads affect the drawing order, or should I change the Z values of the batched node instead? (i.e. the Z values of batched quads on the GUI node are 100% unuseful?)

A mesh is handed to the GPU all together. This has nothing to do with JME. It’s OpenGL.

JME sends the whole buffer to OpenGL which sends the whole buffer to your graphics card and renders it in the order of the buffer. JME management of “order” ends at Geometry… it will sort the geometry based on Z but that’s it.

1 Like