backfaces

This commit is contained in:
ScorpionX90
2025-09-18 20:06:04 +02:00
parent 8c6b945e66
commit 451e94b5fd
2 changed files with 13 additions and 11 deletions
+2
View File
@@ -89,6 +89,8 @@ together, it is impossible to observe rotational transformations from only
changing one value at a time, starting from the identity matrix.
## Bonus task a) is implemented in code
## Bonus task b)
Applying some perspective to our scene, we see that the smooth interolation qualifier yields a color interpolation which is corrected in terms of perspective. In the below image you can clearly see how the colors are shifted between the smooth and noperspective interpolation models:
+11 -11
View File
@@ -199,8 +199,11 @@ fn main() {
let indices = vec![
0,1,2,
0,2,1,
3,4,5,
6,7,8
3,5,4,
6,7,8,
6,8,7
];
let colors = vec![
@@ -292,21 +295,18 @@ fn main() {
VirtualKeyCode::Up => {
tilt_transform = glm::rotation(-angle_speed,
&glm::vec3(0.0, 1.0, 0.0).cross(&cam_direction));
&glm::vec3(1.0, 0.0, 0.0));
}
VirtualKeyCode::Down => {
tilt_transform = glm::rotation(angle_speed,
&glm::vec3(0.0, 1.0, 0.0).cross(&cam_direction));
&glm::vec3(1.0, 0.0, 0.0));
}
VirtualKeyCode::Left => {
yaw_transform = glm::rotation(-angle_speed, &glm::vec3(0.0, 1.0, 0.0));
cam_direction = glm::rotate_vec3(
&cam_direction, -angle_speed, &glm::vec3(0.0, 1.0, 0.0));
}
VirtualKeyCode::Right => {
yaw_transform = glm::rotation(angle_speed, &glm::vec3(0.0, 1.0, 0.0));
cam_direction = glm::rotate_vec3(
&cam_direction, angle_speed, &glm::vec3(0.0, 1.0, 0.0));
}
// default handler:
@@ -325,10 +325,10 @@ fn main() {
// == // Please compute camera transforms here (exercise 2 & 3)
motion_transform = glm::identity();
motion_transform *= glm::translate(&motion_transform, &camera_motion);
motion_transform *= yaw_transform;
motion_transform *= tilt_transform;
transformation = motion_transform * transformation;
motion_transform *= tilt_transform; // local tilt
motion_transform *= glm::translate(&glm::identity(), &camera_motion); // move in world space
transformation = yaw_transform * motion_transform * transformation;
// Reset frame transforms
camera_motion = glm::vec3(0.0, 0.0, 0.0);