Advertisement Jump to content
Sign in to follow this  
kgstation

Need HELP!Question about Post processing.

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

I followed D3D Post Processing sample in windows 8.1.

And I have successfully rendered my object with post processing effect.

But now I met a problem.I have many objects to render.I want only a part of objects rendered with post processing effect.I know this problem is about rendertarget.But I don't know how to deal with it.

Following is my code:

void D3DPostProcessing::DrawWithoutPostProcessing()
{
	m_d3dContext->OMSetRenderTargets(1, m_d3dRenderTargetView.GetAddressOf(), m_d3dDepthStencilView.Get());
	const float clearColor[4] = { 0.071f, 0.040f, 0.561f, 1.0f };
	m_d3dContext->ClearRenderTargetView(m_d3dRenderTargetView.Get(), clearColor);
	m_d3dContext->ClearDepthStencilView(m_d3dDepthStencilView.Get(), D3D11_CLEAR_DEPTH, 1.0f, 0);
	m_d3dContext->IASetInputLayout(m_inputLayout.Get());

	unsigned int stride = sizeof(VertexPNTTBI);
	unsigned int offset = 0;

	m_d3dContext->IASetVertexBuffers(0, 1, mYHMMesh.Geometry[0].VertexBuffer.GetAddressOf(), &stride, &offset);
	m_d3dContext->IASetIndexBuffer(mYHMMesh.Geometry[0].IndexBuffer.Get(), DXGI_FORMAT_R16_UINT, 0);
	m_d3dContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
	m_d3dContext->VSSetShader(m_vertexShader.Get(), nullptr, 0);
	m_d3dContext->VSSetConstantBuffers(0, 1, m_constantBuffer.GetAddressOf());
	// set the pixel shader stage state
	m_d3dContext->PSSetShader(m_pixelShader.Get(), nullptr, 0);
	m_d3dContext->PSSetShaderResources(0, 1, mYHMMesh.Geometry[0].textureSVR.GetAddressOf());
	m_d3dContext->PSSetSamplers(0, 1, m_sampler.GetAddressOf());
	m_d3dContext->DrawIndexed(mYHMMesh.Geometry[0].IndexCount, 0, 0);
}

void D3DPostProcessing::DrawPostProcessing()
{
	m_d3dContext->OMSetRenderTargets(1, m_intermediateTextureRenderTargetView.GetAddressOf(), m_d3dDepthStencilView.Get());
	const float clearColor[4] = { 0.071f, 0.040f, 0.561f, 1.0f };
	m_d3dContext->ClearRenderTargetView(m_intermediateTextureRenderTargetView.Get(), clearColor);
	m_d3dContext->ClearDepthStencilView(m_d3dDepthStencilView.Get(), D3D11_CLEAR_DEPTH, 1.0f, 0);
	m_d3dContext->IASetInputLayout(m_inputLayout.Get());

	unsigned int stride = sizeof(VertexPNTTBI);
	unsigned int offset = 0;

	m_d3dContext->IASetVertexBuffers(0, 1, mYHMMesh.Geometry[0].VertexBuffer.GetAddressOf(), &stride, &offset);
	m_d3dContext->IASetIndexBuffer(mYHMMesh.Geometry[0].IndexBuffer.Get(), DXGI_FORMAT_R16_UINT, 0);
	m_d3dContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
	m_d3dContext->VSSetShader(m_vertexShader.Get(), nullptr, 0);
	m_d3dContext->VSSetConstantBuffers(0, 1, m_constantBuffer.GetAddressOf());
	// set the pixel shader stage state
	m_d3dContext->PSSetShader(m_pixelShader.Get(), nullptr, 0);
	m_d3dContext->PSSetShaderResources(0, 1, mYHMMesh.Geometry[0].textureSVR.GetAddressOf());
	m_d3dContext->PSSetSamplers(0, 1, m_sampler.GetAddressOf());
	// Save the backbuffer viewport
	D3D11_VIEWPORT oldViewPort[1];
	unsigned int numberOfViewPorts = 1;
	m_d3dContext->RSGetViewports(&numberOfViewPorts, oldViewPort);
	// Setup the viewport to match the Intermediate Render Target
	D3D11_VIEWPORT viewPort = { 0 };
	viewPort.Width = static_cast<float>(m_intermediateRenderTargetWidth);
	viewPort.Height = static_cast<float>(m_intermediateRenderTargetHeight);
	viewPort.MinDepth = 0.0f;
	viewPort.MaxDepth = 1.0f;
	viewPort.TopLeftX = 0;
	viewPort.TopLeftY = 0;
	m_d3dContext->RSSetViewports(1, &viewPort);
	m_d3dContext->DrawIndexed(mYHMMesh.Geometry[0].IndexCount, 0, 0);
	// Restore the backbuffer viewport
	m_d3dContext->RSSetViewports(numberOfViewPorts, oldViewPort);
	BrightPassDownFilter();
	RenderGlow();
	CombineGlow();
}

In my code, both object rendered with post processing effect.Before rendering a post processing effect, I want to render one object that without post processing effect.

Any help would be appreciated.Thanks.

And this is my full code[attachment=20537:FullCode.rar]

Share this post


Link to post
Share on other sites
Advertisement

There are different ways to go.

1. use the stencil buffer to mask objects (eg only masked objects will be touched by the post-processing.

2. use different passes: renderObjectsOfTypeA => postProcessing => renderObjectsOfTypeB

3. use different render targets: renderObjectOfTypeA to renderTarget1 and renderTarget2, renderObjectOfTypeB to renderTarget1 only, do postprocesssing on renderTarget2 only

 

You need to check, which way is the best for your issue.

Share this post


Link to post
Share on other sites

But generally post-processing, as the name implies is a post processing effect that works on images. Generally it is not geometry aware.

 

I can't think of one post-processing effect of the top of my head that I wouldn't want to either apply on the full scene, or apply it on a full scene but using a stencil mask.

 

Maybe if you tell us how you want your scene to look with one object not rendered with post-processing and the rest with we can get a better idea of what you are trying to do.

 

But in the meanwhile, what happens if you render your scene sans the problematic object, do post processing, render the full screen quad to the screen without Z-write and without clearing your depth buffer and back buffer you render your problematic object?

Share this post


Link to post
Share on other sites

There are different ways to go.

1. use the stencil buffer to mask objects (eg only masked objects will be touched by the post-processing.

2. use different passes: renderObjectsOfTypeA => postProcessing => renderObjectsOfTypeB

3. use different render targets: renderObjectOfTypeA to renderTarget1 and renderTarget2, renderObjectOfTypeB to renderTarget1 only, do postprocesssing on renderTarget2 only

 

You need to check, which way is the best for your issue.

I'm using the 3rd way currently.Could you give me more detail?I do I mix these two rendertarget?

Share this post


Link to post
Share on other sites

But generally post-processing, as the name implies is a post processing effect that works on images. Generally it is not geometry aware.

 

I can't think of one post-processing effect of the top of my head that I wouldn't want to either apply on the full scene, or apply it on a full scene but using a stencil mask.

 

Maybe if you tell us how you want your scene to look with one object not rendered with post-processing and the rest with we can get a better idea of what you are trying to do.

 

But in the meanwhile, what happens if you render your scene sans the problematic object, do post processing, render the full screen quad to the screen without Z-write and without clearing your depth buffer and back buffer you render your problematic object?

 

I have a scene and several people in my scene.

People can release some skills.

I want the post processing effect only work with skills!

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!