Intro to Texture Mapping

In graphics, texture mapping has many uses! We can describe surface material properties & add details without raising the geometric complexity of an object. We can either paste a texture map onto geometry, or define it procedurally.

Here's an example of texture mapping - notice how we start from the plain, 2D image on the left and add a 3D-like texture effect as we work our way right.

Here's an example of texture mapping - notice how we start from the plain, 2D image on the left and add a 3D-like texture effect as we work our way right.

To add texture to an object, we use something called a texture map - a 2D map corresponding to every point on our surface. In general, we typically deal with three spaces:

World Space: where the surface "lives" in our 3D world..

Screen Space: the actual 2D frame buffer // screen pixel map.

Texture Space: the 2D texture map that defines the texture of an object.

To conceptualize how texture mappings work, think about chocolate wrappers. Every point on the 3D chocolate object corresponds to a point in the 2D wrapper.

To conceptualize how texture mappings work, think about chocolate wrappers. Every point on the 3D chocolate object corresponds to a point in the 2D wrapper.

Mapping a two-dimensional texture onto a three-dimensional model.

Mapping a two-dimensional texture onto a three-dimensional model.

When we apply image texture to a surface, each triangle "copies" a piece of the texture image back to the surface. Notice how each surface point is assigned a texture coordinate $(u, v)$ in texture space.

The texture image consists of triangles that are mapped onto the rendered screen image.

The texture image consists of triangles that are mapped onto the rendered screen image.


Interpolation Across Triangles: Barycentric Coordinates

Motivation

Why do we want to interpolate? We need a way to specify values (e.g. texture coordinates) at vertices, and obtain smoothly varying values across surfaces. Essentially, we want to sample locations within the triangle & produce a "gradient" of sorts!

What do we want to interpolate? Texture coordinates, normal vectors, colors, etc.

How do we interpolate? We use Barycentric coordinates!

Barycentric Coordinates are a coordinate system designed for triangles.


In a 2D plane, the red point can be defined as (x, y). However, within the triangle, the point can be defined by the barycentric coordinates (𝛼, β, Ɣ). If all three coordinates are positive, the point lies inside the triangle.

In a 2D plane, the red point can be defined as (x, y). However, within the triangle, the point can be defined by the barycentric coordinates (𝛼, β, Ɣ). If all three coordinates are positive, the point lies inside the triangle.

Geometrically, the coordinates are defined by the proportional distances to each "axis". We can use this definition to derive the formulas for barycentric coordinates.

Geometrically, the coordinates are defined by the proportional distances to each "axis". We can use this definition to derive the formulas for barycentric coordinates.

As an example, the point that lies on the vertex A is defined by (1, 0, 0).

As an example, the point that lies on the vertex A is defined by (1, 0, 0).

The point that lies in the center of the triangle is defined by (1/3, 1/3, 1/3).

The point that lies in the center of the triangle is defined by (1/3, 1/3, 1/3).