Tidy up
This commit is contained in:
103 files changed
+3663
-3779
No files matched your search
@@ -2,17 +2,17 @@
|
||||
|
||||
**Rendering** is the process of drawing images on the computer display. In this course we will focus on images which are made up of triangles.
|
||||
|
||||
Rendering in 2-Dimensions involves the following
|
||||
Rendering in 2-Dimensions involves the following
|
||||
|
||||
1. The graphics programmer specifies vertices which make up some triangles to be drawn.
|
||||
2. The API assembles triangles from the vertices.
|
||||
1. The graphics programmer specifies vertices which make up some triangles to be drawn.
|
||||
2. The API assembles triangles from the vertices.
|
||||
3. The API rasterises the triangles to calculate which pixels are inside each triangle.
|
||||
4. The pixels inside triangles, called fragments, are shaded to calculate the colour.
|
||||
4. The pixels inside triangles, called fragments, are shaded to calculate the colour.
|
||||
5. The colours are displayed at the appropriate pixels.
|
||||
|
||||
A **vertex** is a point in space and is used to model geometry. A vertex can be presented using a vector, which is like an arrow. Can be written as $v=(3,2,0)$
|
||||
A **vertex** is a point in space and is used to model geometry. A vertex can be presented using a vector, which is like an arrow. Can be written as $v=(3,2,0)$
|
||||
|
||||
A *fragement* is a piece of a triangle which will be drawn to a pixel.
|
||||
A *fragment* is a piece of a triangle which will be drawn to a pixel.
|
||||
|
||||
A section of memory called a **frame buffer** (or colour buffer) stores the colour values that will be used at each pixel.
|
||||
|
||||
@@ -21,15 +21,15 @@ A shader is a program. Shaders are run on the GPU.
|
||||
#### Rendering Stages
|
||||
|
||||
1. Vertex Specification
|
||||
- In the application the vertices making up the triangles are specified, that is, given positions. The application is a software program which might be a Computer Aided Design (CAD), some kind of simulation, a visualisation, or a videogame. The graphics programmer specifies the location of vertices which make up the triangles to be rendered. These vertices are passed to the vertex shaders.
|
||||
- In the application the vertices making up the triangles are specified, that is, given positions. The application is a software program which might be a computer-aided design (CAD) program, some kind of simulation, a visualisation, or a video game. The graphics programmer specifies the location of vertices which make up the triangles to be rendered. These vertices are passed to the vertex shaders.
|
||||
2. Vertex Shader
|
||||
- Vertex processing by the vertex shader moves the vertices around. . The Vertices are used to construct triangles.
|
||||
- Vertex processing by the vertex shader moves the vertices around. The vertices are used to construct triangles.
|
||||
3. Rasterisation
|
||||
- There may be empty space around the triangles. Rasterisation is the process of taking all of the triangles and figuring out which pixels are inside each of the triangles.
|
||||
- Each of these pixels inside the triangles is called a fragment.
|
||||
- Rasterisation will generate a fragment for each pixel which is inside a triangle. The fragments are passed to the fragment shaders.
|
||||
4. Fragment Shader
|
||||
- The colour of Fragments is calculated by the fragment shader.
|
||||
- There may be empty space around the triangles. Rasterisation is the process of taking all of the triangles and figuring out which pixels are inside each of the triangles.
|
||||
- Each of these pixels inside the triangles is called a fragment.
|
||||
- Rasterisation will generate a fragment for each pixel which is inside a triangle. The fragments are passed to the fragment shaders.
|
||||
4. Fragment Shader
|
||||
- The colour of fragments is calculated by the fragment shader.
|
||||
|
||||
## Rasterisation
|
||||
|
||||
@@ -46,11 +46,11 @@ for each pixel y in Y dimension {
|
||||
}
|
||||
```
|
||||
|
||||
#### Barcentric Coordinates
|
||||
#### Barycentric Coordinates
|
||||
|
||||
We can use this to calculate if a point is inside a triangle or not.
|
||||
|
||||
The barrcentric coordintates are $\alpha, \beta, \gamma$.
|
||||
The barycentric coordinates are $\alpha, \beta, \gamma$.
|
||||
|
||||
$\alpha$ corresponds to the normalised linear distance of P between the line $\alpha$=0 and $\alpha$=1
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
1. Make a window and a context
|
||||
|
||||
- This is OS specific, therefore we need GLFW to set this up for us
|
||||
- This is OS specific, therefore we need GLFW to set this up for us
|
||||
|
||||
2. Load all OpenGL methods (GLAD)
|
||||
|
||||
@@ -12,9 +12,8 @@
|
||||
|
||||
4. Specify vertices (C)
|
||||
|
||||
5. Setup objects to communicate to the shaders (OpenGL)
|
||||
5. Set up objects to communicate with the shaders (OpenGL)
|
||||
|
||||
6. Render loop (OpenGL)
|
||||
|
||||
7. Deinitialisation (GLFW)
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
### Vectors
|
||||
|
||||
- The n-dimensional Euclidean Space is $\mathbb{R}^n$
|
||||
- $\mathbb{R}^n = \{(v_0, v_1, ... v_{n-1}) | v_0, v_1, ...v_{n-1} \in \mathbb{R}\}$
|
||||
- A vector is an n-turple
|
||||
- $\mathbb{R}^n = \{(v_0, v_1, ... v_{n-1}) | v_0, v_1, ...v_{n-1} \in \mathbb{R}\}$
|
||||
- A vector is an n-tuple
|
||||
- $v\in \mathbb{R}^n \Longleftrightarrow v=(v_0, v_1, ...v_{n-1}) | v_0, v_1, ...v_{n-1} \in \mathbb{R}$
|
||||
- In computer graphics we normally deal with 3-Dimensional Euclidean space $\mathbb{R}^3$
|
||||
- vec3 notation:
|
||||
- $v=(v_0, v_1, v_2)$
|
||||
- $v = \begin{pmatrix} {v_0}\\{v_1}\\{v_2} \end{pmatrix}$
|
||||
- Where $v_0$ represents x, $v_1$ represents y, and $v_2$ represents z axis
|
||||
- vec3 notation:
|
||||
- $v=(v_0, v_1, v_2)$
|
||||
- $v = \begin{pmatrix} {v_0}\\{v_1}\\{v_2} \end{pmatrix}$
|
||||
- Where $v_0$ represents the x axis, $v_1$ represents the y axis, and $v_2$ represents the z axis
|
||||
|
||||
##### Vector Scaling
|
||||
|
||||
@@ -104,18 +104,18 @@ Two matrices can only be multiplied if they both have the same number of columns
|
||||
|
||||
To get the resulting matrix, for each $(x,y)$ pair, is the cross product of the $x^{th}$ column and the $y^{th}$ row.
|
||||
|
||||
- Matrix multiplication is not communative
|
||||
- $MN \neq NM$
|
||||
- Matrix multiplication is not commutative
|
||||
- $MN \neq NM$
|
||||
|
||||
###### Matrix-Vector Multiplication
|
||||
|
||||
A matrix multiplied by vector gives new vector
|
||||
A matrix multiplied by a vector gives a new vector
|
||||
|
||||
Each row of the resulting vector is that row of the vector, dot producted with that row on the matrix.
|
||||
|
||||
##### Trigonometry
|
||||
|
||||
If $p=(p_x, p_y)$ is a unit vector, we can write them as:
|
||||
If $p=(p_x, p_y)$ is a unit vector, we can write its components as:
|
||||
|
||||
$$
|
||||
p_x = cos \space \alpha \\
|
||||
|
||||
@@ -33,7 +33,7 @@ $$
|
||||
v \cdot s = \begin{pmatrix} v_0 \cdot s_0 \\ v_1\cdot s_1 \end{pmatrix}
|
||||
$$
|
||||
|
||||
We can scale triangles by scaling each of its vertices
|
||||
We can scale triangles by scaling each of their vertices
|
||||
|
||||
### Transformation Matrix
|
||||
|
||||
@@ -106,7 +106,7 @@ z:
|
||||
|
||||
#### Combining Transformations
|
||||
|
||||
For example if point $p$ needs to be scaled by $s=(2,1,1)$ and then translated by $t=(1,0,0)$
|
||||
For example, if point $p$ needs to be scaled by $s=(2,1,1)$ and then translated by $t=(1,0,0)$
|
||||
|
||||
$$
|
||||
S = \begin{pmatrix}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
- A cube has one vertex at each corner which are positioned relative to the centre of the cube
|
||||
- In model space there is no information about where a model is relative to anything in the world, there is only information about the relative positions of the vertices which make up the model
|
||||
- **World Space**
|
||||
- World space is relative top a larger coordinate system
|
||||
- World space is relative to a larger coordinate system
|
||||
- Vertices are positioned in model space and then all moved to the appropriate position in the world
|
||||
- **View Space**
|
||||
- View space has all vertices from the perspective of the viewer
|
||||
@@ -17,11 +17,11 @@
|
||||
- **Clip space**
|
||||
- Clip space is an intermediate space after vertices have been projected to what is going to be drawn to the screen
|
||||
- **Normalised Device Coordinate space**
|
||||
- NDC space is almost identical to the pixels on the screen.
|
||||
- NDC space is almost identical to the pixels on the screen.
|
||||
- Vertices inside the NDC space will be rendered at those positions
|
||||
- **Screen space**
|
||||
- Screen space maps directly to the pixels on the screen
|
||||
- From now vertices can be used to construct triangles, which are rasterised and the appropriate pixels are coloured
|
||||
- From this point, vertices can be used to construct triangles, which are rasterised and the appropriate pixels are coloured
|
||||
|
||||
- Model Transform
|
||||
- The transformation of vertices from model space to world space
|
||||
@@ -32,7 +32,7 @@
|
||||
- Perspective Division
|
||||
- The division of each component by its homogeneous $w$ component
|
||||
- Viewport Transformation
|
||||
- The mapping of normalised coordinates to vertices at screen pixel coordinates
|
||||
- The mapping of normalised coordinates to vertices at screen pixel coordinates
|
||||
|
||||
#### View Space with Frustum
|
||||
|
||||
|
||||
@@ -10,17 +10,22 @@ The four rendering stages:
|
||||

|
||||
|
||||
- **Application stage** is the software that runs on the CPU
|
||||
- 
|
||||
|
||||

|
||||
|
||||
- **Vertex processing stage** is responsible for processing operations on individual vertices
|
||||
- In this stage vertex positions are transformed from model space to world and then view space, and projected to clip coordinates
|
||||
- Vertex **post processing**:
|
||||
1. Primitive Assembly
|
||||
2. Clipping
|
||||
- 
|
||||
3. Perspective divide
|
||||
4. View-port transformation
|
||||
- In this stage vertex positions are transformed from model space to world and then view space, and projected to clip coordinates
|
||||
- Vertex **post-processing**:
|
||||
1. Primitive Assembly
|
||||
2. Clipping
|
||||
|
||||

|
||||
|
||||
3. Perspective divide
|
||||
4. Viewport transformation
|
||||
|
||||
- **Rasterisation stage** is responsible for calculating all of the pixels inside the triangles that are being rendered
|
||||
- **Pixel processing stage** is responsible for processing operations on individual fragments.
|
||||
- Texturing can also happen in the fragment shader
|
||||
- Fragment shader computes a colour which is then merged with the colour buffer
|
||||
- Merging calculates which fragments are hidden behind other fragments and only keeps the colour for the visible fragment
|
||||
- Texturing can also happen in the fragment shader
|
||||
- Fragment shader computes a colour which is then merged with the colour buffer
|
||||
- Merging calculates which fragments are hidden behind other fragments and only keeps the colour for the visible fragment
|
||||
@@ -12,14 +12,14 @@ A camera involves
|
||||
3. A right direction
|
||||
4. An up direction
|
||||
|
||||
Calculating a camera direction can be achieved using Euler angles, **pitch**, **yaw** and **roll** .
|
||||
Calculating a camera direction can be achieved using Euler angles, **pitch**, **yaw** and **roll**.
|
||||
|
||||
- Pitch rotates the camera on the x axis
|
||||
- Think of a plane pointing its nose to the floor or to the sky
|
||||
- Think of a plane pointing its nose to the floor or to the sky
|
||||
- Yaw rotates the camera on the y axis
|
||||
- Think a plane moving the nose left to right keeping the wings parallel with the ground
|
||||
- Think of a plane moving the nose left to right keeping the wings parallel with the ground
|
||||
- Roll rotates the camera on the z axis
|
||||
- Think tilting the plane’s wings left and right, but not changing the direction of the nose
|
||||
- Think of tilting the plane’s wings left and right, but not changing the direction of the nose
|
||||
|
||||
#### Model-Viewer Camera
|
||||
|
||||
@@ -49,7 +49,7 @@ The camera has a position in world space and a focus direction `front`, which ca
|
||||
|
||||
We can move this kind of camera, forward, backward, left and right along with pitch, roll and yaw.
|
||||
|
||||
The camera is at the center of the sphere, and the model moves around the edge of the sphere.
|
||||
The camera is at the centre of the sphere, and the model moves around the edge of the sphere.
|
||||
|
||||
A unit vector points from the camera to the model as the front direction of the camera
|
||||
|
||||
|
||||
Reference in new issue
Block a user