[SOLVED] Set render order to object

Hello, I’m trying to make similar thing like markers on this reference
Well, I need to show entities that covered behind another. Also it will be useful for GUI: in VR Starter Kit we have a cursor, but when I’m looking down, it hides behind floor. How can I draw VR cursor over all objects?

The ‘cheat’ way is to disable depth testing on the material. It’s cheating because it is still rendered at the same depth in world space and therefore your eyes are trying focus between the floor (near object) and the cursor (far object) at the same time and makes your eyes go weird.

The ‘correct’ way to project the cursor onto the surface (which is done in WebVR Lab sample in the tutorials section) and if you want to go one step further, resize the cursor so it’s always the same size to the user no matter how near/far it is.

1 Like

@yaustar, Thank you for reply. But I’ve tried to switch depth test off, and object just disappears. Please, look the project. What am I doing wrong?

I just looked at the project on my tablet and I can see the cursor. Is this only happening in VR view?

Oh, that’s weird. I watched on my android phone and PC, but can’t see neither cursor, nor red box. Both have depthTest off… In all views, VR and debug

Can you check my fork here and see if you get the same issue? https://playcanvas.com/editor/scene/541911

Holy moly! It works. But what a difference?
Also, red cube shows in weird way: 2nd screen is exactily what I need, but it still covered by blue cube.

No difference, which is why I’m very confused. My guess because it doesn’t do a depth test, the render order needs to be explicitly change and forking it changes it somehow.

I believe I did this in WebVR Lab and the API reference can be found here: https://developer.playcanvas.com/en/api/pc.MeshInstance.html#layer

Here is the code from WebVR Lab: https://playcanvas.com/editor/code/446331?tabs=6108752

1 Like

Yeah, I’ve also tried layers with no luck. Change layer to 0 is not working for me :frowning:

Just added render layer to my forked project and it worked for me?


1 Like

Thank you very much. It seems, layer works only without depth testing. Ahh, you’ve saved my day :slight_smile: