# How to fix odd artifacts at the edges of textures in DirectX 11?

In my DirectX 11 project, when I have textures they have odd artifacts at the edges. I've seen it before and searched online, but I can't find any DirectX examples that I can get to work.

You can see it on the skybox too. I'm assuming this is caused because the texture is too small and it's being expanded. I'm using the sampler state filter D3D11_FILTER_MIN_MAG_MIP_LINEAR. How can I fix this?

I'm pretty certain this has to do with Texture addressing. If you could post the sampler state part of your shader then I'd could rule that out. Also is this a texture atlas (many used images stored in 1 texture)?

Texture addressing handles regions outside of the 0.0 to 1.0 range. When filtering other than point is applied the rendered texture will use nearby texture addresses. In the case of edges this means using a texture coordinate outside of the 0.0 to 1.0 range.

To change it simply set the addressing mode in your sampler state. Microsoft states that the default is Clamp which should eliminate this problem but I would set it in your hlsl sampler state and test it.

Edit: Here I was able to replicate your issue in Direct3d 9 simply commenting two lines out

sampler2D colorMap = sampler_state
{
Texture = <texture0>;
MagFilter = Linear;
MinFilter = Anisotropic;
MipFilter = Linear;
MaxAnisotropy = 16;
};


Here is a comparison image. Code commented out on left (thus AddressU and V set to default state) and AddressU and V set in sampler2d to Clamp in right. Sorry if the image is slightly off. This is a skybox in the background and I had to zoom it 2.5x nearest neighbor after printscreen to make it easier to see the white line.

• Oh, thank you! I was using Wrap, not Clamp, and now it works. Jan 6, 2012 at 19:55