Sign in to follow this  

Problem with displaying of texels exactly to pixels

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

We use Direct3D 8 with orthogonal projection to realize 2D as Microsoft recommends instead of old DirectDraw. We need to exactly display in scale 1:1 texture to the screen. Exactly texels to screen pixels. We've read "Directly Mapping Texels to Pixels" article in Microsoft's DirectX SDK, but however rendered image a little bit blurred and not exactly responds to original photography. Also I've tried Microsoft's example 2D over 3D and their example doesn't provide exactly assigning of pixels! What's a strange thing? Moreover we've read in one Microsoft's article that they even recommend to enlarge image and then reduce and it will give exact sharpness. Sounds incredible. We work with low level Direct3D API without using of additional and large d3dx9.lib which increases size of EXE file. Please advice us or if it possible give us URLs to ready examples.

Share this post


Link to post
Share on other sites
I just found that another member in this forum asked for exactly this problem (blurring and artefacts), but without answer. Here is his question:

"Read this article when trying to achieve pixel-per-pixel mapping for my GUI... and spend a whole lot of time figuring out how it would work. I had a basic D3D8 setup, but I did want to keep my DirectX transformation matrices (orthogonal of course) instead of using TLVERTICES, in order to be able to move windows without locking the vertex buffer etc. . With the method from the MSDN article ("Directly Mapping Texels to Pixels"), it did not really work - my test picture (pixel grid) still was very blurred and showed artifacts. After several hours I came to the idea to turn off filtering when loading the texture :-)

The blur was no longer there, but there were still visible artifacts - double top and left borders and some problems in the middle. Offsetting the vertices by 0.5 pixels horizontally to the left and vertically to the top only fixed the borders, after some trying out I managed to get a pixel-perfect copy of my grid by using following offsets: -0.75 horizontal, -0.85 vertical (No shrinking/expanding of the rectangle as recommended by the "microsoft bug" guys). This is kind of strange and I'd like to know how these numbers come along - I tried it with other values and there were artifacts - has anyone of you experienced sth. like that or what method for achieving pixel-perfect mapping did/did not work for you? BTW, in the blit demo, the sprites 1-4 are identical for me as well. My gfx card is a TNT2, I run WXP with DX 8.1 (latest nVidia drivers)."

Share this post


Link to post
Share on other sites
If I were you I'd either use transformed vertices (with this ones you set it's pixel position) or use this to build the camera matrix.
I never tried the later method but I suppose it would work fine as long as you set it's parameters to be the same size as the backbuffer.

i.e.

D3DXMATRIX matView;
D3DXMatrixOrthoOffCenterRH( &matView,
-(float)backbuffer.width / 2.0f,
(float)backbuffer.width / 2.0f,
-(float)backbuffer.height / 2.0f,
(float)backbuffer.height / 2.0f,
nearClipPlane, farClipPlane
);

Share this post


Link to post
Share on other sites

This topic is 4556 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.

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