Back to index

Texture Mapping

Exercises

  1. Inspect the values of texture coordinates by outputting the var_tex vector as the red and green channels.
  2. Use texture() to replace the color in the fragment shader with the pixels from the texture image.
  3. Change the 1.0 values for the s texture coordinate in the vertex buffer to 2.0. The flower should repeat horizontally.
  4. Change the t texture coordinate as well so a grid of flowers form.
  5. Try bricks_seamless.jpg and study the behavior of it for different wrapping modes. How does it compare to flower.jpg?
  6. What happens for non-integer values of s and t?

Inputs

Vertices

Textures

Vertex shader

Fragment shader