CS 4722 1 THE OPENGL PIPELINE Slide Set

  • Slides: 14
Download presentation
CS 4722 1

CS 4722 1

THE OPENGL PIPELINE Slide Set 2. 04

THE OPENGL PIPELINE Slide Set 2. 04

Open. GL Pipeline ■ Gray stages are programmable ■ Dashed outline indicates optional ■

Open. GL Pipeline ■ Gray stages are programmable ■ Dashed outline indicates optional ■ Image is from the Open. GL Wiki 3

Vertex Specification ■ The text describes a vertex as a package of data that

Vertex Specification ■ The text describes a vertex as a package of data that almost always includes a position ■ We use vertices to provide the bulk of the description of a mode, especially the vertices of triangles 4

Vertex Shader ■ Can carry out whatever calculations are desired ■ Must send an

Vertex Shader ■ Can carry out whatever calculations are desired ■ Must send an output value, a vertex location ■ Mostly used to transform coordinates of vertices ■ Pass information to the fragment shader ■ Some lighting and shading may be computed in the vertex shader 5

Tessellation Shader ■ The Open. GL specification allows for model data provided by the

Tessellation Shader ■ The Open. GL specification allows for model data provided by the driver program to be more complex than the standard primitive shapes 1. ■ The tessellation stages subdivide those more complex shapes into the standard primitives ■ These stages are optional if the model does not use non-primitives. ■ We will not be using the tessellation stages, but they are fully described in the text. 6

Geometry Shader ■ Takes primitives as input and outputs one or more primitives to

Geometry Shader ■ Takes primitives as input and outputs one or more primitives to the pipeline ■ Might be used to render a scene to multiple images ■ We will not be using the geometry shader in this course 7

Vertex Post-processing ■ After the vertex, tessellation, and geometry shaders have finished, vertex post-processing

Vertex Post-processing ■ After the vertex, tessellation, and geometry shaders have finished, vertex post-processing covers a couple of fixed operations ■ The main operation is clipping: removing parts of the image that are outside the clipping volume ■ This is a fixed process, there is no programmable aspect 8

Primitive Assembly ■ Take a sequence of vertices and define a geometric figure from

Primitive Assembly ■ Take a sequence of vertices and define a geometric figure from it/them: point, line segment, triangle – Some of the drawing modes allow ■ A simplified version of primitive assembly is performed earlier in the pipeline if the tessellation and/or geometry shaders are programmed 9

Rasterization ■ The input to the rasterizer is a primitive ■ Which pixels are

Rasterization ■ The input to the rasterizer is a primitive ■ Which pixels are covered by a primitive? ■ Any one pixel in the final image may have been covered by several primitives – A pixel is processed once for each primitive that contains that pixel 10

Fragment Shader ■ Called for each pixel covered by each fragment ■ Some pixels

Fragment Shader ■ Called for each pixel covered by each fragment ■ Some pixels are processed multiple times by the fragment shader ■ Assigns a color to the pixel – May use the existing value of the pixel – Other information is used, especially depth, distance from the viewer ■ We will be focusing a great deal of attention on the fragment shader since some of the most important effects in graphics are implemented at the pixel level 11

Pixels ■ A framebuffer stores image information. – Typically a two dimensional array with

Pixels ■ A framebuffer stores image information. – Typically a two dimensional array with one entry for each pixel in the image being produced – Will also contain arrays of the same dimensions that contain other information about the pixels ■ For example, depth testing ■ The content of a framebuffer is displayed by mapping the color layer to corresponding pixels in the display window ■ Blending of colors may happen as different fragments store data to the same pixel 12

Depth Testing ■ The framebuffer used to store the rendered image contains parallel 2

Depth Testing ■ The framebuffer used to store the rendered image contains parallel 2 dimensional arrays – Color layer – Depth layer – Others not of interest here ■ Z coordinate of a fragment stored in the depth layer if it is smaller than what is stored there already – Otherwise, the fragment value is discarded ■ Depth testing must be enabled ■ Painters algorithm 13

Parallel Processing ■ This is how multiple processors are useful ■ Generally very difficult

Parallel Processing ■ This is how multiple processors are useful ■ Generally very difficult to get right: deadlock, race conditions ■ The kinds of computations needed in graphics can often be run in parallel safely – Matrix multiplication – Vector algebra ■ Shader programming has restrictions to ensure that parallel processing of objects does not suffer from interference ■ Pipeline is an efficient and safe processing strategy provided that there is very limited feedback from later stages to earlier 14