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 Gian-Reto · Jul 09, 2010 at 11:54 AM · terrainmeshruntimedetail

Add Detail Mesh at runtime

Hi all

I have a gun in my project that splurts out empty shells. After tweaking the objects and doint some scripting I could get the performance to a good level even with a high rate of fire, but one thing is still not right. When the empty shells finally lie on the ground, all physic components will be destroyed, but the mesh itself is still a separate object from the ground. Now, I have read in the Performance Pages that as there is a separate draw call for each object, a lot of visible objects could slow down performance, and that is exactly what I can observe after some 1000 of shells being put on the ground.

I know, the sensible thing to do would be to only allow a certain number of this meshes in game, or destroy them after a certain time, but I would like to try something different first:

  • Is there any possability to transform a gameobject into a terrain detail mesh at runtime, to reduce the number of draw calls and make this former gameobject dissapear in the distance set for detail meshes?

Please point me in the right direction if this question was already asked, I found a answer to how to combine and uncombine objects, but after opening the script couldn't tell if this is what I am looking for.

Thanks in advance

GR

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Mike 3 · Jul 09, 2010 at 12:31 PM

Adding a detail mesh isn't the issue here, but what you want to do with it is

Detail meshes use a texture for the positioning, which is going to give you severe issues if you try to add moving bullets into it - for a start, you'll need to update the texture so much it'll kill your system, and then on top of that, they'll just slide across the floor (you can't set a height for them)

I would honestly look into other ways of doing it - particles, mesh combining or object pools

Comment
Add comment · Show 6 · 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 Gian-Reto · Jul 09, 2010 at 12:59 PM 0
Share

Okay, right, I haven't thought about that... would mesh combining come at a reasonable cost to do multiple times in a short span of time? Would the resulting combined object be drawn in one call?

Thanks for the hints

Gian-Reto

avatar image Mike 3 · Jul 09, 2010 at 01:54 PM 0
Share

a combined mesh would be done in 1 draw call - and yes, it's possible (assu$$anonymous$$g your meshes aren't too large). you may be better off combining small batches of them ins$$anonymous$$d

avatar image Gian-Reto · Jul 09, 2010 at 04:33 PM 0
Share

Okay, now I have a small question concerning the combine mesh.

I have now the following script:

avatar image Gian-Reto · Jul 09, 2010 at 04:34 PM 0
Share

if (Time.time >= nextCombine) { // combine the terrain with the debris lieing around

     var meshFilters = GetComponentsInChildren($$anonymous$$eshFilter);
     var combine : CombineInstance[] = new CombineInstance[meshFilters.Length];
     var index = 0;

     for (var i = 0; i < meshFilters.Length; i++) {
         if (meshFilters[i].shared$$anonymous$$esh == null) continue;
avatar image Gian-Reto · Jul 09, 2010 at 04:34 PM 0
Share

combine[index].mesh = meshFilters[i].shared$$anonymous$$esh; combine[index++].transform = meshFilters[i].transform.localToWorld$$anonymous$$atrix; meshFilters[i].renderer.enabled = false; // index++; } GetComponent($$anonymous$$eshFilter).mesh = new $$anonymous$$esh(); GetComponent($$anonymous$$eshFilter).mesh.Combine$$anonymous$$eshes (combine, 0, 1); renderer.material = meshFilters[1].renderer.shared$$anonymous$$aterial;

     nextCombine = nextCombine + garbageCombineInterval;
 }
Show more comments

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

No one has followed this question yet.

Related Questions

Can terrain detail meshes have basic shading applied? 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Modify a mesh at runtime 0 Answers

How do I test if car is grounded to stop it from driving in mid-air? 2 Answers

Level of details in a script-made mesh in the sceneview 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