• Advertisement
Sign in to follow this  

Render Target isn't rendering scene objects for post processing effects.

This topic is 1390 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

Hey everyone, I am trying to understand this issue I'm having with render target I've created for post process effects. What I can understand about rendering to texture is that you:

 

  1. Render the scene to the render target.
  2. Switch back to default back buffer.
  3. Render the scene.
  4. Render the quad for 2D rendering.

I've cleared the rendertarget for post processing to black then blue and it does change accordingly what I clear the render target for. However, it doesn't render out any scene meshes inside the render target like it should. I've followed raster tek's example and brayansoft example as well. I'll have a look at the code tomorrow.

 

I've looked at the render target texture description and changed it from DXGI_FORMAT_R32G32B32A32_FLOAT to match the backbuffer texture description. It's still not rendering any scene objects.

 

Would I have to make a copy resource of the backbuffer texture description for the render target? How would I go about fixing this issue? Thanks!

 

For clarification... Say if I load a ball inside the level. The back buffer will distplay the ball but not the render target. The render target will be the color I cleared it to. Hope this clarifies things up.

Share this post


Link to post
Share on other sites
Advertisement
Do you have a depth buffer for that render target? Is depth-testing off?
What does PIX/Visual Studio 2013/your graphics-debugger-of-choice tell you?


L. Spiro

Share this post


Link to post
Share on other sites

Do you have a depth buffer for that render target? Is depth-testing off?
What does PIX/Visual Studio 2013/your graphics-debugger-of-choice tell you?


L. Spiro

depth is disabled for rendering the quad then re-enabled for normal rendering after it's done doing the 2D quad. 

 

When started for now - the quad shows black indicating no texture has been applied. This won't show up in the main editor but only for me during the development in process.

[sharedmedia=core:attachments:20745]

 

When the mesh is loaded. The quad is color I set it to. However, the backbuffer still displays the mesh but the render target doesn't render anything.

[sharedmedia=core:attachments:20746]

 

Also, alphablending is disabled. If I wanted the quad to display an image file then it'll be fine. If the snipplet of code will help then great. Also, I can't use PIX because it crashes everytime I try. The reason why I think is because I imported my functions from C++ to C# and the editor is inside C# language.

 

I looked over the code again and I believe that nothing is getting passed to the render target just a beautiful blue square. I looked over and made sure the render target wasn't being initialized no where else and it wasn't. So, perhaps it's the creation of the shader resource view for the render target?

Share this post


Link to post
Share on other sites

What I think is going on is the render target is successfully set but the texture applied to the render target is just showing up blue and not the mesh or any of the screen objects. A brief snipplet:

_declspec(dllexport) bool createRenderTarget() {
	
	HRESULT result = S_OK;

	D3D11_TEXTURE2D_DESC textureDesc;
	D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDesc;
	D3D11_SHADER_RESOURCE_VIEW_DESC shaderResourceViewDesc;

	///////////////////////// Map's Texture
	// Initialize the  texture description.
	ZeroMemory(&textureDesc, sizeof(textureDesc));

	
	// Setup the texture description.
	// We will have our map be a square
	// We will need to have this texture bound as a render target AND a shader resource
	textureDesc.Width = m_TextureWidth; //-- Gloabl Texture Height and Texture Width varables.
	textureDesc.Height = m_TextureHeight;
	textureDesc.MipLevels = 1;
	textureDesc.ArraySize = 1;
	textureDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; //-- This is what the backbuffer is created when DirectX is initialized. 
	textureDesc.SampleDesc.Count = 1;
	textureDesc.SampleDesc.Quality = 0;

	textureDesc.Usage = D3D11_USAGE_DEFAULT;
	textureDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
	textureDesc.CPUAccessFlags = 0;
	textureDesc.MiscFlags = 0;

	// Create the texture
	result = dev->CreateTexture2D(&textureDesc, NULL, &renderTargetTextureMap);
	if (FAILED(result)) {
		MessageBox(0, L"Unable to create render target texture!", L"Render Target failed!", 0);
		return false;

	}
	/////////////////////// Map's Render Target
	// Setup the description of the render target view.
	ZeroMemory(&renderTargetViewDesc, sizeof(renderTargetViewDesc));
	
	renderTargetViewDesc.Format = textureDesc.Format;
	renderTargetViewDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
	renderTargetViewDesc.Texture2D.MipSlice = 0;

	// Create the render target view.
	result = dev->CreateRenderTargetView(renderTargetTextureMap, &renderTargetViewDesc, &renderTargetViewMap);
	if (FAILED(result)) {
		MessageBox(0, L"Unable to create render target.", L"Render Target failed!", 0);
		return false;
	}
	// Setup the description of the shader resource view.
	ZeroMemory(&shaderResourceViewDesc, sizeof(shaderResourceViewDesc));

	shaderResourceViewDesc.Format = textureDesc.Format;
	shaderResourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
	shaderResourceViewDesc.Texture2D.MostDetailedMip = 0;
	shaderResourceViewDesc.Texture2D.MipLevels = 1;

	// Create the shader resource view.
	result = dev->CreateShaderResourceView(renderTargetTextureMap, &shaderResourceViewDesc, &shaderResourceViewMap);
	if (FAILED(result)) {
		MessageBox(0, L"Unable to create Render Target.", L"Render Target Failed!", 0);
		return false;
	}

	return true;

}

As for the quad rendering it uses the shaderResourceShaderMap. If I load a normal texture - it will be fine; however when I attempt to load what the render target has rendered out to the shaderResourceViewMap then it display blue quad. Inside the shader for the quad I just have it return the texture sample.

 

Perhaps inside the rendering loop of the quad I have to obtain the address for the shader resource view?

Share this post


Link to post
Share on other sites

This is in no way of an improvement. Inside the rendering loop - where I render the scene inside the render target I created a new camera. So, which is why I have this issue now.

Share this post


Link to post
Share on other sites

the render target is blue just like the back buffer however, just some how I am moving the (monster - that's not created by me) around as if it was a 2D Texture. So, I'm a bit confused.

Share this post


Link to post
Share on other sites

I looked through the debug flags and there seems to be a mismatch between the back buffer and the render target. It complained about the sample quality being different. In the back buffer I'm using a count of 8 and quality of 32 on a DXGI_FORMAT_D24_S8_UINT. On the render target I'm using DXGI_FORMAT_R32G32B32A32_FLOAT with 1 count and 0 quality. When I make the count and quality an same as back buffer - I get returned a invalid argument was passed. So, something is correctly filled out right.

 

I'm still plugging away at this.

Share this post


Link to post
Share on other sites

Issue is fixed - just had to make backbuffer and the swap chain to count 1 and quality 0. I wanted high multisampling ablities. For now I'll leave it like this but I want to be able to change it in the near future back to where it was without any issue. Any feedback would be great.

Share this post


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

  • Advertisement