md5 mesh rendered wrong in directX application

Started by
16 comments, last by rekotc 4 years, 11 months ago

Hi,

i'm trying to develop a basic md5 mesh viewer (without animations) using directX11, right now i'm still cleaning the code so i can't show you the entire project, but maybe you can give me a hint. The mesh is loaded correctly but some triangles are not filled up with the textures, they are invisible. Does the screenshot help? 

I hope i will be able to upload the code on github during the weekend.

Thanks in advance.

rendering-sbagliato.jpg

I love to learn new stuff about computer graphics and the DirectX APIs.

 

Advertisement

Hello.

My first guess is that you have face culling enabled and polygons have different orientation. Look from inside of the model to see if these triangles are visible.

The second guess would be that you don't draw these triangles.

If I were debugging this, I think the first thing that I would do would be to grab a capture in RenderDoc and navigate to the draw call. From there you can look at each triangle individually and see what indices and vertices are being used, which can help you figure out if you have a bug in building your vertex and index buffers. I would also recommend turning off culling in your rasterizer state like _Flame_ suggested, since that will tell you if you have an issue where your winding order is incorrect for your triangles.

Quote

Look from inside of the model to see if these triangles are visible.

Thanks, from inside the model the body seems fully rendered....!

Quote

I would also recommend turning off culling in your rasterizer state like _Flame_ suggested, since that will tell you if you have an issue where your winding order is incorrect for your triangles.

I tried to run the demo with the following descriptor and still no difference:

    ZeroMemory(&cmdesc, sizeof(D3D11_RASTERIZER_DESC));
    cmdesc.FillMode = D3D11_FILL_SOLID;
    cmdesc.FrontCounterClockwise = false;

    cmdesc.CullMode = D3D11_CULL_NONE;

    hr = m_device->CreateRasterizerState(&cmdesc, &RSCullNone);

 

I love to learn new stuff about computer graphics and the DirectX APIs.

 

I would say you definetely have incorrect indexing loaded up while winding is one thing incorrect as well.

I found when debugging these things starting with the simplest possible object can help a lot, like a cube with known coordinates and uvs (e.g. exactly 2x2x2 and a basic "t" texture unwrap).

At that point its a small enough thing to check everything manually. Does your mesh loading code have the expected vertices and indices? Are the indices in the expected order to get triangle strip front faces? Does the vertex shader transform each one as expected? Do the right ones get culled? etc. Maybe put 2 cubes in the mesh and make sure the restart is correct (either a -1 index, or some degenerate triangles).

A lot of things it could be, but double check it is not a left versus right hand coordinate system bug. I can't remember what the visual results of this being wrong is, but I have a distant memory of people being caught out by this with md3s.

Hello everybody,

thanks for all your answers and sorry for the late reply, i've been very busy lately.

I was able to clean the code and simplify the pixel shader, the problem is still there (new screenshot) and i still can't find a solution. I'll keep you updated with any progress, i attached a zip file with the source just in case

thanks again!

 

D3D11_MD5_MODEL_LOADER.zip

Immagine.png

I love to learn new stuff about computer graphics and the DirectX APIs.

 

I'm not an expert in DirectX but it looks like depth/stencil is not setup correctly.

You need to do all steps from here- https://docs.microsoft.com/en-us/windows/desktop/direct3d11/d3d10-graphics-programming-guide-depth-stencil

Depth/stencil can be the root cause because if you don't use it then some triangles look transparent(overwritten by other triangles).

I would advice to get familiar with api/basic techniques first.

Try to visualize simple shapes first. It's really hard to learn api and other complex things like loading meshes/animation at the same time.

 

Hello everybody,

thanks for the answer _Flame_! It pointed me to the right direction, you were right, the d3d initialization code was a mess, i had to rewrite it from scratch. I think i've made a big improvement, now all the triangles show up correctly! Still something that bugs me though, the guy's face is totally black, but it gets brighter when i move closer to it...

I attached an updated version of the source.

 

far.jpg

close1.jpg

md5-viewer-git.zip

I love to learn new stuff about computer graphics and the DirectX APIs.

 

This topic is closed to new replies.

Advertisement