Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 jmccnz · Jun 14, 2012 at 10:42 AM · gameobjectsceneperformance

large number of identical objects in scene?

Hi there,

I am making a racing game which has a large number of fence sections to be applied at different rotations and positions along the track. I found some performance issues when all the fences were placed along the track - approximately 2k fence mesh assets. I have looked at solutions such as billboarding etc however I am unsure of what would be the best option in this case? No colliders are needed the fences are static and all have an identical texture.

Any advice would be appreciated!

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

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Wolfram · Jun 14, 2012 at 10:53 AM

This sounds like a job for CombineChildren.cs from the StandardAssets:

Attach your fence objects to one parent (they still can have individual hierarchies), and attach the script to that parent. It will optimize the meshes for rendering, reducing the number of draw calls to one, if they all use the same material.

There is a catch, that the sum of all vertices must not exceed 65000 (it will print an error in the Console if it does, and not render the objects). If this happens, simply distribute your fences over several parent objects with the script attached to each.

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
avatar image
2

Answer by CHPedersen · Jun 14, 2012 at 10:55 AM

I think your bottleneck is the number of drawcalls caused by having 2k+ fences. In your situation, where the fences are static and do not move relative to each other, it's possible to consolidate the drawcalls by combining the fences into a single mesh using Mesh.CombineMeshes. This causes Unity to batch them all into a single mesh so you can "bulk draw" them, so to speak.

Beware that this has the disadvantage that the combined length of the fence mesh will evaluate to visible for all fence segments, since I assume some smaller portion of it will always be within the camera's view frustum. This means frustum culling becomes less efficient as the engine must spend time rendering polygons of a larger mesh that aren't in the scene, because a few polygons of the combined mesh are. But it might still be better than 1 draw call per fence segment.

Perhaps you can come up with some hybrid solution where you use Mesh.CombineMeshes on many fence segments (but not all), so you combine stretches of, say, 100 fence meshes into 1 mesh? Then you'll reduce your 2k fence prefabs to 20 meshes, the origin of each is 100 fence prefabs, position one after another along your track.

A completely alternative solution which doesn't involve Mesh.CombineMeshes might be to dynamically instantiate/destroy fence prefabs based on what portion of the track the camera is currently viewing, so, when the car drives forward, past fences get destroyed and fences just ahead of the camera get instantiated.

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
avatar image
0

Answer by zz74b · Jun 14, 2012 at 11:43 AM

If you can't see all the fences at one time, maybe moving the fences along with the camera (you'll have to work out some way of snapping the fences to the correct positions as the camera moves) then you could reduce the number of fence items in the scene at any one time.

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.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

2D Side Scroller Background 3 Answers

Levels: scenes or GameObjects? 3 Answers

What faster? Make a saved scene with gameobjects, or create it on start? 1 Answer

Why does IsSleeping() keep returning false? (Billiard Logic) 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges