glTF-Tutorials

Previous: Simple Material Table of Contents Next: Simple Texture

Textures, Images, and Samplers

Textures are an important aspect of giving objects a realistic appearance. They make it possible to define the main color of the objects, as well as other characteristics that are used in the material definition in order to precisely describe what the rendered object should look like.

A glTF asset may define multiple texture objects, which can be used as the textures of geometric objects during rendering, and which can be used to encode different material properties. Depending on the graphics API, there may be many features and settings that influence the process of texture mapping. Many of these details are beyond the scope of this tutorial. There are dedicated tutorials that explain the exact meaning of all the texture mapping parameters and settings; for example, on webglfundamentals.org, open.gl, and others. This section will only summarize how the information about textures is encoded in a glTF asset.

There are three top-level arrays for the definition of textures in the glTF JSON. The textures, samplers, and images dictionaries contain texture, sampler, and image objects, respectively. The following is an excerpt from the Simple Texture example, which will be presented in the next section:

"textures": [
  {
    "source": 0,
    "sampler": 0
  }
],
"images": [
  {
    "uri": "testTexture.png"
  }
],
"samplers": [
  {
     "magFilter": 9729,
     "minFilter": 9987,
     "wrapS": 33648,
     "wrapT": 33648
   }
],

The texture itself uses indices to refer to one sampler and one image. The most important element here is the reference to the image. It contains a URI that links to the actual image file that will be used for the texture. Information about how to read this image data can be found in the section about image data in images.

The next section will show how such a texture definition may be used inside a material.

Previous: Simple Material Table of Contents Next: Simple Texture