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

enter image description here

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

enter image description here

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

Everything looks fine. Why my pixel shader affects texture so bad?

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 :).

  • 6
    $\begingroup$ I think you need anisotropic texture sampling $\endgroup$
    – Alan Wolfe
    Sep 10, 2015 at 14:01
  • 1
    $\begingroup$ 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 $\endgroup$
    – Iman Nia
    Sep 10, 2015 at 14:29
  • 3
    $\begingroup$ 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. $\endgroup$
    – glampert
    Sep 10, 2015 at 18:22
  • $\begingroup$ @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 $\endgroup$ Sep 11, 2015 at 6:11

1 Answer 1


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;

enter image description here

graphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;

enter image description here

graphicsDevice.SamplerStates[0] = SamplerState.AnisotropicWrap;

enter image description here

  • 1
    $\begingroup$ Glad to help! Anisotropic filtering is more expensive than bilinear. If that becomes a problem for you, you might try a higher resolution texture, or distance field textures since it looks to be just 2 colors. blog.demofox.org/2014/06/30/distance-field-textures $\endgroup$
    – Alan Wolfe
    Sep 11, 2015 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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