Jump to content
  • Advertisement
Sign in to follow this  
korvax

Render rendertargets.

This topic is 2057 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,

im currently exprementing and trying to learn about buffers/gbuffers and using diffrent rendering targets.

So my question is how do i texture that quad with render target 1 as a texture. All the help i verry much appreacheated.

 

struct PSOutput
{
	float4 Color : SV_Target0;
	float3 Normal : SV_Target1;
};


PSOutput main(PS_INPUT input) 
{
	PSOutput output;
	output.Color = diffuse*txDiffuse.Sample(samLinear, input.texcoord);;
	output.Normal = input.normal;
	return output;
}

 

 

Share this post


Link to post
Share on other sites
Advertisement

You can simply assign the rendertarget as an input texture, like you would do with any other texture. I suppose you have some issue with that...?

Share this post


Link to post
Share on other sites

To be honest, im not even sure where to start. I use ShaderResourceViews as for more "normal" texture.. Im quiet green to DX.

Share this post


Link to post
Share on other sites

Oh, didn't read you was DX11, thats not quite my buisness, sorry! But can't you create a ShaderResourceView from your rendertarget? Unless D3D11 changed handling of rendertarget dramatically they should qualify here as well. If thats not the case, I'd have to pass :/

Share this post


Link to post
Share on other sites
In D3D11 you create the texture you want to use as a render target and CreateRenderTargetView. If you then want to use it as a normal texture as well you create a normal CreateShaderResourceView with the same texture. Just make sure you don't use the views at the same time in one present loop.

Share this post


Link to post
Share on other sites

Thx NightCreature83 that make seens actually. Will see if i can get it to work next week.

What do you men dont use the views at the same time in one present loop?

Share this post


Link to post
Share on other sites

"Present loop" sounds like you couldn't use the same resource as input and output in the same frame. This is of course wrong. What he meant is: You can't bind the same resource as input and output at the same time. (E.g. you can't sample from a texture you're also using as a render target).

The pipeline will automatically nullify such attempts, so make sure you detach a resource before you attach it elsewhere. The debug layer will also report this very clearly (if enabled at device creation).

Share this post


Link to post
Share on other sites

Ok, i think i manged to create a rendertarget and and a shaderview based on the same texture.  

But im no getting the error msg that you guys described "Resource being set to PS shader resource slot 0 is still bound on output! Forcing to NULL".. So my question now is obviously what im doing wrong now? :)

 

im using OMSetRenderTargets to set all my render targets to the device and in my shader it looks like this. 

 

struct PSOutput
{
    float4 Color : SV_Target0;
    float3 Normal : SV_Target1;
};


PSOutput main(PS_INPUT input)
{
    PSOutput output;
    output.Color = diffuse*txDiffuse.Sample(samLinear, input.texcoord);;
    output.Normal = input.normal;
    return output;
}

 

 

Share this post


Link to post
Share on other sites
If you bind either the color or normal buffer to samLinear it will not work. The problem you are now getting is probably that you forgot to reset the render target to the backbuffer when you want to read from these textures.

Share this post


Link to post
Share on other sites

If you bind either the color or normal buffer to samLinear it will not work. The problem you are now getting is probably that you forgot to reset the render target to the backbuffer when you want to read from these textures.

Sorry not quiet following you (quiet green indeed). rest the render target to the backbuffer  when you want to read form these textures, can you elaborate more pls?

 

Complete Warning:

ID3D11DeviceContext::PSSetShaderResources: Resource being set to PS shader resource slot 0 is still bound on output! Forcing to NULL. [ STATE_SETTING WARNING #7: DEVICE_PSSETSHADERRESOURCES_HAZARD]

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!