Depth ordering with QSG
-
I have an application that relies on QSG. I have created a QQuickItem and overwritten
updatePaintNode
. In that I create a root node and append child nodes depending on the state of my application. I cannot control the order in which these nodes are created (Well, except sorting but I'd like to not do that, especially since node updates can happen frequently and I do not want to sort the entire list of children every so often), so I have to resort to depth ordering.My implementation uses the
QSGGeometryNode
as a base for every child node. I have a custom shader implementation that I tried to adjust to respect depth ordering. For that I tried to modify thegl_Position
output vector's Z coordinate based on a value between 0 and 1, however nothing changed. That has me puzzled because in theory (according to OpenGL) this controls the depth. I expect that this is the case for every other qsg-backed renderer. The relevant snippet of my vertex shader is:#version 440 layout(location = 0) in vec4 qt_VertexPosition; layout(std140, binding = 0) uniform buf { mat4 qt_Matrix; } ubuf; out gl_PerVertex { vec4 gl_Position; }; void main() { gl_Position = ubuf.qt_Matrix * qt_VertexPosition; }
How can I enable the usage of a depth buffer, since apparently it isn't being used here?