<p>So I followed Alan Wolfe suggestion (in comment to my question) And turned out he was right. I was using <code>SamplerState.LinearWrap</code> and that was the issue. When I changed this to <code>AnisotropicWrap</code> it looked much better. Below are some examples of different sampling types and how they affect texture:</p>

<pre><code>graphicsDevice.SamplerStates[0] = SamplerState.PointWrap;
</code></pre>

<p><a href="https://i.sstatic.net/p7YQk.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/p7YQk.png" alt="enter image description here"></a></p>

<pre><code>graphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;
</code></pre>

<p><a href="https://i.sstatic.net/pldvb.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/pldvb.png" alt="enter image description here"></a></p>

<pre><code>graphicsDevice.SamplerStates[0] = SamplerState.AnisotropicWrap;
</code></pre>

<p><a href="https://i.sstatic.net/xNkBM.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/xNkBM.png" alt="enter image description here"></a></p>

CC BY-SA 3.0
2015-09-11T14:33:35.453Z
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.  http://blog.demofox.org/2014/06/30/distance-field-textures/
Alan Wolfe
CC BY-SA 3.0
2015-09-11T06:22:54.503Z
2015-09-11T08:28:29.850Z
2015-09-11T08:28:29.850Z
bartosz.baczek
<p>I have an issue with rendering my textures in Silverlight. When I look at it from above everything looks fine:</p>
<p><a href="https://i.sstatic.net/zjAeu.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/zjAeu.png" alt="enter image description here" /></a></p>
<p>But if I only change angle of watching it it looks terrible:</p>
<p><a href="https://i.sstatic.net/4b2AU.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/4b2AU.png" alt="enter image description here" /></a></p>
<p>I am using very simple pixel shader (hlsl):</p>
<pre><code>float4 main(VsOutput vertex) : COLOR
{
        float4 texColor = tex2D(textureSampler, texCoord);

        return texColor;
}
</code></pre>
<p>If I don' t use that pixel shader and load texture via BasicEffect like:</p>
<pre><code>BasicEffect.texture = myTexture
</code></pre>
<p>Everything looks fine. Why my pixel shader affects texture so bad?</p>
<hr />
<p>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 :).</p>
<hr />

CC BY-SA 3.0
2015-09-10T14:01:59.483Z
I think you need anisotropic texture sampling
Alan Wolfe
CC BY-SA 3.0
2015-09-10T14:29:46.250Z
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 Rosstin
CC BY-SA 3.0
2015-09-10T18:22:26.520Z
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
CC BY-SA 3.0
2015-09-11T06:11:48.617Z
@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
<texture><rendering><pixel-shader><hlsl><artifacts>
Texture glitch when using simple pixel shader
bartosz.baczek
# Texture glitch when using simple pixel shader

(Asked by: username_0 on 2015-09-10)

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

[![enter image description here](https://i.sstatic.net/zjAeu.png)](https://i.sstatic.net/zjAeu.png)

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

[![enter image description here](https://i.sstatic.net/4b2AU.png)](https://i.sstatic.net/4b2AU.png)

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

---

**Tags:** texture, rendering, pixel-shader, hlsl, artifacts

> **Comments:**
> **username_1**: I think you need anisotropic texture sampling  
> **username_2**: 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  
> **username_3**: 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.  
> **username_0**: @username_1 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. username_3 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  

---

## 1 answers

### Answer by username_0 on 2015-09-11. Score: 5 | Accepted answer

So I followed username_1 username_1 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](https://i.sstatic.net/p7YQk.png)](https://i.sstatic.net/p7YQk.png)

```
graphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;

```

[![enter image description here](https://i.sstatic.net/pldvb.png)](https://i.sstatic.net/pldvb.png)

```
graphicsDevice.SamplerStates[0] = SamplerState.AnisotropicWrap;

```

[![enter image description here](https://i.sstatic.net/xNkBM.png)](https://i.sstatic.net/xNkBM.png)

> **Comments:**
> **username_1**: 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.  http://blog.demofox.org/2014/06/30/distance-field-textures/  

---

