Jump to content
  • Advertisement
Sign in to follow this  
brega

[dx9] FSQuad texel pixel alignment

This topic is 2808 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

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
Advertisement
Just keep in mind that by using pretransformed vertices (D3DDECLUSAGE_POSITIONT) your vertex shader will be skipped entirely, so you can't do the offsetting in a vertex shader.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!