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 jopzsanji · Sep 17, 2012 at 11:41 AM · shadertexturematerialrendererchange

How can i change detail texture?

I have a gameobject with a "Diffuse Detail" shader.

http://docs.unity3d.com/Documentation/Components/shader-NormalDiffuseDetail.html <- here's a quick info about that shader

this shader can have two texture. The "Base" and "Detail".

The base texture can be change using material.mainTexture

but what i want to "change/add/remove" is the detail texture, because i want the base texture retained.

can someone help me with this?

thank you in advance! ^^,

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
Best Answer

Answer by Owen-Reynolds · Sep 17, 2012 at 07:05 PM

`material.mainTexture` is a shortcut for `material.SetTexture( ... );`. So, of course you'll be using `SetTexture` for the second texture. The tricky part, is, you have to use the actual variable name in the shader, which is hard to find.

To find the correct name, download the Unity "built-in shaders" source code. The file name for diffuseDetail is Normal-DiffuseDetail. Open it in Notepad (or the Mac equivalent) and you'll see `Shader "Diffuse Detail"`, telling you it's the correct one. Scrolling over a little you'll see `_Detail ("Detail (RGB)", 2D) = "grey"`. This says the texture slot you see as Detail(RGB) is really named `_Detail`.

So (not tested recently,) use `material.SetTexture("_Detail", tex2);` If you get the name wrong, there won't be an error -- it just won't do anything.

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 jopzsanji · Sep 18, 2012 at 02:48 AM 0
Share

finally got it working! ^^, thanks

I've done making the shader as a variable, but i can't seem to find the shader that i'm looking for.

that "built-in shaders" saved my day ^^,

thanks again! ;)

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

11 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

Related Questions

How to change a value in custom shader through script, C# 1 Answer

How to switch the texture being used by the material of the mesh renderer 1 Answer

Changing two different objects renderer colour 1 Answer

Changing Eye Colour (Colour only non-white parts of a texture?) 2 Answers

Material trouble 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