DirectX:网格显示遮挡的面

时间:2014-01-23 01:18:01

标签: c++ mesh directx-11 .obj occlusion

使用旧网格,我注意到网格背面的面部正在显示(DirectX 11)已定义状态:

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

深度缓冲区:

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();

模型看起来有什么缺失吗?enter image description here

红色和白色是故意的。提前道歉。

编辑:所有顶点的alpha值均为1.0

1 个答案:

答案 0 :(得分:1)

听起来网格数据中的缠绕顺序不一致。

您可以通过将结果与D3D11_CULL_NONE进行比较来检查这一点,这样您就会看到所有三角形,并且可以评估是否有任何遗漏或不正确的位置信息。