[LibGDX] [Solved] Weird visual artifacts?

Just wondering what might be causing these weird distortions, if I only render a very small area there’s none, but beyond a certain number of vertices they appear (not that many). It’s less noticeable using only color, but with textures enabled it’s… yeah. Perhaps there’s a gl setting I need to enable? (Depth test is on)

Edit: Just triple confirmed none of my vertices are straying outside of where they’re supposed to be, let alone off into space…

I admit I’m just guessing, but it looks like it could be a problem with the indices (the fact that a number of triangles seem to be referencing a ‘phantom’ vertex far below the mesh is somewhat suggestive of that).

An easy first step would be to (programmatically) iterate over all the vertices and ensure that they’re all in the range [0, number of vertices). Note that the range is open, so the value ‘number of vertices’ should be excluded (fairly obvious, I know, but just being thorough). You might also double check that the right number of indices is being specified in your draw call.

Thanks! Yep, it was an issue with the wrong number of indices being passed on the draw call.

Where the issue was for those interested:

    /* @param shader the shader to be used
     * @param primitiveType the primitive type
     * @param offset the offset into the vertex or index buffer
     * @param count number of vertices or indices to use */
    public void render (ShaderProgram shader, int primitiveType, int offset, int count) {
        render(shader, primitiveType, offset, count, autoBind);
    }

For int count I was using my own int vs using the Mesh class’ own getNumVertices()
Source: https://github.com/Zaneris/Tranquil