[dx9] FSQuad texel pixel alignment

Started by
1 comment, last by unbird 13 years, 6 months ago
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.
Advertisement
D3DDECLUSAGE_POSITIONT should get you there...
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.

This topic is closed to new replies.

Advertisement