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 marshall50 · Apr 17, 2018 at 06:00 PM · meshmaterialoptimizationmaterialsmeshes

The best way to have multiple models with only one material

Hello,
straight to the point, I have a lot of models in polygonal style, I know for sure that none of these models will have texture. I only need to assign correct colours to the models.


Also some of the models, for example, wooden barrel, will have more colours, for the wood part and for the metal part and I'd like to have the possibility to change the colour of these parts at runtime.


I'm trying to find a way how to use as fewer materials as possible. In previous projects, I achieved this by creating a texture with colours I wanted to use and each model has its own colour assigned via UVs. But in this case, I won't be able to change the colours.

Any ideas how to achieve this? I ask only for ideas, not scripts.


EDIT1: Let's add an example: I have one big table with a lot of items on it: plates, cutlery, cups, etc... Each model has its mesh. What I want to achieve is to have one material for more tables in the scene with the possibility to change the colour of each mesh and each table. Is this somehow possible?

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
1

Answer by bunnynsnake · Apr 17, 2018 at 06:06 PM

that is a little strange, im not really sure why you would want to do that. But you might want to try using the events system and rect transfrom with a sprite. then again, im not sure how you have your scene set up. But you might want to check out this video : https://www.youtube.com/watch?v=abZ1EnijrSs or perhaps this : https://www.youtube.com/watch?v=Jvj03I81Pl4

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 marshall50 · Apr 17, 2018 at 06:21 PM 1
Share

To reduce draw calls in a quite complicated scene on mobile devices, that's why I want to use few materials only.

avatar image bunnynsnake marshall50 · Apr 17, 2018 at 06:23 PM 0
Share

that makes sense. I am making a mobile game as well, and those videos helped me.

avatar image
1

Answer by Remy_Unity · Apr 18, 2018 at 11:34 AM

You basically have two ways to do that :

  • Have all your objects that support materials using the same shader with gpu instancing enabled, and with the color(s?) parameters that are instance parameters. This will allow the engine to batch objects together and reduce draw calls.

  • Precompute your color in the mesh data and send it to the material's shader. Use the vertex color for example. This way all objects can have exactly the same material, but each have different data. You can use https://docs.unity3d.com/ScriptReference/MeshRenderer-additionalVertexStreams.html to add datas to your mesh without have to create dupplicates.

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 marshall50 · Apr 18, 2018 at 01:01 PM 0
Share
  1. So if I'll have 200 materials on 200 meshes using the same shader with instancing support, will that reduce the draw calls?

  2. I've tried the second approach with $$anonymous$$aterialPropertyBlock. I could use only one material on all objects and set a different colour for each object but it would behave the same as if I would have more materials.

avatar image Remy_Unity marshall50 · Apr 18, 2018 at 01:20 PM 1
Share
  1. Theorically, yes. Will depend of the settings (dynamic/static batching enabled or not, GPU instance enabled or not). See here for infos : https://docs.unity3d.com/$$anonymous$$anual/GPUInstancing.html

  2. Even though it says that $$anonymous$$aterialPropertyBlock doesn't create a new material, it can break your batch. If used on a materials that supports GPU instance, it may work.

  3. $$anonymous$$eshRenderer.additionalVertexStream will change the mesh data when rendering, if your material's shader implement a usage of this data (vertex color for example), then all your meshes cant share exactly the same material, so can be batched together. It's virtually creating new meshes but sharing exactly the same material. It's not the same as $$anonymous$$aterialProperyBlock.

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

104 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

Related Questions

Combine N different meshes with M different materials on each 0 Answers

How do I use the same material on 2 meshes without distortion? 2 Answers

Materials on an imported mesh 1 Answer

Mobile Material Optimization 0 Answers

Why combine meshes that share the same material? 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