Week 5 - OpenGL and Texture & Environment Mapping Flashcards
What is the OpenGL rendering pipeline?
Vertex specification
Vertex shader
Tessellation
Geometry shader
Vertex pre-processing
Primitive assembly
Rasterization
Fragment shader
Per-sample operations
What do OpenGL’s “shaders” do?
They are small programs compiled at run-time by the OpenGL program that can be programmed in a C-like language called GL Shading Language (GLSL). There are two types; vertex shaders and fragment shaders
What do vertex shaders do?
They perform basic processing of individual vertices in the scene (e.g. viewpoint transformation)
What do fragment shaders do?
They process fragments generated by the rasterization
Name 3 GLSL data types.
Basic types (similar to C++; bool, int, uint, float, double)
Vector types
Matrix types
What are the GLSL vector operations?
cross, dot, length, normalize, distance
In terms of GLSL, what are uniforms?
Variables that are shared by all instances of the shader, denoted by the key word uniform
In terms of GLSL, what are inputs?
Variables specific to each instance, denoted by keyword in
In terms of GLSL, what are outputs?
The result of the shader computation, sent down the rendering pipeline, denoted by keyword out
What is the purpose of vertex shaders?
To perform operations applied to all vertices in the model, as all vertices need to be transformed (ie rotated, translated) from world coordinates to the camera view space, including normals
What are the default input and output for vertex shaders?
input: index of the current vertex
output: vertex position in clip space (after projection)
What is the purpose of fragment shaders?
To calculate shading for all fragments (ie pixels), e.g. using Gouraud, Phong or Blinn shading
What is texture mapping?
Mapping a two-dimensional texture (image) onto the surface of a three-dimensional object
How are textures represented in OpenGL?
Textures are images, and each pixel is also called a texture element (texel)
Each vertex of the mesh is associated to a point in the texture ([0, 1] x [0, 1])
Colour is samples from the texture at each fragment at interpolated locations
What are the four texture wrapping options in OpenGL?
GL_REPEAT (the texture pattern is repeated periodically)
GL_MIRRORED_REPEAT (same as above but the texture is flipped in alternance)
GL_CLAMP_TO_EDGE (the coordinate is clamped to [0, 1])
GL_CLAMP_TO_BORDER (anything outside of [0, 1] is set to a default value