# Texture glitch when using simple pixel shader

I have an issue with rendering my textures in Silverlight. When I look at it from above everything looks fine:

But if I only change angle of watching it it looks terrible:

I am using very simple pixel shader (hlsl):

float4 main(VsOutput vertex) : COLOR
{
float4 texColor = tex2D(textureSampler, texCoord);

return texColor;
}


If I don' t use that pixel shader and load texture via BasicEffect like:

BasicEffect.texture = myTexture


I expect that it might be somehow connected with mipmapping, but I am not sure - my texture is pretty small so I guess it shouldn' t have such a big effect. Anyway I need some advices :).

• I think you need anisotropic texture sampling – Alan Wolfe Sep 10 '15 at 14:01
• Please attach your shader completely, it's variable definition I mean, may be you need to define a High precision or mid precision variable instead of lowp – Iman Sep 10 '15 at 14:29
• It migh be an issue with the texture filtering you're using. Which filter is it? Point, bilininear, trilinear? Also, make sure you did compute the correct mipmaps for the texture. – glampert Sep 10 '15 at 18:22
• @AlanWolfe You were right! I will add some proper answer - hope you don' t mind :) Lman I am using floats everywhere, but suggestion above solved the problem anyway. Glampert As I sad I think I don't compute mipmaps at all (I think because it might be done by default somewhere, but I don' t know about it :) I used "LinearWrap" sampler state if that's what you mean – bartosz.baczek Sep 11 '15 at 6:11

So I followed Alan Wolfe suggestion (in comment to my question) And turned out he was right. I was using SamplerState.LinearWrap and that was the issue. When I changed this to AnisotropicWrap it looked much better. Below are some examples of different sampling types and how they affect texture:
graphicsDevice.SamplerStates[0] = SamplerState.PointWrap;

graphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;

graphicsDevice.SamplerStates[0] = SamplerState.AnisotropicWrap;