What is texture mapping?

Texture mapping adds detail, surface texture, or color to the surfaces of 3D objects. It helps achieve a higher degree of visual realism in 3D graphics without the need for complex geometric models. 

How does it work

Texture mapping might seem difficult at first but the process is very simple. Given below are the complete details on how the texture mapping works.

  • Select a texture: The first step is to select a 2D image, which will be used as a texture for the 3D model. The image can be a pattern of bricks if you plan to give a wall-like appearance to your 3D model.

  • UV mapping: It assigns UV coordinates to each vertex of the 3D model. "U" represents the horizontal axis, and "V" represents the vertical axs of the 2D texture.

  • Create a UV map: A UV map is created by using the assigned coordinates to the vertices of the 3D models. The map stores information on how each point on the 3D object corresponds to a point on the 2D texture. If you flatten the UV map, it will look like a 2D representation of your 3D model. It should contain a mapping of each coordinate on the texture to your 3D model.

  • Texture application: After creating a UV map, the texture can easily be applied to the 3D object. The 3D image renderer uses the UV map to determine which part of the 2D image should be displayed on exactly which part of the 3D model. Each pixel on the 3D object's surface is matched to a pixel on the 2D texture image based on its UV coordinates.

  • Rendering: The texture appears on the surface when the 3D object is rendered according to the UV map. It gives the 3D object the appearance of having a detailed surface. Thus, texture mapping creates an illusion of the detailed surfaces of the 3D models, making them visually appealing.

Manually specifying the coordinates
Manually specifying the coordinates

Overall, texture mapping works by taking a 2D image and stretching it over the surface of a 3D object. The process is controlled by a UV map which ensures that each part of the texture image is at the right place on the 3D object's surface.

The result is a 3D object that looks completely realistic.

Texture mapping of surfaces

Mapping textures onto the surface works like mapping on individual polygons, associating each vertex of the polygon mesh with a vertex coordinate.

UV mapping becomes much more challenging when dealing with more complex 3D shapes. It is due to the need to account for curvatures and maintain texture aspect ratios.

Texture mapping of a cylinder

Texture mapping of a cylinder involves wrapping a 2D image around the surface of a 3D cylindrical object.

We use the parameters ss and tt to represent the position of each point in the 2D texture space and parameters uu and vv to represent the cylindrical surface.

Here,

  • ss represents the horizontal position in a 2D texture image

  • tt represents the vertical position in a 2D texture image

  • uu represents the angular position around the circumference of cylinder

  • vv represents the vertical position along the height of the cylinder

When mapping texture onto a cylindrical shape, we use the above parameters as given below.

Where,

  • segmentsegment represents the current angular position around the cylinder

  • total  segmentstotal \;segments represents the total angular measurement of the cylinder's circumference (2π2 \pi in radians)

  • By dividing the current segment by the total segments, we normalize the uu (cylinder's circumference) value to fall between 00 and 11.

  • As uu increases, ss also increases by moving horizontally across the texture image

  • When uu complete a full circle (2π2 \pi), s=1s = 1

The parameter vv on the cylinder is equal to tt in the texture space.

Where,

  • vv varies from 00 to 11 (from the bottom of the cylinder to the top)

  • tt varies from 00 to 11 (from the bottom of the texture to the top)

Note: Since the parameter ss in the 2D texture wraps around the cylinder, texture on the cylinder repeats around its circumference.

Thus, every point on the cylinder can be mapped to a corresponding point in the 2D texture space by using the above approach.

Texture mapping of a sphere

Longitudes and latitudes are the most common ways to parameterize a sphere.

For a sphere,

  • Assign ϕ\phi as the longitude (surface parameteruu)

  • Assign θ\theta as the latitude (surface parametervv)

The parameters θ\theta and ϕ\phi are used to describe a position of the point on the surface of the sphere.

  • ϕ\phi varies from 00 to 2π2 \pi (00^\circ to 360360^\circaround the sphere)

  • θ\theta ranges from 00 to π\pi(00^\circ to 180180^\circ)

These surface parameters are then mapped onto the texture parameters.

  • ss is the horizontal coordinate in the 2D texture image.

  • tt is the vertical coordinate in the 2D texture image.

Here,

  • segmentsegment denotes the current longitude position around the sphere.

  • total  segmentstotal \;segments denotes the total longitude measurement of the sphere's circumference (2π2\pi in radians).

By dividing the current segment by the total segments, we normalize the ϕ\phi value to fall between 00 and 11 which corresponds to the horizontal position (ss) in the 2D texture space.

Here,

  • We normalize the latitude value (θ\theta) to fall within the range of 00 and 11.

  • It corresponds to the vertical position (tt) in the 2D texture image.

Using these mappings, every point on the surface of the sphere can be linked to a corresponding point in the 2D texture space. It allows us to apply textures onto the sphere to achieve realistic visual effects.

Conclusion

In conclusion, texture mapping, specifically UV mapping, is essential to 3D modeling and rendering. It enables the creation of visually complex and detailed models without increasing geometric complexity.
Whether working with simple planes or complex shapes like cylinders and spheres, understanding UV mapping will allow you to bring your 3D models to life with realistic textures.

Continue reading


Copyright ©2024 Educative, Inc. All rights reserved