From 33f7772ddddf2a1c2bfefc50ef39f123df8af3e4 Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 24 Apr 2024 20:43:18 +0200 Subject: feat(engine): add colors to materials --- engine/src/renderer/mod.rs | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'engine/src/renderer') diff --git a/engine/src/renderer/mod.rs b/engine/src/renderer/mod.rs index 5125da8..af91257 100644 --- a/engine/src/renderer/mod.rs +++ b/engine/src/renderer/mod.rs @@ -383,21 +383,49 @@ fn apply_light( .into(), ); + gl_shader_program.set_uniform_vec_3fv( + cstr!("material.ambient"), + &material + .ambient() + .cloned() + .unwrap_or(Color { red: 1.0, green: 1.0, blue: 1.0 }) + .into(), + ); + + gl_shader_program.set_uniform_vec_3fv( + cstr!("material.diffuse"), + &material + .diffuse() + .cloned() + .unwrap_or(Color { red: 1.0, green: 1.0, blue: 1.0 }) + .into(), + ); + + #[allow(clippy::cast_possible_wrap)] + gl_shader_program.set_uniform_vec_3fv( + cstr!("material.specular"), + &material + .specular() + .cloned() + .unwrap_or(Color { red: 1.0, green: 1.0, blue: 1.0 }) + .into(), + ); + #[allow(clippy::cast_possible_wrap)] gl_shader_program.set_uniform_1i( - cstr!("material.ambient"), + cstr!("material.ambient_map"), material.ambient_map().into_inner() as i32, ); #[allow(clippy::cast_possible_wrap)] gl_shader_program.set_uniform_1i( - cstr!("material.diffuse"), + cstr!("material.diffuse_map"), material.diffuse_map().into_inner() as i32, ); #[allow(clippy::cast_possible_wrap)] gl_shader_program.set_uniform_1i( - cstr!("material.specular"), + cstr!("material.specular_map"), material.specular_map().into_inner() as i32, ); -- cgit v1.2.3-18-g5258