Here be thy transparent triangles
This commit is contained in:
@@ -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
|
||||
|
||||

|
||||
|
||||
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
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
@@ -3,8 +3,6 @@
|
||||
in vec4 fragment_colors;
|
||||
out vec4 color;
|
||||
|
||||
uint gridSize = 200;
|
||||
|
||||
void main()
|
||||
{
|
||||
color = fragment_colors;
|
||||
|
||||
+22
-19
@@ -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) };
|
||||
|
||||
Reference in New Issue
Block a user