In Review

In this tutorial, you have learned the following:

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.

Fork me on GitHub