Lab 7: Textures
CS 445: Computer Graphics, Fall 2017


Due Date: be ready to demo at the beginning of lab Friday, Nov 3

Goals

Resources

Before you begin, review the following:

Overview

To add textures to your scene, you need to address the 3 items below. The directions will lead you through each of these :

  1. Texture Coordinates: These determine how the texture is going to sit on your geometry. They are associated with the vertices.
  2. Texture Objects: These are the textures themselves, e.g. an image or a procedurally generated texture such as a checkerboard. A texture object is placed on the geometry according to the texture coordinates.
  3. Shader variables: You will need a shader attribute variable (e.g. vTexCoords) for the texture coordinates. You will need a shader uniform sampler variable (e.g. uTexture) to hold the texture. You will also add a uniform variable to select how you want to color a shape object.

Directions - Part 1



Directions - Part 2

Directions - Part 3

When your run your code, everything gets it's color from a texture. However, you may sometimes want a texture and, at other times, a uniform color, or something else. You are now to modify your code to make it possible to select which kind of color you want. Let's list all of the possible choices:

  1. vertex colors (vColor)
  2. uniform colors (uColor)
  3. texture colors (uTexture)
  4. calculated in the shader (e.g. as in the fractal landscape). For example, here are polka dots which are calculated in the fragment shader:

To be able to choose:

There are many other tricks you can do right in the shaders. For example, there is a discard function that lets you throw fragments away. This is completely different from setting a fragment to be transparent (ask why if you want to know). Here is the result when the dots of the polka dot pattern are discarded:

To Hand In

By the beginning of lab on the due date above, be ready to demonstrate your finished program. The scene should include:

Then submit your code to WISE: