• Advertisement
Sign in to follow this  

Multiple Render Targets

This topic is 867 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi guys, I've made 4 render targets for Depth, normal, position and flux.

unfortunately, only first render target (which is Depth) has results in my output. others give me a blank screen which shows noting.

 

this is my implementation, can anyone tell me what am i doing wrong ?

thanks

 

 

Here are my declarations:

const int MRT_BUFFER_COUNT = 4;
ID3D11Texture2D* RT_renderTargetTexture[MRT_BUFFER_COUNT];
ID3D11RenderTargetView* RT_renderTargetView[MRT_BUFFER_COUNT];
ID3D11ShaderResourceView* RT_shaderResourceView[MRT_BUFFER_COUNT];
ID3D11Texture2D* RT_depthStencilBuffer;
ID3D11DepthStencilView* RT_depthStencilView;
D3D11_VIEWPORT RT_viewport;
D3DXMATRIX RT_projectionMatrix;
D3DXMATRIX RT_orthoMatrix;

and making MRTs:

        //Declarations
        D3D11_TEXTURE2D_DESC textureDesc;
	HRESULT result;
	D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDesc;
	D3D11_SHADER_RESOURCE_VIEW_DESC shaderResourceViewDesc;
	D3D11_TEXTURE2D_DESC depthBufferDesc;
	D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc;


	// Initialize the render target texture description.
	ZeroMemory(&textureDesc, sizeof(textureDesc));

	// Setup the render target texture description.
	textureDesc.Width = Width;
	textureDesc.Height = Height;
	textureDesc.MipLevels = 1;
	textureDesc.ArraySize = 1;
	textureDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
	textureDesc.SampleDesc.Count = 1;
	textureDesc.Usage = D3D11_USAGE_DEFAULT;
	textureDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
	textureDesc.CPUAccessFlags = 0;
	textureDesc.MiscFlags = 0;


	// Create the render target texture.
	for (int i = 0; i < MRT_BUFFER_COUNT; i++)
	{
		result = d3d11Device->CreateTexture2D(&textureDesc, NULL, &RT_renderTargetTexture[i]);
		if (FAILED(result))
		{
			return false;
		}
	}
	

	// Setup the description of the render target view.
	renderTargetViewDesc.Format = textureDesc.Format;
	renderTargetViewDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
	renderTargetViewDesc.Texture2D.MipSlice = 0;

	// Create the render target view.
	for (int i = 0; i < MRT_BUFFER_COUNT; i++)
	{
		result = d3d11Device->CreateRenderTargetView(RT_renderTargetTexture[i], &renderTargetViewDesc, &RT_renderTargetView[i]);
		if (FAILED(result))
		{
			return false;
		}
	}

	// Setup the description of the shader resource view.
	shaderResourceViewDesc.Format = textureDesc.Format;
	shaderResourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
	shaderResourceViewDesc.Texture2D.MostDetailedMip = 0;
	shaderResourceViewDesc.Texture2D.MipLevels = 1;


	// Create the shader resource view.
	for (int i = 0; i < MRT_BUFFER_COUNT; i++)
	{
		result = d3d11Device->CreateShaderResourceView(RT_renderTargetTexture[i], &shaderResourceViewDesc, &RT_shaderResourceView[i]);
		if (FAILED(result))
		{
			return false;
		}
	}

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement