Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool ShadowShaderClass::initializeDepthStencil(ID3D11Device* gDevice)
- {
- HRESULT resultHandler;
- bool result = false;
- D3D11_TEXTURE2D_DESC textureDepthDesc;
- textureDepthDesc.Width = 640.0f;
- textureDepthDesc.Height = 480.0f;
- textureDepthDesc.MipLevels = 1;
- textureDepthDesc.ArraySize = 1;
- textureDepthDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
- textureDepthDesc.SampleDesc.Count = 4; //must match the swap chain
- textureDepthDesc.SampleDesc.Quality = 0;
- textureDepthDesc.Usage = D3D11_USAGE_DEFAULT;
- textureDepthDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
- textureDepthDesc.CPUAccessFlags = 0;
- textureDepthDesc.MiscFlags = 0;
- //create the texture for depthmap?
- resultHandler = gDevice->CreateTexture2D
- (
- &textureDepthDesc,
- NULL,
- &(this->shadowmapDepthtexture)
- );
- //create another texture for the render target view
- D3D11_TEXTURE2D_DESC textureDescRTV;
- ZeroMemory(&textureDescRTV, sizeof(textureDescRTV));
- //setup the render target texture description
- textureDescRTV.Width = 640.0f;
- textureDescRTV.Height = 480.0f;
- textureDescRTV.MipLevels = 1;
- textureDescRTV.ArraySize = 1;
- textureDescRTV.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
- textureDescRTV.SampleDesc.Count = 4; //must match swapchain
- textureDescRTV.SampleDesc.Quality = 0;
- textureDescRTV.Usage = D3D11_USAGE_DEFAULT;
- textureDescRTV.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
- textureDescRTV.CPUAccessFlags = 0;
- textureDescRTV.MiscFlags = 0;
- resultHandler = gDevice->CreateTexture2D(&textureDescRTV, NULL, &this->shadowmapRenderTargetViewTexture);
- //create render target view
- D3D11_SHADER_RESOURCE_VIEW_DESC shaderResourseViewDesc;
- ZeroMemory(&shaderResourseViewDesc, sizeof(shaderResourseViewDesc));
- //setup the description of the render target view
- //didn't work, but with null it does, no questions asked
- //Create the render target view using the depthbuffer?
- //resultHandler = gDevice->CreateRenderTargetView(this->shadowmapRenderTargetViewTexture, &renderTargetViewDesc, &this->shadowMapRTV);
- //http://www.rastertek.com/dx11tut22.html <--- here
- resultHandler = gDevice->CreateRenderTargetView(this->shadowmapRenderTargetViewTexture, NULL, &this->shadowMapRTV);
- //set upp description to the shader resource view
- shaderResourseViewDesc.Format = DXGI_FORMAT_D32_FLOAT; //textureDescRTV.Format;
- shaderResourseViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DMS;
- shaderResourseViewDesc.Texture2D.MostDetailedMip = 0;
- shaderResourseViewDesc.Texture2D.MipLevels = 0;
- //create the shader resourse view
- resultHandler = gDevice->CreateShaderResourceView(this->shadowmapRenderTargetViewTexture, NULL, &this->shaderResourceView);
- //create depthStencilView
- resultHandler = gDevice->CreateDepthStencilView(
- this->shadowmapDepthtexture, //resorse we want to create a view to
- 0,
- &(this->shadowDepthStencilView) //the depthStencilView
- );
Advertisement
Add Comment
Please, Sign In to add comment