Sunday, December 11, 2016

directx - Question about mipmaps + anisotropic filtering


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



Answer




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.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...