Sign in to follow this  
OliverSharpe

DirectX 10 Render targets

Recommended Posts

I'll admit it, I haven't had much experience with render targets, but trying to go through the DX10 SDK samples and NVIDIA samples to learn how to use them is driving me nuts. I've used them only a couple times in XNA before, so I am not entirely familiar with the steps needed to use them. What I'm trying to do is create a simple post process effect that takes a rendered screen and modulates or adds to the red channel. I'm only doing this as practice, as I would very much like to create a gaussian blur and depth of field effect all on my own. Is there a simple way to get render targets working? Theory/steps would work just as well as code examples, as I would like to make a reusable class that I could use to make my other post process effects from. Currently I'm trying to draw a full screen quad using a sprite, which worked in XNA, but would it be better to use a basic textured quad in DirectX 10?

Share this post


Link to post
Share on other sites
Here's the d3d basic tutorial, which includes creating a render target:

http://msdn.microsoft.com/en-us/library/ee416436(VS.85).aspx

The meat of it is:


hr = g_pd3dDevice->CreateRenderTargetView( pBackBuffer, NULL, &g_pRenderTargetView );


And setting the current render target:


g_pd3dDevice->OMSetRenderTargets( 1, &g_pRenderTargetView, NULL );

Share this post


Link to post
Share on other sites
Okay, thanks!

I'm also having trouble acquiring the texture, right now I'm doing some crazy thing trying to get the resource from the render target and convert it to a Texture2D that I can pass to the shader. Obviously this is not a good method and it certainly isn't working.

In XNA it was really simple to just acquire the render target texture, there has to be a way to do this in DirectX 10, but I just can't find it!

Share this post


Link to post
Share on other sites
CreateRenderTargetView takes the texture as its first argument, so you should already have the texture there..

You'll need to make a shader resource view for the texture so you can bind it to a shader

create a D3D10_SHADER_RESOURCE_VIEW_DESC and call CreateShaderResourceView() on the device to create a ID3D10ShaderResourceView, which you can bind to an effect like:


effect->GetVariableByName("tex")->AsShaderResource()->SetResource( texShaderResource );

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this