diff --git a/assets/GrassTop.png b/assets/GrassTop.png new file mode 100644 index 0000000..e53b61b Binary files /dev/null and b/assets/GrassTop.png differ diff --git a/assets/shade.frag b/assets/shade.frag index 968b39f..a09cc1a 100644 --- a/assets/shade.frag +++ b/assets/shade.frag @@ -1,10 +1,18 @@ #version 140 in vec2 v_tex_coords; +in vec3 v_frag_color; +in float v_sun_intensity; + + out vec4 color; + uniform sampler2D tex; void main() { - color = texture(tex, v_tex_coords); + vec4 sun_color = vec4(v_sun_intensity , v_sun_intensity , 0.0, 1.0); + + + color = texture(tex, v_tex_coords) * vec4(v_frag_color, 1.0) * sun_color; } \ No newline at end of file diff --git a/assets/shade.vert b/assets/shade.vert index 275eac1..8109deb 100644 --- a/assets/shade.vert +++ b/assets/shade.vert @@ -2,11 +2,19 @@ in vec2 position; in vec2 tex_coords; +in vec4 light_color; + +out vec3 v_frag_color; out vec2 v_tex_coords; +out float v_sun_intensity; uniform mat4 matrix; void main() { v_tex_coords = tex_coords; + + v_frag_color = vec3(light_color.rgb); + v_sun_intensity = light_color.a; + gl_Position = matrix * vec4(position, 0.0, 1.0); } \ No newline at end of file diff --git a/assets/shaders/grass/grass.frag b/assets/shaders/grass/grass.frag new file mode 100644 index 0000000..c8c1aec --- /dev/null +++ b/assets/shaders/grass/grass.frag @@ -0,0 +1,4 @@ +#version 140 + +void main() { +} \ No newline at end of file diff --git a/assets/shaders/grass/grass.vert b/assets/shaders/grass/grass.vert new file mode 100644 index 0000000..c8c1aec --- /dev/null +++ b/assets/shaders/grass/grass.vert @@ -0,0 +1,4 @@ +#version 140 + +void main() { +} \ No newline at end of file diff --git a/assets/shaders/water/water.frag b/assets/shaders/water/water.frag new file mode 100644 index 0000000..c8c1aec --- /dev/null +++ b/assets/shaders/water/water.frag @@ -0,0 +1,4 @@ +#version 140 + +void main() { +} \ No newline at end of file diff --git a/assets/shaders/water/water.vert b/assets/shaders/water/water.vert new file mode 100644 index 0000000..c8c1aec --- /dev/null +++ b/assets/shaders/water/water.vert @@ -0,0 +1,4 @@ +#version 140 + +void main() { +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 51f52cb..60e764a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,7 +24,7 @@ fn main() { let display = glium::Display::new(wb, cb, &event_loop).unwrap(); let image = image::load( - Cursor::new(&include_bytes!("../assets/opengl.png")), + Cursor::new(&include_bytes!("../assets/GrassTop.png")), image::ImageFormat::Png, ) .unwrap() @@ -38,16 +38,28 @@ fn main() { struct Vertex { position: [f32; 2], tex_coords: [f32; 2], + light_color: [f32; 4], } - implement_vertex!(Vertex, position, tex_coords); + implement_vertex!(Vertex, position, tex_coords, light_color); - #[rustfmt::skip] - let vertex1 = Vertex { position: [-0.5, -0.5], tex_coords: [0.0, 0.0] }; - #[rustfmt::skip] - let vertex2 = Vertex { position: [ 0.0, 0.5], tex_coords: [0.0, 1.0] }; - #[rustfmt::skip] - let vertex3 = Vertex { position: [ 0.5, -0.25], tex_coords: [1.0, 0.0] }; + let vertex1 = Vertex { + position: [-0.5, -0.5], + tex_coords: [0.0, 0.0], + light_color: [1.0, 1.0, 1.0, 0.0], + }; + + let vertex2 = Vertex { + position: [0.0, 0.5], + tex_coords: [0.0, 1.0], + light_color: [1.0, 0.0, 0.0, 1.0], + }; + + let vertex3 = Vertex { + position: [0.5, -0.25], + tex_coords: [1.0, 0.0], + light_color: [0.0, 1.0, 0.0, 0.5], + }; let shape = vec![vertex1, vertex2, vertex3]; @@ -122,7 +134,7 @@ fn main() { } let mut target = display.draw(); - target.clear_color(0.0, 0.0, 1.0, 0.0); + target.clear_color(0.0, 0.0, 1.0, 1.0); let uniforms = uniform! { matrix: [ @@ -132,6 +144,8 @@ fn main() { [ t , 0.0, 0.0, 1.0f32], ], tex: &texture, + + }; target