2
\$\begingroup\$

I'm a bit confused here and maybe someone can explain this to me. I created a simple test texture for my terrain which is nothing more than a solid green color with a black grid overlayed on top of it. If I look at the terrain in the distance with mipmapping on and linear filtering, the grid lines become blurry fairly quickly and further back the grid is pretty much invisible. With these settings, I don't get any moire patterns at all. If I turn on anisotropic filtering, however, the higher the anisotropic level, the more the terrain looks like it did with without mipmapping. The lines are much crisper nearby but in the distance I start to see terrible moire patterns.

My understanding was that mipmapping is supposed to get rid of moire patterns. I've always had anisotropic filtering on in every game I play and I've never noticed any moire patterns as a result, so I don't understand why it's happening in my game. I am using logarithmic depth however, could that be causing any problems? And if it is, how do I resolve it?

I've created my sampler state like so (I'm using slimdx):

ssa = SamplerState.FromDescription(Engine.Device, new SamplerDescription
{
       AddressU = TextureAddressMode.Clamp,
       AddressV = TextureAddressMode.Clamp,
       AddressW = TextureAddressMode.Clamp,
       Filter = Filter.Anisotropic,
       MaximumAnisotropy = anisotropicLevel,
       MinimumLod = 0,
       MaximumLod = float.MaxValue
});

Point Filtering Point Filter

Anisotropic 1 enter image description here

Anisotropic 8 enter image description here

Anisotropic 16 enter image description here

Anisotropic 16 at an angle enter image description here

\$\endgroup\$
5
  • \$\begingroup\$ Could you post a screenshot of the patterns you get with anisotropic filtering on? \$\endgroup\$ Commented Jun 8, 2012 at 5:32
  • \$\begingroup\$ @NathanReed Done \$\endgroup\$
    – Telanor
    Commented Jun 8, 2012 at 5:43
  • \$\begingroup\$ Thanks. Interesting pictures. I'm not completely sure what's going on, but I wonder if hardware aniso simply doesn't work well with a texture like this. Aniso is, after all, just another approximation, like mipmaps. I wonder if something like EWA would fare better? \$\endgroup\$ Commented Jun 8, 2012 at 6:12
  • \$\begingroup\$ Would the fact that I'm using a texture atlas cause this? \$\endgroup\$
    – Telanor
    Commented Jun 8, 2012 at 7:12
  • \$\begingroup\$ As in, the green square is only a sub-rectangle within a larger image? Yeah, I could definitely see that causing issues - mipmapping in general doesn't work well with texture atlases. \$\endgroup\$ Commented Jun 8, 2012 at 16:23

1 Answer 1

3
\$\begingroup\$

Would the fact that I'm using a texture atlas cause this?

Anisotropic filtering only works within a topologically continuous surface. Two adjacent triangles that share an edge position-wise, but have different texture coordinates are not topologically continuous. And thus, aniso won't work very well between triangles.

Just use mipmap filtering.

\$\endgroup\$
2
  • \$\begingroup\$ I had a feeling that might be it. I'll try using a texture array instead of a texture atlas and see if I get better results with that \$\endgroup\$
    – Telanor
    Commented Jun 8, 2012 at 23:17
  • \$\begingroup\$ @Telanor Technically, using a texture array is by far the better solution, but you can also take a look at this alternative solution that might work. \$\endgroup\$
    – danijar
    Commented Aug 27, 2013 at 23:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .