Fragment Processing

The Fragment Processing stage converts varying values to on-screen pixels.

This trivial fragment shader simply copies the varying color onto the screen, converting the RGB value to RGBA by giving it an opaque alpha value.

varying vec3 fragmentColor;

void main() {
    gl_FragColor = vec4(fragmentColor, 1.0);
}

This is a big topic. The Fragment Processing stage often derives material properties from texture images. When high quality illumination is desired, lighting calculation happens here instead of in the Vertex Processing stage. We'll see examples of these soon.