In Review
Prev | Chapter 2. Playing with Colors | Next

## In Review

In this tutorial, you have learned the following:

- Data is passed to vertex shaders via buffer objects and attribute arrays. This data is processed into triangles.

- The `gl_FragCoord` built-in GLSL variable can be used in fragment shaders to get the window-space coordinates of the current fragment.

- Data can be passed from a vertex shader to a fragment shader, using output variables in the vertex shader and corresponding input variables in the fragment shader.

- Data passed from the vertex shader to the fragment shader is interpolated across the surface of the triangle, based on the interpolation qualifier used for the output and input variables in the vertex and fragment shaders respectively.

### Further Study

Here are some ideas to play around with.

- Change the viewport in the FragPosition tutorial. Put the viewport in the top half of the display, and then put it in the bottom half. See how this affects the shading on the triangle.

- Combine the FragPosition tutorial with the Vertex Color tutorial. Use interpolated color from the vertex shader and multiply that with the value computed based on the screen-space position of the fragment.

### GLSL Functions of Note

`vec mix(` | vec initial,
| vec final,
| float alpha`)`;

Performs a linear interpolation between `initial`, `final`, based on `alpha`. An `alpha` value of 0 means that the `inital` value is returned, while an `alpha` of 1 means the `final` value is returned. The vec type means that the parameter can be a vector or float. All occurrences of vec must be the same in a particular function call, however, so `initial` and `final` must have the same type.

The `alpha` value can be either a scalar or a vector of the same length as `initial` and `final`. If it is a scalar, then all of the components of the two values are interpolated by that scalar. If it is a vector, then the components of `initial` and `final` are interpolated by their corresponding components of `alpha`.

If `alpha`, or any component of `alpha`, is outside of the range [0, 1], then the return value of this function is undefined.

Prev | Up | Next
Vertex Attributes | Home | Glossary