Missing triangles on bigger meshes

Help
Soukupov
2013-05-27
2013-06-03
  • Soukupov

    Soukupov - 2013-05-27

    Hello,
    I have been working on simple program for viewing shaders for my bachelor theses. I use assimp for loading various models of various formats and it really helped me a lot, but I have little problem. When I load larger meshes there are missing triangless in the model.
    I tried loading the object in assimp viewer and even there are missing triangles.
    The model wich i have problem with is simple three times subsurfaced suzi from blender with 31658 vertices and 31488 quad faces and 62976 tris. I export the object to collada, but the same thing hapens with obj and ply.
    I did try to find some solution for this issue and it seems that if I triagulate all the faces of the model befor export the problem is gone. So maybe something is wrong with triangulation?


    this is how it looks like in assimp viewer


    and the same hapens in my aplication

    So i was wondering if it is faulty export from blender or some bug or did i miss something?

     
  • Thomas Ziegenhagen

    Could you please upload the erroneous Collada file somewhere? I'd like to have a look on it.

    My thoughts on it so far:
    - missing triangles or triangles strechting far are usually index buffer problems: if you use a 16bit index buffer, your rendering will break for all vertices > 65535
    - but here this can't be the case as AssimpView automatically switches to 32Bit index buffers as far as I know
    - but maybe I'm wrong, so check what format your index buffer uses
    - you say the issue is gone if you triangulate before exporting
    - so it might also be a bug in our triangulation code
    - or one of the other post fx
    - so please post your exact set of importer flags
    - the whole mesh is faceted - looks like hard normals to me
    - that means that most vertices are unique
    - so there's a real lot of them
    - so maybe it's just the 16Bit index buffer issue, and triangulation before exporting just smoothed the normals, thus pushing the vertex count below 65k

     
  • Soukupov

    Soukupov - 2013-05-28

    Hi,
    thanks for your reply. Here is the collada file.

    http://uloz.to/xMu7pztg/opice-med-dae

    I checked the code of my application and I use GLuint array for indices which is 32bit unsigned integer. Anyway here is the code which handles creating of index buffer.

    GLuint * indBuff = new GLuint[3 * numTr];
        unsigned int faceIndex = 0;
        for (unsigned int t = 0; t < numTr; t++) 
        {
                const struct aiFace* face = &mesh->mFaces[t];
                memcpy(&indBuff[faceIndex], face->mIndices,3 * sizeof(GLuint));
                faceIndex += 3;
        }
        glGenBuffers(1, &_indBuffHandle);
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indBuffHandle);
        glBufferData(GL_ELEMENT_ARRAY_BUFFER, (3 * numTr) * sizeof(GLuint), indBuff, GL_STATIC_DRAW);
        ExitOnGLError("ERROR: Could not bind the IBO to the VAO");
    

    numTr is aiMesh->mNumFaces

    I use aiProcessPreset_TargetRealtime_MaxQuality flag.

    About the normals, here I am doing something wrong probably, because although there is flag for generating smooth normals in aiProcessPreset_TargetRealtime_MaxQuality the model still looks faceted and I have to export it with smooth normals already generated, for it to look smooth.

     
  • Thomas Ziegenhagen

    Ok, PostFx flags are fine. Your index buffer code also looks fine. The GenSmoothNormals step only applies if a model doesn't already have normals. So if your exporter writes out normals, Assimp won't touch them unless you specifically ask it to remove them using the RemoveComponent step.

    BTW: I checked the file you uploaded. It loads and displays without errors with the latest repository version from GitHub. What version are you using?

     
  • Soukupov

    Soukupov - 2013-05-29

    I was using compiled version 3.0.1270.
    This mornig I tried compiling from GitHub source and it is working now !

    Thank you for your help.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks