Skip to content

Commit 04bc5db

Browse files
committed
chore: remove TODO's comments
1 parent 7c55d6a commit 04bc5db

30 files changed

Lines changed: 212 additions & 357 deletions

assets/shaders/checkerboard.frag

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
#version 330 core
2-
3-
out vec4 frag_color;
4-
5-
// In this shader, we want to draw a checkboard where the size of each tile is (size x size).
6-
// The color of the top-left most tile should be "colors[0]" and the 2 tiles adjacent to it
7-
// should have the color "colors[1]".
8-
9-
//TODO: (Req 1) Finish this shader.
10-
11-
uniform int size = 32;
12-
uniform vec3 colors[2];
13-
14-
void main(){
15-
ivec2 tile = ivec2(gl_FragCoord.xy) / size;
16-
if ((tile.x + tile.y) % 2 == 0) {
17-
frag_color = vec4(colors[0], 1.0);
18-
} else {
19-
frag_color = vec4(colors[1], 1.0);
20-
}
21-
}
1+
#version 330 core
2+
3+
out vec4 frag_color;
4+
5+
// In this shader, we want to draw a checkboard where the size of each tile is (size x size).
6+
// The color of the top-left most tile should be "colors[0]" and the 2 tiles adjacent to it
7+
// should have the color "colors[1]".
8+
9+
uniform int size = 32;
10+
uniform vec3 colors[2];
11+
12+
void main(){
13+
ivec2 tile = ivec2(gl_FragCoord.xy) / size;
14+
if ((tile.x + tile.y) % 2 == 0) {
15+
frag_color = vec4(colors[0], 1.0);
16+
} else {
17+
frag_color = vec4(colors[1], 1.0);
18+
}
19+
}

assets/shaders/color-mixer.frag

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ out vec4 frag_color;
1818
// However, this line is too long to write, so we can simplify it using a dot product
1919
// (which is defined in the "dot" function).
2020

21-
//TODO: (Req 1) Finish this shader and apply the channel mixing using the "dot" function.
2221
uniform vec4 red = vec4(1.0, 0.0, 0.0, 0.0);
2322
uniform vec4 green = vec4(0.0, 1.0, 0.0, 0.0);
2423
uniform vec4 blue = vec4(0.0, 0.0, 1.0, 0.0);
Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
#version 330
2-
3-
// The texture holding the scene pixels
4-
uniform sampler2D tex;
5-
6-
// Read "assets/shaders/fullscreen.vert" to know what "tex_coord" holds;
7-
in vec2 tex_coord;
8-
out vec4 frag_color;
9-
10-
// How far (in the texture space) is the distance (on the x-axis) between
11-
// the pixels from which the red/green (or green/blue) channels are sampled
12-
#define STRENGTH 0.005
13-
14-
// Chromatic aberration mimics some old cameras where the lens disperses light
15-
// differently based on its wavelength. In this shader, we will implement a
16-
// cheap version of that effect
17-
18-
void main(){
19-
//TODO: Modify this shader to apply chromatic abberation
20-
// To apply this effect, we only read the green channel from the correct pixel (as defined by tex_coord)
21-
// To get the red channel, we move by amount STRENGTH to the left then sample another pixel from which we take the red channel
22-
// To get the blue channel, we move by amount STRENGTH to the right then sample another pixel from which we take the blue channel
23-
frag_color.r = texture(tex, tex_coord - vec2(STRENGTH, 0.0)).r;
24-
frag_color.ga = texture(tex, tex_coord).ga;
25-
frag_color.b = texture(tex, tex_coord + vec2(STRENGTH, 0.0)).b;
26-
}
1+
#version 330
2+
3+
// The texture holding the scene pixels
4+
uniform sampler2D tex;
5+
6+
// Read "assets/shaders/fullscreen.vert" to know what "tex_coord" holds;
7+
in vec2 tex_coord;
8+
out vec4 frag_color;
9+
10+
// How far (in the texture space) is the distance (on the x-axis) between
11+
// the pixels from which the red/green (or green/blue) channels are sampled
12+
#define STRENGTH 0.005
13+
14+
// Chromatic aberration mimics some old cameras where the lens disperses light
15+
// differently based on its wavelength. In this shader, we will implement a
16+
// cheap version of that effect
17+
18+
void main() {
19+
// red = move by STRENGTH to the left, then sample the red channel
20+
// green = sample the green channel from the correct pixel
21+
// blue = move by STRENGTH to the right, then sample the blue channel
22+
frag_color.r = texture(tex, tex_coord - vec2(STRENGTH, 0.0)).r;
23+
frag_color.ga = texture(tex, tex_coord).ga;
24+
frag_color.b = texture(tex, tex_coord + vec2(STRENGTH, 0.0)).b;
25+
}
Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
1-
#version 330
2-
3-
// The texture holding the scene pixels
4-
uniform sampler2D tex;
5-
6-
// Read "assets/shaders/fullscreen.vert" to know what "tex_coord" holds;
7-
in vec2 tex_coord;
8-
9-
out vec4 frag_color;
10-
11-
// Vignette is a postprocessing effect that darkens the corners of the screen
12-
// to grab the attention of the viewer towards the center of the screen
13-
14-
void main(){
15-
//TODO: Modify this shader to apply vignette
16-
// To apply vignette, divide the scene color
17-
// by 1 + the squared length of the 2D pixel location the NDC space
18-
// Hint: remember that the NDC space ranges from -1 to 1
19-
// while the texture coordinate space ranges from 0 to 1
20-
// We have the pixel's texture coordinate, how can we compute its location in the NDC space?
21-
vec2 ndc = tex_coord * 2.0 - 1.0; // Convert texture coordinates to NDC space
22-
float vignette = 1.0 / (1.0 + dot(ndc, ndc)); // Calculate vignette factor based on distance from center
23-
frag_color = texture(tex, tex_coord) * vignette;
24-
}
1+
#version 330
2+
3+
// The texture holding the scene pixels
4+
uniform sampler2D tex;
5+
6+
// Read "assets/shaders/fullscreen.vert" to know what "tex_coord" holds;
7+
in vec2 tex_coord;
8+
9+
out vec4 frag_color;
10+
11+
// Vignette is a postprocessing effect that darkens the corners of the screen
12+
// to grab the attention of the viewer towards the center of the screen
13+
14+
void main() {
15+
// To apply vignette, divide the scene color
16+
// by 1 + the squared length of the 2D pixel location the NDC space
17+
vec2 ndc = tex_coord * 2.0 - 1.0; // Convert texture coordinates to NDC space
18+
float vignette = 1.0 / (1.0 + dot(ndc, ndc)); // Calculate vignette factor based on distance from center
19+
frag_color = texture(tex, tex_coord) * vignette;
20+
}

assets/shaders/texture-test.frag

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
#version 330 core
2-
3-
in Varyings {
4-
vec3 position;
5-
vec4 color;
6-
vec2 tex_coord;
7-
vec3 normal;
8-
} fs_in;
9-
10-
out vec4 frag_color;
11-
12-
uniform sampler2D tex;
13-
14-
void main(){
15-
//TODO: (Req 5) Change the following line to read the fragment color
16-
// from the texture at the received texture coordinates
17-
frag_color = texture(tex, fs_in.tex_coord) * fs_in.color;
18-
}
1+
#version 330 core
2+
3+
in Varyings {
4+
vec3 position;
5+
vec4 color;
6+
vec2 tex_coord;
7+
vec3 normal;
8+
} fs_in;
9+
10+
out vec4 frag_color;
11+
12+
uniform sampler2D tex;
13+
14+
void main(){
15+
frag_color = texture(tex, fs_in.tex_coord) * fs_in.color;
16+
}

assets/shaders/textured.frag

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
#version 330 core
2-
3-
in Varyings {
4-
vec4 color;
5-
vec2 tex_coord;
6-
} fs_in;
7-
8-
out vec4 frag_color;
9-
10-
uniform vec4 tint;
11-
uniform sampler2D tex;
12-
13-
void main(){
14-
//TODO: (Req 7) Modify the following line to compute the fragment color
15-
// by multiplying the tint with the vertex color and with the texture color
16-
frag_color = tint * fs_in.color * texture(tex, fs_in.tex_coord);
17-
}
1+
#version 330 core
2+
3+
in Varyings {
4+
vec4 color;
5+
vec2 tex_coord;
6+
} fs_in;
7+
8+
out vec4 frag_color;
9+
10+
uniform vec4 tint;
11+
uniform sampler2D tex;
12+
13+
void main(){
14+
frag_color = tint * fs_in.color * texture(tex, fs_in.tex_coord);
15+
}

assets/shaders/textured.vert

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
#version 330 core
2-
3-
layout(location = 0) in vec3 position;
4-
layout(location = 1) in vec4 color;
5-
layout(location = 2) in vec2 tex_coord;
6-
7-
out Varyings {
8-
vec4 color;
9-
vec2 tex_coord;
10-
} vs_out;
11-
12-
uniform mat4 transform;
13-
14-
void main(){
15-
//TODO: (Req 7) Change the next line to apply the transformation matrix
16-
gl_Position = transform * vec4(position, 1.0);
17-
vs_out.color = color;
18-
vs_out.tex_coord = tex_coord;
19-
}
1+
#version 330 core
2+
3+
layout(location = 0) in vec3 position;
4+
layout(location = 1) in vec4 color;
5+
layout(location = 2) in vec2 tex_coord;
6+
7+
out Varyings {
8+
vec4 color;
9+
vec2 tex_coord;
10+
} vs_out;
11+
12+
uniform mat4 transform;
13+
14+
void main(){
15+
gl_Position = transform * vec4(position, 1.0);
16+
vs_out.color = color;
17+
vs_out.tex_coord = tex_coord;
18+
}

assets/shaders/tinted.frag

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
#version 330 core
2-
3-
in Varyings {
4-
vec4 color;
5-
} fs_in;
6-
7-
out vec4 frag_color;
8-
9-
uniform vec4 tint;
10-
11-
void main() {
12-
//TODO: (Req 7) Modify the following line to compute the fragment color
13-
// by multiplying the tint with the vertex color
14-
frag_color = tint * fs_in.color;
15-
}
1+
#version 330 core
2+
3+
in Varyings {
4+
vec4 color;
5+
} fs_in;
6+
7+
out vec4 frag_color;
8+
9+
uniform vec4 tint;
10+
11+
void main() {
12+
frag_color = tint * fs_in.color;
13+
}

assets/shaders/tinted.vert

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
#version 330 core
2-
3-
layout(location = 0) in vec3 position;
4-
layout(location = 1) in vec4 color;
5-
6-
out Varyings {
7-
vec4 color;
8-
} vs_out;
9-
10-
uniform mat4 transform;
11-
12-
void main(){
13-
//TODO: (Req 7) Change the next line to apply the transformation matrix
14-
gl_Position = transform * vec4(position, 1.0);
15-
vs_out.color = color;
16-
}
1+
#version 330 core
2+
3+
layout(location = 0) in vec3 position;
4+
layout(location = 1) in vec4 color;
5+
6+
out Varyings {
7+
vec4 color;
8+
} vs_out;
9+
10+
uniform mat4 transform;
11+
12+
void main(){
13+
gl_Position = transform * vec4(position, 1.0);
14+
vs_out.color = color;
15+
}

assets/shaders/transform-test.vert

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
1-
#version 330 core
2-
3-
layout(location = 0) in vec3 position;
4-
layout(location = 1) in vec4 color;
5-
layout(location = 2) in vec2 tex_coord;
6-
layout(location = 3) in vec3 normal;
7-
8-
out Varyings {
9-
vec3 position;
10-
vec4 color;
11-
vec2 tex_coord;
12-
vec3 normal;
13-
} vs_out;
14-
15-
uniform mat4 transform;
16-
17-
void main(){
18-
//TODO: (Req 3) Change the next line to apply the transformation matrix
19-
gl_Position = transform * vec4(position, 1.0f);
20-
// No need to change any of the following lines
21-
vs_out.position = position;
22-
vs_out.color = color;
23-
vs_out.tex_coord = tex_coord;
24-
vs_out.normal = normal;
25-
}
1+
#version 330 core
2+
3+
layout(location = 0) in vec3 position;
4+
layout(location = 1) in vec4 color;
5+
layout(location = 2) in vec2 tex_coord;
6+
layout(location = 3) in vec3 normal;
7+
8+
out Varyings {
9+
vec3 position;
10+
vec4 color;
11+
vec2 tex_coord;
12+
vec3 normal;
13+
} vs_out;
14+
15+
uniform mat4 transform;
16+
17+
void main(){
18+
gl_Position = transform * vec4(position, 1.0f);
19+
vs_out.position = position;
20+
vs_out.color = color;
21+
vs_out.tex_coord = tex_coord;
22+
vs_out.normal = normal;
23+
}

0 commit comments

Comments
 (0)