Jump to content
  • Advertisement
Sign in to follow this  
_Flecko

Texture precision

This topic is 4729 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'm working with 2D using textured quads and am having some difficulty getting images to display precisely. If I turn off texture filtering, the images are displayed perfectly, but look terrible when rotated and scaled. If I use texture filtering then the images show artifacts. For example: Notice that the one on the right has a darkened border on the top and left. It was drawn with texture filtering on, and as a result the right and bottom wrap around a bit to the left and top. Of course, the one on the left is pixel-perfect now, but if I rotated it it would look pretty bad. This quad in particular uses an entire image file, so the vertices' texture coordinates are just (0,0) to (1,1) - can't really get any more precise there. Is there anything I can do? Thanks, Max [Edited by - _Flecko on June 12, 2005 11:10:04 PM]

Share this post


Link to post
Share on other sites
Advertisement
A couple of things to check out:

1) Mapping texels to pixels:
http://www.gamedev.net/community/forums/topic.asp?topic_id=325372

Also check the topic in the DirectX SDK docs:
DirectX Graphics ->
Programming Guide ->
Getting Started ->
Direct3D Textures ->
Texture Coordinates ->
Directly Mapping Texels to Pixels


2) Try setting the D3DSAMP_ADDRESSU and D3DSAMP_ADDRESSV sampler states to D3DTADDRESS_CLAMP


There are a couple of issues to think about:

a) the position of a pixel in D3D represents its centre rather than a corner - if you don't take that into account, assuming no anti-aliasing, the rasterizer will miss out some texels in cases where a pixel at outer the edge of the polygon is ever so slightly off-centre.

b) with bilinear filtering, the average of texels around the sample is taken - consider what happens when the sample point is right at an extreme edge of the texture map and the hardware needs to get a sample to the right of that... That's what the address mode affects - if you have the address mode set to WRAP, then the sample for the filter will come from the *opposite* side of the texture map; the CLAMP address mode ensures that any samples from outside the extremities of the map are clamped to the nearest edge rather than the opposite edge.

Share this post


Link to post
Share on other sites
Awesome, wish I'd know this a long time ago. Draw calls for my graphics library are recursive and the public call passes an initial transformation to the private recursive call, so all I had to do was pass a (-0.5,-0.5,0) transformation instead of Matrix.Identity :P

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!