Am I missing something here? Why would a flat cube that a player works along with a concrete tile texture have aliasing? I thought it aliasing was a geometry problem. I tried tried removing height map and only leaving albedo and normal maps but aliasing is still present. I tried futzing around with the texture import settings and it changed the appearance but it never fixed the problem. It occurs during game mode in editor but also in runtime build. Does anyone have any suggestions on texture settings or any other way on how to limit this – it seems like this shouldn’t happen on a flat box.
Sorry Eric, I’m just wondering why a flat cube with a concrete texture would have aliasing as the distance from the camera increases. I was under the assumption that aliasing occurred only due to geometry. And my follow up was if possible, do you have any suggestions for texture import settings that would reduce this aliasing when the texture is applied to a flat surface.
Unfortunately because it’s an aliasing issue I can’t really capture it in a static image. It’s one of those things where as you move you can see the classic alias “sliding” as i term it where the grout between the concrete tile gives the mirage that it is moving. I tried taking a photo but it seems fine until you move then the grout seems to slide sideways.
edit: In the process of recording a video to try and illustrate it
I was able to reproduce it quite well with a different texture actually so no need for a video…you can see the aliasing on this flat cube. Was wondering if there are any texture import settings that will minimize this, it looks horrible even with MSAA enabled. I’ve also tried using trilinear and adjusting aniso levels, but it doesn’t seem to help the issue.
MSAA only helps with geometry edges. If that’s a single flat surface with a repeating texture, MSAA won’t do anything at all and it’s purely a texture sampling issue. For that the best you can do is what it sounds like you’ve already done, which is enable anisotropic filtering. That’s best done in the project quality settings by setting Anisotropic to Forced On.
However it kind of looks like the texture is using a bias of some kind. Is this just using the straight standard shader and did you do anything apart from just put the texutres in your asset folder and fiddle with the import settings?
No its just the straight standard shader with a normal map and height map. On fantastic setting, that particular texture has the following import settings: bilinear with aniso 1 (which is standard, I didn’t touch it). Literally opened a brand new project with a brand new scene and created a cube and put the material on it. Looks horrible right? I don’t get what’s going on or how to prevent it. Do you get these kind of results if you were to do the same thing – is it just unity or is something wrong on my end?
Remove the height map, does that fix it? I never use Unity’s Standard Shader height maps, they’re kind of an ugly hack. They’re cheap, and on kind of lumpy surfaces they can give a surface some extra depth, but for hard edges they fall down pretty terribly.
Thinking about how they implemented parallax offset mapping (what they use the height map for) the aliasing actually makes perfect sense and I can see exactly how it would cause aliasing. The solution is don’t use it, ever. It’s not displacement mapping like you might expect if you’re coming from non-realtime. If you want something more like that, you might want to look into a displacement shader or Uber Standard shaders from the asset store.
It would be less noticeable if you used less contrast in the texture, and it would also help if you’re using mipmaps (which it sounds like you are), but otherwise there’s nothing you can do about it, mathematically speaking, aside from having a higher resolution display. I mean, you have thin dark and light lines and a finite pixel size, so something has to give.
Removing the height map doesn’t fix it – it makes it slightly less noticeable but doesn’t come close to rectifying the issue. I was just hoping something could be done, I’ve never seen these kind of aliasing in professional games with sidewalks and what not - so I thought maybe there was some magical import setting I was missing but I guess that it is just unity. Please let me know if you guys think of anything else…there is such a terrible limitation it makes everything look so amateurish.
I agree, this isn’t Unity, this is just a general real time rendering issue. I recreated the issue myself and I was wrong about this being caused by the height map. This is shading aliasing from the normal map. This is actually kind of a hard problem to solve; with anisotropic filtering the normals are too sharp causing the aliasing, but with out the normals are too soft and kind of blur away in the distance. UE4 solves it with their temporal AA which is effectively super sampling the entire screen. You can try to use Unity’s implementation of TAA as part of their Post-Process Stack asset.
Curiously the reason why it’s showing up is kind of counter to the reason @Eric5h5 suggested. Technically he is correct, the normal map being high contrast and having thin edges is the cause of the aliasing, but if you had a higher contrast diffuse texture it would be less noticeable since the anisotropic filtering on a high contrast texture works really well.
Basically a lit normal map of a thin edge using anisotropic filtered is not the same as the result from super sampling.
Thanks @bgolus I can confirm it is definitely the normal map. Removing the normal map removes the aliasing effect - but then of course you have a noticeably flat texture. Thanks yea I’ve tried using TAA and it ameliorates it to some degree but it still occurs. I’ve tried changing the import settings on the normal map but it didn’t really help the issue. These are third party textures so not much I can do about them. Is the answer here to create a lower contrast normal map on textures I create myself? Thanks for help in pinpointing the issue – if only I could figure out how to solve it – I was thinking of trying to generate my own normal map from xNormal but not sure if this would even help the issue or not.
You can set the aniso level to zero and filtering to trilinear for the normal map, which will get rid of most of the aliasing, but then the normals are a little blurry in the distance. However that extra blurring is why the aliasing mostly goes away.