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 Samuel · Nov 19, 2010 at 09:14 AM · shadertexturematerialaccessother

How can I get or set textures on a material other than the main texture? (eg, the bump map)

I can't figure what is the name of this component, so I'll try to describe it somehow.

When selecting a mesh in the inspector, there are 2 textures displayed. One texture is accessible trough

Texture2D tex = renderer.material.GetTexture("_MainTex") as Texture2D; 

How can I accesses the other texture?

Thanks.

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 duck · Nov 19, 2010 at 12:06 PM

Different shaders which have multiple textures will have an internal variable name for each texture. As you've shown, the common name for the main diffuse texture is "_MainTex", and some other names used in some of Unity's built in shaders are:

  • "_BumpMap" (the normal map in bumpmapped shaders)
  • "_Cube" (the reflection cubemap in reflective shaders)
  • "_DecalTex" (for the decal shader)
  • "_Detail" (for a shader which allows detail maps)
  • "_ParallaxMap" (for parallax mapped shaders)

You can also access the "_MainTex" more conveniently by using the .mainTexture property of the Material class like this:

Texture2D tex = renderer.material.mainTexture;
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 Samuel · Nov 19, 2010 at 12:10 PM 0
Share

Excellent explanation, Thanks a lot!

avatar image vivalarosa · Jul 12, 2011 at 07:25 AM 0
Share

is there a list of this somewhere we can view / can I access the Illu$$anonymous$$ map?

avatar image Bunny83 · Jan 03, 2012 at 03:49 PM 0
Share

@mehowe7: What shader do you use? Not every shader has every texture variable. The variable names in this answer are common names, but noone stops a shader-author to use something completely different.

btw. don't post question as answers to other questions!!!

If you have further questions on this topic, ask your own question. But first think about it. What's your concrete question. What information is necessary to understand your question. Ask one question at a time and phrase it as clearly as possible. Include all "relevant" code, don't post the whole script

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Cutout Material is not showing texture transparency? 0 Answers

2 materials/shaders 1 texture? 2 Answers

Converting a RenderTexture to a Texture2D for use in a shader 2 Answers

How can I add another "layer" to my shader? 1 Answer

Textures not showing up 0 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