• 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
2
Question by jc_lvngstn · Dec 29, 2010 at 11:32 PM · meshoptimizationmemoryshort

I need my meshes to use less memory

If I'm not mistaken, Unity's vertex arrays use floats. Is there any way to use a different data type? Some of my meshes store vertex data that could easily be represented with shorts instead. The meshes take up a huge amount of memory, as they have many vertices. While I could use a mesh optimization algorithm, it seems like using smaller datatypes would be the first thing to check.

Any ideas?

(Actually, they may even be able to be represented as bytes, but not sure if opengl/directx supports that).

Comment
Add comment · Show 1
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 Waz · Nov 26, 2012 at 08:58 AM 0
Share

This would be nice. 2-byte UVs would save a bit (so long as your UVs stay within 0..1).

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Eric5h5 · Dec 30, 2010 at 12:17 AM

Unity already does this...you can set mesh compression to low, medium, or high in the import settings. Though the best thing to do is reduce the number of vertices used in the first place.

Comment
Add comment · Show 3 · 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 jc_lvngstn · Dec 30, 2010 at 12:59 AM 0
Share

$$anonymous$$y apologies...I left out an important bit of information. I'm creating the meshes procedurally, it's a $$anonymous$$ecraftish terrain. Even breaking the terrain into chunks of 32x32x128 blocks, the chunks often break the 65k vertex limit. Performance is no problem at all. It's the meshes gobbling up so much memory. Also, I'm using a collision mesh for each mesh, which probably uses up quite a bit also. I could probably handle collision on my own, and drop the collision mesh...that might help out a bit. I was just looking into the quicker options first :)

avatar image jc_lvngstn · Dec 30, 2010 at 01:06 AM 0
Share

Here's a screenshot for easier visualization: https://dl.dropbox.com/u/5556115/AwesomeTrees.jpg

avatar image Waz · Nov 26, 2012 at 08:48 AM 0
Share

In case anyone looks at this, no, Unity does not compress the mesh using different value types. The compression appears to just be rounding in the stored file. The documentation now also says that it does not affect runtime memory usage.

avatar image
0

Answer by BerggreenDK · Dec 29, 2010 at 11:36 PM

I believe most 3D programs produces Vector3D coords with floats or bigger variables.

Perhaps you could rethink the meshes for low-poly and level of details (LOD) ?

Is it only a memory problem or a performance problem while rendering a frame? How big are the meshes? how many poly/vertexes are we talking about?

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 Ben Throop · Dec 30, 2010 at 02:41 AM

What about using instanced geometry instead of explicit mesh? You could go beyond a single cube, and determine a few patterns that repeat (2x2, 3x3, 4x4 as easy examples, but there are no doubt many, many repeating patterns to be found). You'd probably trade some CPU for the transform/material switch on these, but if memory's what you're after, it would make sense to investigate this route.

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 Ben Throop · Dec 30, 2010 at 02:44 AM 0
Share

And while I'm thinking of it, it would seem that some kind of tree data structure would be helpful. So whereas a 4x4 chunk might start out as a leaf node, once it gets broken, you turn off the mesh renderer and add the appropriate children underneath that node. You would only render the leaf nodes.

avatar image jc_lvngstn · Dec 30, 2010 at 04:03 AM 0
Share

If by instanced geometry you mean gpu/hardware instancing, from what I understand Unity does not support this. If you mean create meshes for patterns, and just create gameobject copies of that, wouldn't the vertex and collision information also be duplicated, or no?

Also, as far as a tree data structure...the raw terrain data doesn't use that much memory. One byte of data for each terrain means 33 megs of memory, a pittance. The meshes use several hundred megs of memory, by comparison...about 4 or 5 hundred.

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

Huge world without huge lag? 1 Answer

What do I add to the LOD Renderer in MonoBehaviour? 2 Answers

Memory management and C# do's and don'ts? 5 Answers

WebPlayer memory usage 0 Answers

RecalculateNormals optimization 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