Jump to content
  • Advertisement
rekotc

DX11 md5 mesh rendered wrong in directX application

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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);

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Posted (edited)

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).

Edited by SyncViews

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Posted (edited)

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.

 

Edited by _Flame_

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!