Putting UI in worldspace but not on UI camera layer

I’m having some depth/z-indexing issues when trying to put UI elements on a layer that isn’t the UI layer.

If you’re wondering why I’m not putting it on the UI layer, its because I believe it renders topdown hierarchy-wise, and I need it to instead render depth-wise since things in the front should hide things in the back. (Though there’s a chance I’m doing something wrong here as well)

The problem I’m running into is when putting UI elements onto layers other than the UI layer, I get things popping in and out (despite having physically placed some in front of others)

I’m not sure if its zfighting, or if at some camera rotations it assumes its offscreen and is culling the element, but wanted to ask if anyone has run into this or solved it before… or if I’m just doing something wrong and no one has had the issue… because thats always possible.

Hi @trigandrew!

Can you share a sample project please?

Oops completely forgot to send the one I took the video from PlayCanvas | HTML5 Game Engine

If you just rotate in editor from where the camera currently is, you can see the same thing

I think you can try to change Camera Clip Near to something like 0.01 in the editor settings.

I tried setting to 0.01 as well as throwing a couple extra zeroes to see if that would help, but it seems to still vanish. My guess is it isnt getting culled out by the near or far clip planes. I guess it must be a little funky on how its trying to figure out the depth.

Well quick update, if I set UI elements to use materials instead of color or textures, it seems the problem goes away. Im guessing it has something to do with writing to the depth buffer being tied to having an actual material. Not sure if this is gonna work permanently but I guess Im gonna find out since thats what Im going to go with.

1 Like

It can be an editor bug, so the result at runtime can be different.