Jump to content

  • Log In with Google      Sign In   
  • Create Account


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 SIC Games   Members   -  Reputation: 609

Like
0Likes
Like

Posted 02 April 2014 - 11:00 PM

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.


Game Engine's WIP Videos - http://www.youtube.com/sicgames88


Sponsor:

#2 L. Spiro   Crossbones+   -  Reputation: 13318

Like
1Likes
Like

Posted 03 April 2014 - 01:20 AM

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
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#3 SIC Games   Members   -  Reputation: 609

Like
0Likes
Like

Posted 03 April 2014 - 08:05 AM

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.

Snapshot 0.jpg

 

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.

Snapshot 1.jpg

 

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?

Attached Thumbnails

  • Snapshot 0.jpg
  • Snapshot 1.jpg

Game Engine's WIP Videos - http://www.youtube.com/sicgames88


#4 SIC Games   Members   -  Reputation: 609

Like
0Likes
Like

Posted 03 April 2014 - 08:52 AM

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?


Game Engine's WIP Videos - http://www.youtube.com/sicgames88


#5 SIC Games   Members   -  Reputation: 609

Like
0Likes
Like

Posted 04 April 2014 - 07:23 PM

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.

Attached Thumbnails

  • Snapshot 0.jpg

Game Engine's WIP Videos - http://www.youtube.com/sicgames88


#6 SIC Games   Members   -  Reputation: 609

Like
0Likes
Like

Posted 04 April 2014 - 07:26 PM

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.


Game Engine's WIP Videos - http://www.youtube.com/sicgames88


#7 SIC Games   Members   -  Reputation: 609

Like
0Likes
Like

Posted 04 April 2014 - 09:41 PM

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.


Game Engine's WIP Videos - http://www.youtube.com/sicgames88


#8 SIC Games   Members   -  Reputation: 609

Like
0Likes
Like

Posted 04 April 2014 - 10:02 PM

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.


Game Engine's WIP Videos - http://www.youtube.com/sicgames88





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS