- Home /
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! ^^,
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.
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
Follow this Question
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