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\$
  • \$\begingroup\$ Is that happening in mobile (Android/iOS) only or it's also happening in desktop (PC, Mac)? \$\endgroup\$ – Ming-Tang Sep 5 '14 at 16:41
  • \$\begingroup\$ It's occurs on PC. \$\endgroup\$ – lewis Sep 5 '14 at 22:16
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\$
  • \$\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 Sep 5 '14 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 Sep 6 '14 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 Dec 5 '15 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.