Sign in to follow this  
Xmon

Screen filling quad

Recommended Posts

Xmon    136
What is the best way to create a quad that should cover the whole render target and never move; its vertex shold be positioned in the corners and it should be passed through shaders?

Share this post


Link to post
Share on other sites
Armadon    1091
a Simple sprite should do it with the width and height of the backbuffer.
Look into The ID3DXSprite interface for Native DirectX and the Sprite class for Managed DirectX. Sprites are rendered in screen space and won't be affected by transformations so they won't move unless you really want them to.

You could also opt to go for a simple polygon made up of 2 triangles and position that accordingly.

I hope this helps.
Take care.

Share this post


Link to post
Share on other sites
Xmon    136
Quote:
Original post by Armadon
a Simple sprite should do it with the width and height of the backbuffer.
Look into The ID3DXSprite interface for Native DirectX and the Sprite class for Managed DirectX. Sprites are rendered in screen space and won't be affected by transformations so they won't move unless you really want them to.

You could also opt to go for a simple polygon made up of 2 triangles and position that accordingly.

I hope this helps.
Take care.


Can I have the shaders to render the sprites?

Share this post


Link to post
Share on other sites
Xmon    136
Quote:
Original post by haegarr
The DirectX9 SDK tutorial named "Real-Time shadowing" does render a full screen quad. Maybe it is suitable for your purpose.


I did'nt found that. I just found "ShadowMap Sample" and "ShadowVolume Sample" is it any of them?

Share this post


Link to post
Share on other sites
Armadon    1091
Yes, you can use pixel shaders to render a sprite. It all depends on what states you set as a sprite will handle most (default) states itself such as T&L in some cases as it needs to be able to rotate itself to always be visible. but you could change that using some simple flags.

The simple answer is yes.

I hope this helps.
Take care.

[Edited by - Armadon on November 12, 2005 7:12:14 AM]

Share this post


Link to post
Share on other sites
Xmon    136
Quote:
Original post by Armadon
Yes, you can use pixel shaders to render a sprite. It all depends on what states you set as a sprite will handle some states itself such as T&L in some cases as it needs to be able to rotate itself to always be visible. but you could change that using some simple flags.

The simple answer is yes.

I hope this helps.
Take care.


Should I set the technique whit "VertexShader = NULL;"? I did'nt mentioned this but I also nead to know the position of the pixel on the screen sience I blend it whit a texture, can I do that whit a sprite?

Share this post


Link to post
Share on other sites
haegarr    7372
Quote:
Original post by Xmon
Quote:
Original post by haegarr
The DirectX9 SDK tutorial named "Real-Time shadowing" does render a full screen quad. Maybe it is suitable for your purpose.


I did'nt found that. I just found "ShadowMap Sample" and "ShadowVolume Sample" is it any of them?


Must be the "ShadowVolume Sample", since only those uses stencil buffering. However, here follows the snippet I mean:

Here a "ShadowVertex" array is build to cover the entire back buffer:

//Get the width & height of the back-buffer.
LPDIRECT3DSURFACE9 pBackBuffer = NULL;
D3DSURFACE_DESC d3dsd;
Device->GetBackBuffer( 0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer );
pBackBuffer->GetDesc( &d3dsd );
pBackBuffer->Release();
float sx = (float)d3dsd.Width;
float sy = (float)d3dsd.Height;

// Set the size of the big square shadow
ShadowVertex *v;

m_pBigSquareVB->Lock( 0, 0, (void**)&v, 0 );
{
v[0].p = D3DXVECTOR4( 0, sy, 0.0f, 1.0f );
v[1].p = D3DXVECTOR4( 0, 0, 0.0f, 1.0f );
v[2].p = D3DXVECTOR4( sx, sy, 0.0f, 1.0f );
v[3].p = D3DXVECTOR4( sx, 0, 0.0f, 1.0f );
v[0].color = 0x7f000000;
v[1].color = 0x7f000000;
v[2].color = 0x7f000000;
v[3].color = 0x7f000000;
}
m_pBigSquareVB->Unlock();


Notice the determination of sx and sy, and the later use as co-ordinates of a quad.

Share this post


Link to post
Share on other sites
Xmon    136
I was thinking of using D3DFVF_XYZW as the FVF flag, and just let the vertex position go through the vertex shader whitout transforming them. Is this approach corect and what values should I assign the vertex?

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