Graphics Pipeline
The high level [see page 25, Stages] in rendering something. Involves a mapping points through a [see page 2, bunch] of coordinate spaces until we get a 2D projection on the display space.
A basic graphics system goes from the CPU, to the Graphics Processor to the Frame Buffer, before finally rendering the result back to the users screen.
Fixed Function Pipeline
- We build up a state (data about camera, lights etc.) in the OpenGL state machine.
- Pass in the modelled data (points, lines, polygons)
- The GPU modifies the model using the state and passes the result to the screen.
The [see page 31, functions] uses in this model are provided by the GPU and interfaced through OpenGL. We have little control over them
[see page 31, Programmable] Pipeline
Differs from the fixed function
pipeline by letting us ALSO send program code to
the GPU (alongside the data). This program code is run in the GPU and gives us
control over how the GPU functions are used to render the data.
Stages in the Pipeline
See example here.
Vertex Shader
Converts points from the local coordinate system to the world coordinate system and then clips out parts of the world which aren't visible.
The vertex shader uses the predefined gl_Position
variable (vec4) as the output
coordinates that're passed through to the next shader in the graphics pipeline.
#version 330 core
layout (location = 0) in vec3 aPos;
void main() {
gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);
}
Shape Assembly
The second stage of the graphics pipeline which takes points from the vertex-shader and groups them into a 3D surface that's to be drawn.
This shader specialises in building the boundary for an object that's passed into the graphics pipeline.
Geometry Shader
The third stage in the graphics-pipeline which takes a primitive from the shape-assembly stage and produces zero-or more primitives.
For example it can tessellate a triangle into two triangles.
Rasterisation
A stage in the graphics pipeline which maps primitives to pixels on the final screen. This process produces Fragments for the fragment shader to then color.
Fragment Shader
Calculates the color values for pixel Fragments. It outputs a vec4 (RGBA) variable
called FragColor
to indicate the color of a pixel.
#version 330 core
out vec4 FragColor;
void main() {
FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f);
}