• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Sir-Spunky · Dec 10, 2014 at 02:22 AM · terrainperformanceprocedural-terrain

Why are multiple terrains slower?

In my attempt at procedural terrain generation, I'm forced to divide my world into many small terrains with 129x129 heightmap resolution each, because spawning larger terrains at runtime causes a noticable lag.

However, for some reason, having multiple small terrains seems to be a big hit on performance. In the example pictures below I compare a scene of 6x6 terrains with a scene of 12x12. Although the second gives only a slight increase in polygon count and draw calls, the fps is more than halved. Unless it's related to some kind of camera culling or similar, the reason must be that having multiple terrains causes an overhead by itself.

What's the reason for this overhead? Any ideas how I can improve the performance?

6x6 terrains: http://i.imgur.com/eKDMNv7.jpg

12x12 terrains: http://i.imgur.com/jan0JYn.jpg

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by BMayne · Dec 10, 2014 at 02:38 AM

Hey there,

(This might not be the prefect answer but it gives you a direction to look at)

It's not the amount of polygons that causes big performance issues it's the texture looks ups.

If your not fermiler with shaders a texture lookup is what it sounds like. Every time the shader has to look at a texture and read a pixel that has an over head (it has to do this for every pixel on screen).

Saying this I have a question. How many textures are you feeding your shader?

Regards,

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Sir-Spunky · Dec 10, 2014 at 08:46 AM 0
Share

Hi! Ahh, I didn't think about that! Thanks! I'm currently only using one and the same texture for all terrains, no normal maps or anything. I kind of assumed that the texture was re-used, but because there's no "material" used, I guess it isn't.

I'm currently setting the texture by this code:

 SplatPrototype[] terrainSplats = new SplatPrototype[1];
 terrainSplats[0] = new SplatPrototype();
 terrainSplats[0].texture = terrainTexture;
 terrainSplats[0].tileSize = new Vector2(3, 3);
 terrainData.splatPrototypes = terrainSplats;

I'll look into improving this. $$anonymous$$aybe I can work with the "$$anonymous$$aterial" slot that's found in the terrain settings directly ins$$anonymous$$d, so that I can use the same $$anonymous$$aterial for all terrains and apply textures to the material ins$$anonymous$$d of the terrain.

But if I need more detailed texturing through splatmaps I guess there's no other way than to have unique textures for each terrain. I'm also planning to combine it with RTP terrain shaders from the Asset Store later, which will multiply the texture count by a lot.

Another solution would be to use fewer but bigger terrains, but then the main problem is that terrain.setHeights causes a lag and there's no way around that from what I've heard. Really hope Unity improves on that part.

avatar image Sir-Spunky · Jan 19, 2015 at 11:03 PM 0
Share

After experimenting some more, I'm afraid this might not be related to texture lookups either. Even after I disable the above texturing code, which makes the terrains completely white without any texturing, I get the same frame rate. Reducing poly count does nothing for the frame rate either.

There just seems to be some strange performance overhead on using multiple built-in terrains that I can't get rid of. This is very unfortunate as it means I'll either have to sacrifice a lot of viewing distance or suffer from lag when generating larger terrain chunks procedurally.

avatar image
0

Answer by CJGames · Dec 10, 2014 at 02:58 AM

Well, every type of generation is performed by your computer processor, if you generate 12x12 terrains, you'll have bigger terrains (but less), and if you generate 6x6 terrains, you'll have smaller terrains (and more). Maybe (for some reason) a single 12x12 terrain costs less memory than 2 6x6 terrains, so generating 12x12 terrains will make the game run "faster". However this depends on the USER processor, so if the player's processor is more powerfull than your's, the game will not lag (or will have less lag). I think there are some changes you can do to improve the performance, such as ajusting the shader and all shadows options (cuz they cause big performance impact) and making each terrain as big as possible.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to improve the Performance of Removing Trees during runtime? 1 Answer

Adding layers to Unity Terrain ( 4, 8, 14) 1 Answer

SketchUp Sandbox vs. Unity Terrain 2 Answers

Empty flat terrain: low performance on iPhone 4G 0 Answers

2d fake 3d objects cheaper in terms of drawcalls/ performance? 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges