In code i’m creating a Material with ‘Standard (Specular setup)’ shader.
I’m setting mainTexture, normalmap and specularmap and assign the material to a skinned mesh renderer.
But specular map does not work after execution of code.
But if i expand the shader panel - while game is running in unity editor - the specular map suddenly is working correct.
You must enable the Standard Shader variant by using the EnableKeyword function. A different variant would be required if you start using a shader feature that was not initially in use by the material. For example assigning a Normal Map to a Material that did not have one, or setting the Emissive level to a value greater than zero, when it was previously zero.
The specific Keywords required to enable the Standard Shader features are as follows:
_NORMALMAP (Normal Mapping)
_ALPHATEST_ON (“Cut out” Transparency Rendering Mode)
_ALPHABLEND_ON (“Fade” Transparency Rendering Mode)
_ALPHAPREMULTIPLY_ON (“Transparent” Transparency Rendering Mode)
_EMISSION (Emission Colour or Emission Mapping)
_PARALLAXMAP (Height Mapping)
_DETAIL_MULX2 (Secondary “Detail” Maps (Albedo & Normal Map)
_METALLICGLOSSMAP (Metallic/Smoothness Mapping in Metallic Workflow)
_SPECCGLOSSMAP (Specular/Smoothness Mapping in Specular Workflow)