Understanding render_priority, sorting_offset, etc - making objects render behind others

Godot Version



I’ve been trying to properly understand how the various settings regarding render sorting work. I’m just trying to make an object that renders into the “background” (before subsequent objects are rendered) without needing to add an additional viewport etc to the game, but have been struggling.

I’ve boiled it down just to a test setup of two cubes. I’ve been trying various combinations of the no-depth-test, depth draw, render priority, sorting offset and anything else that seems tangentially related, but all I can make happen is having the cube show up in front of the other, never behind.

It’s not exactly a complex test scene:

I’ve specifically tried this with the blue cube’s render priority set both to 1 and -1 (and other values for good measure) and the white cube’s set to 0. The blue cube has No Depth Test set and as mentioned I’ve tried the various other options - all it really ever does is change its sorting with respect to the editor grid and gizmo, not the other cube. (I’ve tried in the proper game view as well, same thing). There’s nothing special done to the white cube.

So… I am clearly just not understanding something about how the render pipeline handles these things. I’ve been staring at it and squinting for too long, so I figured it was time to just get some outside assistance. I would appreciate, if nothing else, some help understanding where my thinking is going astray.

Sorting offset is only for transparent objects. Opaque objects are drawn first in TAA pass (or last, i don’t remember), then front to back. Transparent objects are drawn back to front.
Render priority right now works for opaque, unless they end up in the TAA pass. However, this will change in future releases, where there will be more reliable ways to order objects.

1 Like

So, I guess there’s not much I can do at present since the object I’m trying to push to the back is opaque as well?

Not reliably with future versions

Oh well - I’ll work something out. Thanks for the help either way. I’ll probably just add another viewport in my case, probably the least hassle in the end

1 Like