diff --git a/gloom-rs/report/exercise2.md b/gloom-rs/report/exercise2.md index ef34e8f..2e904db 100644 --- a/gloom-rs/report/exercise2.md +++ b/gloom-rs/report/exercise2.md @@ -33,3 +33,10 @@ This task was already implemented as part of exercise 1. But for ease of access OpenGL does a simple interpolation between the vertex colors, and assigns a color to a pixel during shading based on a weighted blend of the vertex colors based on how close the location of a pixel is to the vertices of the fragment. All weights should add up to 1, resulting in a varying mix of all the vertex colors at any given point in the fragment. In other words it does a simple linear interpolation. +## Task 2) + +# a) Transparent triangles + +![](./images/transparent_triangles.png) + +Here we have drawn three partially overlapping triangles drawn in the order "red - green - blue" with red having the highest z-index (furthest back), followed by green and finally blue. All triangles are rendered with alpha = 0.4 diff --git a/gloom-rs/report/images/transparent_triangles.png b/gloom-rs/report/images/transparent_triangles.png new file mode 100644 index 0000000..932d14a Binary files /dev/null and b/gloom-rs/report/images/transparent_triangles.png differ diff --git a/gloom-rs/shaders/simple.frag b/gloom-rs/shaders/simple.frag index 04641d9..9845402 100644 --- a/gloom-rs/shaders/simple.frag +++ b/gloom-rs/shaders/simple.frag @@ -3,8 +3,6 @@ in vec4 fragment_colors; out vec4 color; -uint gridSize = 200; - void main() { color = fragment_colors; diff --git a/gloom-rs/src/main.rs b/gloom-rs/src/main.rs index b879d71..2f8506a 100644 --- a/gloom-rs/src/main.rs +++ b/gloom-rs/src/main.rs @@ -123,6 +123,7 @@ fn main() { let el = glutin::event_loop::EventLoop::new(); let wb = glutin::window::WindowBuilder::new() .with_title("Gloom-rs") + .with_transparent(false) .with_resizable(true) .with_inner_size(glutin::dpi::LogicalSize::new(INITIAL_SCREEN_W, INITIAL_SCREEN_H)); let cb = glutin::ContextBuilder::new() @@ -180,35 +181,37 @@ fn main() { // == // Set up your VAO around here let vertices = vec![ //Triangle 1 - 0.8, 0.2, 0.2, - -0.2, 0.2, 0.2, - 0.3, -0.8, 0.2, + 0.8, 0.2, 0.6, + -0.2, 0.2, 0.6, + 0.3, -0.8, 0.6, // // Triangle 2 - -0.8, 0.2, 0.2, - 0.2, 0.2, 0.2, - -0.3, -0.8, 0.2, + -0.8, 0.2, 0.4, + -0.3, -0.8, 0.4, + 0.2, 0.2, 0.4, // // Triangle 3 - // 0.5, 0.0, 0.0, - // 0.0, -0.9, 0.0, - // 0.6, -0.9, 0.0, + 0.0, -0.2, 0.2, + 0.5, 0.8, 0.2, + -0.5, 0.8, 0.2, ]; let indices = vec![ - 0,1,2 + 0,1,2, + 3,4,5, + 6,7,8 ]; let colors = vec![ - 1.0, 0.0, 0.0, 0.4, - 1.0, 0.0, 0.0, 0.4, - 1.0, 0.0, 0.0, 0.4, - 0.0, 1.0, 0.0, 0.4, - 0.0, 1.0, 0.0, 0.4, - 0.0, 1.0, 0.0, 0.4, - 0.0, 0.0, 1.0, 0.4, - 0.0, 0.0, 1.0, 0.4, - 0.0, 0.0, 1.0, 0.4, + 1.0, 0.0, 0.0, 0.5, + 1.0, 0.0, 0.0, 0.5, + 1.0, 0.0, 0.0, 0.5, + 0.0, 1.0, 0.0, 0.5, + 0.0, 1.0, 0.0, 0.5, + 0.0, 1.0, 0.0, 0.5, + 0.0, 0.0, 1.0, 0.5, + 0.0, 0.0, 1.0, 0.5, + 0.0, 0.0, 1.0, 0.5, ]; let vao_id = unsafe { create_vao(&vertices, &indices, &colors) };