In the previous article I explained what textures are and how they are used in 3D rendering. Now there is one important step in-between that I deliberately skipped. And this is how to actually get a 2D image onto a 3D object. I will discuss how that is done in this article.
1. What is mapping?
The process of getting a 2D image texture onto your 3D model is called mapping. Now there are more or less 2 methods that you can distinguish in the process of mapping. That is Projection mapping and UV mapping. UV mapping is actually a form of projection mapping. But it is a more powerful and special form, that takes some more work to accomplish.
2. What is projection mapping?
Projection mapping can basically be considered as projecting your 2D image texture onto your 3D object. Like a projector projecting an image onto a screen.
But instead of a projector (as you would have it in real life), you have specific basic geometric shapes that the 2D image is projected from. You can see examples of projection methods below. Using a simple brick texture, you can see how each method projects the brick texture on a 3D object.
In most 3D software you can move these projection shapes around relative to your 3D model. And you can scale them smaller or larger (as you saw with the planar projection example above). In this way you control the position and scale of the texture.
Now the issue with these projection methods is, that you will always get distortions of your 2D texture if the 3D model is not a basic geometric shape similar to the projection shape. This can be seen below.
To combat this issue, we have another mapping method called UV mapping.
3. What is UV mapping?
UV mapping is the process of unfolding a 3D shape into a 2D flat shape. So basically going from a 3 dimensional coordinate space designated by an X-, Y- and Z-axis, to a 2-dimensional coordinate space designated by a U- and V-axis. Hence the name UV mapping. This process is often called unwrapping. As you basically are unwrapping a 3D object into a 2D space. Like the cube example below.
The final 2D unwwrap you end up with is called the object’s UV map. You can either export such an image and make a custom texture in an image editing software (using the UV map as reference). Or there are dedicated texture painting software packages, where you can paint directly onto a 3D model. The painted texture is directly saved into the UV map coordinates for a perfect texture placement. But that is far out of the scope for now.
Below you can see what the UV map looks like for the cube. Plus what the Brick texture looks like that we made for the cube. This brick texture fits perfectly in the UV map, and is therefore perfectly projected onto the 3D model.
As you can see, for a cube the unwrapping is pretty straightforward. But you can imagine that for more complex objects the UV unwrapping process can become quite tricky.
4. Binoculars UV mapping example
We again will use the binoculars from the previous articles as an example. The side grips of the binoculars, were UV mapped. Because the leather texture on the grips would otherwise get distorted due to the irregular shape of the grip model.
Below you can see the UV map that was made for the grips. Next to the UV map you see a special colored/numbered texture we are going to apply to the side grips. This to demonstrate that the UV map is good. And with good I mean that it does not create any weird distortions.
Below you see an interactive animation for the left side grip 3D model, with the leather texture applied. Below that you see another interactive animation of the left side grip 3D model, but this time with the checkered color/number texture applied. We can see that there is little to no distortion (local stretching or shrinking) of the checkered texture on the object. Which means the UV map is good. This is a little trick 3D artists often use to check if a UV map is good.
And below we have a little comparison of the final render for the binoculars and a render with the checkered texture applied to the side grips. Again there is no distortion (local stretching or shrinking) visible of the checkered texture on the object. So the UV map is good.
I hope you have enjoyed this post and have learned something new. Let me know if you have any questions or comments below.