[SOLVED] Z-Depth Control for SlippyTiles in Geovisual application

I’m working on a 3d globe interface similar to google maps utilizing slippy tile formats. Tiles are loaded and rendered dynamically based on distance from camera. My question is how can I force higher detail tiles to render on top of lower detailed tiles? I discovered Material.getAdditionalRenderState().setDepthTest(false); which gets me close, but without actually moving the tile closer to the camera I can’t guaranty render order. I can’t use the translucent bucket as there may be an arbitrary number of overlapping tiles. Any ideas out there?


Not too many details to go on about your current approach but if you don’t care about depth then you can turn depth write off for everything.

I don’t know what your requirements are so it’s hard to say otherwise. Solutions get more complicated when you have more complicated requirements.

Actually, that part isn’t really true. You can set your own comparator and render things in whatever order you like.

That sounds perfect… Can you elaborate?



Worked like a charm. Thank you!

So I’ve been running with the solution above for a while now, but am running into limitations. I have 3 layers of geometry, within each layer, I want objects to overlap and depth test normally, but members of different layers should always be forced to render in a fixed order.

Some research has turned up different options, but I’d like your opinion on the best way to achieve this. I’m experimenting with multiple cameras and overlapping viewports, but objects attached to different scenes with different cameras/viewports are still z testing with each other. Even if farther away, I need objects in the ‘front’ viewport to render in front of objects in background layers.

Implement your own GeometryComparator:

Edit: you can look at how Lemur does it if you like:

This lets me control the rendering order with up to 10 layers per hierarchy level. If you only have one layer that needs to be ordered a specific way then you could always use user data as that sort order and if the data doesn’t exist then default to the z sort.

A custom comparator was the original solution I adopted from the start of this thread , granted that was a year ago :wink:

The problem there is that the custom sorted object still intersects with background geometry unless I use setDepthTest(false); Which prevents the foreground model from hiding it’s own obscured pixels. Am I missing something simple here?


No. You are running into the limitations of GPU transparency.

If you can’t decide which object to draw first to sort properly (ie: they can’t be sorted properly) then there really isn’t anything left to do… unless you want to start sorting at the triangle level. But even triangles can interpenetrate and mess up transparency.

It’s just the nature of it.

Edit: I mean you can still have a viewport for every layer… but you should make sure to clear the zbuffer in the clear flags.

Awesome, clearing the flags was the part I was missing. Thanks again.

1 Like