【问题标题】:DirectX: Mesh displaying occluded facesDirectX:网格显示被遮挡的面
【发布时间】:2014-02-13 08:53:32
【问题描述】:

使用旧的网格,我注意到网格背面的面正在显示 (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();

模型看起来像这样有什么遗漏吗?

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

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

【问题讨论】:

  • 您的网格数据中的缠绕顺序可能不一致。 D3D11_CULL_NONE 是什么样子的?
  • 它看起来是缠绕顺序,我将D3D11_CULL_BACK 更改为D3D11_CULL_NONE。这是一个嘶哑的问题:您将如何重新排序顶点数组以便以“正确”方向连续创建面? (我的索引是从 .obj 文件中提取的)我应该跳回 Maya 并进行一些重命名吗?或者是否有从顶点1开始的算法。此外,似乎还有一个透视问题:距离较远的物体比距离较近的物体大。这是我在这里工作的XMMatrixPerspectiveFovLH(XM_PIDIV2, 1.0, 0.0f, 1000.0f) 吗?
  • 当你有机会时,你能定制这个作为答案吗?网格上的缠绕顺序确实不一致。

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


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多