37
$\begingroup$

How exactly to texture coordinates work? I know they are represented by vectors, but how does a vector store texture mapping information? How does each type of texture coordinates work and what are their respective advantages and disadvantages?

$\endgroup$
1
  • 1
    $\begingroup$ I know there are a lot of similar questions about texturing, but I felt it would be useful to have an exhaustive explanation of how texturing works. $\endgroup$
    – PGmath
    Commented Jan 14, 2015 at 3:40

1 Answer 1

48
$\begingroup$

First, a little explanation of how texturing works.

The process of applying a texture to a mesh is called UVW mapping. The result of UVW mapping an object is a set of UVW coordinates that define what parts of the texture go where on the mesh.

A texture can be thought of as a three-dimensional space with each point assigned a color. A two-dimensional image texture can be thought of as a “solid” three-dimensional texture where the color is the same regardless of the Z position we are looking. Looking straight at an image texture, the bottom left corner is (0, 0, 0) and the top right corner is (1, 1, 0).

The way mapping works is every point on the mesh is assigned a three dimensional UVW coordinate (for some reason the letters U, V, and W are used instead of X, Y, and Z in texturing). This coordinate defines where in the texture blender should look to find the color for that point.

You may be wondering why we need a third (W) dimension for texturing. This is probably because you are used to thinking of image textures (which are two-dimensional). When you are using an image texture, it is true, the third dimension is basically ignored. But, there is another type of texture: a procedural texture. Procedural textures (such as noise, Voronoi, magic, etc.) are generated based on some kind of a computer algorithm or formula which need not be restricted to two-dimensions.


Now a look at the main types of texturing.

I will look at four different types of texture coordinates here: generated, unwrapped, camera, and window. There are many other types, but these are generally the most useful, especially the first two.

Generated texture coordinates:
Generated coordinates are based on the bounding box of the object. The bottom, left, front corner of the bounding box is assigned the coordinates (0, 0, 0) and the top, right, back corner of the bounding box is assigned the coordinates (1, 1, 1). The UVW coordinates of each point on the object's surface are simply their coordinates in the bounding box. Generated coordinates are most often used for procedural textures.

Unwrapped texture coordinates:
The most common and versatile way of UV mapping an object is by UV unwrapping it. This is done by cutting up the mesh of the object with seams along the edges. The cut out pieces of the object (called islands) are then flattened out (the flattened out version of the object is called a pelt or a UV map) and further adjusted to fix distortions. This is typically done just for two-dimensional textures as the W (Z depth) coordinate of all points will always be 0 since you are flattening the object out.

Camera texture coordinates:
Camera texture coordinates are based on the object's position relative to the camera. The origin of this coordinate system is the location of the camera and the U, V, and W axes are parallel to the camera's local X, Y, and Z axes. This is typically used for lining up the texture with the camera-plane; i.e. the texture will be “squared” with the camera's view.

Window texture coordinates:
Window texture coordinates produce a similar (but not identical) result to camera coordinates, but in a different way. Window coordinates are based on the viewing window. They, like unwrapped coordinates, produce no W coordinates (W is always 0). The U and V coordinates of a point on the surface of the mesh are equal to the coordinates of that point on the view screen/window. With the bottom left corner of the screen being (0, 0) and the top right being (1, 1). The main distinctions from camera coordinates is that window coordinates are always 0 in the W direction, and are stretched based on the aspect ratio of the final render (since the top right corner is always 1, 1).

$\endgroup$
4
  • 2
    $\begingroup$ How can the answer be considered "exhaustive" when no mention is made of Blender ' procedural textures? $\endgroup$
    – brasshat
    Commented Jan 19, 2016 at 16:15
  • 2
    $\begingroup$ @brasshat I'm talking about texture coordinates, not the textures themselves. The 4th paragraph does mention procedural textures though. $\endgroup$
    – PGmath
    Commented Jan 19, 2016 at 16:26
  • 2
    $\begingroup$ Terrific Q/A, thanks! You might consider adding Object texture coordinates, although from the above, I would assume that it assigns the object's origin as the texture's 0,0,0, or similar, and proceeds through the object's coordinate space? (Not sure if I'm saying that right...) $\endgroup$ Commented Feb 10, 2017 at 16:50
  • $\begingroup$ Thank you sir. Very useful. $\endgroup$
    – Orange Cat
    Commented Dec 31, 2021 at 3:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .