Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

Example

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?

share|improve this question
add comment

1 Answer 1

up vote 7 down vote accepted

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>;
    //AddressU = Clamp;
    //AddressV = Clamp;
    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.

Clamping on and off

See: D3D11_TEXTURE_ADDRESS_MODE enumeration

share|improve this answer
    
Oh, thank you! I was using Wrap, not Clamp, and now it works. –  smoth190 Jan 6 '12 at 19:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.