Unity Texture Mapping

Texture Mapping in Unity

By Yuanbo Li

The Problem

"Where my color goes?" 

A common problem for import mesh to Unity is the loss of color (see the right image). How can we retain color for the imported object in Unity? We need the help of texture mapping.


<- After texture mapping

What is Texture Mapping

The image above shows the process of texture mapping. In short: we have an object and an image. We want to attach the image on to the object.


A formal definition (by wikipedia): 

"Texture mapping originally referred to diffuse mapping, a method that simply mapped pixels from a texture to a 3D surface ("wrapping" the image around the object). In recent decades, the advent of multi-pass rendering, multitexturing, mipmaps, and more complex mappings such as height mapping, bump mapping, normal mapping, displacement mapping, reflection mapping, specular mapping, occlusion mapping, and many other variations on the technique (controlled by a materials system) have made it possible to simulate near-photorealism in real time by vastly reducing the number of polygons and lighting calculations needed to construct a realistic and functional 3D scene."

with/ without Texture mapping :

Introduction to UV Coordinates

Texture mapping maps a 2D image to the 3D object. So it involves two coordinations: the UV coordinates and the XYZ coordinates.

UV coordinates are a way to specify how the 2D texture should be mapped onto the 3D object. The UV coordinates define a mapping between the vertices of the 3D object and the corresponding points on the 2D texture. The U and V axes represent the horizontal and vertical dimensions of the texture, respectively. XYZ coordinates, on the other hand, are used to specify the position of vertices in 3D space. The X, Y, and Z axes represent the horizontal, vertical, and depth dimensions of the 3D space, respectively.

(An example is shown below)

Introduction to Normal Maps

Another concept that often accompanies the discussion of texture mapping is the normal maps. A normal map is a type of texture map used in 3D computer graphics to create the illusion of surface detail on an otherwise flat, low-polygon model. It is a type of bump map that encodes the direction of surface normals using RGB color values, allowing for more realistic lighting and shading of the model.

In a normal map, each pixel corresponds to a surface normal vector, which defines the orientation of the surface at that point. The direction of the normal is encoded in the red, green, and blue channels of the pixel as a range of values from -1.0 to 1.0. By manipulating the values in the normal map, the surface normals of the model can be adjusted to simulate the appearance of fine surface details.

(The image on the right is the original object, the image on the left is its normals, aka "normal )

How to do Texture Mapping in Unity?

Please see this Unity Documentation for detail

In short, you need to save different asset together with your mesh, and then connect them inside Unity.