Week 5 - OpenGL and Texture & Environment Mapping Flashcards

1
Q

What is the OpenGL rendering pipeline?

A

Vertex specification
Vertex shader
Tessellation
Geometry shader
Vertex pre-processing
Primitive assembly
Rasterization
Fragment shader
Per-sample operations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What do OpenGL’s “shaders” do?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What do vertex shaders do?

A

They perform basic processing of individual vertices in the scene (e.g. viewpoint transformation)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What do fragment shaders do?

A

They process fragments generated by the rasterization

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Name 3 GLSL data types.

A

Basic types (similar to C++; bool, int, uint, float, double)

Vector types

Matrix types

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the GLSL vector operations?

A

cross, dot, length, normalize, distance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

In terms of GLSL, what are uniforms?

A

Variables that are shared by all instances of the shader, denoted by the key word uniform

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

In terms of GLSL, what are inputs?

A

Variables specific to each instance, denoted by keyword in

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In terms of GLSL, what are outputs?

A

The result of the shader computation, sent down the rendering pipeline, denoted by keyword out

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the purpose of vertex shaders?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the default input and output for vertex shaders?

A

input: index of the current vertex
output: vertex position in clip space (after projection)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the purpose of fragment shaders?

A

To calculate shading for all fragments (ie pixels), e.g. using Gouraud, Phong or Blinn shading

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is texture mapping?

A

Mapping a two-dimensional texture (image) onto the surface of a three-dimensional object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How are textures represented in OpenGL?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the four texture wrapping options in OpenGL?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Where is texture coordinate information stored?

A

At vertex locations, and when rendering, each fragment’s texture coordinates are interpolated from the triangle it belongs to, e.g. using Barycentric interpolation

17
Q

How can you sample colour from a texture in OpenGL (as pixels don’t always align with textures)?

A

GL_NEAREST (returns the texel closest to (s, t))
or
GL_LINEAR (returns the weighted average of the four neighbours)

18
Q

What is forward mapping?

A

The texture space is mapped to object space via surface parameterization, and then it is mapped to the screen space via projection

19
Q

What is inverse mapping?

A

A pixel is mapped to a pre-image of the pixel

20
Q

Name a benefit of forward mapping.

A

Simple to comprehend

21
Q

Name 2 benefits of inverse mapping.

A

Suited to scan-line algorithms

Efficient (only required textures are computed)

22
Q

How does OpenGL use textures?

A
  1. Create the texture in Python - create the texture object, bind it, and set the texture data
  2. In the shader, add texture coordinates per fragment, create a texture object, and an output colour to display
  3. Sending the texture in Python - activate texture zero, get the location of the texture uniform by name, set this uniform to point of texture unit zero, and bind the texture we want to this unit
23
Q

What is environment mapping?

A

Representing the distant “environment” as a texture

Intensity and colour of the reflected ray found by texture mapping the environment map onto the rendered polygon

24
Q

How does sphere mapping work?

A

Map the environment onto the surface of a distant sphere surrounding the scene

Simple calculations to find incident illumination

Inadequate resolution of texels near boundaries of map leads to distortions

25
Q

How does cube mapping work?

A

The environment is mapped onto 6 faces of a cube

Simple to render map and calculate incident light

Each image easily rendered by placing “camera” at the centre of the cube facing each face in turn

6 textures need to be accessed (easy on GPUs)

Cube maps need to be recalculated for objects moving in the environment or changes in viewpoint

26
Q

How is a cube map rendered?

A

Need to render the view from all six faces of the cube with framebuffers

27
Q

How do you sample from a cube map texture?

A

Calculate which texel from the cube map would reflect on which fragment by reflecting the view vector with the surface normal (dome by the GLSL reflect() function)

28
Q

The result of what is a sequence of fragments?

A

Rasterization

29
Q

We calculate texture coordinates (s, t) for each pixel using what of the texture coordinates at the triangle’s vertices?

A

Barycentric interpolation

30
Q

When Scissor test is enabled, it fails if the fragment’s pixel lies outside of a specified rectangle of the screen. Where in the graphics pipeline is this test located?

A

Per sample operations