1
\$\begingroup\$

I'm making RTS project on Unity3D.

I created terrain with Unity's standard Terrain tool, and added textures of grass, mood etc. on it. Then, for creating "man-made" objects of terrain (roads, sidewalks, road curbs etc) - I'm created this objects in separate assets, and placed on terrain.

And I have one issue with this solution. On moving camera away from the terrain, terrain's texture(e.g. mood) are flickering under roads, sidewalks and other objects. AFAIK, this bug caused by insuficcient accuracy of floating-point coordinates in Unity3D engine (?).

Now, as I concerned, my approach to creating terrain objects is not correct. I must create one mesh with terrain, and all manmade objects in 3D modeling software, and then create UV-map for texturing all of it. Is this approach correct? If "yes", is any special approach for modelling and texturing so large and complex object as terrain?

\$\endgroup\$
2
  • \$\begingroup\$ Is that happening in mobile (Android/iOS) only or it's also happening in desktop (PC, Mac)? \$\endgroup\$
    – Ming-Tang
    Commented Sep 5, 2014 at 16:41
  • \$\begingroup\$ It's occurs on PC. \$\endgroup\$
    – lewis
    Commented Sep 5, 2014 at 22:16

2 Answers 2

2
\$\begingroup\$

What you are experiencing is commonly referred to as Z-figthing. That might help with finding some additional leads/ideas. And I would not call it a "bug", just a regular challenge in 3D applications.

Changing the far and near clipping plane values can help with the Z-buffer resolution, more specifically increasing the value for the near plane (see this exaplantion):

Remember that the key to Z-fighting is the ratio between the near and far planes.

For example:

Near: 0.1, Far: 1000

Near: 0.5, Far: 1000

You've only offset your near plane by 0.4 world units. It's not a huge distance. The ratio between your near and far planes just improved 5 fold, however.

So don't just automatically crank down the far plane, as you can often get more mileage cranking up the near plane. Often without much/any noticeable difference too!

Also, you should remember that the z-buffer is not linear. So you inherently get greater precision closer to the camera than you do further away. This is logical and helpful, but it makes it even more important not to needlessly set your nearplane too low or you're wasting a huge proportion of your z-precision on things you don't need/won't see.

Some further potentially helpful links:

\$\endgroup\$
3
  • \$\begingroup\$ Changing camera's clipping plane has no tangible effect. I think, creating terrain as single mesh with roads and sidewalks is better approach. \$\endgroup\$
    – lewis
    Commented Sep 5, 2014 at 12:43
  • \$\begingroup\$ Also don't forget the simplest approach: just move roads etc higher - i.e. a bit further from the terrain. \$\endgroup\$
    – Nevermind
    Commented Sep 6, 2014 at 6:52
  • \$\begingroup\$ Thought there was no way this could be my problem after trying to reduce my Far plane from 1500 to 1000. After another 30 minutes of research, realized that my near plane was at 0.01. Bumping it up to 0.1 fixed everything. \$\endgroup\$
    – lase
    Commented Dec 5, 2015 at 15:58
0
\$\begingroup\$

I am probably late, but, I made the following videos which solve many flickering issues:

https://www.youtube.com/watch?v=Lls93SG94Os

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Welcome to gamedev. Please consider editing you answer to directly include some explanation as to how you dealt with this issue. Link only answers are discouraged as they become useless if the link rots. You can find more information on how to write good answers in gamedev.stackexchange.com/help/how-to-answer \$\endgroup\$
    – Roy Ward
    Commented Jun 4, 2023 at 1:31

You must log in to answer this question.

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