1

Using an old mesh, I noticed that faces in the back of the mesh were being displayed (DirectX 11) Having defined a state:

D3D11_RASTERIZER_DESC DrawStyleState;
DrawStyleState.AntialiasedLineEnable=true;
DrawStyleState.CullMode=D3D11_CULL_BACK;
DrawStyleState.DepthBias=0;
DrawStyleState.FillMode=D3D11_FILL_SOLID;
DrawStyleState.DepthClipEnable=true;
DrawStyleState.MultisampleEnable=true;
DrawStyleState.FrontCounterClockwise=false;
DrawStyleState.ScissorEnable=false;

ID3D11RasterizerState *DS_State;
Device->CreateRasterizerState(&DrawStyleState, &DS_State);
DeviceContext->RSSetState(DS_State);

And a depth buffer:

ID3D11Texture2D *Texture2d;
Swapchain->GetBuffer(0,__uuidof(ID3D11Texture2D),(LPVOID*)&Texture2d);

D3D11_TEXTURE2D_DESC DepthStenDescription;
ZeroMemory(&DepthStenDescription, sizeof(D3D11_TEXTURE2D_DESC));

DepthStenDescription.Width              =ScreenWidth;
DepthStenDescription.Height             =ScreenHeight;
DepthStenDescription.MipLevels          =1;
DepthStenDescription.ArraySize          =1;
DepthStenDescription.Format             =DXGI_FORMAT_D24_UNORM_S8_UINT;
DepthStenDescription.SampleDesc.Count   =0;
DepthStenDescription.SampleDesc.Quality =1;
DepthStenDescription.Usage              =D3D11_USAGE_DEFAULT;
DepthStenDescription.BindFlags          =D3D11_BIND_DEPTH_STENCIL;
DepthStenDescription.CPUAccessFlags     =0;
DepthStenDescription.MiscFlags          =0;

D3D11_DEPTH_STENCIL_VIEW_DESC DSVDesc;
ZeroMemory(&DSVDesc, sizeof(D3D11_DEPTH_STENCIL_VIEW_DESC));
DSVDesc.Format=DSVDesc.Format;
DSVDesc.ViewDimension=D3D11_DSV_DIMENSION_TEXTURE2D;
DSVDesc.Texture2D.MipSlice=0;

Device->CreateTexture2D(&DepthStenDescription, NULL, &DepthStenBuffer);
Device->CreateDepthStencilView(DepthStenBuffer, &DSVDesc, &DepthStenView);
//---------------------------------------------------------------
Device->CreateRenderTargetView(Texture2d,NULL,&RenderTargetView);
Texture2d->Release();

Is there anything missing that the model looks like this?enter image description here

The red and white is intentional. Apologies in advance.

Edit: All vertices have an alpha value of 1.0

derpface
  • 1,611
  • 1
  • 10
  • 20
Rashid Ellis
  • 330
  • 3
  • 22
  • 1
    It's possibly inconsistent winding order in your mesh data. What does it look like with `D3D11_CULL_NONE`? – Roger Rowland Jan 23 '14 at 05:43
  • It's looking to be the winding order, I changed `D3D11_CULL_BACK` to `D3D11_CULL_NONE`. Here's a hoarse question: how would you reorder a vertex array so that faces are created consecutively in the "correct" orientation? (My indices were extracted from an .obj file) Should I hop back into Maya and do some retoping? or is there an algorithm to start from vertex 1, on. Additionally, there seems to be a perspective issue: objects farther away are larger then object in closer proximity. Is this my `XMMatrixPerspectiveFovLH(XM_PIDIV2, 1.0, 0.0f, 1000.0f)` at work here? – Rashid Ellis Jan 23 '14 at 23:59
  • When you get a chance can you tailor this as the answer? The winding order on the mesh was indeed inconsistent. – Rashid Ellis Jan 29 '14 at 08:12

1 Answers1

1

It sounds like it's inconsistent winding order in your mesh data.

You can check this by comparing the results you get with D3D11_CULL_NONE, so you will see all triangles and can assess if anything is missing or incorrect as far as the position information goes.

Roger Rowland
  • 25,885
  • 11
  • 72
  • 113