- Home /
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.
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;
is there a list of this somewhere we can view / can I access the Illu$$anonymous$$ map?
@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
![](https://koobas.hobune.stream/wayback/20220613083653im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
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