From f82ceb5587954802352e00ffacd229559a2ca4df Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 12 May 2024 19:02:35 +0200 Subject: feat(engine): add global material ambient color offsetting --- engine/src/renderer/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'engine/src/renderer') diff --git a/engine/src/renderer/mod.rs b/engine/src/renderer/mod.rs index e2a567a..f9082fc 100644 --- a/engine/src/renderer/mod.rs +++ b/engine/src/renderer/mod.rs @@ -12,7 +12,7 @@ use crate::camera::Camera; use crate::color::Color; use crate::data_types::dimens::Dimens; use crate::event::{Present as PresentEvent, Start as StartEvent}; -use crate::lighting::LightSource; +use crate::lighting::{GlobalLight, LightSource}; use crate::material::Material; use crate::matrix::Matrix; use crate::mesh::Mesh; @@ -95,6 +95,7 @@ fn render( light_source_query: Query<(LightSource, Transform)>, camera_query: Query<(Camera,)>, window: Single, + global_light: Single, mut gl_objects: Local, ) { @@ -138,6 +139,7 @@ fn render( apply_light( &material, + &global_light, shader_program, light_source .as_ref() @@ -344,6 +346,7 @@ fn apply_transformation_matrices( fn apply_light( material: &Material, + global_light: &GlobalLight, gl_shader_program: &mut GlShaderProgram, light_source: Option<(&LightSource, &Transform)>, camera: &Camera, @@ -385,7 +388,7 @@ fn apply_light( gl_shader_program.set_uniform_vec_3fv( cstr!("material.ambient"), - &material.ambient().clone().into(), + &(material.ambient().clone() + global_light.ambient_offset.clone()).into(), ); gl_shader_program.set_uniform_vec_3fv( -- cgit v1.2.3-18-g5258