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 mehowe7 · Jan 03, 2012 at 03:18 PM · texturematerialdiffusedetailcycle

changing both texture images on a material

i have an object which has a diffuse detail material attached. i want to be able to change both the main texture and the detail texture at different times. how would i refer to each element to do so? (the scenario is a car which changes colour on the main texture, but also gets dirtier on the detail texture

 doorMaterial.mainTexture = doorColour[doorTexture];

this is the code i am using to change the car colour on the main 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
1

Answer by luizgpa · Jan 03, 2012 at 04:10 PM

Use Material.SetTexture(). To know the name of a texture you will need to look at shader code used by the material. For builtin shaders take a look here.

The code for a material using Diffuse Detail would be:

 doorMaterial.SetTexture("_Detail", detailTexture);


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 mehowe7 · Jan 16, 2012 at 11:50 AM 0
Share

thankyou for that. I've used the _detail and an array to change them. do you know how i could fade between 2 details?

avatar image luizgpa · Jan 16, 2012 at 02:43 PM 0
Share

I can think of 2 ways:

1 - create a texture dynamically that mix 2 detail textures you want to fade.

2 - write a shader, based on the built-in, that takes 2 textures ins$$anonymous$$d of 1 and interpolate between them.

I don't know how are you planning to use it, but I think the 2nd approach would be better in most of the cases. It requires some shader program$$anonymous$$g skills though.

avatar image mehowe7 · Jan 16, 2012 at 04:32 PM 0
Share

I have gone with option 2, thank you. the shader has a main texture with 3 overlaying details. I'm just working out now how to apply alpha channels to the details to fade each one in

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I access secondary maps through c# 1 Answer

mix diffuse with alpha channel 1 Answer

Gameobject with Diffuse Shader visible in darkness 1 Answer

Material doesn't have a texture property '_RendererColor' 1 Answer

Bumped Diffuse not working correctly 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