Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 NathanJSmith · Sep 13, 2018 at 05:06 AM · graphicsdrawcallssimulationdrawmesh

Populate people in city with DrawMeshInstancedIndirect?

Hi,

I see the API DrawMeshInstancedIndirect is efficient to draw a large number of mesh.

My purpose is drawing a large number of people in the city, similar to SimCity people. It requires:

  • The people move on path and can disappear when get into the house.

  • Each person (or group of people) can disappear when a specific event happens (for example: the house near that people is destroyed)

I've checked the DrawMeshInstancedIndirect example (github) and see that the draw mesh is moved with the shader file, not C# file. So I don't know if it's possible to use DrawMeshInstancedIndirect to populate the people with the requirement above?

Thanks for your time.

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
0
Best Answer

Answer by NathanJSmith · Sep 14, 2018 at 08:16 AM

Use DrawMeshInstanced() instead of DrawMeshInstancedIndirect().

Requirements:

  • The people move on path and can disappear when get into the house. --> You can pass the array of transform (which is position/rotation/size, use Matrix4x4.TRS() to set each of them) to control the peds movement.

  • Animation ---> check zulfajuniadi for his incredible open source Animation-Texture-Baker on github. Edit: About animation, it's just the shader play animation from an image file: check this project Animation-Texture-Baker of sugi-cho which is simpler and easier to understand.

  • Each person (or group of people) can disappear when a specific event happens (for example: the house near that people is destroyed) ---> Unlike DrawMeshInstancedIndirect(), with DrawMeshInstanced() you can easily call multiple DrawMeshInstanced() each frame, so make each DrawMeshInstanced() a group of ped, if you want a group of ped disappear then stop calling DrawMeshInstanced() for that group of ped.

Check this forum thread.

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 I5 · Sep 14, 2018 at 08:29 AM 1
Share

sweet. please post an update on the implemented solution.

avatar image NathanJSmith I5 · Sep 14, 2018 at 03:13 PM 0
Share

Thanks :) the answer above is already the implemented solution. The detail implement is based on the need of the project - maybe more complex, maybe simpler. Check the forum thread for more detail and discussion.

avatar image
0

Answer by I5 · Sep 13, 2018 at 05:23 AM

You''ll need an entirely different solution, and it will require a high LOE (level of effort), to include character models, rigs, animators, navmeshagents and a lot of coding. Sorry for the disappointing answer. The amount of time and resources to create the SimCity people is likely in terms of months to years and millions of dollars. Unity only provide the "dials" to create a world, but you have to setup, code and configure every dial, and there's hundreds of them, that you control using the editor and by writing code. I'd guess that there's about 200,000 lines (or more) of code that creates and controls the people in SimCity (and not including the environment).

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 NathanJSmith · Sep 13, 2018 at 08:45 AM 0
Share

I know it's hard to create, but do you think Draw$$anonymous$$eshInstancedIndirect is capable to meet the requirement in the question. Is it because Draw$$anonymous$$eshInstancedIndirect isn't flexible enough to set position for each mesh draw?

avatar image I5 NathanJSmith · Sep 13, 2018 at 02:32 PM 0
Share

Your requirements state:

"The people move on path and can disappear when get into the house."

If by "move" you mean realistic-like human movement, with any sort of rendering of body limbs, then no, I don't think Draw$$anonymous$$eshInstanceIndirect will meet your requirements, at least not until you first create animators, set up animation, navigation, colliders, and on an on (all the "dials").

$$anonymous$$y understanding of Draw$$anonymous$$eshInstanceIndirect is that it is a lower level/layer of code that Unity provides to coders/developers to help them improve the performance of their code/game, and make it easier to render a large number of objects (that have already been setup). There is a lot of stuff you have to first do, setup, code etc ahead of time before you can take advantage of Draw$$anonymous$$eshInstanceIndirect. If you did all of that work, then yes, Draw$$anonymous$$eshInstanceIndirect could be something you can leverage in your code that would help you and save time and avoid performance problems. Essentially, you have to do a lot of work setting up your characters before you can realize the benefits of Draw$$anonymous$$eshInstanceIndirect.

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

102 People are following this question.

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

Related Questions

Graphics.DrawMesh not working 2 Answers

Help me to optimize my mobile game 1 Answer

Will Unity support hardware mesh instancing? 0 Answers

What is a reasonable number of draw calls relative to one hardware configuration ? 6 Answers

Using Graphics.DrawMeshNow() in the Repaint event of an OnGUI function of an EditorWindow with custom projection matrix 1 Answer


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