Master1114
Master1114

Reputation: 43

Flickering of 2D meshes in Unity

I am using Unity to create a simple driving simulator. Roads and road markings are definied by a set of points. To display them in the scene, I am creating two-dimensionals meshes and position them on the terrain. When the camera moves along the streets, the meshes look fine. But when looking at them from some distance or from the side, they start flickering heavily. Especially when approaching curved roads, it looks horrible. The camera has to get extremly close before the flickering dissappears. From some distance, the road is not even visible at all.

Flickering roads

At first, I thought the meshes are intersecting with each other or the terrain, but they are not. I even added some space between terrain, road and road marking. Then I thought, adding some anti aliasing to the scene will reduce the problem. But even MSAA 8x does not help with the flickering at all. I think the problem is caused by the "flatness" of my roads and road markings. As they are only 2D and the camera is only 1.5 units above the terrain, the view angle might just be too flat for the roads to be visible without flickering. Is there any simple trick to reduce this effect?

Upvotes: 1

Views: 1211

Answers (1)

Lotan
Lotan

Reputation: 4283

I've been working in a similar problem with a project where the angle of the camera was really close to the ground. My recommendation is to enable the Anisotropic filtering on your textures and project:

https://docs.unity3d.com/ScriptReference/AnisotropicFiltering.html

To enable Texture Filtering:

You can also enable it from Edit->Project Settings->Quality->Project Quality Settings->Anisotropic Textures->Per Texture

To set Aniso level:

Assets->Select your texture, and on inspector view-> Filter Mode->Aniso Level

Upvotes: 0

Related Questions