Day 5 - UVs

Catch Up

Finish code from Day 4.


  • Review Calendar
  • Upcoming Sprint

See it

The fundamental problem with graphics 2.0.

Since everything in graphics is a simplification and an optimization, we cannot color things the way they are colored physically. We have to find another way to do this that fits in the our everything-is-a-surface-made-of-infinitely-thin-triangles paradigm.


The general pattern for coloring triangles is to map a 2D image to the 3D mesh and use information from the 2D image to make coloring decisions.

Unfortunately, mapping from 2D to 3D (or 3D to 2D) is hard. Fortunately, you already do this kind of mapping physically without thinking about it. For example, consider wrapping a present. The wrapping paper can be thought of a two-dimensional image that you are mapping to a three-dimensional image. Video about wrapping a present professionally.

This can get more complicated, though, when you are mapping objects that are more complex that simple boxes. A classic example is the "cartographers problem", or the fact that all flat maps introduce distortion in how they represent a globe. This website about map projections is a great example of different map projects and their relative strengths and weaknesses.


Before we work with mapping between 2D and 3D in code, we'll do it in 3D with Blender. The process in a 3D modeling tool is called UV mapping.


Since XYZ refers to the three axes in 3D space, the two axes in an image (or texture space) are called U and V, which represent X and Y respectively. By referring to X and Y as U and V, your audience immediately knows that you are talking about texture space and not world or model space.

UV mapping has several steps in blender.

  • Select the object to be textured in blender.

  • Open the material tab and assign a new material

  • Open the texture tab and assign a new texture

  • Still in the texture tab, click the open file button and select the file to use.

Now that a texture has been assigned to the object, you can start mapping between 2D and 3D for your model.

  • Open up the UV view in blender. The view selector is at the top of the IDE. When your open Blender, the current view is listed as Default.

  • Select the object in the 3D view and change to Edit Mode.

  • Click on the Mesh menu, UV Unwrapping... menu, and then either UV Unwrap or (better choice) Smart UV Project.

You should now see the triangles in the left view on the UV plane.

  • To add the texture you loaded earlier on the UV plane, click on the image selector on the left side and choose the image you loaded previously. It should now appear in the UV editor.

  • In the 3D view, change the view mode from Solid to Textured. You should now see your model with your texture on it. Notice that at this point your texture is affected by lighting, so be sure that you have some light somewhere in your scene.


To help you with your exploration, here are some assets you can use.

CC0 Wood Crate Texture.

CC0 Wooden Crates.

NASA Blue Marble Earth Map. This is great for working with UV maps on a sphere. You can read NASA's usage guidelines here.

From class

In class we texture mapped a box and then a sphere. You can see the .blend files for these in our classes GitHub repo.

We also learned how to export your UV mapping as an image so you can import it into a drawing program and draw directly onto your mapping. You can see an example of such an export (taken from Suzanne the Blender Monkey) in the same repo here.

We also discussed professional tools that are designed to make this process much more intuitive for artists. These included: