Several pixels of texture offsets

Started by
1 comment, last by Milleniumas 16 years, 10 months ago
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.
Advertisement
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.
thanks, it helped :)

This topic is closed to new replies.

Advertisement