Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm in the beginning stages of building a road system in Unity. It'll be your basic SimCity style road construction, with building and destroying roads done on the fly at runtime. When doing thing, given the fact that geometry will be so often added and destroyed, should I keep a separate mesh for each segment of road, or should I maintain one big road mesh for the whole scene and add and remove vertices to it when roads are modified? In larger road networks would there be any performance difference between the two? I'm not so familiar with this sort of optimization in Unity, so any help is appreciated.

So basically, many small meshes or one big mesh? Does it matter?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

Yes it matters but there's no general rule, it depends on the specific scenario and requirements. Here's some hints:

1 Mesh Scenario

Pros:

  • Reduce drawcalls(state changes).

Cons:

  • No occlusion culling(it's done on a per GameObject resolution in Unity)
  • Potentially time consuming updating the required vertices (depends on the geometry complexity, but for a large street network it may not be the best choice)

Multiple Mesh Scenario

Pros:

  • Easy to update
  • Occlusion culling (even with static batched geometry)

Cons:

  • 1 drawcall per object/material without batching
  • Memory footprint increase with static batching
  • If static batching is used modify geometry at runtime could be difficult (definitely possible but eventually requires some work)

A possible approach I think you could evaluate is to subdivide your world into several patches. For each patch use a single mesh for the street network. In such a way you can potentially have reasonable performances dynamically updating the geometry, while still relying on culling for geometry outside the frustum or occluded.

share|improve this answer

You should keep in mind there's a set limit to mesh sizes in Unity3D.

The maximum number of vertices a mesh can have in Unity3D is 65,534 vertices. Regardless of the merits of using a single mesh, this will almost certainly force you to separate your meshes.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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