1
\$\begingroup\$

I was recreating a small city in Unity3D and was going to place streets and pathways according to a sketch. I'm building for Android and the city is quite small; I'm planning to have the entire road mesh(es) loaded during play, without a load/unload algorithm. I made a few road meshes in Sketchup and imported them into Unity, but was unsure on how to manage them. I thought of two strategies but was unable to identify the pros and cons of either:

  1. Place all the separate road meshes in Unity and position them, recreating the sketch and make them children of an empty GameObject to order them in the Editor window.

  2. Create the entire city roadmap in Sketchup, making it a single and complete mesh. Then, import it into Unity and that's it.

The city is quite small and I'm planning to have the entire road mesh(es) loaded during play, without a load/unload algorithm. I'm building for Android.

Which strategy should I prefer in this situation? Or are both basically the same?

\$\endgroup\$
  • \$\begingroup\$ Can the road pieces be tiled? \$\endgroup\$ – aces Nov 9 '16 at 3:25
  • \$\begingroup\$ I'm not sure what you mean! A long street is a long mesh, and a small street is a short mesh. \$\endgroup\$ – Zimano Nov 9 '16 at 11:44
  • \$\begingroup\$ I would also appreciate it if the downvoter/unupvoter would explain the motive behind his actions. \$\endgroup\$ – Zimano Nov 9 '16 at 11:46
  • \$\begingroup\$ So there's a total of only two unique meshes? I'm just asking because some games use more complex, organically shaped roads, and this would complicate things. \$\endgroup\$ – aces Nov 10 '16 at 2:22
  • 1
    \$\begingroup\$ I have about 5 different 'street'-, and 2 different 'footpath' meshes and I reuse them to create the entire citymap. They're not organic-looking in that they don't swerve or mix textures and such; they're just rectangles with tiled textures on the mesh. Hope to have provided you with enough info that way! \$\endgroup\$ – Zimano Nov 10 '16 at 14:15
1
\$\begingroup\$

Using many small meshes (option 1) will likely be favorable in this scenario for the following reasons:

  • You can make heavy use of instancing.
    • Loading the map will likely be faster since you only need to allocate and transfer data for a few small meshes.
    • Takes up less VRAM.
  • Each tile that is not in view or is far away can be hidden or can have an LOD object.
    • Instancing will make LOD switching difficult (but you could instance LOD levels as well if you need to), but you can find clever ways to deal with this.
    • Frustum culling, occlusion culling, and distance thresholds can all be used to take out road pieces. You said you were making a city, so I suppose it's likely building may be blocking parts of the streets.
  • The application will take up less space on your phone.
  • It may be easy to make modifications when designing your city.
    • This isn't a technical reason, but when doing level design, I find it easier to work many small, modular meshes than a large mesh, especially when I need to make modifications.

Batching may help performance as well, but dynamic batching can cause lag. Either way, you'll want to profile the any combination of optimizations to see what works for you.

\$\endgroup\$
  • \$\begingroup\$ Excellent answer! It answers the base question while giving many well-documented pointers to possible augmentations of the proposed strategy. \$\endgroup\$ – Zimano Nov 11 '16 at 21:12
-1
\$\begingroup\$

A complete mesh would reduce the amount of draw calls so I recommend you do that but it can be strange to get the measurements right so if you have trouble with that then you should put it together piece by piece in Unity With Loading/Unloading so it doesn't take up too much time with the draw calls. It really depends on how big the city really is, if it is that small then it is ok to do it in small pieces without loading/unloading but keep in mind that you are building for Mobile which isn't very powerful.

\$\endgroup\$
  • 1
    \$\begingroup\$ Keep in mind that under favourable conditions, Unity will batch-together geometry with the same material and draw it in a single draw call. Check out static batching and dynamic batching for more info. This gets many of the benefits of assembling the roads into one mesh, but may be easier to iterate on because you don't need to leave Unity to make every change (and as you say, you can more easily split it up for streaming). I'd try this first, and profile to see if it's a substantial burden. \$\endgroup\$ – DMGregory Nov 5 '16 at 13:41
  • \$\begingroup\$ I didn't know that Unity did batching. Cool. \$\endgroup\$ – UDXS Nov 5 '16 at 20:59

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.