DirectX11深度值仅为0和1
DirectX11 Depth values only 0 and 1
我正在将我的OpenGL Renderer移植到DirectX。几乎一切都很好,但我有深度的问题。3D中的所有内容都呈现为平面。我已经检查了Visual Studio图形分析器和深度缓冲,状态是绑定的。如果我检查深度/模板纹理资源,只有值0。F(屏幕上的东西)和1。F(没有渲染)。使用gDEBugger检查OpenGL渲染器显示从0开始的值。从F到1。f和OpenGL工作。我还检查了错误代码。一切都返回S_OK。我能做错什么呢?
这是我的DepthStencilState创建:
D3D11_DEPTH_STENCIL_DESC dsDescEn;
ZeroMemory(&dsDescEn, sizeof(D3D11_DEPTH_STENCIL_DESC));
dsDescEn.DepthEnable = TRUE;
dsDescEn.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
dsDescEn.DepthFunc = D3D11_COMPARISON_LESS;
dsDescEn.StencilEnable = TRUE;
dsDescEn.StencilReadMask = 0xFF;
dsDescEn.StencilWriteMask = 0xFF;
dsDescEn.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
dsDescEn.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR;
dsDescEn.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
dsDescEn.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
dsDescEn.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
dsDescEn.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR;
dsDescEn.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
dsDescEn.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
DirectX11Device::getDevice().getDevicePtr()->CreateDepthStencilState(&dsDescEn, &m_dSStateEn);
我通过OMSetDepthStencilState绑定State。
D3D11_TEXTURE2D_DESC depthStencilDesc;
depthStencilDesc.Width = width;
depthStencilDesc.Height = height;
depthStencilDesc.MipLevels = 1;
depthStencilDesc.ArraySize = 1;
depthStencilDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
depthStencilDesc.SampleDesc.Count = 1;
depthStencilDesc.SampleDesc.Quality = 0;
depthStencilDesc.Usage = D3D11_USAGE_DEFAULT;
depthStencilDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
depthStencilDesc.CPUAccessFlags = 0;
depthStencilDesc.MiscFlags = 0;
D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc;
ZeroMemory(&depthStencilViewDesc, sizeof(D3D11_DEPTH_STENCIL_VIEW_DESC));
depthStencilViewDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
depthStencilViewDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
depthStencilViewDesc.Texture2D.MipSlice = 0;
DirectX11Device::getDevice().getDevicePtr()->CreateTexture2D(&depthStencilDesc, NULL, &m_stencilDepthBuff);
DirectX11Device::getDevice().getDevicePtr()->CreateDepthStencilView(m_stencilDepthBuff, &depthStencilViewDesc, &m_stencilDepthView);
我找到了解决办法。问题是矩阵乘法。我把它从c++移到shader中,现在它可以正常工作了。
相关文章:
- C++17复制构造函数,在std::unordereded_map上进行深度复制
- OpenGL在启用深度测试时不会丢弃我的碎片
- C++尝试深度复制唯一指针时出现内存访问冲突
- 试图找到二叉树的深度
- 操纵安卓相机的深度图导致应用程序崩溃
- 深度值没有意义 R200 相机
- 对如何制作双链表的深度副本感到困惑?
- 以C++访问 HoloLens 2 深度图像
- 在 c++ 中使用深度复制的运算符重载
- 如何深度复制链表对象指针
- 提升图:当我的图使用 listS 作为 VertexList 时,如何调用深度优先搜索()?
- 在 OpenCV 中按深度维度排序,C++
- 如何在编译时获得多维 std::vector 的深度?
- 需要帮助生成C++深度有限的随机表达式树
- C++ 可变参数模板实例化深度超过最大值 900
- C++ - 如何找到 n 元树的给定节点的深度
- C++ 和 directx11 深度测试 不适用于少数对象场景
- 在DirectX11中创建深度模板失败
- Kinect -深度流+视频流到DirectX11纹理
- DirectX11深度值仅为0和1