aligning pixels to texels

asmatic

Newcomer
Hi

I'm trying to render an image as a d3d texture and apply post processing filters with pixel shaders.

I use already transformed coordinates for my vertex data:
Code:
TVertex quad[] ={ 
        //x              y              z    rhw   u  v
        {0.0f-0.5f,           0.0f-0.5f,          .5f, 1.0f, 0, 0},
        {(float)m_width-0.5f, 0.0f-0.5f,          .5f, 1.0f, 1, 0},
        {0.0f-0.5f,           (float)m_heigh-0.5f, .5f, 1.0f, 0, 1},
        {(float)m_m_width-0.5f, (float)m_heigh-0.5f, .5f, 1.0f, 1, 1},
    };

As you can see I create a tranformed quad wit the same height and widht than the image i want to draw.
The vertex coordinates are biased by -0.5 and -0.5 (As indicated in the DirectX SDK) in order to aling the pixel centers to the texel centers.

texture sampler state magfilter & minfilter are set to D3DTEXF_POINT

I'm using this texture to test if pixel/textel are aligned:
16x16.jpg
(this image has been resized to make it morevisible, the original is 16x16)

When I debug the default pixel shader (no transform at all, only sample texture and return that value)i'm obtaining for the first row green values, or reading red values 2 times .

It seems like the pixel/texels are not centered. I also noticed that te V component of a texel coordinate can change from texel to texel even in the same row.

Anyone have any clue of how to align properly the pixels? or what am I doing wrong?

thanks
 
OOOps I think my problem is that the shader fills the pixels in an order diferent as the one i was expecting...

I was thinking that the pixels enter to the shader in row order:

(1) (2) (3) (4)
(5) (6) (7) ...

but instead they enter in "triangle order"

(1) (2) (5) (7)
(3) (4) (8 ) (9)
(6) (10) (13) (14)
(11) (12) (15) (16)

Sorry, it seems my pixel/texel are aligned but i was misinterpreting the data
:p
 
Back
Top