summaryrefslogtreecommitdiff
path: root/engine/src/renderer
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src/renderer')
-rw-r--r--engine/src/renderer/mod.rs61
1 files changed, 42 insertions, 19 deletions
diff --git a/engine/src/renderer/mod.rs b/engine/src/renderer/mod.rs
index d46612f..6fa692c 100644
--- a/engine/src/renderer/mod.rs
+++ b/engine/src/renderer/mod.rs
@@ -6,7 +6,7 @@ use glfw::WindowSize;
use crate::camera::Camera;
use crate::color::Color;
-use crate::lighting::{LightSettings, LightSource};
+use crate::lighting::LightSource;
use crate::object::Object;
use crate::opengl::buffer::{
ArrayKind as ArrayBufferKind,
@@ -68,7 +68,6 @@ impl Renderer
&self,
objects: impl IntoIterator<Item = &'obj Object>,
light_source: Option<&LightSource>,
- light_settings: &LightSettings,
window_size: &WindowSize,
)
{
@@ -90,7 +89,6 @@ impl Renderer
light_source,
&self.camera,
&shader_program_curr_bound,
- light_settings,
);
if let Some(texture) = obj.texture() {
@@ -262,43 +260,68 @@ fn apply_light(
light_source: Option<&LightSource>,
camera: &Camera,
shader_program_curr_bound: &CurrentlyBound<ShaderProgram>,
- light_settings: &LightSettings,
)
{
obj.renderable().shader_program.set_uniform_vec_3fv(
shader_program_curr_bound,
- cstr!("light_color"),
+ cstr!("light.position"),
+ &light_source.map_or_else(Vec3::default, |light_source| {
+ light_source.position().clone()
+ }),
+ );
+
+ obj.renderable().shader_program.set_uniform_vec_3fv(
+ shader_program_curr_bound,
+ cstr!("light.ambient"),
&light_source
.map_or(Color::WHITE_F32, |light_source| {
- light_source.color().clone()
+ light_source.ambient().clone()
})
.into(),
);
obj.renderable().shader_program.set_uniform_vec_3fv(
shader_program_curr_bound,
- cstr!("light_pos"),
- &light_source.map_or_else(Vec3::default, |light_source| {
- light_source.position().clone()
- }),
+ cstr!("light.diffuse"),
+ &light_source
+ .map_or(Color::WHITE_F32, |light_source| {
+ light_source.diffuse().clone()
+ })
+ .into(),
);
- obj.renderable().shader_program.set_uniform_1fv(
+ obj.renderable().shader_program.set_uniform_vec_3fv(
shader_program_curr_bound,
- cstr!("ambient_light_strength"),
- light_settings.ambient_light_strength,
+ cstr!("light.specular"),
+ &light_source
+ .map_or(Color::WHITE_F32, |light_source| {
+ light_source.specular().clone()
+ })
+ .into(),
);
- obj.renderable().shader_program.set_uniform_1fv(
+ obj.renderable().shader_program.set_uniform_vec_3fv(
shader_program_curr_bound,
- cstr!("specular_light_strength"),
- light_settings.specular_light_strength,
+ cstr!("material.ambient"),
+ &obj.material().ambient().clone().into(),
);
- obj.renderable().shader_program.set_uniform_1uiv(
+ obj.renderable().shader_program.set_uniform_vec_3fv(
+ shader_program_curr_bound,
+ cstr!("material.diffuse"),
+ &obj.material().diffuse().clone().into(),
+ );
+
+ obj.renderable().shader_program.set_uniform_vec_3fv(
+ shader_program_curr_bound,
+ cstr!("material.specular"),
+ &obj.material().specular().clone().into(),
+ );
+
+ obj.renderable().shader_program.set_uniform_1fv(
shader_program_curr_bound,
- cstr!("specular_shininess"),
- light_settings.specular_shininess,
+ cstr!("material.shininess"),
+ obj.material().shininess(),
);
obj.renderable().shader_program.set_uniform_vec_3fv(