Sign in to follow this  
brega

[dx9] FSQuad texel pixel alignment

Recommended Posts

I have read this Directly Mapping Texels to Pixels
but i didnt understand it well. I want to use fsquad with simple
post processing effect (learning shaders). So if i have quad created like this:


struct Vertex
{
D3DXVECTOR3 Position;
D3DXVECTOR2 TexCoord;
};

D3DVERTEXELEMENT9 VertexElements[] =
{
{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
{0, 12, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
D3DDECL_END()
};

float p = 1.0f;
Vertex* pVertices = 0;
VertexBuffer->Lock(0, 0, (LPVOID*)&pVertices, 0);

pVertices[0].Position = D3DXVECTOR3( -p, p, p );
pVertices[1].Position = D3DXVECTOR3( p, p, p );
pVertices[2].Position = D3DXVECTOR3( p, -p, p );
pVertices[3].Position = D3DXVECTOR3( -p, -p, p );

pVertices[0].TexCoord = D3DXVECTOR2(0.0f, 0.0f);
pVertices[1].TexCoord = D3DXVECTOR2(1.0f, 0.0f);
pVertices[2].TexCoord = D3DXVECTOR2(1.0f, 1.0f);
pVertices[3].TexCoord = D3DXVECTOR2(0.0f, 1.0f);

VertexBuffer->Unlock();




how do i "offset" vertex positions to get perfect alignment on
variable screen resolutions?

vertex shader:

struct QuadInput
{
float3 Position : POSITION;
float2 TexCoord0 : TEXCOORD0;
};

struct VSOutput
{
float4 Position : POSITION;
float2 TexCoord : TEXCOORD0;
};

void VS(in QuadInput IN, out VSOutput OUT)
{
OUT.Position.x = ???;//IN.Position.x;
OUT.Position.y = ???;//IN.Position.y;
OUT.Position.z = IN.Position.z;
OUT.Position.w = ???;

OUT.TexCoord = IN.TexCoord;
}




Thanks in advance.

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