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
0
Question by JoaquinRD · Feb 08, 2013 at 07:44 PM · shadermeshmaterialrenderer

Why is only the last Material in the Materials array on a Mesh Renderer used?

I am trying to apply Diffuse, Specular, and Normal maps to a single mesh. I have the Diffuse map in a Diffuse Material, and the Specular and Normal maps in a Bumped Specular Material. After placing both materials in the Materials array on the object's Mesh Renderer Component, only the last material in the array is used. If the Diffuse material is the last material, then I have a colored mesh with no specular or normal map applied. If the Bumped Specular material is the last material, then I have an uncolored mesh with specular and normal maps applied.

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

Answer by Eric5h5 · Feb 08, 2013 at 07:54 PM

You can't combine materials like that; you'd need to use a single shader with a single material that contains all the elements, which in this case is the Bumped Specular shader. The reason you'd use an array of materials is if you had a mesh with submeshes, so each material gets applied to a different submesh.

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 JoaquinRD · Feb 08, 2013 at 08:22 PM 0
Share

Ok, that makes sense. I see now that the "Shininess" slot in the Bumped Specular uses the RGB channels for diffuse and the Alpha channel for specular. Before, it seemed like this was a shader that omitted Diffuse.

avatar image
0

Answer by ThePunisher · Feb 08, 2013 at 08:28 PM

You can stack materials on the same mesh, but in your case what's probably happening is that only the top material is showing because it's covering all the previous materials. In other words, the last material in the array being applied.

To prove it you could grab a texture with some alpha sections in it and create a new material with a shader that handles transparency, then apply it as the last material in the array. Other materials (and their textures) should show through the alpha sections.

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 JoaquinRD · Feb 08, 2013 at 08:34 PM 0
Share

Thanks, that helps a lot. If I understand correctly, all of the materials are being used, but they are drawn in order, such that the last one is the only one that shows since it covers the rest.

avatar image ThePunisher · Feb 08, 2013 at 08:36 PM 0
Share

That is correct.

avatar image inum76 · Apr 13, 2016 at 10:55 AM 0
Share

@ThePunisher That is some fantastic info!

I am still learning textures and material settings. Just got the Uber Shader to play with.

I also just found out I can have one UV and have many materials set to that one UV and use them all over the model. That is possibly what submeshes are? One UV with a different material applied to different polygons within the same UV? Correct me if I am wrong on that.

Regardless, it works for me to do that.

The UV can look like a mess, depending on how it is set up. But I also found the UV only has to look nice for those that have to work with it, not for the render to use it well, or to have the textures look great on the model when rendered.

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

12 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

Related Questions

Changing two different objects renderer colour 1 Answer

Is it possible for a shader to know the name of the mesh? 0 Answers

Multiple materials for multiple submeshes 3 Answers

Destroy mesh / material after attaching to renderer 0 Answers

Mesh Clipping / Cross Sections 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