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
2
Question by Noam · Dec 16, 2010 at 12:26 PM · meshmaterialrenderersubmesh

Multiple materials for multiple submeshes

Hi,

I have been using the fact that MeshRenderer's materials is an array for two things :

1) Render a mesh with multiple submeshes, each with its own material 2) Render a mesh with one submesh several times, each time with a different material (for example, adding a rimlight effect to the model regardless of what the main shader is)

However, I don't know how to combine the two. I have a model with two submeshes, and I want to render one of them twice - once with each material. That means a total of three materials. I tried putting the three materials in different orders, but could not get this effect.

Is this possible?

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 tomekkie2 · Feb 15, 2017 at 07:02 AM 0
Share

If you put 3 materials on a mesh with sub$$anonymous$$esh.Count = 1, mesh (or submesh) will be rendered three times, and if you put 3 materials on a mesh with sub$$anonymous$$esh.Count = 2, the third material will be ignored, right?

3 Replies

· Add your reply
  • Sort: 
avatar image
-1

Answer by Max Kaufmann · Dec 16, 2010 at 07:24 PM

Occam's Razor: Split the submeshes into multiple meshes.

Aside: I don't know how it works in Unity, but in the last game engine we used "submesh" was used to describe draw calls that were not interleaved with material/state switches, which required them to all have the same material.

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 Jessy · Dec 17, 2010 at 06:33 PM

Unity does not currently have the capability to do what you want, without a little bit of extra hassle and stored data. You need to rework the mesh so that it has three submeshes. If your modeling tool doesn't permit assigning the same triangle set to two materials, you can make an Editor script to copy the triangle indeces from one submesh to a new one.

Comment
Add comment · Show 1 · 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 tomekkie2 · Feb 15, 2017 at 07:04 AM 0
Share

If you put 3 materials on a mesh with sub$$anonymous$$esh.Count = 1, mesh (or submesh) will be rendered three times, and if you put 3 materials on a mesh with sub$$anonymous$$esh.Count = 2, the third material will be ignored, right?

avatar image
0

Answer by Whatever560 · Jan 17, 2020 at 06:31 PM

@tomekkie2 Actually it is clarified in unity documentation https://docs.unity3d.com/Manual/class-MeshRenderer.html#Materials

"If a Mesh contains more Materials than sub-Meshes, Unity renders the last sub-Mesh with each of the remaining Materials, one on top of the next. This allows you to set up multi-pass rendering on that sub-Mesh. However, this can impact the performance at run time. Fully opaque Materials overwrite the previous layers, which causes a decrease in performance with no advantage."

I'll have to retest myself as it seems that the behaviour is a bit random in the case of multiple submeshes.

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

2 People are following this question.

avatar image avatar image

Related Questions

Changing two different objects renderer colour 1 Answer

How to apply a texture to a submesh 1 Answer

Surfaces from merged submeshes are affected by light differently. 0 Answers

Layered Textures/Materials 0 Answers

Detect material by position on a mesh with multiple materials 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