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
1
Question by dvochin2 · Sep 20, 2017 at 10:49 PM · c#materialsblender-exportingmeshesimporting problems

Can a mesh vertex have multiple materials?

Hello Unity gurus!

I have a complex mesh in Blender that features 10+ different materials that I'd like to render as-is in Unity.

For technical reasons I must stream the mesh from Blender to Unity but unfortunately Blender's ability to have a single vert map to a number of materials (each having different uv) doesn't appear to be possible with Unity...

Which is odd because if I import the same mesh into Unity via FBX and the Unity editor it will render beautifully without seams between the textures without adding any verts.

Currently the only way I was able to make this work was to manually split the vertices in Blender to enforce one-vert-per-uv and if I adjust the normals at the split verts then everything looks perfect but this is complex and expensive.

Since the Unity importer can make this work without splitting verts is there a way to programmatically accomplish the same via C#?

Thanks so much for a hint in the right direction! That one got me stumped!! :-)

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

Answer by Bunny83 · Sep 21, 2017 at 12:05 AM

Vertices are not linked to any material, only triangles are. A normal mesh has only a single material and a single "triangles list". However a mesh can have multiple "submeshes". That means the mesh uses the same vertices but seperate index lists, one for each submesh.

However keep in mind that all vertex attributes stay the same for all submeshes. So you can't have different UV0 coordinates on the same vertex for different materials. If you need this the vertex has to be splitted. Unity does this automatically on import. In general if any vertex attribute is different for two triangles which share that vertex it has to be splitted, even when both triangles use the same material / blong to the same submesh. That's why a cube has 24 vertices instead of 8 since each side need to have it's own normal. Since each of the 8 corners are shared by 3 different sides you need 8*3 == 24 vertices.

To manually set the triangles for a submesh you first have to set vertices, then the subMeshCount to the number of submeshes you have and finally use SetTriangles for each submesh index to define the triangles for each submesh.

The used MeshRenderer need to have as many materials as there are submeshes in the mesh. The order is the same. So submesh0 uses the material at index 0.

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 dvochin2 · Sep 21, 2017 at 01:55 AM 0
Share

Hi Bunny83!

Thank you very much for the expert information!

It turns out that I've been using this method (with 'sub$$anonymous$$eshCount' and SetTriangles()) in the past and I get perfect results if I set normals to the split verts the same.

So to confirm... I guess there is no other way to do it eh? Split verts are indeed a must?

If so it is just so odd that the Unity importer makes this happen without adding verts... perhaps it does split the verts but adds an order of indirection so that the C# code can still refer to the mesh using the original (smaller) mesh indices?

Thanks again!! :)

avatar image Bunny83 dvochin2 · Sep 21, 2017 at 02:37 AM 1
Share

No, the Unity importer can't import a mesh without splitting vertices if it's necessary. For example if you calculate normals on import there's a smoother angle you specify. If you set it to "0" you want sharp edges everywhere. So if the original mesh had shared vertices everywhere you will end up with more vertices in Unity.

Actually many artists have experienced this behaviour and were suprised why after importing the mesh it has more vertices than in their modelling application. Such as this, this, this, this, this, this and this.

avatar image dvochin2 Bunny83 · Sep 21, 2017 at 02:57 AM 0
Share

Hi again Bunny83,

Thanks for the prompt and usable answers! Helps me in my day! I appreciated all the links and have read most of that. I guess I will continue using my current sub$$anonymous$$eshCount and SetTriangles() with shared normals and try to make things faster if I can.

Answer accepted! Have a great day! :)

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

394 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 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 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 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

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer

How do I attach a Created Material A Texture, NormalMap and OcclussionMap? 0 Answers

How to combine object hierarchy meshes as a single one 2 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