I got the files and edited the material to show all the parts of the character.
I get exactly the same visual bug as you do, though my visual bug can vary from time to time (each startup seems to be a bit different).
When I add a simple shader to the materials, the same result is given at a core. Since per-pixel lighting works with the new shader means that the material is not the issue, that get rendered correctly.
Because I added a shader, I could now debug the shader in Visual Studio 2017 with the Graphics Debugging tool, which in turn shows me that the UV from TEXCOORD0 in the vertex shader is always [0, 0]. It never gets sent to the shader (at least not correctly).
This means that the UV gets messed up somehow, and I have not been able to track where it has gone wrong (and yes, I tried it in the materials also with "tex_address_mode wrap").
I have tried getting the UV data directly from the mesh, but that data always seems to be fine.
But I know for a fact that it has to do with animations as you suggested, as the code below shows the mesh when it works and then when the bug happens (add this code to a key press if you want to try it):
Code: Select all
if (ent->getMesh()->getSkeletonName() == "")
The data for the position, normal and UV seems to be the same even if I enable/disable the bug with the code above. This means that the data is actually correct, but it does not get bound correctly for rendering somewhere.
Another weird thing is also that when I build tangents for the mesh (just for a test), the tangent also gets sent into the shader as [0, 0, 0], even though the code that built it shows that it has valid values (like the UV shows).
Things you could try:
1. Simplify the skeleton, try to only use one or two bones. That way we know for sure that every vertex only has weight from less than 5 bones at a time (a maximum of 4 bones per vertex are actually weighted, might be a bug because it might be more than that).
2. Make sure the 3D mesh does not have any strange faces, for example, the mesh might show in the 3D program that it has double the triangles needed, and those triangles might always have a UV of [0, 0]. These strange faces could possibly randomly be drawn before the others when using animation.
3. Try exporting the mesh with only one submesh. The current one has 3 submeshes and that might also have something to do with the bug.
4. Check through all options in the 3D program when exporting the mesh and its skeleton. Also check the UV editor that the mesh actually seems to be correct there (I know for a fact that the UV is minus in Y in your mesh, you could try fixing that also to the range of 0-1).