Weird pop-in of individual triangles with distance I'm getting a strange pop in issue after increasing the size of the terrain. This was not an issue before the size increase, so I'm thinking it's got something to do with either the depth buffer or the far planes. I'm including a video of what it looks like and some code snippets from what I think are relevant places. Depth buffer //create depth stencil texture D3D11_TEXTURE2D_DESC descDepth; descDepth.Width = mClientWidth; descDepth.Height = mClientHeight; descDepth.MipLevels = 1; descDepth.ArraySize = 1; descDepth.Format = DXGI_FORMAT_D32_FLOAT; descDepth.SampleDesc.Count = 1; descDepth.SampleDesc.Quality = 0; descDepth.Usage = D3D11_USAGE_DEFAULT; descDepth.BindFlags = D3D11_BIND_DEPTH_STENCIL; descDepth.CPUAccessFlags = 0; descDepth.MiscFlags = 0; if (FAILED(mD3DDevice->CreateTexture2D(&descDepth, NULL, &mD3D11DepthStencilTexture))) return; if (FAILED(mD3DDevice->CreateDepthStencilView(mD3D11DepthStencilTexture, 0, &mD3D11DepthStencilView))) return; Viewport //set view port =================================================== mD3D11Viewport.Width = swapChainDesc.BufferDesc.Width; mD3D11Viewport.Height = swapChainDesc.BufferDesc.Height; mD3D11Viewport.MinDepth = 0.0f; mD3D11Viewport.MaxDepth = 1.0f; mD3D11Viewport.TopLeftX = 0; mD3D11Viewport.TopLeftY = 0; mDeviceContext->RSSetViewports(1, &mD3D11Viewport); Blend state D3D11_BLEND_DESC BlendDesc; ZeroMemory(&BlendDesc, sizeof(D3D11_BLEND_DESC)); BlendDesc.RenderTarget[0].BlendEnable = TRUE; BlendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA; BlendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; BlendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; BlendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ZERO; BlendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO; BlendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; BlendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; mD3DDevice->CreateBlendState(&BlendDesc, &mD3D11BlendState); mDeviceContext->OMSetBlendState(mD3D11BlendState, 0, 0xffffffff); Clearing the depth buffer // Clear the back buffer float clearColor[4] = { 0.0f, 0.125f, 0.3f, 1.0f }; // red,green,blue,alpha mDeviceContext->ClearRenderTargetView(mD3D11RenderTargetView, clearColor); mDeviceContext->ClearDepthStencilView(mD3D11DepthStencilView, D3D11_CLEAR_DEPTH, 1, 1); Projection matrix calculation mProjectionMatrix = XMMatrixPerspectiveFovLH(3.14159265f / 4.0f, 4.0f/3.0f, 0.01f, 100000.0f); Any ideas what this could be? https://ift.tt/eA8V8J
I'm getting a strange pop in issue after increasing the size of the terrain. This was not an issue before the size increase, so I'm thinking it's got something to do with either the depth buffer or the far planes. I'm including a video of what it looks like and some code snippets from what I think are relevant places. Depth buffer //create depth stencil texture D3D11_TEXTURE2D_DESC descDepth; descDepth.Width = mClientWidth; descDepth.Height = mClientHeight; descDepth.MipLevels = 1; descDepth.ArraySize = 1; descDepth.Format = DXGI_FORMAT_D32_FLOAT; descDepth.SampleDesc.Count = 1; descDepth.SampleDesc.Quality = 0; descDepth.Usage = D3D11_USAGE_DEFAULT; descDepth.BindFlags = D3D11_BIND_DEPTH_STENCIL; descDepth.CPUAccessFlags = 0; descDepth.MiscFlags = 0; if (FAILED(mD3DDevice->CreateTexture2D(&descDepth, NULL, &mD3D11DepthStencilTexture))) return; if (FAILED(mD3DDevice->CreateDepthStencilView(mD3D11DepthStencilTexture, 0, &mD3D11DepthStencilView))) return; Viewport //set view port =================================================== mD3D11Viewport.Width = swapChainDesc.BufferDesc.Width; mD3D11Viewport.Height = swapChainDesc.BufferDesc.Height; mD3D11Viewport.MinDepth = 0.0f; mD3D11Viewport.MaxDepth = 1.0f; mD3D11Viewport.TopLeftX = 0; mD3D11Viewport.TopLeftY = 0; mDeviceContext->RSSetViewports(1, &mD3D11Viewport); Blend state D3D11_BLEND_DESC BlendDesc; ZeroMemory(&BlendDesc, sizeof(D3D11_BLEND_DESC)); BlendDesc.RenderTarget[0].BlendEnable = TRUE; BlendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA; BlendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; BlendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; BlendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ZERO; BlendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO; BlendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; BlendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; mD3DDevice->CreateBlendState(&BlendDesc, &mD3D11BlendState); mDeviceContext->OMSetBlendState(mD3D11BlendState, 0, 0xffffffff); Clearing the depth buffer // Clear the back buffer float clearColor[4] = { 0.0f, 0.125f, 0.3f, 1.0f }; // red,green,blue,alpha mDeviceContext->ClearRenderTargetView(mD3D11RenderTargetView, clearColor); mDeviceContext->ClearDepthStencilView(mD3D11DepthStencilView, D3D11_CLEAR_DEPTH, 1, 1); Projection matrix calculation mProjectionMatrix = XMMatrixPerspectiveFovLH(3.14159265f / 4.0f, 4.0f/3.0f, 0.01f, 100000.0f); Any ideas what this could be?
from GameDev.net http://bit.ly/2wwTk3h
from GameDev.net http://bit.ly/2wwTk3h
ليست هناك تعليقات