summaryrefslogtreecommitdiff
path: root/engine/src/renderer/mod.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-05-12 19:02:35 +0200
committerHampusM <hampus@hampusmat.com>2024-05-12 19:38:01 +0200
commitf82ceb5587954802352e00ffacd229559a2ca4df (patch)
treeb23d62d86108274fe4c1fc704e00c35ce3983ae8 /engine/src/renderer/mod.rs
parentbf5cf271702b1ed00cf3475c29011cb1b5de7345 (diff)
feat(engine): add global material ambient color offsetting
Diffstat (limited to 'engine/src/renderer/mod.rs')
-rw-r--r--engine/src/renderer/mod.rs7
1 files changed, 5 insertions, 2 deletions
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<Window>,
+ global_light: Single<GlobalLight>,
mut gl_objects: Local<GlObjects>,
)
{
@@ -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(