• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
korvax

Render rendertargets.

13 posts in this topic

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;
}

 

 

0

Share this post


Link to post
Share on other sites

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...?

2

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.

0

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 :/

0

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.
1

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?

0

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 [i]before[/i] you attach it elsewhere. The debug layer will also report this very clearly (if enabled at device creation).

1

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;
}

 

 

0

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.
1

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]

0

Share this post


Link to post
Share on other sites
When you want to use the rendertargets as a texture to read from you need to unbind the rendertargetviews for them and reset this to the actual backbuffer the one you want to show on screen.

Before you set your render targets you want to call this function http://msdn.microsoft.com/en-us/library/windows/desktop/ff476460%28v=vs.85%29.aspx and once you are done rendering to these targets you call OMSetRenderTargets again and pass it the information the function call in the link gives you.
1

Share this post


Link to post
Share on other sites

When you want to use the rendertargets as a texture to read from you need to unbind the rendertargetviews for them and reset this to the actual backbuffer the one you want to show on screen.

Before you set your render targets you want to call this function http://msdn.microsoft.com/en-us/library/windows/desktop/ff476460%28v=vs.85%29.aspx and once you are done rendering to these targets you call OMSetRenderTargets again and pass it the information the function call in the link gives you.

 

I manged to get it work and but even better i full understand it want im doing as well   Thx so much for you help NightCreature83.

 

I havent got the GetRenderTargets -> SetRenderTargets to work, think i need to do some reading about ** to * i guess.  But thx again for you help!

0

Share this post


Link to post
Share on other sites
Thats an easy fix just put a & in front of the variable you are passing to getRenderTargets, as like this (pseudo code for your problem)
void function(int** var);

//This is then called as this
int* anotherVar;
function(&anotherVar);

0

Share this post


Link to post
Share on other sites

HI again, sorry for this NightCreateure83 (or anyone else :) just one more thing. 

I got it to work as i wrote before, but im getting some warnings that i would like to get ride off. I gueesing im not resting the them correctly or that im doing it in the wrong order.

 

 * D3D11 WARNING: ID3D11DeviceContext::DrawIndexed: The Pixel Shader expects a Render Target View bound to slot 1, but none is bound. This is OK, as writes of an unbound Render Target View are discarded. It is also possible the developer knows the data will not be used anyway. This is only a problem if the developer actually intended to bind a Render Target View here. [ EXECUTION WARNING #3146081: DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET]
 
* D3D11 WARNING: ID3D11DeviceContext::OMSetRenderTargets: Resource being set to OM RenderTarget slot 1 is still bound on input! [ STATE_SETTING WARNING #9: DEVICE_OMSETRENDERTARGETS_HAZARD]
 
* D3D11 WARNING: ID3D11DeviceContext::OMSetRenderTargets[AndUnorderedAccessViews]: Forcing PS shader resource slot 0 to NULL. [ STATE_SETTING WARNING #7: DEVICE_PSSETSHADERRESOURCES_HAZARD]
 
 
My order.
 
1) Setting all rendertargets, there are two off them the main output and one with normals that Im rendering to a Quad.
void PipelineManagerDX11::SetRenderTargetView(TArray<ID3D11RenderTargetView*> renderTargets,ID3D11DepthStencilView* pDepthStencilView)
{
	m_RenderTargets = renderTargets;	
	m_pDepthStencilView = pDepthStencilView;
	UINT nViews = m_RenderTargets.count();
	ID3D11RenderTargetView*	rtvs[2];	
	for (UINT i= 0; i<nViews;++i){	
		rtvs[i] = m_RenderTargets[i];
	}
	m_pContext->OMSetRenderTargets(nViews,rtvs,m_pDepthStencilView);	
}
 

 

2) Render the scene 

 

3) Resting the Rendertarget, setting Rendertarget 2 to null so i can use the the texture and Setting render target 1 to the device.

 

ID3D11RenderTargetView* rTargets[2] = {m_RenderTargets[0], NULL };
m_pContext->OMSetRenderTargets(2, rTargets, NULL);

 

4) rendering the quad with Shaderview bound to the texture that Rendertarget 2 is using.

 

m_pContext->PSSetShaderResources(0, 1, &m_pShaderResourceView);		
m_pContext->VSSetShader(m_pVertexShader, NULL, 0 );
m_pContext->PSSetShader(m_pPixelShader, NULL, 0);
m_pContext->DrawIndexed(m_QuadIB->m_numIndices,0,0);


 

5) Setting all the rendertargets as i did in step one.

 

SetRenderTargetView(m_RenderTargets,m_pDepthStencilView);

 

6) Ending the pipeline with the usual stuff, clearing all the renderingtargets, swaping the backbufffer, present etc.

 

 

 

 
 
Stupied me, this I already knew :), thx anyway!

 

Thats an easy fix just put a & in front of the variable you are passing to getRenderTargets, as like this (pseudo code for your problem)

void function(int** var);

//This is then called as this
int* anotherVar;
function(&anotherVar);

 

0

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  
Followers 0