Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSGGeometryNode DrawLineStrip (GL_LINE_STRIP) not respecting the depth value

QSGGeometryNode DrawLineStrip (GL_LINE_STRIP) not respecting the depth value

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 330 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    alberto.toglia
    wrote on last edited by alberto.toglia
    #1

    I'm currently using a "QSGGeometryNode" with a "DrawLineStrip" "DrawingMode" to render a stroke. My vertex attributes look like this:

    using Attributes = std::vector<QSGGeometry::Attribute>;
    static auto attributeIndex = 0;
    static auto attributes = Attributes
    {
       QSGGeometry::Attribute::create(attributeIndex++, 2, GL_FLOAT, true),   //position
       QSGGeometry::Attribute::create(attributeIndex++, 4, GL_FLOAT),         //color
       QSGGeometry::Attribute::create(attributeIndex++, 1, GL_FLOAT),         //depth
    };
    

    As you can see the depth is fed to the vertex shader separately to the position for simplicity's sake, but also so that the vertex shader can change the depth dynamically.

    The following image illustrates the problem where I'm rendering just one line strip geometry (one draw call).

    On the left of the following image, you can see that I'm showing the depth value of the stroke in the fragment shader like this:

    gl_FragColor = vec4(vec3(gl_FragCoord.z), qt_Opacity);
    

    depth1.jpg

    Note that the stroke looks like it has the correct incremental depth yet there's a lot of self-intersecting happening which I'm guessing has to do with how the vertex data is aligned in the buffer, meaning that the strips that are last in the buffer are rendering last, but instead I want a depth test to be responsible for this.

    From what I've read in the documentation the depth testing should be enabled by default, and I can see that the surface is created with a 24bit depth channel.

    • The scene graph can support pseudo 3D and proper 3D primitives. For instance, one can implement a "page curl" effect using a ShaderEffect or implement a bumpmapped torus using QSGGeometry and a custom material. While doing so, one needs to take into account that the default renderer already makes use of the depth buffer.

    Now I'm not even sure if this is an OpenGL issue or a Qt issue. I've tried enabling the depth test using OpenGL commands like:

    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_ALWAYS);
    

    but I'm not entirely sure where these commands should live exactly. Please take into account that I'm using a plain QQuickItem and a updatePaintNode to create this geometry.

    Any help would be much appreciated.

    1 Reply Last reply
    1

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved