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.
gl_FragCoord built-in GLSL variable can be used in
fragment shaders to get the window-space coordinates of the current
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.
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.
Performs a linear interpolation between
final, based on
alpha value of 0 means that the
inital value is returned, while an
alpha of 1 means the
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
final must have the same type.
alpha value can be either a scalar or a vector of the
same length as
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
final are interpolated
by their corresponding components of
alpha, or any component of
is outside of the range [0, 1], then the return value of this function is