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 FxWolfxe · Aug 19, 2018 at 10:03 PM · meshmeshes

Can you store arbitrary data in a Mesh?

I’m familiar enough with meshes that I know in addition to vertex data, they can store uv, normal, and even color data for each vertex in the mesh, so are there other kinds of data you can put into a mesh? For context I’ve been making procedurally generated meshes that serve as terrain for a map and am at the point where I want to start storing region data, like were trees should spawn, what color should the ground be, ect. So, I was wondering, one, could I store this information in the meshes themselves and two, if I can do this, is It a good idea?

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 madks13 · Aug 20, 2018 at 12:03 AM

  1. No

  2. No

Each class/struct in Unity serves only one purpose. As such, meshes only have data needed for proper displaying of said meshes.

It also is a bad idea because clumping all data together would make a big monolithic class/struct which would be hard to debug, maintain and evolve. In programming, you always want to separate a program in as small as possible, elementary parts that are easy to debug, maintain and evolve. Also, even if you could attach such complementary data, how would you use it? A mesh that represents terrain and placables at same time? That would make each mesh extremly complex and you yourself wouldn't be able to debug them.

I suggest you separate your generation in layers of detail. For example :

  1. General topography : terrain heigh levels

  2. Detailed topography : adding more details to the terrain heights (is it jagged? lean? how each chunk connects?...)

  3. General details : which biome to use where

  4. Detailed details : custom parameters for each biome based on previous generations

  5. General placeables : where to put trees? houses? loot? enemies?

  6. Detailed placeables : what type of tree? enemy? how big/small each unit?...

With this layered system you would be able to have as much or as few details as you want on any individual part/chunk/mesh you want.

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 FxWolfxe · Aug 20, 2018 at 12:58 PM 0
Share

After explaining it like that my original idea does seem rather foolish, so thanks for giving a detailed answer with a better approach to my problem

avatar image madks13 FxWolfxe · Aug 20, 2018 at 04:12 PM 0
Share

$$anonymous$$eep in $$anonymous$$d the last part is a simple example to illustrate my explanation. You don't have to have as many, or as few, layers of it. The layered system can have as many or as few as needed. The one thing to keep in $$anonymous$$d is that you will need to properly seprarate the generation to be able to parallelize it, since it generaly adds generation time.

That said, it only applies if you are continually generating. If you generate everything at the begining, i don't think users will $$anonymous$$d waiting a few seconds more for it to finish.

avatar image
0

Answer by trapazza · Dec 08, 2020 at 11:28 PM

@FxWolfxe Actually yes (not for some of the purposes you mentioned though) but it's indeed a common technique used as a way to feed per-vertex data to a shader.

As an example, the Color property is seldom used in shading and it gives you 4 floats for free to store whatever you want. In my case, I use the red and green channels to store the uv coords to a secondary texture, and the blue and alpha channels to store the normalized terrain height and the blend factor between the two main textures.

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

101 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

Related Questions

Materials on an imported mesh 1 Answer

Missing/Replaced Unity default mesh Assets? 1 Answer

Mesh between lines - Mesh.SetIndices 1 Answer

Different prefabs using same mesh. Any performance gain? 1 Answer

Mesh coloring isnt working 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