Sign in to follow this  
Milleniumas

Several pixels of texture offsets

Recommended Posts

ok first of all here is the screen: Free Image Hosting at www.ImageShack.us As you can see, there is 1-2 pixels offset in every texture. Texture filter causes all this nonsences as for example: p_lpd3d9->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_ANISOTROPIC);. I havent't applied any other special filters or functions to textures. Any idea who can cause this bug? Earlier to prevent this bug I have used Render Target and then applied filter via simple shader, but now i want to sole this problem.

Share this post


Link to post
Share on other sites
It seems your rendering 2D rects, so your problem is probably that you don't set a half pixel offset in your texcoord or rect.

you need to move your rect half a pixel to the left and up, this won't cause your rect to draw pixels more to the left and up, but it will change the UV alignement with the pixels of the texture.

When you draw a rect on screen a coord of (100, 100) will put your vertex at the center of pixel (100, 100), so your UV of (0, 0) will make it fetch from half a pixel around for filtering, wich will take pixels from the other side of the texture because of the wrap. Thats why you apparently see the botom of the fence in the air.

Of course since you gave little info on what you do exactly in your code, I could be wrong...

BTW anisotropic filtering should not be used when doing 2d rendering, it's only useful when rendering something not flat on screen.

Share this post


Link to post
Share on other sites

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