Home

Introduction to Texturing

Distributed under the terms of the CC BY-NC-ND 4.0 License.

  1. Introduction to Texturing
  2. Basic Implementation
  3. Texture Filtering
  4. Manipulating Textures
  5. Color Space
  6. Normal Mapping
  7. Source Code (external link GitHub)

Introduction to Texturing

Reading time: 7 mins.

This lesson is WIP (August 2024) - It is NOT complete.

What is Texturing and Why is Texturing Useful

In a world without texturing, all we could do with our 3D objects would be to shade them using uniform colors. Of course, using lights and simple shading techniques such as those we studied in the introduction to shading and lights, we can give objects the appearance of being diffuse or shiny, but their surfaces would still have a uniform color throughout, like the geometry in the figure below. However, most surfaces in the real world exhibit some color variation across their surface (for now, we will just focus on color; to see how we can make the specularity of an object vary across its surface, check the lesson on BRDFs in the intermediate section). Imagine, for example, the surface of a sheet of wood where the wood grain or knots form complex patterns.

The idea of texturing is quite simple and can be compared to the concept of wallpaper. The idea is to cover the surface of an object with an image, the content of which is, of course, up to you. For instance, you could take a photo of a wooden plank and apply it to the surface of a quad, using the colors from this image instead of a uniform color. Much like wallpaper, you can now see that the colors of the object vary across its surface.

Texture mapping is a shading technique for image synthesis in which a texture image is mapped onto a surface in a three dimensional scene, much as wallpaper is applied to a wall. If we were modeling a table, for example, we might use a rectangular box for the table top, and four cylinders for the legs. Unadorned, this table model would look quite dull when rendered. The realism of the rendered image can be enhanced immensely by mapping a wood grain pattern onto the table top, using the values in the texture to define the color at each point of the surface. The advantage of texture mapping is that it adds much detail to a scene while requiring only a modest increase in rendering time. Texture mapping does not affect hidden surface elimination, but merely adds a small incremental cost to the shading process. Paul S. Heckbert's thesis, "Fundamentals of Texture Mapping and Image Warping", 1984.

In computer graphics, these images have a specific name: they are called textures, and the technique of applying these images or textures to the surface of a 3D object is called texturing. Since the technique is similar to applying wallpaper to the surface of an object, we also refer to it as texture mapping. There are, broadly speaking, two types of textures: those that come from an image, and those that are generated procedurally by an algorithm. Noise is perhaps the most well-known procedural texture. Two lessons are specifically dedicated to the topic of creating a procedural noise texture using the technique described by Ken Perlin in 1984. In this lesson, we will study both types of textures: procedural and those that use a simple image as a color source. We can also distinguish between 2D texturing (the best analogy remains that of wallpaper applied to the surface of an object) and 3D texturing, which can be compared to a block of marble whose veins and colors form patterns in 3D space. We will focus on 2D textures in this lesson.

Now, before we dive into the details of how this technique works, a few words about its history. It is not really possible to say who invented the technique of texturing, but it is almost as old as the invention of 3D on computers. The earliest reference mentioning this technique can be found in Ed Catmull’s thesis published in 1974, titled A Subdivision Algorithm for Computer Display of Curved Surfaces..

In addition, photographs can be "mapped" onto patches thus providing a means for putting texture on computer-generated pictures. (in the absract)
It gives a method for putting texture, drawings, or photographs onto surfaces. (p. 36)

Though the term "texture" appears in "Illumination for Computer Generated Pictures" too (1973, by Bui Tuong Phong).

Note that Ed Catmull was not only a great researcher, discoverer, and inventor of 3D techniques, and contributed to the development of the legendary PRman rendering engine developed by Pixar to create equally legendary films like Toy Story, but he also later became the CEO of Pixar until 2019.

Before we go any further, let's remember that in this lesson, we will only apply this technique to change the color of objects. However, the technique of 2D texturing can be used, as I mentioned earlier, to vary any other shader parameters that control the appearance of objects. For example, there are other methods such as bump mapping or displacement mapping, which use images to give an object relief (or the illusion of relief in the case of bump mapping). Other techniques exist, such as reflection mapping, which is used to simulate the reflection of an environment on the surface of objects in a 3D scene, or specular mapping, which allows for varying the specularity or reflectivity parameters of objects. Once again, we will not study these techniques in this lesson, as we will focus on texture mapping that controls only the color parameter. However, after studying the lessons in the intermediate section, you will find it easy to extend the method to specular mapping or even implement displacement or bump (also called normal) mapping.

Texture mapping can be used to define many surface parameters besides color. These include the perturbation of surface normal vectors to simulate bumpy surfaces (bump mapping), transparency mapping to modulate the opacity of a translucent surface, specularity mapping to vary the glossiness of a surface, and illumination mapping to model the distribution of incoming light in all directions. Paul S. Heckbert's thesis, "Fundamentals of Texture Mapping and Image Warping", 1984.

Also, why is this lesson called just an introduction to texture mapping? Because, contrary to appearances, texture mapping is not as simple as it might seem at first glance. The basic technique of mapping an image onto a surface is fairly straightforward, but the challenge with texture mapping is more related to the fact that when the texture appears small in the image (when the object to which the texture is applied is small in the image) compared to the size of the image itself, texture mapping can cause visual artifacts. This issue is related to filtering, which in turn is connected to complex topics like signal frequency, Nyquist's theorem, and so on—topics that we will set aside for now.

In particular, a technique exists in ray-tracing to address this problem called ray differentials. While this technique isn’t overly complicated, the mathematics behind it require some time and effort to understand. Another method for reducing visual artifacts, primarily used in the GPU world, which typically employs rasterization, is mip-mapping—a technique that we will also set aside in this lesson.

We will conclude the lesson by showing examples of these visual artifacts and briefly explaining how these two techniques help mitigate them. However, within the context of this lesson, we will focus on explaining how to implement a simple version of texture mapping without delving into these additional technical details.

Let's dive in. Now, let's look in detail at how to implement this method. Note that some terminology associated with texture mapping will be introduced along the way, so be sure to read the lesson completely to acquire all the foundational knowledge on this topic. Our goal in the next few chapters is to replicate the image (specifically the ball and the sphere) as a tribute to the Pixar Luxo Ball, which you can find a replica of at the Pixar Animation Studios in California.

-next