I am currently programmatically settings some shader textures, related to a Mesh Filter. The Mesh Filter is using a standard shader, and I am merely generating and setting the Bump and Height maps, via code.

Sphere.materials [0].mainTexture = biome;
Sphere.GetComponent<MeshRenderer> ().materials [0].SetTexture ("_BumpMap", bump);
Sphere.GetComponent<MeshRenderer> ().materials [0].SetTexture ("_ParallaxMap", heightTexture);

This is fine. The issue is that the shader only seems to activate itself once it is clicked in the inspector. Is there some sort of Activate() function I need to call in order to apply the shader effects to the Mesh?


Notice in the example (this is running in Play mode), that the shader only activates once I click the expand button on the Shader in the inspector.

What is going on here?

  • \$\begingroup\$ It's because of the walking clock. \$\endgroup\$
    – Vaillancourt
    Jan 14, 2016 at 18:51
  • \$\begingroup\$ Haha, I said it wasn't a walking clock! \$\endgroup\$
    – jgallant
    Jan 14, 2016 at 18:52

1 Answer 1


OK, So taken from http://docs.unity3d.com/Manual/MaterialsAccessingViaScript.html :

The Standard Shader has some extra requirements if you want to modify Materials at runtime, because - behind the scenes - it is actually many different shaders rolled into one.

These different types of shader are called Shader Variants and can be thought of as all the different possible combinations of the shader’s features, when activated or not activated.

For example, if you choose to assign a Normal Map to your material, you activate that variant of the shader which supports Normal Mapping. If you subsequently also assign a Height Map then you activate the variant of the shader which supports Normal Mapping and Height Mapping.

If you do not set a default image for the Height Map of your shader, it will not activate the shader feature.

By setting a default HeightMap (just a blank image for example), the Shader activates on run as expected.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .