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 ckfinite · May 20, 2012 at 11:47 PM · renderingperformanceinstance

Non-Gameobject Instances of a mesh

I am working on a game with a large, dynamically generated terrain. The method uses many identical instances of a simple square geometry to create the terrain. As the rectangles change VERY quickly, I would rather not create new gameobjects for each and every one of these squares, as it is comparatively slow against directly calling the renderer API with the mesh and the correct transformation matrix.

I don't have Unity Pro, so I can't use the GL library. My question is whether I can use the MeshRenderer to render the same object into a different position, without creating a new object.

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
0

Answer by Bunny83 · May 21, 2012 at 12:02 AM

No, the MeshRenderer is a component. So it's responsible to render the attached mesh at the gameobjects position. The GL class actually works in the free version (but since the docs states it's pro only it can change at any time). Also the GL class isn't suited for your task. There is the Graphics class but this is unfortunately truly pro only ;)

However depending on your needs it's propably better to pack all those squares into one mesh and adjust the vertices manually.

Mesh.vertices

Keep in mind that Unity has a hardlimit of 64k vertices which means you can only have a limited count of quads in one Mesh so you might need to split your terrain into chunks.

Comment
Add comment · Show 9 · 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 ckfinite · May 21, 2012 at 12:10 AM 0
Share

Packing the squares won't work for me - the mesh manipulation is far, far too slow, especially when compared to true instancing. If I could cause the $$anonymous$$eshRenderer to re-render with a new transformation matrix, that would be best, but as far as I can tell, that is completely restricted to pro with Graphics.

$$anonymous$$y terrain is going to overrun the number of indices more or less immediately. I am already using the mesh generation features to create the base squares, so I know roughly how fast it is.

The algorithm does frustum culling, so I need to be able to alter what is rendered very fast. I really do need hardware caching as well in order to make it be anywhere near real time as well.

avatar image ckfinite · May 21, 2012 at 12:11 AM 0
Share

Also, since purchasing Pro is an option for me, does the Graphics class support keeping the mesh on the GPU, or does it to the transfer every time Draw$$anonymous$$eshNow is called?

For your reference, here is the paper: http://www.vertexasylum.com/downloads/cdlod/cdlod_latest.pdf

I have already done an implementation in XNA, which is way, way closer to the rendering hardware than Unity is.

avatar image Bunny83 · May 21, 2012 at 12:31 AM 0
Share

Why is manipulating the mesh data too slow? What platform do you want to build to? If you draw each little piece manually this would kill your performance since every of your manual draws is causing a drawcall. In this case it would propably faster to use seperate gameobjects since Unity can batch them together into one $$anonymous$$esh automatically.

In the old docs i've read somewhere that changing up to 1$$anonymous$$ vertices a frame should be no problem.

If you want to target mobile i think the best way is to pack all in one $$anonymous$$esh like the sprite manager. The drawcalls is the real bottleneck. ;)

avatar image Bunny83 · May 21, 2012 at 12:35 AM 0
Share

Btw. The particle renderer does actually the same. It displays a lot of individual quads which are packed into one mesh. That's why a single particle emitter / renderer can only render up to 16250 particles.

avatar image Eric5h5 · May 21, 2012 at 12:44 AM 0
Share

The vertex limit per mesh is actually 65354. (2^16, $$anonymous$$us two for some reason.) Triangles can have shared vertices (which would be common in terrains), so the vertex limit doesn't tell you how many triangles you can have. There isn't any hard limit on triangles as far as I know, though practically speaking it's somewhat limited by the number of vertices.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Performance spikes 1 Answer

how to i off load rendering to my gpu? 0 Answers

slow rendering and frozen frames in unity 2019.4.16f 3 Answers

Performance drop with transparent objecs overlying big meshes 1 Answer

Can I not occlussion cull stuff that has been copied in my level, like the walls? 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