blog games developers documentation portfolio gallery

More in this category:

Normal maps

bool IsNormalMap()


Returns true if the texture is recognized as a normal map. This is not a 100% guarantee. The color of the pixels is used to determine if it has enought resemblance with a normal map

void ConvertToNormalMap(this Texture2D tex, float strength)


Changes the texture in a normal map using the the difference between dark and lighter pixels to determine the height and direction of the normal. The parameter strength can be used to influence the strength of the normal map.

Note that Unity is not able to use the Texture as a normal map in materials directly. You will need to convert it into Unity's internal format with GetUnityNormalMap().
A code example would be:

material.SetTexture("_BumpMap", aRegularTexture.ConvertToNormalMap(0.8f).GetUnityNormalMap();


Texture2D GetNormalMap(float strength)


Same as ConvertToNormalMap(), but creates a new texture and leaves the receiver untouched.

Texture2D GetUnityNormalMap()


When you have a normal map that is imported as a regular texture or a normal map that is generated with ConvertToNormalMap(), you can not use it directly in your materials. You need to convert it into Unity's internal format. This functions does not change the receiver, but returns a new texture.
































follow us