سؤال

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

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top