Lemur LayerComparator

Hi

While looking Silicon Gemini example I noticed the use of LayerComparator.setLayer() on some transparent geometries

when I removed those lines I noticed some artifacts on the power-ups

here is how it looks like when using LayerComparator

I could not understand much from Javadoc except that it is more useful in a GUI environment. :upside_down_face:

So I am curious to know what does LayerComparator.setLayer(); do and when I should consider using it?

Regards

1 Like

LayerComparator is automatically installed for all relevant buckets when you use Lemur and it can be super useful for forcing a rendering sort order between things that would otherwise fight.

For example, if you are rendering two quads right on top of each other and always want quad 1 to render first then you can set its layer to 1 and the second quad’s layer to 2. No matter what angle you view them or what sort JME will give them, quad 1 will always render before quad 2.

Lemur uses this for UI elements to make sure the top layers always render over the bottom layers. But it can also be useful in 3D scenes if you want to render something like a flat cursor on top of some flat terrain and they are both already in the same queue bucket or something.

Note that the layer is also hierarchical. So if parent node A is layer 1 and parent node B is layer 2 then all children of A will be drawn before B’s children. (And children of A or B can still have their own layers.)

1 Like